Version Notes
Credit points for Customers
Download this release
Release Info
Developer | Vikram |
Extension | ei_creditpoint |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- app/code/community/Ei/Creditpoint/Adminhtml/Model/System/Config/Source/Orderoptions.php +26 -0
- app/code/community/Ei/Creditpoint/Block/Adminhtml/Customer/Edit/Tab/Creditpoint.php +72 -0
- app/code/community/Ei/Creditpoint/Block/Creditpoint.php +33 -0
- app/code/community/Ei/Creditpoint/Block/Sales/Order/Totals.php +27 -0
- app/code/community/Ei/Creditpoint/Helper/Data.php +128 -0
- app/code/community/Ei/Creditpoint/Model/Creditpoint.php +11 -0
- app/code/community/Ei/Creditpoint/Model/Mysql4/Creditpoint.php +11 -0
- app/code/community/Ei/Creditpoint/Model/Mysql4/Creditpoint/Collection.php +18 -0
- app/code/community/Ei/Creditpoint/Model/Observer.php +147 -0
- app/code/community/Ei/Creditpoint/Model/Sales/Order/Total/Creditmemo/Creditpoint.php +19 -0
- app/code/community/Ei/Creditpoint/Model/Sales/Order/Total/Invoice/Creditpoint.php +26 -0
- app/code/community/Ei/Creditpoint/Model/Sales/Pdf/Creditpoint.php +38 -0
- app/code/community/Ei/Creditpoint/Model/Sales/Quote/Address/Total/Creditpoint.php +69 -0
- app/code/community/Ei/Creditpoint/RW/Adminhtml/Block/Sales/Order/Creditmemo/Totals.php +31 -0
- app/code/community/Ei/Creditpoint/RW/Adminhtml/Block/Sales/Order/Invoice/Totals.php +30 -0
- app/code/community/Ei/Creditpoint/RW/Adminhtml/Block/Sales/Order/Totals.php +31 -0
- app/code/community/Ei/Creditpoint/controllers/CreditpointController.php +76 -0
- app/code/community/Ei/Creditpoint/etc/adminhtml.xml +26 -0
- app/code/community/Ei/Creditpoint/etc/config.xml +205 -0
- app/code/community/Ei/Creditpoint/etc/system.xml +94 -0
- app/code/community/Ei/Creditpoint/sql/creditpoint_setup/mysql4-install-1.0.0.php +44 -0
- app/code/community/Ei/Creditpoint/sql/creditpoint_setup/mysql4-upgrade-1.0.0-1.0.1.php +30 -0
- app/design/adminhtml/default/default/layout/ei/creditpoint.xml +11 -0
- app/design/adminhtml/default/default/template/ei/creditpoint/creditpoint.phtml +21 -0
- app/design/adminhtml/default/default/template/ei/creditpoint/sales/order/refunded.phtml +21 -0
- app/design/adminhtml/default/default/template/ei/creditpoint/sales/order/total.phtml +21 -0
- app/design/frontend/default/default/layout/ei/creditpoint.xml +44 -0
- app/design/frontend/default/default/template/ei/creditpoint/checkout/cart/creditpoint_cart.phtml +207 -0
- app/design/frontend/default/default/template/ei/creditpoint/creditpoint.phtml +118 -0
- app/etc/modules/Ei_Creditpoint.xml +10 -0
- package.xml +18 -0
- skin/frontend/default/default/css/ei/creditpoint/creditpoint.slider.css +50 -0
- skin/frontend/default/default/images/ei/creditpoint/minus_hover.png +0 -0
- skin/frontend/default/default/images/ei/creditpoint/minus_normal.png +0 -0
- skin/frontend/default/default/images/ei/creditpoint/plus_hover.png +0 -0
- skin/frontend/default/default/images/ei/creditpoint/plus_normal.png +0 -0
- skin/frontend/default/default/images/ei/creditpoint/slider_bg.png +0 -0
- skin/frontend/default/default/images/ei/creditpoint/slider_circle.png +0 -0
- skin/frontend/default/default/js/ei/creditpoint/creditpoint.slider.js +75 -0
app/code/community/Ei/Creditpoint/Adminhtml/Model/System/Config/Source/Orderoptions.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Order options
|
6 |
+
*
|
7 |
+
*/
|
8 |
+
class Ei_Creditpoint_Adminhtml_Model_System_Config_Source_Orderoptions
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Options getter
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
return array(
|
19 |
+
//array('value' => '', 'label'=>Mage::helper('adminhtml')->__('Please Select')),
|
20 |
+
array('value' => 'processing', 'label'=>Mage::helper('adminhtml')->__('Processing')),
|
21 |
+
array('value' => 'complete', 'label'=>Mage::helper('adminhtml')->__('Complete')),
|
22 |
+
array('value' => 'closed', 'label'=>Mage::helper('adminhtml')->__('Closed')),
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
app/code/community/Ei/Creditpoint/Block/Adminhtml/Customer/Edit/Tab/Creditpoint.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Block_Adminhtml_Customer_Edit_Tab_Creditpoint extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
|
9 |
+
$this->setTemplate('ei/creditpoint/creditpoint.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getCreditPoint()
|
13 |
+
{
|
14 |
+
$customer = Mage::registry('current_customer');
|
15 |
+
$creditPoint = Mage::helper('creditpoint')->getFormatCreditPoint($customer->getCreditPoint());
|
16 |
+
return $creditPoint;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Return Tab label
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getTabLabel()
|
25 |
+
{
|
26 |
+
return $this->__('Customer Credit Points');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Return Tab title
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getTabTitle()
|
35 |
+
{
|
36 |
+
return $this->__('Credit Points');
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Can show tab in tabs
|
41 |
+
*
|
42 |
+
* @return boolean
|
43 |
+
*/
|
44 |
+
public function canShowTab()
|
45 |
+
{
|
46 |
+
$customer = Mage::registry('current_customer');
|
47 |
+
return (bool)$customer->getId();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Tab is hidden
|
52 |
+
*
|
53 |
+
* @return boolean
|
54 |
+
*/
|
55 |
+
public function isHidden()
|
56 |
+
{
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Defines after which tab, this tab should be rendered
|
62 |
+
*
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function getAfter()
|
66 |
+
{
|
67 |
+
return 'account';
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
}
|
72 |
+
?>
|
app/code/community/Ei/Creditpoint/Block/Creditpoint.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Block_Creditpoint extends Mage_Core_Block_Template{
|
4 |
+
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$collection = Mage::getModel('creditpoint/creditpoint')->getCollection();
|
10 |
+
$customerId = Mage::helper('creditpoint')->getCurrentCustomerId();
|
11 |
+
$collection->addCustomFilter($customerId);
|
12 |
+
$this->setCollection($collection);
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
protected function _prepareLayout()
|
17 |
+
{
|
18 |
+
parent::_prepareLayout();
|
19 |
+
|
20 |
+
$pager = $this->getLayout()->createBlock('page/html_pager', 'creditpoint.pager');
|
21 |
+
$pager->setAvailableLimit(array(10=>10,20=>20,50=>50,'all'=>'all'));
|
22 |
+
$pager->setCollection($this->getCollection());
|
23 |
+
$this->setChild('pager', $pager);
|
24 |
+
$this->getCollection()->load();
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getPagerHtml()
|
29 |
+
{
|
30 |
+
return $this->getChildHtml('pager');
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/Ei/Creditpoint/Block/Sales/Order/Totals.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initTotals()
|
7 |
+
{
|
8 |
+
parent::_initTotals();
|
9 |
+
if((float) $this->getOrder()->getBaseCreditpointAmount()){
|
10 |
+
$source = $this->getSource();
|
11 |
+
$creditPoints = number_format(Mage::getModel('creditpoint/creditpoint')->load($source->getEntityId(), 'order_id')->getAppliedCreditPoint());
|
12 |
+
$value = '-'.$source->getCreditpointAmount();
|
13 |
+
|
14 |
+
$this->addTotalBefore(new Varien_Object(array(
|
15 |
+
'code' => Mage::helper('creditpoint')->getCode(),
|
16 |
+
'strong' => false,
|
17 |
+
'label' => Mage::helper('creditpoint')->getCreditPointLabel($creditPoints),
|
18 |
+
'value' => $source instanceof Mage_Sales_Model_Order_Creditmemo ? - $value : $value )));
|
19 |
+
}
|
20 |
+
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
?>
|
app/code/community/Ei/Creditpoint/Helper/Data.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getModuleStatus() {
|
6 |
+
|
7 |
+
$status = Mage::getStoreConfig('creditpoint/general/active');
|
8 |
+
return $status;
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getCode() {
|
12 |
+
|
13 |
+
return 'creditpoint';
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getCurrentCustomerId() {
|
17 |
+
|
18 |
+
$currentCustomerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
|
19 |
+
return $currentCustomerId;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getCustomerCreditPointsAssigned() {
|
23 |
+
|
24 |
+
$customerCreditPoints = round(Mage::getSingleton('customer/session')->getCustomer()->getCreditPoint());
|
25 |
+
return $customerCreditPoints;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getCreditPointLabel($points) {
|
29 |
+
|
30 |
+
return Mage::helper('creditpoint')->__('Credit Points Discount ('.$points.' Points)');
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getTotalItemsInCart() {
|
34 |
+
|
35 |
+
return Mage::helper('checkout/cart')->getItemsCount();
|
36 |
+
}
|
37 |
+
|
38 |
+
//get current currency symbol
|
39 |
+
public function getCurrentCurrencySymbol() {
|
40 |
+
|
41 |
+
$currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
|
42 |
+
return $currencySymbol;
|
43 |
+
}
|
44 |
+
|
45 |
+
//this will give points/currency ratio defined in admin
|
46 |
+
public function getPointCurrencyRatio() {
|
47 |
+
|
48 |
+
$ratio = Mage::getStoreConfig('creditpoint/general/points_currency');
|
49 |
+
$currency = Mage::helper('creditpoint')->getCurrentCurrencySymbol();
|
50 |
+
$formatRatio = explode('/', $ratio);
|
51 |
+
$finalRatio = $formatRatio[0] . ' points = ' . $currency . number_format($formatRatio[1], 2, '.', '');
|
52 |
+
return $finalRatio;
|
53 |
+
}
|
54 |
+
|
55 |
+
//this will give currency as per the customer's available credit points
|
56 |
+
public function getPointCurrencyAmount($creditpoints) {
|
57 |
+
|
58 |
+
$ratio = Mage::getStoreConfig('creditpoint/general/points_currency');
|
59 |
+
$formatRatio = explode('/', $ratio);
|
60 |
+
$finalExchangeValue = $formatRatio[1] / $formatRatio[0];
|
61 |
+
$finalAmount = round($finalExchangeValue * $creditpoints);
|
62 |
+
return $finalAmount;
|
63 |
+
}
|
64 |
+
|
65 |
+
//this will give points earned on currency spent by customer
|
66 |
+
public function getEarnedPointsRatio() {
|
67 |
+
|
68 |
+
$ratio = Mage::getStoreConfig('creditpoint/general/points_earn');
|
69 |
+
$currency = Mage::helper('creditpoint')->getCurrentCurrencySymbol();
|
70 |
+
$formatRatio = explode('/', $ratio);
|
71 |
+
$finalEarnedPointsRatio = 'You Earn ' . $formatRatio[1] . ' points for every ' . $currency . $formatRatio[0] . ' spent';
|
72 |
+
return $finalEarnedPointsRatio;
|
73 |
+
}
|
74 |
+
|
75 |
+
//this will give points as per the amount spent by customer per order
|
76 |
+
public function getCreditPointsAwarded($grandtotal) {
|
77 |
+
|
78 |
+
$ratio = Mage::getStoreConfig('creditpoint/general/points_earn');
|
79 |
+
$formatRatio = explode('/', $ratio);
|
80 |
+
$finalExchangeValue = $formatRatio[1] / $formatRatio[0];
|
81 |
+
$creditPointsAwarded = round($finalExchangeValue * $grandtotal);
|
82 |
+
return $creditPointsAwarded;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function getMinimumCredit() {
|
86 |
+
|
87 |
+
$minCredit = Mage::getStoreConfig('creditpoint/general/minimum_credit_required');
|
88 |
+
return $minCredit;
|
89 |
+
}
|
90 |
+
|
91 |
+
public function getMaximumCredit() {
|
92 |
+
|
93 |
+
$maxCredit = Mage::getStoreConfig('creditpoint/general/maximum_credit_allowed');
|
94 |
+
return $maxCredit;
|
95 |
+
}
|
96 |
+
|
97 |
+
//This will convert the points into available currency
|
98 |
+
public function getPrice($creditPoints) {
|
99 |
+
|
100 |
+
$currentPointAmount = number_format(Mage::helper('creditpoint')->getPointCurrencyAmount($creditPoints), 2, '.', '');
|
101 |
+
return $currentPointAmount;
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
public function getRestoreConfig(){
|
106 |
+
|
107 |
+
$restoreCredit = Mage::getStoreConfig('creditpoint/general/restore_redeemed_credits');
|
108 |
+
return $restoreCredit;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getOrderStatus() {
|
112 |
+
|
113 |
+
$orderStatus = Mage::getStoreConfig('creditpoint/general/order_status');
|
114 |
+
return $orderStatus;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getFormatCreditPoint($point) {
|
118 |
+
|
119 |
+
$creditPoint = round($point, 2);
|
120 |
+
return $creditPoint;
|
121 |
+
}
|
122 |
+
|
123 |
+
public function getOrderUrl($orderId) {
|
124 |
+
|
125 |
+
return Mage::getUrl('sales/order/view', array('order_id' => $orderId));
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Creditpoint.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Model_Creditpoint extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('creditpoint/creditpoint');
|
9 |
+
|
10 |
+
}
|
11 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Mysql4/Creditpoint.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Model_Mysql4_Creditpoint extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct(){
|
7 |
+
|
8 |
+
// Note that the id refers to the key field in your database table.
|
9 |
+
$this->_init('creditpoint/creditpoint', 'id');
|
10 |
+
}
|
11 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Mysql4/Creditpoint/Collection.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Model_Mysql4_Creditpoint_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
4 |
+
|
5 |
+
public function _construct() {
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('creditpoint/creditpoint');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function addCustomFilter($customerId) {
|
11 |
+
|
12 |
+
$sortByCustomer = 'customer_id = ?';
|
13 |
+
$sortByOrder = 'order_id DESC';
|
14 |
+
$filteredResult = $this->getSelect()->where($sortByCustomer, $customerId)->order(new Zend_Db_Expr($sortByOrder));
|
15 |
+
return $filteredResult;
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Observer.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Model_Observer {
|
4 |
+
|
5 |
+
//this function is used to deduct credit points from customer's account after order is placed
|
6 |
+
public function deductCreditAmount(Varien_Event_Observer $observer) {
|
7 |
+
|
8 |
+
|
9 |
+
$order = $observer->getEvent()->getOrder();
|
10 |
+
$orderId = $order->getId();
|
11 |
+
$customerId = $order->getCustomerId();
|
12 |
+
$datetime = $order->getCreatedAt();
|
13 |
+
|
14 |
+
$pointsRedeem = Mage::getSingleton('core/session')->getData('points_redeem');
|
15 |
+
$pointsPrice = Mage::getSingleton('core/session')->getData('points_price');
|
16 |
+
$customerCreditPoints = Mage::getSingleton('customer/session')->getCustomer()->getCreditPoint();
|
17 |
+
|
18 |
+
if ($pointsRedeem && $pointsPrice != NULL) {
|
19 |
+
|
20 |
+
//init our model, set data and save
|
21 |
+
//deduct redeemed credit points from customer account and revise
|
22 |
+
try {
|
23 |
+
|
24 |
+
$revisedCreditPoints = $customerCreditPoints - $pointsRedeem;
|
25 |
+
$creditModel = Mage::getSingleton('creditpoint/creditpoint')
|
26 |
+
->setCustomerId($customerId)
|
27 |
+
->setOrderId($orderId)
|
28 |
+
->setAppliedCreditPoint($pointsRedeem)
|
29 |
+
->setAppliedCreditPointPrice($pointsPrice)
|
30 |
+
->setCreatedTime($datetime)
|
31 |
+
->save();
|
32 |
+
|
33 |
+
$customerData = Mage::getSingleton('customer/customer')->load($customerId)->setCreditPoint($revisedCreditPoints)->save();
|
34 |
+
|
35 |
+
//unset credit points data
|
36 |
+
Mage::getSingleton('core/session')->unsEstimateCredit();
|
37 |
+
Mage::getSingleton('core/session')->unsPointsRedeem();
|
38 |
+
Mage::getSingleton('core/session')->unsPointsPrice();
|
39 |
+
} catch (Exception $e) {
|
40 |
+
Mage::getModel('core/session')->addError($e->getMessage());
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
//this function is used to add credit points to customer's account balance.
|
46 |
+
//grandtotal is used to calculate the amount of points to be deposited
|
47 |
+
public function revertCreditPoints($observer) {
|
48 |
+
|
49 |
+
$order = $observer->getEvent()->getOrder();
|
50 |
+
$customerId = $order->getCustomerId();
|
51 |
+
$orderStatus = Mage::helper('creditpoint')->getOrderStatus();
|
52 |
+
$moduleStatus = Mage::helper('creditpoint')->getModuleStatus();
|
53 |
+
$restoreConfig = Mage::helper('creditpoint')->getRestoreConfig();
|
54 |
+
|
55 |
+
$grandTotal = round($order->getGrandTotal());
|
56 |
+
$customerEarnedPoints = Mage::helper('creditpoint')->getCreditPointsAwarded($grandTotal);
|
57 |
+
$customerCurrentPoints = Mage::getSingleton('customer/customer')->load($order->getCustomerId())->getCreditPoint();
|
58 |
+
$customerAppliedPoints = Mage::getSingleton('creditpoint/creditpoint')->load($order->getEntityId(), 'order_id')->getAppliedCreditPoint();
|
59 |
+
|
60 |
+
|
61 |
+
//check if order status matches configuration order status, order is not closed, can restore points, order is closed and module is active
|
62 |
+
if (($order->getState() == $orderStatus && $moduleStatus == 1 && $restoreConfig == 1 && $order->getState() == Mage_Sales_Model_Order::STATE_CLOSED) || ($restoreConfig == 1 && $order->getState() == Mage_Sales_Model_Order::STATE_CLOSED)) {
|
63 |
+
|
64 |
+
try {
|
65 |
+
|
66 |
+
$restoredPoints = ($customerCurrentPoints - $customerEarnedPoints) + $customerAppliedPoints;
|
67 |
+
|
68 |
+
$creditModel = Mage::getSingleton('creditpoint/creditpoint')
|
69 |
+
->load($order->getId(), 'order_id')
|
70 |
+
->setOrderRefund($restoreConfig)
|
71 |
+
->save();
|
72 |
+
|
73 |
+
//set restored customer's points
|
74 |
+
$customerData = Mage::getSingleton('customer/customer')->load($order->getCustomerId())
|
75 |
+
->setCreditPoint($restoredPoints)
|
76 |
+
->save();
|
77 |
+
} catch (Exception $e) {
|
78 |
+
Mage::getModel('core/session')->addError($e->getMessage());
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
//check if order status matches configuration order status, order is not closed and module is active
|
83 |
+
} elseif ($order->getState() == $orderStatus && $moduleStatus == 1) {
|
84 |
+
|
85 |
+
try {
|
86 |
+
|
87 |
+
//check if the order is placed first time OR no credit points applied on this order
|
88 |
+
if ($customerAppliedPoints == NULL) {
|
89 |
+
|
90 |
+
//add earned points to current balance only
|
91 |
+
$revisedCreditPoints = $customerCurrentPoints + $customerEarnedPoints;
|
92 |
+
|
93 |
+
$creditModel = Mage::getSingleton('creditpoint/creditpoint')
|
94 |
+
->load($order->getId(), 'order_id')
|
95 |
+
->setCustomerId($order->getCustomerId())
|
96 |
+
->setOrderId($order->getEntityId())
|
97 |
+
->setEarnedCreditPoint($customerEarnedPoints)
|
98 |
+
->setCreatedTime($order->getCreatedAt())
|
99 |
+
->save();
|
100 |
+
|
101 |
+
//set customer's credit points
|
102 |
+
$customerData = Mage::getSingleton('customer/customer')->load($order->getCustomerId())
|
103 |
+
->setCreditPoint($revisedCreditPoints)
|
104 |
+
->save();
|
105 |
+
|
106 |
+
|
107 |
+
//check if creditpoints applied on order
|
108 |
+
} else {
|
109 |
+
|
110 |
+
//add earned points to current balance only
|
111 |
+
$revisedCreditPoints = $customerCurrentPoints + $customerEarnedPoints;
|
112 |
+
|
113 |
+
$creditModel = Mage::getSingleton('creditpoint/creditpoint')
|
114 |
+
->load($order->getId(), 'order_id')
|
115 |
+
->setEarnedCreditPoint($customerEarnedPoints)
|
116 |
+
->save();
|
117 |
+
|
118 |
+
//set customer's credit points
|
119 |
+
$customerData = Mage::getSingleton('customer/customer')->load($order->getCustomerId())
|
120 |
+
->setCreditPoint($revisedCreditPoints)
|
121 |
+
->save();
|
122 |
+
}
|
123 |
+
} catch (Exception $e) {
|
124 |
+
Mage::getModel('core/session')->addError($e->getMessage());
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
//this function will display creditpoint amount value when invoice is created
|
130 |
+
public function invoiceSaveAfter(Varien_Event_Observer $observer) {
|
131 |
+
|
132 |
+
$invoice = $observer->getEvent()->getInvoice();
|
133 |
+
if ($invoice->getBaseCreditpointAmount()) {
|
134 |
+
$order = $invoice->getOrder();
|
135 |
+
$order->setCreditpointAmountInvoiced($order->getCreditpointAmountInvoiced() + $invoice->getCreditpointAmount());
|
136 |
+
$order->setBaseCreditpointAmountInvoiced($order->getBaseCreditpointAmountInvoiced() + $invoice->getBaseCreditpointAmount());
|
137 |
+
}
|
138 |
+
return $this;
|
139 |
+
}
|
140 |
+
|
141 |
+
public function updatePaypalTotal($evt) {
|
142 |
+
|
143 |
+
$cart = $evt->getPaypalCart();
|
144 |
+
$cart->updateTotal(Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL, $cart->getSalesEntity()->getCreditpointAmount());
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Sales/Order/Total/Creditmemo/Creditpoint.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ei_Creditpoint_Model_Sales_Order_Total_Creditmemo_Creditpoint extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
|
3 |
+
{
|
4 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
5 |
+
{
|
6 |
+
$order = $creditmemo->getOrder();
|
7 |
+
$creditpointAmountLeft = $order->getCreditpointAmountInvoiced() - $order->getCreditpointAmountRefunded();
|
8 |
+
$basecreditpointAmountLeft = $order->getBaseCreditpointAmountInvoiced() - $order->getBaseCreditpointAmountRefunded();
|
9 |
+
if ($basecreditpointAmountLeft > 0) {
|
10 |
+
|
11 |
+
//customer redeemed discount so we are subtracting the value from total
|
12 |
+
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $creditpointAmountLeft);
|
13 |
+
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $basecreditpointAmountLeft);
|
14 |
+
$creditmemo->setCreditpointAmount($creditpointAmountLeft);
|
15 |
+
$creditmemo->setBaseCreditpointAmount($basecreditpointAmountLeft);
|
16 |
+
}
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Sales/Order/Total/Invoice/Creditpoint.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ei_Creditpoint_Model_Sales_Order_Total_Invoice_Creditpoint extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
3 |
+
{
|
4 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
|
5 |
+
{
|
6 |
+
$order = $invoice->getOrder();
|
7 |
+
$creditpointAmountLeft = $order->getCreditpointAmount() - $order->getCreditpointAmountInvoiced();
|
8 |
+
$basecreditpointAmountLeft = $order->getBaseCreditpointAmount() - $order->getBaseCreditpointAmountInvoiced();
|
9 |
+
if (abs($basecreditpointAmountLeft) < $invoice->getBaseGrandTotal()) {
|
10 |
+
|
11 |
+
//customer redeemed discount so we are subtracting the value from total
|
12 |
+
$invoice->setGrandTotal($invoice->getGrandTotal() - $creditpointAmountLeft);
|
13 |
+
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $basecreditpointAmountLeft);
|
14 |
+
} else {
|
15 |
+
$creditpointAmountLeft = $invoice->getGrandTotal() * -1;
|
16 |
+
$basecreditpointAmountLeft = $invoice->getBaseGrandTotal() * -1;
|
17 |
+
|
18 |
+
$invoice->setGrandTotal(0);
|
19 |
+
$invoice->setBaseGrandTotal(0);
|
20 |
+
}
|
21 |
+
|
22 |
+
$invoice->setCreditpointAmount($creditpointAmountLeft);
|
23 |
+
$invoice->setBaseCreditpointAmount($basecreditpointAmountLeft);
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Sales/Pdf/Creditpoint.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_Model_Sales_Pdf_Creditpoint extends Mage_Sales_Model_Order_Pdf_Total_Default
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Get Total amount from source
|
8 |
+
*
|
9 |
+
* @return float
|
10 |
+
*/
|
11 |
+
public function getCreditpointAmt()
|
12 |
+
{
|
13 |
+
//we can use $this->getSource()->getCreditpointAmount() but it will return without formatted price.
|
14 |
+
//below code should get you the formatted price amount. This is taken directly from the original getTotalsForDisplay code
|
15 |
+
|
16 |
+
return $this->getOrder()->formatPriceTxt($this->getAmount());
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
public function getTotalsForDisplay()
|
21 |
+
{
|
22 |
+
parent::getTotalsForDisplay();
|
23 |
+
// getAmount is defined in the parent class and should read
|
24 |
+
// the value from the defined source_field in config.xml
|
25 |
+
$creditPointAmount = $this->getCreditpointAmt();
|
26 |
+
$creditPoints = number_format(Mage::getModel('creditpoint/creditpoint')->load($this->getOrder()->getEntityId(), 'order_id')->getAppliedCreditPoint());
|
27 |
+
|
28 |
+
$label = Mage::helper('creditpoint')->getCreditPointLabel($creditPoints);
|
29 |
+
$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
|
30 |
+
$total = array(
|
31 |
+
'amount' => '-'.$creditPointAmount,
|
32 |
+
'label' => $label,
|
33 |
+
'font_size' => $fontSize
|
34 |
+
);
|
35 |
+
return array($total);
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/Ei/Creditpoint/Model/Sales/Quote/Address/Total/Creditpoint.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ei_Creditpoint_Model_Sales_Quote_Address_Total_Creditpoint extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
3 |
+
|
4 |
+
protected $CreditPointCode = '';
|
5 |
+
protected $EstimateCredit = '';
|
6 |
+
|
7 |
+
public function __construct(){
|
8 |
+
|
9 |
+
$this->moduleStatus = Mage::helper('creditpoint')->getModuleStatus();
|
10 |
+
$this->minCreditConfig = Mage::helper('creditpoint')->getMinimumCredit();
|
11 |
+
$this->creditPoints = Mage::helper('creditpoint')->getCustomerCreditPointsAssigned();
|
12 |
+
$this->CreditPointCode = Mage::helper('creditpoint')->getCode();
|
13 |
+
$this->EstimateCredit = Mage::getSingleton('core/session')->getEstimateCredit();
|
14 |
+
$this->PointsRedeem = Mage::getSingleton('core/session')->getPointsRedeem();
|
15 |
+
$this->PointsPrice = Mage::getSingleton('core/session')->getPointsPrice();
|
16 |
+
}
|
17 |
+
|
18 |
+
//In function collect() you can add whatever amount you want to the order totals
|
19 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
20 |
+
{
|
21 |
+
|
22 |
+
parent::collect($address);
|
23 |
+
|
24 |
+
$this->_setAmount(0);
|
25 |
+
$this->_setBaseAmount(0);
|
26 |
+
|
27 |
+
$items = $this->_getAddressItems($address);
|
28 |
+
if (!count($items)) {
|
29 |
+
return $this; //this makes only address type shipping to come through
|
30 |
+
}
|
31 |
+
|
32 |
+
$quote = $address->getQuote();
|
33 |
+
|
34 |
+
//check if module enabled, mincredit < credit assigned and creditpoint redeemed only then display in grand_total block
|
35 |
+
if( ($this->CreditPointCode == $this->EstimateCredit) && ($this->moduleStatus == 1) && ($this->minCreditConfig < $this->creditPoints) ){
|
36 |
+
|
37 |
+
$exist_amount = $quote->getCreditpointAmount();
|
38 |
+
$creditPointPrice = Mage::helper('creditpoint')->getPrice($this->PointsRedeem);
|
39 |
+
$balance = $creditPointPrice - $exist_amount;
|
40 |
+
|
41 |
+
$address->setCreditpointAmount($balance);
|
42 |
+
$address->setBaseCreditpointAmount($balance);
|
43 |
+
|
44 |
+
$quote->setCreditpointAmount($balance);
|
45 |
+
|
46 |
+
$address->setGrandTotal($address->getGrandTotal() - $address->getCreditpointAmount());
|
47 |
+
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseCreditpointAmount());
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
//The function fetch() is used for display purposes
|
53 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
54 |
+
{
|
55 |
+
//check if module enabled, mincredit < credit assigned and creditpoint redeemed only then display in grand_total block
|
56 |
+
if(($this->CreditPointCode == $this->EstimateCredit) && ($this->moduleStatus == 1) && ($this->minCreditConfig < $this->creditPoints)){
|
57 |
+
|
58 |
+
$amount = $address->getCreditpointAmount();
|
59 |
+
$address->addTotal(array(
|
60 |
+
'code' => Mage::helper('creditpoint')->getCode(),
|
61 |
+
'title' => Mage::helper('creditpoint')->__('Points Redeem ('.$this->PointsRedeem.' points)'),
|
62 |
+
'value' => '-'.$amount
|
63 |
+
));
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Ei/Creditpoint/RW/Adminhtml/Block/Sales/Order/Creditmemo/Totals.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_RW_Adminhtml_Block_Sales_Order_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initTotals()
|
7 |
+
{
|
8 |
+
parent::_initTotals();
|
9 |
+
|
10 |
+
//Retrieve Creditpoint Amount from sales_flat_order table order wise
|
11 |
+
$creditPointAmount = $this->getSource()->getCreditpointAmount();
|
12 |
+
$creditPoints = number_format(Mage::getModel('creditpoint/creditpoint')->load($this->getSource()->getOrderId(), 'order_id')->getAppliedCreditPoint());
|
13 |
+
|
14 |
+
if($creditPointAmount > 0){
|
15 |
+
|
16 |
+
$this->addTotalBefore(new Varien_Object(array(
|
17 |
+
'code' => Mage::helper('creditpoint')->getCode(),
|
18 |
+
'value' => '-'.$creditPointAmount,
|
19 |
+
'base_value' => '-'.$creditPointAmount,
|
20 |
+
'strong' => false,
|
21 |
+
'label' => Mage::helper('creditpoint')->getCreditPointLabel($creditPoints),
|
22 |
+
), array('shipping', 'tax')));
|
23 |
+
}
|
24 |
+
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
?>
|
app/code/community/Ei/Creditpoint/RW/Adminhtml/Block/Sales/Order/Invoice/Totals.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_RW_Adminhtml_Block_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initTotals()
|
7 |
+
{
|
8 |
+
parent::_initTotals();
|
9 |
+
|
10 |
+
//Retrieve Creditpoint Amount from sales_flat_order table order wise
|
11 |
+
$creditPointAmount = $this->getSource()->getCreditpointAmount();
|
12 |
+
$creditPoints = number_format(Mage::getModel('creditpoint/creditpoint')->load($this->getSource()->getOrderId(), 'order_id')->getAppliedCreditPoint());
|
13 |
+
if($creditPointAmount > 0){
|
14 |
+
|
15 |
+
$this->addTotalBefore(new Varien_Object(array(
|
16 |
+
'code' => Mage::helper('creditpoint')->getCode(),
|
17 |
+
'value' => '-'.$creditPointAmount,
|
18 |
+
'base_value' => '-'.$creditPointAmount,
|
19 |
+
'strong' => false,
|
20 |
+
'label' => Mage::helper('creditpoint')->getCreditPointLabel($creditPoints),
|
21 |
+
), array('shipping', 'tax')));
|
22 |
+
}
|
23 |
+
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
?>
|
app/code/community/Ei/Creditpoint/RW/Adminhtml/Block/Sales/Order/Totals.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_RW_Adminhtml_Block_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initTotals()
|
7 |
+
{
|
8 |
+
|
9 |
+
parent::_initTotals();
|
10 |
+
|
11 |
+
//Retrieve Creditpoint Amount from sales_flat_order table order wise
|
12 |
+
$creditPointAmount = $this->getSource()->getCreditpointAmount();
|
13 |
+
$creditPoints = number_format(Mage::getModel('creditpoint/creditpoint')->load($this->getSource()->getEntityId(), 'order_id')->getAppliedCreditPoint());
|
14 |
+
if($creditPointAmount > 0){
|
15 |
+
|
16 |
+
$this->addTotalBefore(new Varien_Object(array(
|
17 |
+
'code' => Mage::helper('creditpoint')->getCode(),
|
18 |
+
'value' => '-'.$creditPointAmount,
|
19 |
+
'base_value' => '-'.$creditPointAmount,
|
20 |
+
'strong' => false,
|
21 |
+
'label' => Mage::helper('creditpoint')->getCreditPointLabel($creditPoints),
|
22 |
+
), array('shipping', 'tax')));
|
23 |
+
}
|
24 |
+
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
?>
|
app/code/community/Ei/Creditpoint/controllers/CreditpointController.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Ei_Creditpoint_CreditpointController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
protected function _getSession() {
|
6 |
+
return Mage::getSingleton('customer/session');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function preDispatch() {
|
10 |
+
|
11 |
+
parent::preDispatch();
|
12 |
+
$action = $this->getRequest()->getActionName();
|
13 |
+
$loginUrl = Mage::helper('customer')->getLoginUrl();
|
14 |
+
if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
|
15 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
public function indexAction() {
|
20 |
+
|
21 |
+
$this->loadLayout();
|
22 |
+
$this->renderLayout();
|
23 |
+
}
|
24 |
+
|
25 |
+
public function estimateCreditPointAction() {
|
26 |
+
|
27 |
+
|
28 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
29 |
+
//$userSelection = $this->getRequest()->getParam('isChecked');
|
30 |
+
$code = (string) $this->getRequest()->getParam('estimate_credit');
|
31 |
+
$pointsRedeem = Mage::app()->getRequest()->getParam('pointsredeem');
|
32 |
+
$pointsAmount = Mage::helper('creditpoint')->getPrice($pointsRedeem);
|
33 |
+
|
34 |
+
//if estimate_credit code set and redeemed points greater than 0
|
35 |
+
if ( (!empty($pointsRedeem)) && (!empty($code)) ) {
|
36 |
+
|
37 |
+
Mage::getSingleton('core/session')->setEstimateCredit($code);
|
38 |
+
Mage::getSingleton('core/session')->setPointsRedeem($pointsRedeem);
|
39 |
+
Mage::getSingleton('core/session')->setPointsPrice($pointsAmount);
|
40 |
+
|
41 |
+
//call collectTotals on quote with the totals collected flag set to false.
|
42 |
+
//$quote->collectTotals() one the first line checks for the totals_collected_flag,
|
43 |
+
//if it is set to true it returns without doing anything but we want to update it after applying discount so its set to false.
|
44 |
+
//Look at the definition : Mage_Sales_Model_Quote::collectTotals()
|
45 |
+
$quote->setTotalsCollectedFlag(false);
|
46 |
+
$quote->collectTotals();
|
47 |
+
|
48 |
+
}else{
|
49 |
+
|
50 |
+
Mage::getSingleton('core/session')->unsEstimateCredit();
|
51 |
+
Mage::getSingleton('core/session')->unsPointsRedeem();
|
52 |
+
Mage::getSingleton('core/session')->unsPointsPrice();
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
$response = array();
|
58 |
+
|
59 |
+
//here 'creditpointblock' will be key and cart block html as value for that key
|
60 |
+
$response['creditpointblock'] = $this->creditpointAjax();
|
61 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true);
|
62 |
+
return $this->getResponse()->setBody(json_encode($response));
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
protected function creditpointAjax()
|
68 |
+
{
|
69 |
+
|
70 |
+
$layout = $this->getLayout();
|
71 |
+
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
|
72 |
+
$totalsBlock = $layout->createBlock('checkout/cart_totals')->setTemplate('checkout/cart/totals.phtml');
|
73 |
+
return $totalsBlock->toHtml();
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
app/code/community/Ei/Creditpoint/etc/adminhtml.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<all>
|
6 |
+
<title>Allow Everything</title>
|
7 |
+
</all>
|
8 |
+
<admin>
|
9 |
+
<children>
|
10 |
+
<system>
|
11 |
+
<children>
|
12 |
+
<config>
|
13 |
+
<children>
|
14 |
+
<creditpoint translate="title" module="creditpoint">
|
15 |
+
<title>Customer Credit Points</title>
|
16 |
+
<sort_order>80</sort_order>
|
17 |
+
</creditpoint>
|
18 |
+
</children>
|
19 |
+
</config>
|
20 |
+
</children>
|
21 |
+
</system>
|
22 |
+
</children>
|
23 |
+
</admin>
|
24 |
+
</resources>
|
25 |
+
</acl>
|
26 |
+
</config>
|
app/code/community/Ei/Creditpoint/etc/config.xml
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ei_Creditpoint>
|
5 |
+
<version>1.0.1</version>
|
6 |
+
</Ei_Creditpoint>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<ei_creditpoint>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Ei_Creditpoint</module>
|
14 |
+
<frontName>creditpoint</frontName>
|
15 |
+
</args>
|
16 |
+
</ei_creditpoint>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<creditpoint module="Ei_Creditpoint">
|
21 |
+
<file>ei/creditpoint.xml</file>
|
22 |
+
</creditpoint>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<ei_creditpoint>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Ei_Creditpoint</module>
|
32 |
+
<frontName>creditpoint</frontName>
|
33 |
+
</args>
|
34 |
+
</ei_creditpoint>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<layout>
|
39 |
+
<updates>
|
40 |
+
<creditpoint>
|
41 |
+
<file>ei/creditpoint.xml</file>
|
42 |
+
</creditpoint>
|
43 |
+
</updates>
|
44 |
+
</layout>
|
45 |
+
</adminhtml>
|
46 |
+
<default>
|
47 |
+
<creditpoint>
|
48 |
+
<general>
|
49 |
+
<points_currency>10/10</points_currency>
|
50 |
+
<points_earn>100/10</points_earn>
|
51 |
+
<minimum_credit_required>0</minimum_credit_required>
|
52 |
+
<maximum_credit_allowed>0</maximum_credit_allowed>
|
53 |
+
</general>
|
54 |
+
</creditpoint>
|
55 |
+
</default>
|
56 |
+
<global>
|
57 |
+
<blocks>
|
58 |
+
<creditpoint>
|
59 |
+
<class>Ei_Creditpoint_Block</class>
|
60 |
+
</creditpoint>
|
61 |
+
<sales>
|
62 |
+
<rewrite>
|
63 |
+
<order_totals>Ei_Creditpoint_Block_Sales_Order_Totals</order_totals>
|
64 |
+
</rewrite>
|
65 |
+
</sales>
|
66 |
+
<adminhtml>
|
67 |
+
<rewrite>
|
68 |
+
<sales_order_totals>Ei_Creditpoint_RW_Adminhtml_Block_Sales_Order_Totals</sales_order_totals>
|
69 |
+
<sales_order_invoice_totals>Ei_Creditpoint_RW_Adminhtml_Block_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
|
70 |
+
<sales_order_creditmemo_totals>Ei_Creditpoint_RW_Adminhtml_Block_Sales_Order_Creditmemo_Totals</sales_order_creditmemo_totals>
|
71 |
+
</rewrite>
|
72 |
+
</adminhtml>
|
73 |
+
</blocks>
|
74 |
+
<helpers>
|
75 |
+
<creditpoint>
|
76 |
+
<class>Ei_Creditpoint_Helper</class>
|
77 |
+
</creditpoint>
|
78 |
+
</helpers>
|
79 |
+
<sales>
|
80 |
+
<quote>
|
81 |
+
<totals>
|
82 |
+
<creditpoint>
|
83 |
+
<class>creditpoint/sales_quote_address_total_creditpoint</class>
|
84 |
+
<after>subtotal</after>
|
85 |
+
<before>tax</before>
|
86 |
+
</creditpoint>
|
87 |
+
</totals>
|
88 |
+
</quote>
|
89 |
+
<order_invoice>
|
90 |
+
<totals>
|
91 |
+
<creditpoint>
|
92 |
+
<class>creditpoint/sales_order_total_invoice_creditpoint</class>
|
93 |
+
<after>subtotal</after>
|
94 |
+
<before>tax</before>
|
95 |
+
</creditpoint>
|
96 |
+
</totals>
|
97 |
+
</order_invoice>
|
98 |
+
<order_creditmemo>
|
99 |
+
<totals>
|
100 |
+
<creditpoint>
|
101 |
+
<class>creditpoint/sales_order_total_creditmemo_creditpoint</class>
|
102 |
+
<after>subtotal</after>
|
103 |
+
<before>tax</before>
|
104 |
+
</creditpoint>
|
105 |
+
</totals>
|
106 |
+
</order_creditmemo>
|
107 |
+
</sales>
|
108 |
+
<events>
|
109 |
+
<checkout_type_onepage_save_order_after>
|
110 |
+
<observers>
|
111 |
+
<checkout_deduct_credit_amount>
|
112 |
+
<type>singleton</type>
|
113 |
+
<class>creditpoint/observer</class>
|
114 |
+
<method>deductCreditAmount</method>
|
115 |
+
</checkout_deduct_credit_amount>
|
116 |
+
</observers>
|
117 |
+
</checkout_type_onepage_save_order_after>
|
118 |
+
<sales_order_save_after>
|
119 |
+
<observers>
|
120 |
+
<deposit_creditamount>
|
121 |
+
<type>singleton</type>
|
122 |
+
<class>creditpoint/observer</class>
|
123 |
+
<method>revertCreditPoints</method>
|
124 |
+
</deposit_creditamount>
|
125 |
+
</observers>
|
126 |
+
</sales_order_save_after>
|
127 |
+
<paypal_prepare_line_items>
|
128 |
+
<observers>
|
129 |
+
<paypal_prepare_line_items>
|
130 |
+
<class>creditpoint/observer</class>
|
131 |
+
<method>updatePaypalTotal</method>
|
132 |
+
</paypal_prepare_line_items>
|
133 |
+
</observers>
|
134 |
+
</paypal_prepare_line_items>
|
135 |
+
<sales_order_invoice_save_after>
|
136 |
+
<observers>
|
137 |
+
<sales_order_invoice_save_after>
|
138 |
+
<class>creditpoint/observer</class>
|
139 |
+
<method>invoiceSaveAfter</method>
|
140 |
+
</sales_order_invoice_save_after>
|
141 |
+
</observers>
|
142 |
+
</sales_order_invoice_save_after>
|
143 |
+
</events>
|
144 |
+
<fieldsets>
|
145 |
+
<sales_convert_quote_address>
|
146 |
+
<creditpoint_amount>
|
147 |
+
<to_order>*</to_order>
|
148 |
+
</creditpoint_amount>
|
149 |
+
<base_creditpoint_amount>
|
150 |
+
<to_order>*</to_order>
|
151 |
+
</base_creditpoint_amount>
|
152 |
+
</sales_convert_quote_address>
|
153 |
+
</fieldsets>
|
154 |
+
<pdf>
|
155 |
+
<totals>
|
156 |
+
<creditpoint translate ="title">
|
157 |
+
<title>Credit Points Discount</title>
|
158 |
+
<source_field>creditpoint_amount</source_field>
|
159 |
+
<model>creditpoint/sales_pdf_creditpoint</model>
|
160 |
+
<font_size>7</font_size>
|
161 |
+
<display_zero>0</display_zero>
|
162 |
+
<sort_order>650</sort_order>
|
163 |
+
</creditpoint>
|
164 |
+
</totals>
|
165 |
+
</pdf>
|
166 |
+
<models>
|
167 |
+
<creditpoint>
|
168 |
+
<class>Ei_Creditpoint_Model</class>
|
169 |
+
<resourceModel>creditpoint_mysql4</resourceModel>
|
170 |
+
</creditpoint>
|
171 |
+
<creditpoint_adminhtml>
|
172 |
+
<class>Ei_Creditpoint_Adminhtml_Model</class>
|
173 |
+
</creditpoint_adminhtml>
|
174 |
+
<creditpoint_mysql4>
|
175 |
+
<class>Ei_Creditpoint_Model_Mysql4</class>
|
176 |
+
<entities>
|
177 |
+
<creditpoint>
|
178 |
+
<table>customer_credit_point</table>
|
179 |
+
</creditpoint>
|
180 |
+
</entities>
|
181 |
+
</creditpoint_mysql4>
|
182 |
+
</models>
|
183 |
+
<resources>
|
184 |
+
<creditpoint_setup>
|
185 |
+
<setup>
|
186 |
+
<module>Ei_Creditpoint</module>
|
187 |
+
<class>Mage_Eav_Model_Entity_Setup</class>
|
188 |
+
</setup>
|
189 |
+
<connection>
|
190 |
+
<use>core_setup</use>
|
191 |
+
</connection>
|
192 |
+
</creditpoint_setup>
|
193 |
+
<creditpoint_write>
|
194 |
+
<connection>
|
195 |
+
<use>core_write</use>
|
196 |
+
</connection>
|
197 |
+
</creditpoint_write>
|
198 |
+
<creditpoint_read>
|
199 |
+
<connection>
|
200 |
+
<use>core_read</use>
|
201 |
+
</connection>
|
202 |
+
</creditpoint_read>
|
203 |
+
</resources>
|
204 |
+
</global>
|
205 |
+
</config>
|
app/code/community/Ei/Creditpoint/etc/system.xml
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<creditpoint translate="label" module="creditpoint">
|
5 |
+
<class>separator-top</class>
|
6 |
+
<label>Customer Credit Points</label>
|
7 |
+
<tab>customer</tab>
|
8 |
+
<sort_order>100</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</show_in_store>
|
12 |
+
<groups>
|
13 |
+
<general translate="label" module="creditpoint">
|
14 |
+
<label>Credit Points Configuration</label>
|
15 |
+
<sort_order>20</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<fields>
|
20 |
+
<active translate="label">
|
21 |
+
<label>Enable Credit Points</label>
|
22 |
+
<frontend_type>select</frontend_type>
|
23 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
24 |
+
<sort_order>1</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<show_in_store>1</show_in_store>
|
28 |
+
</active>
|
29 |
+
<points_currency translate="label">
|
30 |
+
<label>Points / Currency Exchange Rate</label>
|
31 |
+
<frontend_type>text</frontend_type>
|
32 |
+
<comment>Format x/y (x points / y currency). X and Y must be integer. For ex: 10 points = $1</comment>
|
33 |
+
<validate>required-entry</validate>
|
34 |
+
<sort_order>2</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
</points_currency>
|
39 |
+
<points_earn translate="label">
|
40 |
+
<label>Customer Earn Points Ratio</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<comment>Format x/y (x currency / y points). X and Y must be integer. For ex: $100 = 10 points (Customer will earn 10 points for every $100 spent)</comment>
|
43 |
+
<sort_order>3</sort_order>
|
44 |
+
<validate>required-entry</validate>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>1</show_in_store>
|
48 |
+
</points_earn>
|
49 |
+
<minimum_credit_required translate="label">
|
50 |
+
<label>Minimum Points required to be redeemed per purchase</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<comment>Set 0 or leave empty if no limitations.</comment>
|
53 |
+
<validate>validate-number</validate>
|
54 |
+
<sort_order>4</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>1</show_in_store>
|
58 |
+
</minimum_credit_required>
|
59 |
+
<maximum_credit_allowed translate="label">
|
60 |
+
<label>Maximum Points allowed to be redeemed per purchase</label>
|
61 |
+
<frontend_type>text</frontend_type>
|
62 |
+
<comment>Set 0 or leave empty if no limitations.</comment>
|
63 |
+
<validate>validate-number</validate>
|
64 |
+
<sort_order>5</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
</maximum_credit_allowed>
|
69 |
+
<order_status translate="label">
|
70 |
+
<label>Add credit points to account balance when order status is</label>
|
71 |
+
<frontend_type>select</frontend_type>
|
72 |
+
<sort_order>7</sort_order>
|
73 |
+
<!--<source_model>adminhtml/system_config_source_order_status</source_model>-->
|
74 |
+
<source_model>creditpoint_adminhtml/system_config_source_orderoptions</source_model>
|
75 |
+
<validate>validate-select</validate>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
</order_status>
|
80 |
+
<restore_redeemed_credits translate="label">
|
81 |
+
<label>Restore redeemed points when order is refunded</label>
|
82 |
+
<frontend_type>select</frontend_type>
|
83 |
+
<sort_order>8</sort_order>
|
84 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
85 |
+
<show_in_default>1</show_in_default>
|
86 |
+
<show_in_website>1</show_in_website>
|
87 |
+
<show_in_store>1</show_in_store>
|
88 |
+
</restore_redeemed_credits>
|
89 |
+
</fields>
|
90 |
+
</general>
|
91 |
+
</groups>
|
92 |
+
</creditpoint>
|
93 |
+
</sections>
|
94 |
+
</config>
|
app/code/community/Ei/Creditpoint/sql/creditpoint_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* @category Mage
|
5 |
+
* @package Inic_Creditpayment
|
6 |
+
*/
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
$installer->addAttribute('customer', 'credit_point', array(
|
12 |
+
'label' => 'Credit Point',
|
13 |
+
'visible' => 1,
|
14 |
+
'type' => 'decimal',
|
15 |
+
'required' => 0,
|
16 |
+
'position' => 2,
|
17 |
+
'sort_order' => 200
|
18 |
+
));
|
19 |
+
|
20 |
+
|
21 |
+
$installer->run("
|
22 |
+
-- DROP TABLE IF EXISTS {$this->getTable('customer_credit_point')};
|
23 |
+
|
24 |
+
CREATE TABLE `{$this->getTable('customer_credit_point')}` (
|
25 |
+
`id` INT(10) unsigned NOT NULL auto_increment,
|
26 |
+
`customer_id` INT(10) NOT NULL,
|
27 |
+
`order_id` INT(10) NOT NULL,
|
28 |
+
`applied_credit_point` DECIMAL(12,2) NOT NULL,
|
29 |
+
`applied_credit_point_price` DECIMAL(12,2) NOT NULL,
|
30 |
+
`earned_credit_point` DECIMAL(12,2) NOT NULL,
|
31 |
+
`order_refund` INT(10) NOT NULL,
|
32 |
+
`created_time` timestamp NULL,
|
33 |
+
PRIMARY KEY (`id`)
|
34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
35 |
+
|
36 |
+
");
|
37 |
+
|
38 |
+
|
39 |
+
$customerattrubute = Mage::getModel('customer/attribute')->loadByCode('customer', 'credit_point');
|
40 |
+
$forms=array('adminhtml_customer'); // //to make the attribute can be created in backend only
|
41 |
+
$customerattrubute->setData('used_in_forms', $forms);
|
42 |
+
$customerattrubute->save();
|
43 |
+
|
44 |
+
$installer->endSetup();
|
app/code/community/Ei/Creditpoint/sql/creditpoint_setup/mysql4-upgrade-1.0.0-1.0.1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
|
7 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
8 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
9 |
+
|
10 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
11 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `base_creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
12 |
+
|
13 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `creditpoint_amount_invoiced` DECIMAL (10,2) NOT NULL;
|
14 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_creditpoint_amount_invoiced` DECIMAL (10,2) NOT NULL;
|
15 |
+
|
16 |
+
ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
17 |
+
ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `base_creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
18 |
+
|
19 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `creditpoint_amount_refunded` DECIMAL (10,2) NOT NULL;
|
20 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_creditpoint_amount_refunded` DECIMAL (10,2) NOT NULL;
|
21 |
+
|
22 |
+
ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
23 |
+
ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `base_creditpoint_amount` DECIMAL (10,2) NOT NULL;
|
24 |
+
|
25 |
+
");
|
26 |
+
|
27 |
+
$installer->endSetup();
|
28 |
+
|
29 |
+
|
30 |
+
?>
|
app/design/adminhtml/default/default/layout/ei/creditpoint.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<adminhtml_customer_edit>
|
4 |
+
<reference name="customer_edit_tabs">
|
5 |
+
<action method="addTab" ifconfig="creditpoint/general/active">
|
6 |
+
<name>customer_edit_tab_creditpoint</name>
|
7 |
+
<block>creditpoint/adminhtml_customer_edit_tab_creditpoint</block>
|
8 |
+
</action>
|
9 |
+
</reference>
|
10 |
+
</adminhtml_customer_edit>
|
11 |
+
</layout>
|
app/design/adminhtml/default/default/template/ei/creditpoint/creditpoint.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="credit-point">
|
2 |
+
<div class="entry-edit">
|
3 |
+
<div class="entry-edit-head">
|
4 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Credit Points Tab</h4>
|
5 |
+
</div>
|
6 |
+
<div id="group_fields4" class="fieldset fieldset-wide">
|
7 |
+
<div class="hor-scroll">
|
8 |
+
<table class="form-list credit-table" cellspacing="0">
|
9 |
+
<tbody>
|
10 |
+
<tr>
|
11 |
+
<td class="label"><label for="_accountcredit_point"><?php echo $this->__('Credit Points') ?></label></td>
|
12 |
+
<td class="value">
|
13 |
+
<input type="text" class=" input-text credit-point" value="<?php echo $this->getCreditPoint() ?>" name="account[credit_point]" id="_accountcredit_point">
|
14 |
+
</td>
|
15 |
+
</tr>
|
16 |
+
</tbody>
|
17 |
+
</table>
|
18 |
+
</div>
|
19 |
+
</div>
|
20 |
+
</div>
|
21 |
+
</div>
|
app/design/adminhtml/default/default/template/ei/creditpoint/sales/order/refunded.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="credit-point">
|
2 |
+
<div class="entry-edit">
|
3 |
+
<div class="entry-edit-head">
|
4 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Credit Points Tab</h4>
|
5 |
+
</div>
|
6 |
+
<div id="group_fields4" class="fieldset fieldset-wide">
|
7 |
+
<div class="hor-scroll">
|
8 |
+
<table class="form-list credit-table" cellspacing="0">
|
9 |
+
<tbody>
|
10 |
+
<tr>
|
11 |
+
<td class="label"><label for="_accountcredit_point"><?php echo $this->__('Credit Points') ?></label></td>
|
12 |
+
<td class="value">
|
13 |
+
<input type="text" class=" input-text credit-point" value="<?php echo $this->getCreditPoint() ?>" name="account[credit_point]" id="_accountcredit_point">
|
14 |
+
</td>
|
15 |
+
</tr>
|
16 |
+
</tbody>
|
17 |
+
</table>
|
18 |
+
</div>
|
19 |
+
</div>
|
20 |
+
</div>
|
21 |
+
</div>
|
app/design/adminhtml/default/default/template/ei/creditpoint/sales/order/total.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="credit-point">
|
2 |
+
<div class="entry-edit">
|
3 |
+
<div class="entry-edit-head">
|
4 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Credit Points Tab</h4>
|
5 |
+
</div>
|
6 |
+
<div id="group_fields4" class="fieldset fieldset-wide">
|
7 |
+
<div class="hor-scroll">
|
8 |
+
<table class="form-list credit-table" cellspacing="0">
|
9 |
+
<tbody>
|
10 |
+
<tr>
|
11 |
+
<td class="label"><label for="_accountcredit_point"><?php echo $this->__('Credit Points') ?></label></td>
|
12 |
+
<td class="value">
|
13 |
+
<input type="text" class=" input-text credit-point" value="<?php echo $this->getCreditPoint() ?>" name="account[credit_point]" id="_accountcredit_point">
|
14 |
+
</td>
|
15 |
+
</tr>
|
16 |
+
</tbody>
|
17 |
+
</table>
|
18 |
+
</div>
|
19 |
+
</div>
|
20 |
+
</div>
|
21 |
+
</div>
|
app/design/frontend/default/default/layout/ei/creditpoint.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<customer_account>
|
4 |
+
<reference name="customer_account_navigation">
|
5 |
+
<action method="addLink" translate="label" module="creditpoint" ifconfig="creditpoint/general/active">
|
6 |
+
<name>credit point</name>
|
7 |
+
<path>creditpoint/creditpoint/</path>
|
8 |
+
<label>My Credit Points</label>
|
9 |
+
</action>
|
10 |
+
</reference>
|
11 |
+
</customer_account>
|
12 |
+
<!--Namespace_Modulename_Controllername_Actionname-->
|
13 |
+
<ei_creditpoint_creditpoint_index translate="label">
|
14 |
+
<label>My Credit Points</label>
|
15 |
+
<reference name="head">
|
16 |
+
<action method="setTitle">
|
17 |
+
<title>My Credit Points</title>
|
18 |
+
</action>
|
19 |
+
</reference>
|
20 |
+
<update handle="customer_account"/>
|
21 |
+
<reference name="my.account.wrapper">
|
22 |
+
<!--<block type="customer/account_dashboard" name="customer_creditpoints" template="creditpoint/creditpoint.phtml"/>-->
|
23 |
+
<block type="creditpoint/creditpoint" name="creditpoint.pager" template="ei/creditpoint/creditpoint.phtml"/>
|
24 |
+
</reference>
|
25 |
+
</ei_creditpoint_creditpoint_index>
|
26 |
+
<!--Namespace_Modulename_Controllername_Actionname-->
|
27 |
+
|
28 |
+
<!-- This will override the coupon output, then adds the coupon block back as well as our own custom creditpoint block-->
|
29 |
+
<checkout_cart_index>
|
30 |
+
<reference name="head">
|
31 |
+
<action method="addItem"><type>skin_css</type><name>css/ei/creditpoint/creditpoint.slider.css</name><params/></action>
|
32 |
+
<action method="addItem"><type>skin_js</type><name>js/ei/creditpoint/creditpoint.slider.js</name><params/></action>
|
33 |
+
</reference>
|
34 |
+
<reference name="checkout.cart">
|
35 |
+
<block type="core/text_list" name="coupon.and.discount" as="coupon">
|
36 |
+
<action method="insert">
|
37 |
+
<block>checkout.cart.coupon</block>
|
38 |
+
</action>
|
39 |
+
<block type="creditpoint/creditpoint" name="creditpoints.cart.block" as ="creditpointblock" template="ei/creditpoint/checkout/cart/creditpoint_cart.phtml" before="checkout.cart.coupon"/>
|
40 |
+
</block>
|
41 |
+
</reference>
|
42 |
+
</checkout_cart_index>
|
43 |
+
<!-- This will override the coupon output, then adds the coupon block back as well as our own custom creditpoint block-->
|
44 |
+
</layout>
|
app/design/frontend/default/default/template/ei/creditpoint/checkout/cart/creditpoint_cart.phtml
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$moduleStatus = Mage::helper('creditpoint')->getModuleStatus();
|
4 |
+
$customerLogin = Mage::getSingleton('customer/session')->isLoggedIn();
|
5 |
+
$totalItemsInCart = Mage::helper('creditpoint')->getTotalItemsInCart();
|
6 |
+
if ($moduleStatus == 1 && $customerLogin && $totalItemsInCart > 0):
|
7 |
+
?>
|
8 |
+
|
9 |
+
<?php
|
10 |
+
$subTotal = Mage::helper('checkout/cart')->getQuote()->getSubtotal();
|
11 |
+
$creditPointCode = Mage::helper('creditpoint')->getCode();
|
12 |
+
$EstimateCredit = Mage::getSingleton('core/session')->getEstimateCredit();
|
13 |
+
$pointsRedeem = Mage::getSingleton('core/session')->getPointsRedeem();
|
14 |
+
$formAction = Mage::getBaseUrl() . 'creditpoint/creditpoint/estimateCreditPoint/';
|
15 |
+
$creditPoints = Mage::helper('creditpoint')->getCustomerCreditPointsAssigned();
|
16 |
+
$finalRatio = Mage::helper('creditpoint')->getPointCurrencyRatio();
|
17 |
+
$maxCreditConfig = Mage::helper('creditpoint')->getMaximumCredit();
|
18 |
+
$minCreditConfig = Mage::helper('creditpoint')->getMinimumCredit();
|
19 |
+
|
20 |
+
$currentPointAmount = number_format(Mage::helper('creditpoint')->getPointCurrencyAmount($creditPoints), 2, '.', '');
|
21 |
+
$ratio = Mage::getStoreConfig('creditpoint/general/points_currency');
|
22 |
+
$formatRatio = explode('/', $ratio);
|
23 |
+
//$pointsRatio = $formatRatio[0];
|
24 |
+
$pointsRatio = $formatRatio[0]/$formatRatio[1];
|
25 |
+
$subtotalCredit = floor($pointsRatio * $subTotal);
|
26 |
+
|
27 |
+
|
28 |
+
// if (($pointsRedeem == '') && ($maxCreditConfig == 0 || $maxCreditConfig == NULL) && ($currentPointAmount >= $subTotal)) {
|
29 |
+
// echo $subtotalCredit;
|
30 |
+
// echo 'YYY11';
|
31 |
+
// $maxCredit = $subtotalCredit;
|
32 |
+
// } elseif (($pointsRedeem == '') && ($maxCreditConfig == 0 || $maxCreditConfig == NULL) && ($currentPointAmount <= $subTotal)) {
|
33 |
+
// echo 'YYY22';
|
34 |
+
// $maxCredit = $creditPoints;
|
35 |
+
// } elseif (($pointsRedeem == '') && ($maxCreditConfig >= $currentPointAmount)) {
|
36 |
+
// echo 'YYY33';
|
37 |
+
// $maxCredit = $creditPoints;
|
38 |
+
// } elseif (($pointsRedeem == '') && ($maxCreditConfig <= $currentPointAmount)) {
|
39 |
+
// echo 'YYY444';
|
40 |
+
// $maxCredit = $maxCreditConfig;
|
41 |
+
// } elseif ($pointsRedeem != '') {
|
42 |
+
// echo 'YYY555';
|
43 |
+
// $maxCredit = $pointsRedeem;
|
44 |
+
// } else {
|
45 |
+
// echo 'YYY';
|
46 |
+
// $maxCredit = $maxCreditConfig;
|
47 |
+
// }
|
48 |
+
|
49 |
+
if (($maxCreditConfig == 0 || $maxCreditConfig == NULL) && ($currentPointAmount >= $subTotal)) {
|
50 |
+
$maxCredit = $subtotalCredit;
|
51 |
+
} elseif (($maxCreditConfig == 0 || $maxCreditConfig == NULL) && ($currentPointAmount <= $subTotal)) {
|
52 |
+
$maxCredit = $creditPoints;
|
53 |
+
} elseif (($maxCreditConfig >= $currentPointAmount)) {
|
54 |
+
$maxCredit = $creditPoints;
|
55 |
+
} elseif (($maxCreditConfig <= $currentPointAmount)) {
|
56 |
+
$maxCredit = $maxCreditConfig;
|
57 |
+
} else {
|
58 |
+
$maxCredit = $maxCreditConfig;
|
59 |
+
}
|
60 |
+
|
61 |
+
?>
|
62 |
+
|
63 |
+
|
64 |
+
<form id="customer-creditpoint-form" action="<?php echo $formAction; ?>" method="post">
|
65 |
+
<div class="discount">
|
66 |
+
<h2><?php echo $this->__('Redeem Credit Points'); ?></h2>
|
67 |
+
<div class="discount-form">
|
68 |
+
|
69 |
+
<input type="hidden" name="estimate_credit" id="estimate_credit" value="<?php echo $this->escapeHtml($creditPointCode) ?>"/>
|
70 |
+
|
71 |
+
<div style="padding-top: 5px;">
|
72 |
+
<label for="use_min_credit" style="display: inline !important;">
|
73 |
+
<?php echo $this->__('Credit Points Available'); ?>: <strong><?php echo $creditPoints; ?></strong>
|
74 |
+
<strong>(<?php echo $finalRatio; ?>)</strong>
|
75 |
+
</label>
|
76 |
+
</div>
|
77 |
+
|
78 |
+
<!--Check minimum credit availability-->
|
79 |
+
<?php if ($minCreditConfig > $creditPoints): ?>
|
80 |
+
<div style="padding-top: 5px;">
|
81 |
+
<label style="display: inline !important;">
|
82 |
+
<?php echo $this->__('Minimum credit points required to redeem'); ?>: <strong><?php echo $minCreditConfig; ?> points</strong>
|
83 |
+
</label>
|
84 |
+
</div>
|
85 |
+
|
86 |
+
<?php elseif (empty($creditPoints)): ?>
|
87 |
+
<div style="padding-top: 5px;">
|
88 |
+
<label style="display: inline !important;">
|
89 |
+
<?php echo $this->__('You do not have sufficient credit points.'); ?>
|
90 |
+
</label>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<?php else: ?>
|
94 |
+
<div style="padding-top: 5px;">
|
95 |
+
<label style="display: inline !important;"><?php echo $this->__('Slide to redeem your credit points.'); ?></label>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
|
99 |
+
<div style="width:215px;" class="ei_creditpoint_slider_container" id="ei_creditpoint_slider_container">
|
100 |
+
<div id="ei_creditpoint_decr_handle"></div>
|
101 |
+
<div id="ei_creditpoint_incr_handle"></div>
|
102 |
+
<div class="ei_creditpoint_select" id="ei_slider" style="left: 214px;"></div>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<div style="padding: 15px 0 5px 0;"><label for="credit_point">Points to redeem </label>
|
106 |
+
<input style="color:#f6931f; width:50px; text-align:center;font-size: 13px;font-weight: bold;" type="text" name="credit_point" id="credit_point" />
|
107 |
+
<label id="ei_label_amount" style="color:#f6931f; font-weight:bold;display:none;"></label></div>
|
108 |
+
|
109 |
+
<div>
|
110 |
+
<input type="checkbox" name="use_max_credit_points" id="use_max_credit_points" />
|
111 |
+
<label for="use_max_credit_points" style="padding-left: 5px;display: inline !important;"><?php echo $this->__('Use maximum'); ?> <span class="price">
|
112 |
+
<strong>(<?php echo $maxCredit; ?> points)</strong></span>
|
113 |
+
</label>
|
114 |
+
</div>
|
115 |
+
|
116 |
+
<?php endif; ?>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
|
121 |
+
<div id="cart-totals-loading" style="display: none; ">
|
122 |
+
<div style="text-align:center;margin-top:30px;">
|
123 |
+
<img src="http://demo.mage-world.com/1611/skin/frontend/default/default/mw_rewardpoints/images/loading.gif" class="v-middle" alt="loading">
|
124 |
+
<?php echo $this->__('Updating cart information...');?>
|
125 |
+
</div>
|
126 |
+
</div>
|
127 |
+
</form>
|
128 |
+
|
129 |
+
<script type="text/javascript">
|
130 |
+
|
131 |
+
var creditPointVal = '<?php echo $maxCredit; ?>';
|
132 |
+
var pointsRedeem = '<?php echo $pointsRedeem; ?>';
|
133 |
+
var time = 1000;
|
134 |
+
var time_new = 1500; //was 2000
|
135 |
+
var timer;
|
136 |
+
var ei_sider = new EiCreditPointSlider(
|
137 |
+
'credit_point',
|
138 |
+
'ei_creditpoint_slider_container',
|
139 |
+
'ei_slider',
|
140 |
+
'ei_creditpoint_decr_handle',
|
141 |
+
'ei_creditpoint_incr_handle',
|
142 |
+
0,
|
143 |
+
creditPointVal,
|
144 |
+
1,
|
145 |
+
'ei_label_amount',
|
146 |
+
'use_max_credit_points'
|
147 |
+
);
|
148 |
+
|
149 |
+
|
150 |
+
ei_sider.setPointChange(0);
|
151 |
+
ei_sider.changeCreditPointCallback = runTimer;
|
152 |
+
|
153 |
+
$('credit_point').observe('keyup', function(e) {
|
154 |
+
|
155 |
+
amount = this.value;
|
156 |
+
clearTimeout(timer);
|
157 |
+
timer = setTimeout("ei_sider.setPointChange(amount);", time_new);
|
158 |
+
|
159 |
+
});
|
160 |
+
|
161 |
+
if(pointsRedeem != '' && pointsRedeem == creditPointVal){
|
162 |
+
$('credit_point').value = pointsRedeem ;
|
163 |
+
$('use_max_credit_points').checked = true;
|
164 |
+
}else if(pointsRedeem != '' && pointsRedeem != creditPointVal){
|
165 |
+
$('credit_point').value = pointsRedeem ;
|
166 |
+
}
|
167 |
+
|
168 |
+
$('use_max_credit_points').observe('click', function(e) {
|
169 |
+
|
170 |
+
if (this.checked)
|
171 |
+
ei_sider.setPointChange(creditPointVal);
|
172 |
+
else
|
173 |
+
ei_sider.setPointChange(0);
|
174 |
+
});
|
175 |
+
|
176 |
+
|
177 |
+
function runTimer()
|
178 |
+
{
|
179 |
+
clearTimeout(timer);
|
180 |
+
timer = setTimeout("updateCreditPoints();", time);
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
function updateCreditPoints()
|
185 |
+
{
|
186 |
+
var amount = $('credit_point').value;
|
187 |
+
amount = parseInt(amount/1) * 1;
|
188 |
+
if(amount < 0) amount = 0;
|
189 |
+
|
190 |
+
$('shopping-cart-totals-table').update($('cart-totals-loading').innerHTML);
|
191 |
+
|
192 |
+
//'data' will be an Object after json is converted into a JS object
|
193 |
+
//and this object should have a property 'creditpointblock' with the HTML for the cart block.
|
194 |
+
new Ajax.Request("<?php echo $formAction;?>", {
|
195 |
+
|
196 |
+
method: 'post',
|
197 |
+
//postBody: "pointsredeem="+$('credit_point').value + "&isChecked="+$('use_max_credit_points').readAttribute('is_itchecked')+ "&estimate_credit="+$('estimate_credit').value,
|
198 |
+
postBody: "pointsredeem="+$('credit_point').value + "&estimate_credit="+$('estimate_credit').value,
|
199 |
+
onComplete: function(response) {
|
200 |
+
var data = response.responseText.evalJSON(true);
|
201 |
+
$('shopping-cart-totals-table').update(data.creditpointblock);
|
202 |
+
}
|
203 |
+
});
|
204 |
+
}
|
205 |
+
|
206 |
+
</script>
|
207 |
+
<?php endif; ?>
|
app/design/frontend/default/default/template/ei/creditpoint/creditpoint.phtml
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$customerId = Mage::helper('creditpoint')->getCurrentCustomerId();
|
3 |
+
$customerCreditPoints = Mage::helper('creditpoint')->getCustomerCreditPointsAssigned();
|
4 |
+
$customerCollection = $this->getCollection();
|
5 |
+
?>
|
6 |
+
|
7 |
+
<?php $currentCurrency = Mage::helper('creditpoint')->getCurrentCurrencySymbol(); ?>
|
8 |
+
<?php $creditPoints = Mage::helper('creditpoint')->getFormatCreditPoint($customerCreditPoints); ?>
|
9 |
+
<?php $currentPointAmount = number_format(Mage::helper('creditpoint')->getPointCurrencyAmount($creditPoints), 2, '.', ''); ?>
|
10 |
+
<?php $finalRatio = Mage::helper('creditpoint')->getPointCurrencyRatio(); ?>
|
11 |
+
<?php $finalEarnedPointsRatio = Mage::helper('creditpoint')->getEarnedPointsRatio(); ?>
|
12 |
+
|
13 |
+
|
14 |
+
<div class="box-account">
|
15 |
+
<div class="box-head">
|
16 |
+
<h2><?php echo $this->__('Credit Points Information') ?></h2>
|
17 |
+
</div>
|
18 |
+
|
19 |
+
<div>
|
20 |
+
<?php echo $this->__('Your Credit Points'); ?>:
|
21 |
+
<strong><?php echo $creditPoints; ?> <?php echo $this->__('Points'); ?> = <?php echo $currentCurrency; ?><?php echo $currentPointAmount; ?></strong>
|
22 |
+
</div>
|
23 |
+
<br/>
|
24 |
+
<div>
|
25 |
+
<?php echo $this->__('Points/Currency Exchange Rate'); ?>: <strong><?php echo $finalRatio; ?></strong>
|
26 |
+
</div>
|
27 |
+
<br/>
|
28 |
+
<div>
|
29 |
+
<?php echo $finalEarnedPointsRatio; ?>
|
30 |
+
</div>
|
31 |
+
|
32 |
+
</div>
|
33 |
+
|
34 |
+
|
35 |
+
<!--Credit Points Transaction History Starts-->
|
36 |
+
<?php if ($customerCollection->getSize()): ?>
|
37 |
+
|
38 |
+
<?php echo $this->getPagerHtml(); ?>
|
39 |
+
<div class="box-account">
|
40 |
+
<div class="head box-head">
|
41 |
+
<h2>Credit Points Transaction History</h2>
|
42 |
+
<a href="javascript:void(0)" id="transaction_box_hander">Hide</a>
|
43 |
+
</div>
|
44 |
+
<div id="transaction_history_box" style="display: block;">
|
45 |
+
<table id="creditpoint-transaction-table" class="data-table">
|
46 |
+
<colgroup>
|
47 |
+
<col width="1" />
|
48 |
+
<col width="1" />
|
49 |
+
<col width="1" />
|
50 |
+
<col width="1" />
|
51 |
+
<col width="1" />
|
52 |
+
<col width="1" />
|
53 |
+
</colgroup>
|
54 |
+
<thead>
|
55 |
+
<tr class="first last">
|
56 |
+
<th style="text-align: center;"><?php echo $this->__('Order #'); ?></th>
|
57 |
+
<th style="text-align: center;"><?php echo $this->__('Date'); ?></th>
|
58 |
+
<th style="text-align: center;"><?php echo $this->__('Points Redeemed'); ?></th>
|
59 |
+
<th style="text-align: center;"><?php echo $this->__('Points Price'); ?></th>
|
60 |
+
<th style="text-align: center;"><?php echo $this->__('Points Earned'); ?></th>
|
61 |
+
</tr>
|
62 |
+
</thead>
|
63 |
+
<tbody>
|
64 |
+
|
65 |
+
<?php
|
66 |
+
foreach ($customerCollection as $collection):
|
67 |
+
|
68 |
+
$order = Mage::getModel('sales/order')->load($collection->getOrderId());
|
69 |
+
$orderUrl = Mage::helper('creditpoint')->getOrderUrl($order->getEntityId());
|
70 |
+
$orderDate = date('m/d/Y', strtotime($collection->getCreatedTime()));
|
71 |
+
if ($collection->getEarnedCreditPoint() != 0):
|
72 |
+
?>
|
73 |
+
|
74 |
+
<tr class="first odd">
|
75 |
+
<td style="text-align: center;"><a href="<?php echo $orderUrl; ?>" target="_blank"><?php echo $order->getIncrementId(); ?></a>
|
76 |
+
<td style="text-align: center;"><?php echo $orderDate; ?>
|
77 |
+
<td style="text-align: center;"><?php echo number_format($collection->getAppliedCreditPoint()); ?>
|
78 |
+
<td style="text-align: center;"><?php echo Mage::helper('creditpoint')->getCurrentCurrencySymbol(); ?><?php echo $collection->getAppliedCreditPointPrice(); ?>
|
79 |
+
<td style="text-align: center;"><?php echo number_format($collection->getEarnedCreditPoint()); ?>
|
80 |
+
</tr>
|
81 |
+
|
82 |
+
<?php else: ?>
|
83 |
+
|
84 |
+
<tr class="first odd">
|
85 |
+
<td style="text-align: center;"><a href="<?php echo $orderUrl; ?>" target="_blank"><?php echo $order->getIncrementId(); ?></a>
|
86 |
+
<td style="text-align: center;"><?php echo $orderDate; ?>
|
87 |
+
<td style="text-align: center;"><?php echo number_format($collection->getAppliedCreditPoint()); ?>
|
88 |
+
<td style="text-align: center;"><?php echo Mage::helper('creditpoint')->getCurrentCurrencySymbol(); ?><?php echo $collection->getAppliedCreditPointPrice(); ?>
|
89 |
+
<td style="text-align: center;"><?php echo $this->__('-'); ?>
|
90 |
+
</tr>
|
91 |
+
|
92 |
+
<?php endif; ?>
|
93 |
+
|
94 |
+
<?php endforeach; ?>
|
95 |
+
</tbody>
|
96 |
+
</table>
|
97 |
+
</div>
|
98 |
+
<script type="text/javascript">decorateTable('creditpoint-transaction-table')</script>
|
99 |
+
</div>
|
100 |
+
<?php echo $this->getPagerHtml(); ?>
|
101 |
+
<?php endif; ?>
|
102 |
+
<!--Credit Points Transaction History Ends-->
|
103 |
+
|
104 |
+
<div class="buttons-set">
|
105 |
+
<p class="back-link"><a href="<?php echo $this->getUrl('customer/account/') ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
106 |
+
</div>
|
107 |
+
|
108 |
+
<script type="text/javascript">
|
109 |
+
$('transaction_box_hander').observe('click', function(event) {
|
110 |
+
Effect.toggle('transaction_history_box', 'slide');
|
111 |
+
if ($('transaction_history_box').visible()) {
|
112 |
+
$('transaction_box_hander').update('Show');
|
113 |
+
} else {
|
114 |
+
$('transaction_box_hander').update('Hide');
|
115 |
+
}
|
116 |
+
Event.stop(event);
|
117 |
+
});
|
118 |
+
</script>
|
app/etc/modules/Ei_Creditpoint.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ei_Creditpoint>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Ei_Creditpoint>
|
8 |
+
</modules>
|
9 |
+
</config>
|
10 |
+
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>ei_creditpoint</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Credit points for Customers</summary>
|
10 |
+
<description>The Customer Credit points module allows customer to earn points while they shop at your store. The earned points can be redeem on cart page. The more they shop, the more they earn points.</description>
|
11 |
+
<notes>Credit points for Customers</notes>
|
12 |
+
<authors><author><name>Vikram</name><user>Purohit</user><email>vikram.purohit@einfochips.com</email></author></authors>
|
13 |
+
<date>2014-09-02</date>
|
14 |
+
<time>07:51:36</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Ei"><dir name="Creditpoint"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Orderoptions.php" hash="385602f3f9db18e649c5c218d7f093d8"/></dir></dir></dir></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Creditpoint.php" hash="b515b9976fcb79d7a1f90d5872e58643"/></dir></dir></dir></dir><file name="Creditpoint.php" hash="9774c56ca6539f887b9ff595edc836c1"/><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="48c5a2befa763c883098bbeabfa9e5c7"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f3f1844d9db3c9c75c5df42bec13dd8f"/></dir><dir name="Model"><file name="Creditpoint.php" hash="487997bbdd06df8bcf2fb0acee9a0a86"/><dir name="Mysql4"><dir name="Creditpoint"><file name="Collection.php" hash="bc0c833c9e8b66a3abe6ff2b2bed928d"/></dir><file name="Creditpoint.php" hash="aeb12f97990677204a06b33bfbd0a815"/></dir><file name="Observer.php" hash="d22cfc0e940ef4821111d604ee72e759"/><dir name="Sales"><dir name="Order"><dir name="Total"><dir name="Creditmemo"><file name="Creditpoint.php" hash="9d7162741d9db0a3c8047b95e9902688"/></dir><dir name="Invoice"><file name="Creditpoint.php" hash="1344f244d6358e53b69bb5483c2999e3"/></dir></dir></dir><dir name="Pdf"><file name="Creditpoint.php" hash="6582b18d709d887cf29329fdf401411f"/></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Creditpoint.php" hash="5061f55386b6febeee618a3ce388ce19"/></dir></dir></dir></dir></dir><dir name="RW"><dir name="Adminhtml"><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="156e60a3964173aef4dc93697a3214a1"/></dir><dir name="Invoice"><file name="Totals.php" hash="a54a18f86bbad6d9c8aef8210de98717"/></dir><file name="Totals.php" hash="512f1b58a6934bfc40c8bb7d3ca4022b"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="CreditpointController.php" hash="3ba7494e74744230e4a24f76e8029fb2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7ac9642f795ddb29b07cc8c6c4e44e9e"/><file name="config.xml" hash="e131c89a942b3dd186f170e2b7ab42d9"/><file name="system.xml" hash="e551ba3bffc0edd1581911d44e85ae6f"/></dir><dir name="sql"><dir name="creditpoint_setup"><file name="mysql4-install-1.0.0.php" hash="880d0ab0ea17e21171eeba6cff9c2f8b"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="111a8005b6307bdef71131d0a919b9bd"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="ei"><file name="creditpoint.xml" hash="06142043ad10531c00e17fcc55dcecb7"/></dir></dir><dir name="template"><dir name="ei"><dir name="creditpoint"><file name="creditpoint.phtml" hash="5810d17566b9ce44af1349e67711d14d"/><dir name="sales"><dir name="order"><file name="refunded.phtml" hash="5810d17566b9ce44af1349e67711d14d"/><file name="total.phtml" hash="5810d17566b9ce44af1349e67711d14d"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="ei"><file name="creditpoint.xml" hash="3badb8166a25afedcfd7e218605d2ac2"/></dir></dir><dir name="template"><dir name="ei"><dir name="creditpoint"><dir name="checkout"><dir name="cart"><file name="creditpoint_cart.phtml" hash="3af89a2def887566f52bf7a01a0f168f"/></dir></dir><file name="creditpoint.phtml" hash="50c343c34a9fe6cd39b037b7797a169e"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ei_Creditpoint.xml" hash="ca3ddeca79bebf390ecae5ba99a02c72"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><dir name="ei"><dir name="creditpoint"><file name="creditpoint.slider.css" hash="3c907174a54c63cb47b3486c78217d29"/></dir></dir></dir><dir name="images"><dir name="ei"><dir name="creditpoint"><file name="minus_hover.png" hash="06f8452db0980deb8f57f2e97fb0a257"/><file name="minus_normal.png" hash="0cc17a65b2f6a5c614b4419ec0375a64"/><file name="plus_hover.png" hash="dc064edecd293e76d77ddd59808c683d"/><file name="plus_normal.png" hash="8c50b00bb07fefe1657d764e919507a1"/><file name="slider_bg.png" hash="908d2cbcdfcb0b4c14cab815586bd1ba"/><file name="slider_circle.png" hash="b5e94f294cbd961db5e2f697e381a484"/></dir></dir></dir><dir name="js"><dir name="ei"><dir name="creditpoint"><file name="creditpoint.slider.js" hash="a515dcefcead733829f6a55bddebe914"/></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/default/default/css/ei/creditpoint/creditpoint.slider.css
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#ei_creditpoint_incr_handle, #ei_creditpoint_decr_handle{
|
3 |
+
width: 18px;
|
4 |
+
height: 18px;
|
5 |
+
float:left;
|
6 |
+
margin-top: -5px;
|
7 |
+
}
|
8 |
+
|
9 |
+
#ei_creditpoint_incr_handle{
|
10 |
+
background: url("../../../images/ei/creditpoint/plus_normal.png") no-repeat scroll 0 0 transparent;
|
11 |
+
position: absolute;
|
12 |
+
right: -20px;
|
13 |
+
}
|
14 |
+
|
15 |
+
#ei_creditpoint_incr_handle:HOVER{
|
16 |
+
background: url("../../../images/ei/creditpoint/plus_hover.png") no-repeat scroll 0 0 transparent;
|
17 |
+
}
|
18 |
+
|
19 |
+
#ei_creditpoint_decr_handle{
|
20 |
+
background: url("../../../images/ei/creditpoint/minus_normal.png") no-repeat scroll 0 0 transparent;
|
21 |
+
position: absolute;
|
22 |
+
margin-left: -20px;
|
23 |
+
}
|
24 |
+
|
25 |
+
#ei_creditpoint_decr_handle:HOVER{
|
26 |
+
background: url("../../../images/ei/creditpoint/minus_hover.png") no-repeat scroll 0 0 transparent;
|
27 |
+
}
|
28 |
+
|
29 |
+
.ei_creditpoint_select {
|
30 |
+
background: url("../../../images/ei/creditpoint/slider_circle.png") no-repeat scroll 0 0 transparent;
|
31 |
+
font-weight: normal;
|
32 |
+
color: #555555;
|
33 |
+
min-height: 16px;
|
34 |
+
cursor: default;
|
35 |
+
height: 2em;
|
36 |
+
margin-top: -5px;
|
37 |
+
position: absolute;
|
38 |
+
width: 1.9em;
|
39 |
+
z-index: 2;
|
40 |
+
}
|
41 |
+
|
42 |
+
.ei_creditpoint_slider_container{
|
43 |
+
background:url(../../../images/ei/creditpoint/slider_bg.png) repeat-x scroll 0 0 transparent;
|
44 |
+
margin-top: 18px;
|
45 |
+
margin-bottom: 5px;
|
46 |
+
margin-left:20px;
|
47 |
+
padding-right: 6px;
|
48 |
+
position: relative;
|
49 |
+
min-height: 10px;
|
50 |
+
}
|
skin/frontend/default/default/images/ei/creditpoint/minus_hover.png
ADDED
Binary file
|
skin/frontend/default/default/images/ei/creditpoint/minus_normal.png
ADDED
Binary file
|
skin/frontend/default/default/images/ei/creditpoint/plus_hover.png
ADDED
Binary file
|
skin/frontend/default/default/images/ei/creditpoint/plus_normal.png
ADDED
Binary file
|
skin/frontend/default/default/images/ei/creditpoint/slider_bg.png
ADDED
Binary file
|
skin/frontend/default/default/images/ei/creditpoint/slider_circle.png
ADDED
Binary file
|
skin/frontend/default/default/js/ei/creditpoint/creditpoint.slider.js
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var EiCreditPointSlider = Class.create();
|
2 |
+
EiCreditPointSlider.prototype = {
|
3 |
+
initialize: function(amountR, trackR, handleR, decrHandleR, incrHandleR, minPointR, maxPointR, stepR, labelAmountR, checkMaxAmountR) {
|
4 |
+
|
5 |
+
this.minPointsCheck = minPointR;
|
6 |
+
this.minPoints = 0;
|
7 |
+
this.maxPoints = maxPointR;
|
8 |
+
this.pointStep = stepR;
|
9 |
+
|
10 |
+
this.amountR = $(amountR);
|
11 |
+
this.trackR = $(trackR);
|
12 |
+
this.handleR = $(handleR);
|
13 |
+
this.labelAmountR = $(labelAmountR);
|
14 |
+
this.checkMaxAmountR = $(checkMaxAmountR);
|
15 |
+
|
16 |
+
|
17 |
+
this.mwSlider = new Control.Slider(this.handleR, this.trackR, {
|
18 |
+
range: $R(this.minPoints, this.maxPoints),
|
19 |
+
values: this.mwAvailableValue(),
|
20 |
+
onSlide: this.changeCreditPoint.bind(this),
|
21 |
+
onChange: this.changeCreditPoint.bind(this)
|
22 |
+
});
|
23 |
+
|
24 |
+
this.changeCreditPointCallback = function(v){};
|
25 |
+
|
26 |
+
Event.observe($(decrHandleR), 'click', this.decrHandle.bind(this));
|
27 |
+
Event.observe($(incrHandleR), 'click', this.incrHandle.bind(this));
|
28 |
+
},
|
29 |
+
mwAvailableValue: function() {
|
30 |
+
var values = [];
|
31 |
+
for (var i = this.minPoints; i <= this.maxPoints; i += this.pointStep) {
|
32 |
+
values.push(i);
|
33 |
+
}
|
34 |
+
return values;
|
35 |
+
},
|
36 |
+
changeCreditPoint: function(points) {
|
37 |
+
this.amountR.value = points;
|
38 |
+
if (this.labelAmountR) {
|
39 |
+
this.labelAmountR.innerHTML = points;
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
if (points == this.maxPoints) {
|
44 |
+
if($(this.checkMaxAmountR)) $(this.checkMaxAmountR).checked = true;
|
45 |
+
} else {
|
46 |
+
if($(this.checkMaxAmountR)) $(this.checkMaxAmountR).checked = false;
|
47 |
+
}
|
48 |
+
if (typeof this.changeCreditPointCallback == 'function') {
|
49 |
+
this.changeCreditPointCallback(points);
|
50 |
+
}
|
51 |
+
},
|
52 |
+
decrHandle: function() {
|
53 |
+
var curVal = this.mwSlider.value - this.pointStep;
|
54 |
+
if (curVal >= this.minPoints) {
|
55 |
+
this.mwSlider.value = curVal;
|
56 |
+
this.mwSlider.setValue(curVal);
|
57 |
+
this.changeCreditPoint(curVal);
|
58 |
+
}
|
59 |
+
},
|
60 |
+
incrHandle: function() {
|
61 |
+
var curVal = this.mwSlider.value + this.pointStep;
|
62 |
+
if (curVal <= this.maxPoints) {
|
63 |
+
this.mwSlider.value = curVal;
|
64 |
+
this.mwSlider.setValue(curVal);
|
65 |
+
this.changeCreditPoint(curVal);
|
66 |
+
}
|
67 |
+
},
|
68 |
+
setPointChange: function(points) {
|
69 |
+
points = this.mwSlider.getNearestValue(parseInt(points));
|
70 |
+
this.mwSlider.value = points;
|
71 |
+
this.mwSlider.setValue(points);
|
72 |
+
this.changeCreditPoint(points);
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|