Imedia_RewardPointsPro - Version 1.0.0.2

Version Notes

Rewards points pro

Download this release

Release Info

Developer iMedia inc.
Extension Imedia_RewardPointsPro
Version 1.0.0.2
Comparing to
See all releases


Version 1.0.0.2

Files changed (37) hide show
  1. app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Renderer/CustomerName.php +17 -0
  2. app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Rewardpointspro.php +24 -0
  3. app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Rewardpointspro/Grid.php +105 -0
  4. app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Sales/Creditmemo.php +21 -0
  5. app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Sales/Invoice.php +19 -0
  6. app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Sales/Order.php +19 -0
  7. app/code/community/Imedia/RewardPointsPro/Block/Reward/Points.php +8 -0
  8. app/code/community/Imedia/RewardPointsPro/Block/Sales/Creditmemo.php +20 -0
  9. app/code/community/Imedia/RewardPointsPro/Block/Sales/Order.php +19 -0
  10. app/code/community/Imedia/RewardPointsPro/Block/Sales/Order/Total.php +64 -0
  11. app/code/community/Imedia/RewardPointsPro/Helper/Data.php +8 -0
  12. app/code/community/Imedia/RewardPointsPro/Model/Account.php +108 -0
  13. app/code/community/Imedia/RewardPointsPro/Model/Creditmemo.php +13 -0
  14. app/code/community/Imedia/RewardPointsPro/Model/Discount.php +58 -0
  15. app/code/community/Imedia/RewardPointsPro/Model/Invoice.php +16 -0
  16. app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Account.php +8 -0
  17. app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Account/Collection.php +9 -0
  18. app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Rewardpointspro.php +8 -0
  19. app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Rewardpointspro/Collection.php +9 -0
  20. app/code/community/Imedia/RewardPointsPro/Model/Observer.php +108 -0
  21. app/code/community/Imedia/RewardPointsPro/Model/Resource/Setup.php +7 -0
  22. app/code/community/Imedia/RewardPointsPro/Model/Rewardpointspro.php +9 -0
  23. app/code/community/Imedia/RewardPointsPro/controllers/Adminhtml/RewardpointsproController.php +50 -0
  24. app/code/community/Imedia/RewardPointsPro/controllers/CartController.php +90 -0
  25. app/code/community/Imedia/RewardPointsPro/controllers/IndexController.php +11 -0
  26. app/code/community/Imedia/RewardPointsPro/etc/adminhtml.xml +56 -0
  27. app/code/community/Imedia/RewardPointsPro/etc/config.xml +220 -0
  28. app/code/community/Imedia/RewardPointsPro/etc/system.xml +116 -0
  29. app/code/community/Imedia/RewardPointsPro/sql/imedia_rewardpointspro_setup/install-0.0.1.php +78 -0
  30. app/design/adminhtml/default/default/layout/imedia/imedia_rewardpointspro.xml +8 -0
  31. app/design/frontend/base/default/layout/imedia/imedia_rewardpointspro.xml +95 -0
  32. app/design/frontend/base/default/template/imedia/rewardpointspro/dashboard_pro_points.phtml +10 -0
  33. app/design/frontend/base/default/template/imedia/rewardpointspro/my_dashboard_pro.phtml +51 -0
  34. app/design/frontend/base/default/template/imedia/rewardproform.phtml +76 -0
  35. app/etc/modules/Imedia_RewardPointsPro.xml +9 -0
  36. package.xml +18 -0
  37. skin/frontend/base/default/css/imedia/im_rewardspro.css +28 -0
app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Renderer/CustomerName.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Adminhtml_Renderer_CustomerName extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
3
+
4
+ public function render(Varien_Object $row) {
5
+ if ($row->getData('firstname') != NULL || $row->getData('lastname') != NULL) {
6
+ $firstName = $row->getData('firstname');
7
+ $lastName = $row->getData('lastname');
8
+ if ($lastName != NULL) {
9
+ return $firstName . ' ' . $lastName;
10
+ } else {
11
+ return $firstName;
12
+ }
13
+ } else {
14
+ return Mage::helper('imedia_rewardpointspro')->__('NO NAME ASSIGNED');
15
+ }
16
+ }
17
+ }
app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Rewardpointspro.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Grid container block
4
+ *
5
+ */
6
+ class Imedia_RewardPointsPro_Block_Adminhtml_Rewardpointspro extends Mage_Adminhtml_Block_Widget_Grid_Container
7
+ {
8
+ public function __construct()
9
+ {
10
+ /*both these variables tell magento the location of our Grid.php(grid block) file.
11
+ * $this->_blockGroup.'/' . $this->_controller . '_grid'
12
+ * i.e imedia_rewardpoints/adminhtml_rewardpoints_grid
13
+ * $_blockGroup - is your module's name.
14
+ * $_controller - is the path to your grid block.
15
+ */
16
+ $this->_controller = 'adminhtml_rewardpointspro';
17
+ $this->_blockGroup = 'imedia_rewardpointspro';
18
+ $this->_headerText = Mage::helper('imedia_rewardpointspro')->__('Manage Reward Points');
19
+
20
+ parent::__construct();
21
+
22
+ $this->_removeButton('add');
23
+ }
24
+ }
app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Rewardpointspro/Grid.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage featured product grid block
4
+ *
5
+ */
6
+ class Imedia_RewardPointsPro_Block_Adminhtml_Rewardpointspro_Grid extends Mage_Adminhtml_Block_Widget_Grid
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('rewardpointsproGrid');
12
+ $this->setDefaultSort('entity_id');
13
+ $this->setDefaultDir('DESC');
14
+ $this->setSaveParametersInSession(true);
15
+ $this->setUseAjax(true);
16
+ $this->setVarNameFilter('product_filter');
17
+
18
+ }
19
+
20
+ protected function _getStore()
21
+ {
22
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
23
+ return Mage::app()->getStore($storeId);
24
+ }
25
+
26
+ /**
27
+ * Prepare rewardpointspro grid collection object
28
+ *
29
+ * @return Imedia_RewardPointsPro_Block_Adminhtml_Rewardpointspro_Grid
30
+ */
31
+ protected function _prepareCollection()
32
+ {
33
+ $store = $this->_getStore();
34
+ $collection = Mage::getModel('customer/customer')->getCollection()
35
+ ->addAttributeToSelect('email')
36
+ ->addAttributeToSelect('firstname')
37
+ ->addAttributeToSelect('lastname')
38
+ ->addAttributeToSelect('entity_id');
39
+ //->addAttributeToSelect('type_id');
40
+
41
+ $collection->joinField('points_current',
42
+ 'rewardpointspro_account',
43
+ 'points_current',
44
+ 'customer_id=entity_id'
45
+ );
46
+
47
+
48
+ $this->setCollection($collection);
49
+
50
+ parent::_prepareCollection();
51
+ //$this->getCollection()->addWebsiteNamesToResult();
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Prepare default grid column
57
+ *
58
+ * @return Imedia_RewardPointsPro_Block_Adminhtml_Rewardpointspro_Grid
59
+ */
60
+ protected function _prepareColumns()
61
+ {
62
+
63
+ $this->addColumn('entity_id',
64
+ array(
65
+ 'header'=> Mage::helper('imedia_rewardpointspro')->__('ID'),
66
+ 'width' => '50px',
67
+ 'type' => 'number',
68
+ 'index' => 'entity_id',
69
+ ));
70
+
71
+ $this->addColumn('firstname',
72
+ array(
73
+ 'header'=> Mage::helper('imedia_rewardpointspro')->__('Firstname'),
74
+ 'index' => 'firstname',
75
+ ));
76
+
77
+ $this->addColumn('lastname',
78
+ array(
79
+ 'header'=> Mage::helper('imedia_rewardpointspro')->__('Lastname'),
80
+ 'index' => 'lastname',
81
+ ));
82
+
83
+ $this->addColumn('email',
84
+ array(
85
+ 'header'=> Mage::helper('imedia_rewardpointspro')->__('Email'),
86
+ 'index' => 'email',
87
+ ));
88
+
89
+ $this->addColumn('points_current',
90
+ array(
91
+ 'header'=> Mage::helper('imedia_rewardpointspro')->__('Rewards Points'),
92
+ 'index' => 'points_current',
93
+ ));
94
+ $this->addExportType('*/*/exportCsv',Mage::helper('imedia_rewardpointspro')->__('CSV'));
95
+
96
+ return parent::_prepareColumns();
97
+ }
98
+
99
+ public function getGridUrl()
100
+ {
101
+ return $this->getUrl('*/*/grid', array('_current'=>true));
102
+ }
103
+
104
+ }
105
+
app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Sales/Creditmemo.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Adminhtml_Sales_Creditmemo extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
3
+ {
4
+ protected function _initTotals() {
5
+ parent::_initTotals();
6
+ $amt = $this->getSource()->getFeeAmount();
7
+ //Mage::log('creditmemo.php: '.$amt);
8
+ $baseAmt = $this->getSource()->getBaseFeeAmount();
9
+ if ($amt != 0) {
10
+
11
+ $this->addTotal(new Varien_Object(array(
12
+ 'code' => 'Discount',
13
+ 'value' => $amt,
14
+ 'base_value' => $baseAmt,
15
+ 'label' => 'Rewards points discount',
16
+ )), 'discount');
17
+ }
18
+ return $this;
19
+ }
20
+
21
+ }
app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Sales/Invoice.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Adminhtml_Sales_Invoice extends Mage_Sales_Block_Order_Invoice_Totals
3
+ {
4
+ protected function _initTotals() {
5
+ parent::_initTotals();
6
+ $amt = $this->getSource()->getFeeAmount();
7
+ $baseAmt = $this->getSource()->getBaseFeeAmount();
8
+ if ($amt != 0) {
9
+ $this->addTotal(new Varien_Object(array(
10
+ 'code' => 'Discount',
11
+ 'value' => $amt,
12
+ 'base_value' => $baseAmt,
13
+ 'label' => 'Reward Points Discount',
14
+ )), 'discount');
15
+ }
16
+ return $this;
17
+ }
18
+
19
+ }
app/code/community/Imedia/RewardPointsPro/Block/Adminhtml/Sales/Order.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Adminhtml_Sales_Order extends Mage_Sales_Block_Order_Totals
3
+ {
4
+ protected function _initTotals() {
5
+
6
+ parent::_initTotals();
7
+ $amt = $this->getSource()->getFeeAmount();
8
+ $baseAmt = $this->getSource()->getBaseFeeAmount();
9
+ if ($amt != 0) {
10
+ $this->addTotal(new Varien_Object(array(
11
+ 'code' => 'Fee',
12
+ 'value' => $amt,
13
+ 'base_value' => $baseAmt,
14
+ 'label' => 'Reward points discount',
15
+ )), 'discount');
16
+ }
17
+ return $this;
18
+ }
19
+ }
app/code/community/Imedia/RewardPointsPro/Block/Reward/Points.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Featured Product List block
4
+ */
5
+ class Imedia_RewardPointsPro_Block_Reward_Points extends Mage_Catalog_Block_Product_Abstract
6
+ {
7
+
8
+ }
app/code/community/Imedia/RewardPointsPro/Block/Sales/Creditmemo.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Sales_Creditmemo extends Mage_Sales_Block_Order_Creditmemo_Totals
3
+ {
4
+ protected function _initTotals() {
5
+ parent::_initTotals();
6
+ $amt = $this->getSource()->getFeeAmount();
7
+ $baseAmt = $this->getSource()->getBaseFeeAmount();
8
+ if ($amt != 0) {
9
+
10
+ $this->addTotal(new Varien_Object(array(
11
+ 'code' => 'Discount',
12
+ 'value' => $amt,
13
+ 'base_value' => $baseAmt,
14
+ 'label' => 'Reward points discount',
15
+ )), 'discount');
16
+ }
17
+ return $this;
18
+ }
19
+
20
+ }
app/code/community/Imedia/RewardPointsPro/Block/Sales/Order.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Sales_Order extends Mage_Sales_Block_Order_Totals
3
+ {
4
+ protected function _initTotals() {
5
+
6
+ parent::_initTotals();
7
+ $amt = $this->getSource()->getFeeAmount();
8
+ $baseAmt = $this->getSource()->getBaseFeeAmount();
9
+ if ($amt != 0) {
10
+ $this->addTotal(new Varien_Object(array(
11
+ 'code' => 'Fee',
12
+ 'value' => $amt,
13
+ 'base_value' => $baseAmt,
14
+ 'label' => 'Reward points discount',
15
+ )), 'discount');
16
+ }
17
+ return $this;
18
+ }
19
+ }
app/code/community/Imedia/RewardPointsPro/Block/Sales/Order/Total.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Block_Sales_Order_Total extends Mage_Core_Block_Template
3
+ {
4
+ /**
5
+ * Get label cell tag properties
6
+ *
7
+ * @return string
8
+ */
9
+ public function getLabelProperties()
10
+ {
11
+ return $this->getParentBlock()->getLabelProperties();
12
+ }
13
+
14
+ /**
15
+ * Get order store object
16
+ *
17
+ * @return Mage_Sales_Model_Order
18
+ */
19
+ public function getOrder()
20
+ {
21
+ return $this->getParentBlock()->getOrder();
22
+ }
23
+
24
+ /**
25
+ * Get totals source object
26
+ *
27
+ * @return Mage_Sales_Model_Order
28
+ */
29
+ public function getSource()
30
+ {
31
+ return $this->getParentBlock()->getSource();
32
+ }
33
+
34
+ /**
35
+ * Get value cell tag properties
36
+ *
37
+ * @return string
38
+ */
39
+ public function getValueProperties()
40
+ {
41
+ return $this->getParentBlock()->getValueProperties();
42
+ }
43
+
44
+ /**
45
+ * Initialize reward points totals
46
+ *
47
+ */
48
+ public function initTotals()
49
+ {
50
+ if ((float) $this->getOrder()->getBaseFeeAmount()) {
51
+ $source = $this->getSource();
52
+ $value = $source->getFeeAmount();
53
+
54
+ $this->getParentBlock()->addTotal(new Varien_Object(array(
55
+ 'code' => 'fee',
56
+ 'strong' => false,
57
+ 'label' => 'Reward points discount',
58
+ 'value' => $source instanceof Mage_Sales_Model_Order_Creditmemo ? - $value : $value
59
+ )));
60
+ }
61
+
62
+ return $this;
63
+ }
64
+ }
app/code/community/Imedia/RewardPointsPro/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reward points data helper
4
+ */
5
+ class Imedia_RewardPointsPro_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+
8
+ }
app/code/community/Imedia/RewardPointsPro/Model/Account.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Account extends Mage_Core_Model_Abstract
3
+ {
4
+
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('imedia_rewardpointspro/account');
9
+ }
10
+
11
+ protected $customerId = -1;
12
+ protected $storeId = -1;
13
+ protected $pointsCurrent = NULL;
14
+ protected $pointsReceived = NULL;
15
+ protected $pointsSpent = NULL;
16
+
17
+
18
+ public function save() {
19
+ $connection = Mage::getSingleton('core/resource')->getConnection('rewardpointspro_write');
20
+
21
+ $connection->beginTransaction();
22
+ $fields = array();
23
+ $fields['customer_id'] = $this->customerId;
24
+ $fields['store_id'] = $this->storeId;
25
+ $fields['points_current'] = $this->pointsCurrent;
26
+ $fields['points_received'] = $this->pointsReceived;
27
+
28
+
29
+ try {
30
+ $this->_beforeSave();
31
+ if (!is_null($this->rewardpointsAccountId)) {
32
+
33
+
34
+ $where = $connection->quoteInto('customer_id=?',$fields['customer_id']);
35
+ $connection->update('rewardpointspro_account', $fields, $where);
36
+ }
37
+ else {
38
+ $connection->insert('rewardpointspro_account', $fields);
39
+ //$this->rewardpointsAccountId =$connection->lastInsertId('rewardpoints_account');
40
+ //$this->rewardpointsAccountId =2;
41
+ }
42
+ $connection->commit();
43
+ $this->_afterSave();
44
+ }
45
+ catch (Exception $e) {
46
+ $connection->rollBack();
47
+ throw $e;
48
+ }
49
+ return $this;
50
+ }
51
+
52
+ public function load($id , $field=null) {
53
+ if ($field === null) {
54
+ $field = 'customer_id';
55
+ }
56
+ $connection = Mage::getSingleton('core/resource')->getConnection('rewardpointspro_read');
57
+ $select = $connection->select()->from('rewardpointspro_account')->where('rewardpointspro_account.'.$field.'=?', $id);
58
+ $data = $connection->fetchRow($select);
59
+ if (!$data) {
60
+ return $this;
61
+ }
62
+ $this->setRewardpointsAccountId($data['rewardpoints_account_id']);
63
+ $this->setCustomerId($data['customer_id']);
64
+ $this->setStoreId($data['store_id']);
65
+ $this->setPointsCurrent($data['points_current']);
66
+ $this->setPointsReceived($data['points_received']);
67
+ $this->setPointsSpent($data['points_spent']);
68
+ $this->_afterLoad();
69
+ return $this;
70
+ }
71
+
72
+
73
+ public function addPoints($p, $customerId) {
74
+ $collpoint = Mage::getModel('rewardpointspro/account')->load($customerId);
75
+ if($collpoint){
76
+ $pointsCurrent = $collpoint->getPointsCurrent();
77
+ $pointsReceived = $collpoint->getPointsReceived();
78
+ $pointsSpent = $collpoint->getPointsSpent();
79
+ }
80
+ else{$pointsSpent = 0;}
81
+ $storeId = Mage::app()->getStore()->getStoreId();;
82
+ Mage::log('add points $p: '. $p);
83
+ $this->pointsCurrent = $pointsCurrent + $p;
84
+ $this->pointsReceived = $pointsReceived + $p;
85
+ $this->pointsSpent = $pointsSpent;
86
+ $this->customerId = $customerId;
87
+ $this->storeId = $storeId;
88
+ }
89
+
90
+ public function subtractPoints($p, $customerId) {
91
+ $collpoint = Mage::getModel('rewardpointspro/account')->load($customerId);
92
+ if($collpoint){
93
+ $pointsCurrent = $collpoint->getPointsCurrent();
94
+ $pointsReceived = $collpoint->getPointsReceived();
95
+ $pointsSpent = $collpoint->getPointsSpent();
96
+ }
97
+ else{$pointsSpent = 0;}
98
+ $storeId = Mage::app()->getStore()->getStoreId();;
99
+ Mage::log('add points $p: '. $p);
100
+ $this->pointsCurrent = $pointsCurrent - $p;
101
+ $this->pointsSpent = $pointsSpent + $p;
102
+ $this->customerId = $customerId;
103
+ $this->pointsReceived = $pointsReceived;
104
+ $this->storeId = $storeId;
105
+ }
106
+
107
+
108
+ }
app/code/community/Imedia/RewardPointsPro/Model/Creditmemo.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Creditmemo extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract {
3
+
4
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) {
5
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $creditmemo->getFeeAmountPro());
6
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $creditmemo->getBaseFeeAmountPro());
7
+ $creditmemo->setFeeAmountPro($creditmemo->getFeeAmountPro());
8
+ $creditmemo->setBaseFeeAmountPro($creditmemo->getBaseFeeAmountPro());
9
+
10
+ return $this;
11
+ }
12
+
13
+ }
app/code/community/Imedia/RewardPointsPro/Model/Discount.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Discount extends Mage_Sales_Model_Quote_Address_Total_Abstract {
3
+
4
+ protected $_code = 'fee';
5
+
6
+ public function collect(Mage_Sales_Model_Quote_Address $address) {
7
+ parent::collect($address);
8
+
9
+ $this->_setAmount(0);
10
+ $this->_setBaseAmount(0);
11
+
12
+ $items = $this->_getAddressItems($address);
13
+ if (!count($items)) {
14
+ return $this; //this makes only address type shipping to come through
15
+ }
16
+
17
+ $quote = $address->getQuote();
18
+
19
+ if ($address->getData('address_type') == 'billing')
20
+
21
+
22
+ $exist_amount = $quote->getFeeAmountPro();
23
+ $fee = Mage::getSingleton('customer/session')->getDisc(); //your discount
24
+ $discount = $fee - $exist_amount ;
25
+
26
+ $address->setFeeAmountPro($discount);
27
+ $address->setBaseFeeAmountPro($discount);
28
+
29
+ $grandTotal = $address->getGrandTotal();
30
+ $baseGrandTotal = $address->getBaseGrandTotal();
31
+ $quote->setFeeAmountPro($discount);
32
+
33
+ $address->setGrandTotal($grandTotal - $address->getFeeAmountPro());
34
+ $address->setBaseGrandTotal($baseGrandTotal - $address->getBaseFeeAmountPro());
35
+
36
+ return $this;
37
+ }
38
+
39
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
40
+ {
41
+ $rewards1 = $address->getFeeAmountPro();
42
+ if ($rewards1!=0) {
43
+ $title = Mage::helper('sales')->__('Reward Points Discount');
44
+ $code = $address->getCouponCode();
45
+ if (strlen($code)) {
46
+ $title = Mage::helper('sales')->__('Reward Points Discount (%s)', $code);
47
+ }
48
+ $address->addTotal(array(
49
+ 'code'=>$this->getCode(),
50
+ 'title'=>$title,
51
+ 'value'=>$rewards1
52
+ ));
53
+
54
+ }
55
+ return $this;
56
+ }
57
+
58
+ }
app/code/community/Imedia/RewardPointsPro/Model/Invoice.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Invoice extends Mage_Sales_Model_Order_Invoice_Total_Abstract {
3
+
4
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
5
+
6
+ $invoice->setGrandTotal($invoice->getGrandTotal() - $invoice->getFeeAmountPro());
7
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $invoice->getBaseFeeAmountPro());
8
+
9
+ $invoice->setFeeAmountPro($invoice->getFeeAmountPro());
10
+ $invoice->setBaseFeeAmountPro($invoice->getBaseFeeAmountPro());
11
+
12
+ return $this;
13
+
14
+ }
15
+
16
+ }
app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Account.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Mysql4_Account extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('imedia_rewardpointspro/account', 'id');
7
+ }
8
+ }
app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Account/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Mysql4_Account_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('imedia_rewardpointspro/account');
8
+ }
9
+ }
app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Rewardpointspro.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Mysql4_Rewardpointspro extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('imedia_rewardpointspro/rewardpointspro', 'id');
7
+ }
8
+ }
app/code/community/Imedia/RewardPointsPro/Model/Mysql4/Rewardpointspro/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Mysql4_Rewardpointspro_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('imedia_rewardpointspro/rewardpointspro');
8
+ }
9
+ }
app/code/community/Imedia/RewardPointsPro/Model/Observer.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reward points Observer
4
+ *
5
+ */
6
+
7
+ class Imedia_RewardPointsPro_Model_Observer extends Mage_Core_Model_Abstract {
8
+ public function orderStatusChange($event)
9
+ {
10
+ $order = $event->getOrder();
11
+ $state = $order->getState();
12
+ $items = $order->getAllVisibleItems();
13
+ $cusId = $order->getCustomerId();
14
+ foreach($items as $item){
15
+ $productId = $item->getProduct()->getId();
16
+ $rewardPoints = $item->getProduct()->getRewardPointsPro();
17
+ if($rewardPoints){
18
+ //canceled order
19
+ if($state == 'canceled'){
20
+ $this->useCouponPoints($rewardPoints, $cusId);
21
+ }
22
+ }
23
+ }
24
+ }
25
+
26
+ public function rewardpoints($observer){
27
+ if(Mage::getStoreConfig('rewardpointspro/rewardpointspro/enabled')&& Mage::getStoreConfig('rewardpointspro/display/signup')){
28
+
29
+ $customer = $observer->getCustomer();
30
+ $customerId = $customer->getEntityId();
31
+ $rewardPoints = 0;
32
+ $rewardPoints = Mage::getStoreConfig('rewardpointspro/display/signup_points');
33
+ $this->recordPoints($rewardPoints, $customerId);
34
+ }
35
+
36
+ }
37
+ public function subscribedToNewsletter(Varien_Event_Observer $observer){
38
+
39
+ if(Mage::getStoreConfig('rewardpointspro/rewardpointspro/enabled') && Mage::getStoreConfig('rewardpointspro/display/newsletter_signup')){
40
+ $event = $observer->getEvent();
41
+ $subscriber = $event->getDataObject();
42
+ $data = $subscriber->getData();
43
+ $email = $data['subscriber_email'];
44
+ $rewardPoints = 0;
45
+ $customer = Mage::getModel('customer/customer');
46
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
47
+ $customer->loadByEmail($email); //load customer by email id
48
+ $customerid = $customer->getId();
49
+ $subscribed = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
50
+ if($subscribed->getId())
51
+ {
52
+ $alreadysubscribed = $subscribed->getStatus();
53
+ }
54
+ else{$alreadysubscribed = 5;}
55
+ $statusChange = $subscriber->getIsStatusChanged();
56
+ if($customerid && $alreadysubscribed==5){
57
+ if ($data['subscriber_status'] == "1" && $statusChange == true) {
58
+ $rewardPoints = Mage::getStoreConfig('rewardpoints/display/newsletter_signup_points');
59
+ $this->recordPoints($rewardPoints, $customerid);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ /**
65
+ * Record the points for each product.
66
+ *
67
+ * @triggeredby: sales_order_place_after
68
+ * @param $eventArgs array "order"=>$order
69
+ */
70
+ public function recordPointsForOrderEvent($observer){
71
+ if(Mage::getStoreConfig('rewardpointspro/rewardpointspro/enabled')&& Mage::getStoreConfig('rewardpointspro/display/product_rewards')){
72
+ $order = $observer->getEvent()->getOrder();
73
+ $items =$order->getItemsCollection();
74
+ $customer_id_from_event = $order->getCustomerId();
75
+ $customerId = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getCustomerId();
76
+ $rewardPoints = 0;
77
+ $prodIds = array();
78
+ foreach ($items as $_item) {
79
+ $prodIds[] = $_item->getProductId();
80
+ }
81
+ $prod = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('reward_points_pro')->addIdFilter($prodIds);
82
+ //sum up points per product per quantity
83
+ foreach ($items as $_item) {
84
+ $rewardPoints += $prod->getItemById($_item->getProductId())->getRewardPointsPro() * $_item->getQtyOrdered();
85
+ }
86
+ //record points for item into db
87
+ $this->recordPoints($rewardPoints, $customerId);
88
+ $discounted = Mage::getSingleton('customer/session')->getApplyPoints();
89
+ //subtract points for this order
90
+ $this->useCouponPoints($discounted, $customerId);
91
+
92
+ }
93
+ Mage::getSingleton('customer/session')->setdisc(0);
94
+ }
95
+
96
+
97
+ public function recordPoints($pointsInt, $customerId){
98
+ $points = Mage::getModel('rewardpointspro/account')->load($customerId);
99
+ $points->addPoints($pointsInt, $customerId);
100
+ $points->save();
101
+ }
102
+ public function useCouponPoints($discounted, $customerId) {
103
+ $pointsAmt = $discounted;
104
+ $points = Mage::getModel('rewardpointspro/account')->load($customerId);
105
+ $points->subtractPoints($pointsAmt, $customerId);
106
+ $points->save();
107
+ }
108
+ }
app/code/community/Imedia/RewardPointsPro/Model/Resource/Setup.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FeaturedProduct Setup Resource class
4
+ */
5
+ class Imedia_RewardPointsPro_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
6
+ {
7
+ }
app/code/community/Imedia/RewardPointsPro/Model/Rewardpointspro.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPointsPro_Model_Rewardpointspro extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('imedia_rewardpointspro/rewardpointspro');
8
+ }
9
+ }
app/code/community/Imedia/RewardPointsPro/controllers/Adminhtml/RewardpointsproController.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin manage Reward pointspro controller
4
+ */
5
+ class Imedia_RewardPointsPro_Adminhtml_RewardpointsproController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ /**
8
+ * Init actions
9
+ *
10
+ */
11
+ protected function _initAction()
12
+ {
13
+ // load layout, set active menu and breadcrumbs
14
+ $this->_title($this->__('Reward Points'));
15
+
16
+ $this->loadLayout()
17
+ ->_setActiveMenu('catalog/reward_pointspro')
18
+ ->_addBreadcrumb(Mage::helper('imedia_rewardpointspro')->__('Reward Points')
19
+ , Mage::helper('imedia_rewardpointspro')->__('Reward Points'));
20
+ return $this;
21
+ }
22
+
23
+ /**
24
+ * Index action method
25
+ */
26
+ public function indexAction()
27
+ {
28
+ $this->_initAction();
29
+ $this->renderLayout();
30
+ }
31
+
32
+ /**
33
+ * Used for Ajax Based Grid
34
+ *
35
+ */
36
+ public function gridAction()
37
+ {
38
+ $this->loadLayout();
39
+ $this->getResponse()->setBody(
40
+ $this->getLayout()->createBlock('imedia_rewardpointspro/adminhtml_rewardpointspro_grid')->toHtml()
41
+ );
42
+ }
43
+ public function exportCsvAction()
44
+ {
45
+ $fileName = 'rewardpoints.csv';
46
+ $content = $this->getLayout()->createBlock('imedia_rewardpointspro/adminhtml_rewardpointspro_grid')->getCsvFile();
47
+ $this->_prepareDownloadResponse($fileName, $content);
48
+ }
49
+
50
+ }
app/code/community/Imedia/RewardPointsPro/controllers/CartController.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Shopping cart controller
29
+ */
30
+ require_once "Mage/Checkout/controllers/CartController.php";
31
+
32
+ class Imedia_RewardPointsPro_CartController extends Mage_Checkout_CartController
33
+ {
34
+ public function applypointsAction(){
35
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
36
+ $customerPoints = Mage::getModel('rewardpointspro/account')->load($customerId);
37
+ $leftpoints = $customerPoints->getPointsCurrent();
38
+
39
+ if (!$this->_getCart()->getQuote()->getItemsCount()) {
40
+ $this->_goBack();
41
+ return;
42
+ }
43
+
44
+ $rewardCode = $this->getRequest()->getParam('reward_code_pro');
45
+ $onePointValue = Mage::getStoreConfig('rewardpointspro/display/pointvalue');
46
+ $discountAmount = '';
47
+ $myrewards = $rewardCode*$onePointValue;
48
+ if($onePointValue == ''){
49
+ $discountAmount = $rewardCode;
50
+ }else{
51
+ $discountAmount = $myrewards;
52
+ }
53
+
54
+ if ($this->getRequest()->getParam('removepoints') == 1) {
55
+ $discountAmount = '';
56
+ $rewardCode = '';
57
+ Mage::getSingleton('customer/session')->setdisc($discountAmount);
58
+ Mage::getSingleton('customer/session')->setApplyPoints($rewardCode);
59
+ $this->_getSession()->addSuccess($this->__('Reward points was canceled.'));
60
+ $this->_goBack();
61
+ }else{
62
+ $codeLength1 = strlen($rewardCode);
63
+ $validtotal = Mage::helper('checkout/cart')->getQuote()->getSubtotal();
64
+ if ($codeLength1 && $rewardCode <=$leftpoints && $rewardCode > 0 && $rewardCode <= $validtotal) {
65
+ Mage::getSingleton('customer/session')->setdisc($discountAmount);
66
+ Mage::getSingleton('customer/session')->setApplyPoints($rewardCode);
67
+ $this->_getSession()->addSuccess(
68
+ $this->__('Reward Points "%s" was applied.', Mage::helper('core')->escapeHtml($rewardCode))
69
+ );
70
+ }else{
71
+ if ($leftpoints==0 or ($leftpoints < $rewardCode and $leftpoints <= $validtotal)) {
72
+ $this->_getSession()->addError(
73
+ $this->__('You do not have enough points to redeem.', Mage::helper('core')->escapeHtml($rewardCode))
74
+ );
75
+ }
76
+ else{
77
+ $this->_getSession()->addError(
78
+ $this->__('reward Points "%s" is not valid.', Mage::helper('core')->escapeHtml($rewardCode))
79
+ );
80
+ }
81
+ }
82
+ }
83
+
84
+ $this->_goBack();
85
+ }
86
+
87
+
88
+
89
+
90
+ }
app/code/community/Imedia/RewardPointsPro/controllers/IndexController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Imedia_RewardPointsPro_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ function indexAction()
6
+ {
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+
11
+ }
app/code/community/Imedia/RewardPointsPro/etc/adminhtml.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Configuration file for admin menu and access permission
5
+ */
6
+ -->
7
+ <config>
8
+
9
+ <menu>
10
+ <imedia_rewards_pointspro>
11
+ <title>Reward Points Pro</title>
12
+ <sort_order>8888</sort_order>
13
+ <children>
14
+ <rewardpointspro translate="title" module="imedia_rewardpointspro">
15
+ <title>Manage Reward Points</title>
16
+ <sort_order>210</sort_order>
17
+ <action>adminhtml/rewardpointspro</action>
18
+ </rewardpointspro>
19
+ </children>
20
+ </imedia_rewards_pointspro>
21
+ </menu>
22
+
23
+ <!-- Access permissions -->
24
+ <acl>
25
+ <resources>
26
+ <all>
27
+ <title>Allow Everything</title>
28
+ </all>
29
+ <admin>
30
+ <children>
31
+ <customer>
32
+ <children>
33
+ <reward_pointspro translate="title" module="imedia_rewardpointspro">
34
+ <title>Manage reward points</title>
35
+ <sort_order>31</sort_order>
36
+ </reward_pointspro>
37
+ </children>
38
+ </customer>
39
+
40
+ <system>
41
+ <children>
42
+ <config>
43
+ <children>
44
+ <rewardpointspro translate="title" module="imedia_rewardpointspro">
45
+ <title>Reward Points Pro</title>
46
+ </rewardpointspro>
47
+ </children>
48
+ </config>
49
+ </children>
50
+ </system>
51
+
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ </config>
app/code/community/Imedia/RewardPointsPro/etc/config.xml ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Configuration file
5
+ */
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <Imedia_RewardPointsPro>
10
+ <version>0.0.1</version>
11
+ </Imedia_RewardPointsPro>
12
+ </modules>
13
+ <frontend>
14
+ <routers>
15
+ <imedia_rewardpointspro>
16
+ <use>standard</use>
17
+ <args>
18
+ <module>Imedia_RewardPointsPro</module>
19
+ <frontName>rewardpointspro</frontName>
20
+ </args>
21
+ </imedia_rewardpointspro>
22
+ <checkout>
23
+ <args>
24
+ <modules>
25
+ <imedia_rewardpointspro before="Mage_Checkout_CartController">Imedia_RewardPointsPro</imedia_rewardpointspro>
26
+ </modules>
27
+ </args>
28
+ </checkout>
29
+
30
+ </routers>
31
+ <!-- set frontend layout file-->
32
+ <layout>
33
+ <updates>
34
+ <imedia_rewardpointspro>
35
+ <file>imedia/imedia_rewardpointspro.xml</file>
36
+ </imedia_rewardpointspro>
37
+ </updates>
38
+ </layout>
39
+ </frontend>
40
+ <global>
41
+ <events>
42
+ <sales_order_place_after>
43
+ <observers>
44
+ <imedia_rewardpointspro_model_observer>
45
+ <type>singleton</type>
46
+ <class>imedia_rewardpointspro/observer</class>
47
+ <method>recordPointsForOrderEvent</method>
48
+ </imedia_rewardpointspro_model_observer>
49
+ </observers>
50
+ </sales_order_place_after>
51
+ <customer_register_success>
52
+ <observers>
53
+ <imedia_rewardpointspro_model_observer>
54
+ <type>singleton</type>
55
+ <class>imedia_rewardpointspro/observer</class>
56
+ <method>rewardpoints</method>
57
+ </imedia_rewardpointspro_model_observer>
58
+ </observers>
59
+ </customer_register_success>
60
+ <newsletter_subscriber_save_before>
61
+ <observers>
62
+ <imedia_rewardpointspro_model_observer>
63
+ <type>singleton</type>
64
+ <class>imedia_rewardpointspro/observer</class>
65
+ <method>subscribedToNewsletter</method>
66
+ </imedia_rewardpointspro_model_observer>
67
+ </observers>
68
+ </newsletter_subscriber_save_before>
69
+ <sales_order_save_commit_after>
70
+ <observers>
71
+ <imedia_rewardpointspro_model_observer>
72
+ <type>singleton</type>
73
+ <class>imedia_rewardpointspro/observer</class>
74
+ <method>orderStatusChange</method>
75
+ </imedia_rewardpointspro_model_observer>
76
+ </observers>
77
+ </sales_order_save_commit_after>
78
+ </events>
79
+ <fieldsets>
80
+ <sales_convert_quote_address>
81
+ <fee_amount><to_order>*</to_order></fee_amount>
82
+ <base_fee_amount><to_order>*</to_order></base_fee_amount>
83
+ </sales_convert_quote_address>
84
+ <sales_convert_order>
85
+ <fee_amount><to_invoice>*</to_invoice></fee_amount>
86
+ <base_fee_amount><to_invoice>*</to_invoice></base_fee_amount>
87
+ </sales_convert_order>
88
+ </fieldsets>
89
+ <pdf>
90
+ <totals>
91
+ <rewardspro translate="title">
92
+ <title>Rewards points discount</title>
93
+ <source_field>fee_amount</source_field>
94
+ <font_size>7</font_size>
95
+ <display_zero>0</display_zero>
96
+ <sort_order>650</sort_order>
97
+ <amount_prefix>-</amount_prefix>
98
+ </rewardspro>
99
+ </totals>
100
+ </pdf>
101
+
102
+
103
+ <sales>
104
+             <quote>
105
+                 <totals>
106
+                     <discount>
107
+                         <class>Imedia_RewardPointsPro_Model_Discount</class>
108
+                         <after>subtotal</after>
109
+                     </discount>
110
+                 </totals>
111
+             </quote>
112
+              
113
+             <order_invoice>
114
+                 <totals>
115
+                     <discount>
116
+                         <class>Imedia_RewardPointsPro_Model_Invoice</class>
117
+                         <after>subtotal</after>
118
+                     </discount>
119
+                 </totals>
120
+             </order_invoice>
121
+              
122
+             <order_creditmemo>
123
+                 <totals>
124
+                     <discount>
125
+                         <class>Imedia_RewardPointsPro_Model_Creditmemo</class>
126
+                         <after>subtotal</after>
127
+                     </discount>
128
+                 </totals>
129
+             </order_creditmemo>
130
+         </sales>
131
+
132
+
133
+ <models>
134
+
135
+ <rewardpointspro>
136
+ <class>Imedia_RewardPointsPro_Model</class>
137
+ <resourceModel>imedia_rewardpointspro_mysql4</resourceModel>
138
+ </rewardpointspro>
139
+ <imedia_rewardpointspro>
140
+ <class>Imedia_RewardPointsPro_Model</class>
141
+ <resourceModel>imedia_rewardpointspro_mysql4</resourceModel>
142
+ </imedia_rewardpointspro>
143
+
144
+ <imedia_rewardpointspro_mysql4>
145
+ <class>Imedia_RewardPointsPro_Model_Mysql4</class>
146
+ <entities>
147
+ <rewardpointspro>
148
+ <table>rewardpointspro_rewardpoints</table>
149
+ <table>rewardpointspro_account</table>
150
+ </rewardpointspro>
151
+ </entities>
152
+ </imedia_rewardpointspro_mysql4>
153
+
154
+ <rewardpointspro_mysql4>
155
+ <class>Imedia_RewardPointsPro_Model_Mysql4</class>
156
+ <entities>
157
+ <rewardpointspro>
158
+ <table>rewardpointspro_account</table>
159
+ </rewardpointspro>
160
+ </entities>
161
+ </rewardpointspro_mysql4>
162
+
163
+ </models>
164
+
165
+ <helpers>
166
+ <imedia_rewardpointspro>
167
+ <class>Imedia_RewardPointsPro_Helper</class>
168
+ </imedia_rewardpointspro>
169
+ </helpers>
170
+
171
+ <blocks>
172
+ <imedia_rewardpointspro>
173
+ <class>Imedia_RewardPointsPro_Block</class>
174
+ </imedia_rewardpointspro>
175
+
176
+ <adminhtml>
177
+ <rewrite>
178
+ <sales_order_totals>Imedia_RewardPointsPro_Block_Adminhtml_Sales_Order</sales_order_totals>
179
+ <sales_order_invoice_totals>Imedia_RewardPointsPro_Block_Adminhtml_Sales_Invoice</sales_order_invoice_totals>
180
+ </rewrite>
181
+ </adminhtml>
182
+
183
+ </blocks>
184
+ <!-- Setup Resource -->
185
+ <resources>
186
+ <imedia_rewardpointspro_setup>
187
+ <setup>
188
+ <module>Imedia_RewardPointsPro</module>
189
+ <class>Imedia_RewardPointsPro_Model_Resource_Setup</class>
190
+ </setup>
191
+ </imedia_rewardpointspro_setup>
192
+ </resources>
193
+
194
+
195
+ </global>
196
+
197
+ <!-- Adminhtml layout xml configuration -->
198
+ <adminhtml>
199
+ <layout>
200
+ <updates>
201
+ <imedia_rewardpointspro>
202
+ <file>imedia/imedia_rewardpointspro.xml</file>
203
+ </imedia_rewardpointspro>
204
+ </updates>
205
+ </layout>
206
+ </adminhtml>
207
+
208
+ <!-- Admin router configuration-->
209
+ <admin>
210
+ <routers>
211
+ <adminhtml>
212
+ <args>
213
+ <modules>
214
+ <Imedia_RewardPointsPro after="Mage_Adminhtml">Imedia_RewardPointsPro_Adminhtml</Imedia_RewardPointsPro>
215
+ </modules>
216
+ </args>
217
+ </adminhtml>
218
+ </routers>
219
+ </admin>
220
+ </config>
app/code/community/Imedia/RewardPointsPro/etc/system.xml ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * System configuration file
5
+ */
6
+ -->
7
+ <config>
8
+ <tabs>
9
+ <imedia translate="label" module="imedia_rewardpointspro">
10
+ <label>iMedia Extensions</label>
11
+ <sort_order>11</sort_order>
12
+ </imedia>
13
+ </tabs>
14
+ <sections>
15
+ <rewardpointspro translate="label" module="imedia_rewardpointspro">
16
+ <class>separator-top</class>
17
+ <label>Reward Points Pro</label>
18
+ <tab>imedia</tab>
19
+ <frontend_type>text</frontend_type>
20
+ <sort_order>13</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <groups>
25
+ <rewardpointspro translate="label">
26
+ <label>Reward Points</label>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>1</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <fields>
33
+ <enabled translate="label">
34
+ <label>Enable Reward Points Pro</label>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <sort_order>1</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ </enabled>
42
+ </fields>
43
+ </rewardpointspro>
44
+ <display translate="label">
45
+ <label>Display Options</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>2</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <fields>
52
+ <pointvalue translate="label">
53
+ <label>Currency value per point</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>1</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ <comment>Enter currency value per point</comment>
60
+ </pointvalue>
61
+ <signup translate="label">
62
+ <label>Enable reward points on sign up</label>
63
+ <frontend_type>select</frontend_type>
64
+ <source_model>adminhtml/system_config_source_yesno</source_model>
65
+ <sort_order>2</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </signup>
70
+ <signup_points translate="label">
71
+ <label>Sign up points</label>
72
+ <frontend_type>text</frontend_type>
73
+ <validate>validate-digits</validate>
74
+ <sort_order>3</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <comment>Enter rewards points for signup</comment>
79
+ </signup_points>
80
+
81
+ <newsletter_signup translate="label">
82
+ <label>Enable reward points on newsletter</label>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>adminhtml/system_config_source_yesno</source_model>
85
+ <sort_order>4</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ </newsletter_signup>
90
+ <newsletter_signup_points translate="label">
91
+ <label>Newsletter Sign up points</label>
92
+ <frontend_type>text</frontend_type>
93
+ <validate>validate-digits</validate>
94
+ <sort_order>5</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ <comment>Enter rewards points for news letter signup</comment>
99
+ </newsletter_signup_points>
100
+
101
+ <product_rewards translate="label">
102
+ <label>Enable reward points on products</label>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>adminhtml/system_config_source_yesno</source_model>
105
+ <sort_order>6</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </product_rewards>
110
+
111
+ </fields>
112
+ </display>
113
+ </groups>
114
+ </rewardpointspro>
115
+ </sections>
116
+ </config>
app/code/community/Imedia/RewardPointsPro/sql/imedia_rewardpointspro_setup/install-0.0.1.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+
8
+ $installer->run("
9
+
10
+ -- DROP TABLE IF EXISTS {$this->getTable('rewardpointspro_rewardpoints')};
11
+ CREATE TABLE {$this->getTable('rewardpointspro_rewardpoints')} (
12
+ `id` int(11) unsigned NOT NULL auto_increment,
13
+ `points` int(11) NOT NULL,
14
+ `entity_id` int(11) NOT NULL,
15
+ PRIMARY KEY (`id`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
+
18
+ ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
19
+ ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `base_fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
20
+
21
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
22
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
23
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_invoiced_pro` DECIMAL( 10, 2 ) NOT NULL;
24
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_invoiced_pro` DECIMAL( 10, 2 ) NOT NULL;
25
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_refunded_pro` DECIMAL( 10, 2 ) NOT NULL;
26
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_refunded_pro` DECIMAL( 10, 2 ) NOT NULL;
27
+
28
+ ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
29
+ ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `base_fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
30
+
31
+
32
+
33
+ ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
34
+ ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `base_fee_amount_pro` DECIMAL( 10, 2 ) NOT NULL;
35
+
36
+
37
+
38
+ -- DROP TABLE IF EXISTS {$this->getTable('rewardpointspro_account')};
39
+ CREATE TABLE {$this->getTable('rewardpointspro_account')} (
40
+ `rewardpoints_account_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
41
+ `customer_id` int(11) unsigned NOT NULL DEFAULT '0',
42
+ `store_id` smallint(5) unsigned NOT NULL DEFAULT '0',
43
+ `points_current` int(5) unsigned NOT NULL DEFAULT '0',
44
+ `points_received` int(5) unsigned NOT NULL DEFAULT '0',
45
+ `points_spent` int(5) unsigned NOT NULL DEFAULT '0',
46
+ PRIMARY KEY (`rewardpoints_account_id`),
47
+ KEY `FK_catalog_category_ENTITY_STORE` (`store_id`),
48
+ KEY `customer_idx` (`customer_id`)
49
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Reward points for an account' AUTO_INCREMENT=1 ;
50
+
51
+ ");
52
+
53
+ $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'reward_points_pro', array(
54
+ 'group' => 'General',
55
+ 'type' => 'int',
56
+ 'backend' => '',
57
+ 'frontend' => '',
58
+ 'label' => 'Reward Points',
59
+ 'input' => 'text',
60
+ 'class' => '',
61
+ 'source' => '',
62
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
63
+ 'visible' => true,
64
+ 'required' => false,
65
+ 'default' => 0,
66
+ 'user_defined' => true,
67
+ 'searchable' => false,
68
+ 'filterable' => false,
69
+ 'comparable' => false,
70
+ 'visible_on_front' => false,
71
+ 'unique' => false,
72
+ 'apply_to' => 'simple',
73
+ 'is_configurable' => false,
74
+ ));
75
+
76
+
77
+
78
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/imedia/imedia_rewardpointspro.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_rewardpointspro_index>
4
+ <reference name="content">
5
+ <block type="imedia_rewardpointspro/adminhtml_rewardpointspro" name="rewardpointspro.grid.container" />
6
+ </reference>
7
+ </adminhtml_rewardpointspro_index>
8
+ </layout>
app/design/frontend/base/default/layout/imedia/imedia_rewardpointspro.xml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <!--
4
+ Customer account home dashboard layout
5
+ -->
6
+ <default>
7
+ <reference name="head">
8
+ <action method="addCss" ><stylesheet>imedia/im_rewardspro.css</stylesheet></action>
9
+ </reference>
10
+ </default>
11
+ <imedia_rewardpointspro_index_index>
12
+ <reference name="content">
13
+ <block type="imedia_rewardpointspro/reward_points" name="myrewardpointspro">
14
+ <action method="setTemplate" ifconfig="rewardpointspro/rewardpointspro/enabled">
15
+ <template>imedia/rewardproform.phtml</template>
16
+ </action>
17
+ </block>
18
+ </reference>
19
+ </imedia_rewardpointspro_index_index>
20
+
21
+ <checkout_cart_index>
22
+ <reference name="checkout.cart">
23
+ <block type="core/text_list" name="coupon.and.discount" as="coupon" >
24
+ <block type="imedia_rewardpointspro/reward_points" name="myrewardpointspro">
25
+ <action method="setTemplate" ifconfig="rewardpointspro/rewardpointspro/enabled">
26
+ <template>imedia/rewardproform.phtml</template>
27
+ </action>
28
+ </block>
29
+ <action method="insert"><block>checkout.cart.coupon</block></action>
30
+ </block>
31
+ </reference>
32
+ </checkout_cart_index>
33
+
34
+ <customer_account_index>
35
+ <reference name="customer_account_dashboard">
36
+ <action method="setTemplate" ifconfig="rewardpointspro/rewardpointspro/enabled">
37
+ <template>imedia/rewardpointspro/my_dashboard_pro.phtml</template>
38
+ </action>
39
+ <block type="core/template" name="customer_account_points" as="points" template="imedia/rewardpointspro/dashboard_pro_points.phtml"/>
40
+ </reference>
41
+ </customer_account_index>
42
+
43
+
44
+ <sales_email_order_items>
45
+ <reference name="order_totals">
46
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
47
+ </reference>
48
+ </sales_email_order_items>
49
+
50
+ <sales_email_order_invoice_items>
51
+ <reference name="invoice_totals">
52
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
53
+ </reference>
54
+ </sales_email_order_invoice_items>
55
+
56
+
57
+ <sales_order_view>
58
+ <reference name="order_totals">
59
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
60
+ </reference>
61
+ </sales_order_view>
62
+ <sales_order_print>
63
+ <reference name="order_totals">
64
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
65
+ </reference>
66
+ </sales_order_print>
67
+ <sales_order_invoice>
68
+ <reference name="invoice_totals">
69
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
70
+ </reference>
71
+ </sales_order_invoice>
72
+ <sales_order_printinvoice>
73
+ <reference name="invoice_totals">
74
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
75
+ </reference>
76
+ </sales_order_printinvoice>
77
+ <sales_order_creditmemo>
78
+ <reference name="creditmemo_totals">
79
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
80
+ </reference>
81
+ </sales_order_creditmemo>
82
+ <sales_order_printcreditmemo>
83
+ <reference name="creditmemo_totals">
84
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
85
+ </reference>
86
+ </sales_order_printcreditmemo>
87
+ <sales_email_order_creditmemo_items>
88
+ <reference name="creditmemo_totals">
89
+ <block type="imedia_rewardpointspro/sales_order_total" name="imedia.sales.order.total" />
90
+ </reference>
91
+ </sales_email_order_creditmemo_items>
92
+
93
+
94
+
95
+ </layout>
app/design/frontend/base/default/template/imedia/rewardpointspro/dashboard_pro_points.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $customerId = Mage::getModel('customer/session')->getCustomerId();
3
+ $customerPoints = Mage::getModel('rewardpointspro/account')->load($customerId);
4
+ ?>
5
+ Your Points: <?php echo sprintf('%d',$customerPoints->getPointsCurrent()); ?>
6
+ <br/>
7
+ Total Points Accumulated: <?php echo sprintf('%d',$customerPoints->getPointsReceived()); ?>
8
+ <br/>
9
+ Total Points Spent: <?php echo sprintf('%d',$customerPoints->getPointsSpent()); ?>
10
+ <br/>
app/design/frontend/base/default/template/imedia/rewardpointspro/my_dashboard_pro.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package rwd_default
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="dashboard">
28
+ <div class="page-title">
29
+ <h1><?php echo $this->__('My Dashboard') ?></h1>
30
+ </div>
31
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
32
+ <?php echo $this->getChildHtml('hello') ?>
33
+ <?php echo $this->getChildHtml('top') ?>
34
+ <div class="box-account box-info">
35
+ <div class="box-head">
36
+ <h2><?php echo $this->__('Account Information') ?></h2>
37
+ </div>
38
+ <?php /* Extensions placeholder */ ?>
39
+ <?php echo $this->getChildHtml('customer.account.dashboard.extra') ?>
40
+ <?php echo $this->getChildHtml('info') ?>
41
+ </div>
42
+ <div class="account-box ad-account-info">
43
+ <div class="head">
44
+ <h4><?php echo $this->__('Points') ?></h4>
45
+ </div>
46
+ <?php echo $this->getChildHtml('points') ?>
47
+ </div>
48
+ <?php echo $this->getChildHtml('address') ?>
49
+ <?php echo $this->getChildHtml('info1') ?>
50
+ <?php echo $this->getChildHtml('info2') ?>
51
+ </div>
app/design/frontend/base/default/template/imedia/rewardproform.phtml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ #rewardpoint .input-text{
3
+ float:left;
4
+ border-radius: 0;
5
+ height: 30px;
6
+ margin: 4px 10px 0 0;
7
+ width: 100px;
8
+ }
9
+
10
+ #rewardpoint .button-wrapper{
11
+ float: left;
12
+ }
13
+
14
+ #rewardpoint label{
15
+ float:left;
16
+ font-family: "Raleway", "Helvetica Neue", Verdana, Arial, sans-serif;
17
+ font-size: 12px;
18
+ font-weight: 400;
19
+ text-align: left;
20
+ text-transform: uppercase;
21
+ min-width: 90px;
22
+ display: inline-block;
23
+ margin-right: 10px;
24
+ line-height:32px;
25
+ }
26
+ </style>
27
+
28
+ <?php
29
+ $customerId = Mage::getModel('customer/session')->getCustomerId();
30
+ $customerPoints = Mage::getModel('rewardpointspro/account')->load($customerId);
31
+ ?>
32
+
33
+ <div class="discount">
34
+ <h2>Reward Points</h2>
35
+ <?php
36
+ $r_disc = Mage::getSingleton('customer/session')->getDisc();
37
+ $l_points = Mage::getSingleton('customer/session')->getApplyPoints();
38
+ ?>
39
+ <form action="<?php echo Mage::getUrl('rewardpointspro/cart/applypoints') ?>" id="rewardpoint" method="post">
40
+
41
+ <div class="discount-form">
42
+ <label for="coupon_code"><?php echo $this->__('Points') ?></label>
43
+ <input type="hidden" name="removepoints" id="remove-points" value="0" />
44
+ <div class="field-wrapper">
45
+ <input class="input-text" type="text" id="reward_code" name="reward_code_pro" value="<?php echo $l_points; ?>" />
46
+ <div class="button-wrapper">
47
+ <button type="button" title="<?php echo $this->__('Apply') ?>" class="button2" onclick="rewardForm.submit(false)" value="<?php echo $this->__('Apply') ?>"><span><span><?php echo $this->__('Apply') ?></span></span></button>
48
+ <?php if(strlen($l_points > 0)): ?>
49
+ <button type="button" title="<?php echo $this->__('Cancel') ?>" class="button2 cancel-coupon" onclick="rewardForm.submit(true)" value="<?php echo $this->__('Cancel') ?>"><span><span><?php echo $this->__('Cancel') ?></span></span>
50
+ </button>
51
+ <?php endif;?>
52
+
53
+ </div>
54
+ </div><br>
55
+ <div style="padding-top:20px;"><?php echo $this->__('Balance Available') ?> : <?php echo sprintf('%d',$customerPoints->getPointsCurrent()) - ($l_points); ?> </div>
56
+ </div>
57
+ </form>
58
+
59
+ </div>
60
+
61
+ <script type="text/javascript">
62
+ //<![CDATA[
63
+ var rewardForm = new VarienForm('rewardpoint');
64
+ rewardForm.submit = function (isRemove) {
65
+ if (isRemove) {
66
+ $('reward_code').removeClassName('required-entry');
67
+ $('remove-points').value = "1";
68
+ } else {
69
+ $('reward_code').addClassName('required-entry');
70
+ $('remove-points').value = "0";
71
+ }
72
+ return VarienForm.prototype.submit.bind(rewardForm)();
73
+
74
+ }
75
+ //]]>
76
+ </script>
app/etc/modules/Imedia_RewardPointsPro.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Imedia_RewardPointsPro>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Imedia_RewardPointsPro>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Imedia_RewardPointsPro</name>
4
+ <version>1.0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customer reward points pro</summary>
10
+ <description>Customer reward points pro on newsletter signups, customer register and on products. Rewards points pro are manageable from admin. </description>
11
+ <notes>Rewards points pro</notes>
12
+ <authors><author><name>iMedia inc.</name><user>imedia</user><email>info@imediadesigns.org</email></author></authors>
13
+ <date>2015-07-16</date>
14
+ <time>09:55:23</time>
15
+ <contents><target name="magecommunity"><dir name="Imedia"><dir name="RewardPointsPro"><dir name="Block"><dir name="Adminhtml"><dir name="Renderer"><file name="CustomerName.php" hash="9880f3ee37b07e5af35ef0cc8f825e4e"/></dir><dir name="Rewardpointspro"><file name="Grid.php" hash="d22b39d0a0155b80661a1ddbf8d5b9ca"/></dir><file name="Rewardpointspro.php" hash="6de26e3169f625e61b98ea4c2c5af234"/><dir name="Sales"><file name="Creditmemo.php" hash="26551092c0dedce71e5162f10a72072e"/><file name="Invoice.php" hash="b05e90d8a4b2aa434fe7ddb63f1c687f"/><file name="Order.php" hash="c62f395e1fc3f059944dd0dba949b117"/></dir></dir><dir name="Reward"><file name="Points.php" hash="3a7c7562fffc83c63dd3be4906586d72"/></dir><dir name="Sales"><file name="Creditmemo.php" hash="116e21ffef79527507b07c492065ebd2"/><dir name="Order"><file name="Total.php" hash="37101295846b957a216a1f9998cec684"/></dir><file name="Order.php" hash="33b5f22132606778769080116046daba"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4f276c0f4c8ea385d780c23b50b349b5"/></dir><dir name="Model"><file name="Account.php" hash="943818979a439d80b672cd916f8832ec"/><file name="Creditmemo.php" hash="ba6c8a5182bb921b79aed5fe32ab5535"/><file name="Discount.php" hash="d44594fc83dd0632c2dc0151ecf58739"/><file name="Invoice.php" hash="06fa01fd6689a8db282d0560087478ca"/><dir name="Mysql4"><dir name="Account"><file name="Collection.php" hash="64b81d1a62d9d964afe0913d6f56207f"/></dir><file name="Account.php" hash="b3669fb000d7274ad25a97f72f5bb497"/><dir name="Rewardpointspro"><file name="Collection.php" hash="5e5bfd54858fa1da52b155f24519647b"/></dir><file name="Rewardpointspro.php" hash="28855cd07a056e045d14d97c31c0ee85"/></dir><file name="Observer.php" hash="9065c785ef6cc6ca16ad4653e4fb88ab"/><dir name="Resource"><file name="Setup.php" hash="7045ffc6c6acf290a2accc45aef2e8f0"/></dir><file name="Rewardpointspro.php" hash="cf9779be9803ee36e5727fa034c37ba9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="RewardpointsproController.php" hash="311c37f21317a4dde9f6d0b7005af6f3"/></dir><file name="CartController.php" hash="53895e47b697c86be73746e93cad3bb6"/><file name="IndexController.php" hash="e668e366b4abe41d262c3eb8710fa245"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c29c05d914a25e1d71d14a6e060990ac"/><file name="config.xml" hash="0fc831654be27b1729e4da80d8dc9fc7"/><file name="system.xml" hash="8787e2406ed52ec7091c137b2d952d41"/></dir><dir name="sql"><dir name="imedia_rewardpointspro_setup"><file name="install-0.0.1.php" hash="7c9122cf6207517dc38bcc64fcf8ca84"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="imedia"><file name="imedia_rewardpointspro.xml" hash="0682d43add3bd93151cfeb755abd36f2"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="imedia"><file name="imedia_rewardpointspro.xml" hash="bc7dea0c578bebb2c444028762bbb0c2"/></dir></dir><dir name="template"><dir name="imedia"><file name="rewardproform.phtml" hash="e279194e1fba55a427d051ae0b4d003f"/><dir name="rewardpointspro"><file name="dashboard_pro_points.phtml" hash="8e7c3233a2ef7f982d992ddfe3b455af"/><file name="my_dashboard_pro.phtml" hash="e4e93745a6a9978074488f7d9448e669"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Imedia_RewardPointsPro.xml" hash="b7c856109447a6197843c8116dbe88d5"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="imedia"><file name="im_rewardspro.css" hash="55bb13de3ffc6a7642c627b9b0546b7e"/></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/base/default/css/imedia/im_rewardspro.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * iMedia Inc.
3
+ */
4
+
5
+ #rewardpoint .input-text{
6
+ float:left;
7
+ border-radius: 0;
8
+ height: 30px;
9
+ margin: 4px 10px 0 0;
10
+ width: 100px;
11
+ }
12
+
13
+ #rewardpoint .button-wrapper{
14
+ float: left;
15
+ }
16
+
17
+ #rewardpoint label{
18
+ float:left;
19
+ font-family: "Raleway", "Helvetica Neue", Verdana, Arial, sans-serif;
20
+ font-size: 12px;
21
+ font-weight: 400;
22
+ text-align: left;
23
+ text-transform: uppercase;
24
+ min-width: 90px;
25
+ display: inline-block;
26
+ margin-right: 10px;
27
+ line-height:32px;
28
+ }