Imedia_RewardPoints - Version 1.0.0.1

Version Notes

First Preview release

Download this release

Release Info

Developer iMedia inc.
Extension Imedia_RewardPoints
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

Files changed (37) hide show
  1. app/code/community/Imedia/RewardPoints/Block/Adminhtml/Renderer/CustomerName.php +17 -0
  2. app/code/community/Imedia/RewardPoints/Block/Adminhtml/Rewardpoints.php +24 -0
  3. app/code/community/Imedia/RewardPoints/Block/Adminhtml/Rewardpoints/Grid.php +105 -0
  4. app/code/community/Imedia/RewardPoints/Block/Adminhtml/Sales/Creditmemo.php +21 -0
  5. app/code/community/Imedia/RewardPoints/Block/Adminhtml/Sales/Invoice.php +19 -0
  6. app/code/community/Imedia/RewardPoints/Block/Adminhtml/Sales/Order.php +19 -0
  7. app/code/community/Imedia/RewardPoints/Block/Reward/Points.php +8 -0
  8. app/code/community/Imedia/RewardPoints/Block/Sales/Creditmemo.php +20 -0
  9. app/code/community/Imedia/RewardPoints/Block/Sales/Order.php +19 -0
  10. app/code/community/Imedia/RewardPoints/Block/Sales/Order/Total.php +64 -0
  11. app/code/community/Imedia/RewardPoints/Helper/Data.php +8 -0
  12. app/code/community/Imedia/RewardPoints/Model/Account.php +108 -0
  13. app/code/community/Imedia/RewardPoints/Model/Creditmemo.php +19 -0
  14. app/code/community/Imedia/RewardPoints/Model/Discount.php +58 -0
  15. app/code/community/Imedia/RewardPoints/Model/Invoice.php +17 -0
  16. app/code/community/Imedia/RewardPoints/Model/Mysql4/Account.php +8 -0
  17. app/code/community/Imedia/RewardPoints/Model/Mysql4/Account/Collection.php +9 -0
  18. app/code/community/Imedia/RewardPoints/Model/Mysql4/Rewardpoints.php +8 -0
  19. app/code/community/Imedia/RewardPoints/Model/Mysql4/Rewardpoints/Collection.php +9 -0
  20. app/code/community/Imedia/RewardPoints/Model/Observer.php +151 -0
  21. app/code/community/Imedia/RewardPoints/Model/Resource/Setup.php +7 -0
  22. app/code/community/Imedia/RewardPoints/Model/Rewardpoints.php +9 -0
  23. app/code/community/Imedia/RewardPoints/controllers/Adminhtml/RewardpointsController.php +50 -0
  24. app/code/community/Imedia/RewardPoints/controllers/CartController.php +99 -0
  25. app/code/community/Imedia/RewardPoints/controllers/IndexController.php +11 -0
  26. app/code/community/Imedia/RewardPoints/etc/adminhtml.xml +56 -0
  27. app/code/community/Imedia/RewardPoints/etc/config.xml +242 -0
  28. app/code/community/Imedia/RewardPoints/etc/system.xml +115 -0
  29. app/code/community/Imedia/RewardPoints/sql/imedia_rewardpoints_setup/install-0.1.0.php +78 -0
  30. app/design/adminhtml/default/default/layout/imedia/imedia_rewardpoints.xml +10 -0
  31. app/design/frontend/base/default/layout/imedia/imedia_rewardpoints.xml +93 -0
  32. app/design/frontend/base/default/template/imedia/rewardform.phtml +73 -0
  33. app/design/frontend/base/default/template/rewardpoints/dashboard_points.phtml +10 -0
  34. app/design/frontend/base/default/template/rewardpoints/my_dashboard.phtml +51 -0
  35. app/etc/modules/Imedia_RewardPoints.xml +10 -0
  36. package.xml +18 -0
  37. skin/frontend/base/default/css/imedia/im_rewards.css +28 -0
app/code/community/Imedia/RewardPoints/Block/Adminhtml/Renderer/CustomerName.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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_rewardpoints')->__('NO NAME ASSIGNED');
15
+ }
16
+ }
17
+ }
app/code/community/Imedia/RewardPoints/Block/Adminhtml/Rewardpoints.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Grid container block
4
+ *
5
+ */
6
+ class Imedia_RewardPoints_Block_Adminhtml_Rewardpoints 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_rewardpoints';
17
+ $this->_blockGroup = 'imedia_rewardpoints';
18
+ $this->_headerText = Mage::helper('imedia_rewardpoints')->__('Manage Reward Points');
19
+
20
+ parent::__construct();
21
+
22
+ $this->_removeButton('add');
23
+ }
24
+ }
app/code/community/Imedia/RewardPoints/Block/Adminhtml/Rewardpoints/Grid.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage featured product grid block
4
+ *
5
+ */
6
+ class Imedia_RewardPoints_Block_Adminhtml_Rewardpoints_Grid extends Mage_Adminhtml_Block_Widget_Grid
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('rewardpointsGrid');
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 rewardpoints grid collection object
28
+ *
29
+ * @return Imedia_RewardPoints_Block_Adminhtml_Rewardpoints_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
+ 'rewardpoints_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_RewardPoints_Block_Adminhtml_Rewardpoints_Grid
59
+ */
60
+ protected function _prepareColumns()
61
+ {
62
+
63
+ $this->addColumn('entity_id',
64
+ array(
65
+ 'header'=> Mage::helper('imedia_rewardpoints')->__('ID'),
66
+ 'width' => '50px',
67
+ 'type' => 'number',
68
+ 'index' => 'entity_id',
69
+ ));
70
+
71
+ $this->addColumn('firstname',
72
+ array(
73
+ 'header'=> Mage::helper('imedia_rewardpoints')->__('Firstname'),
74
+ 'index' => 'firstname',
75
+ ));
76
+
77
+ $this->addColumn('lastname',
78
+ array(
79
+ 'header'=> Mage::helper('imedia_rewardpoints')->__('Lastname'),
80
+ 'index' => 'lastname',
81
+ ));
82
+
83
+ $this->addColumn('email',
84
+ array(
85
+ 'header'=> Mage::helper('imedia_rewardpoints')->__('Email'),
86
+ 'index' => 'email',
87
+ ));
88
+
89
+ $this->addColumn('points_current',
90
+ array(
91
+ 'header'=> Mage::helper('imedia_rewardpoints')->__('Rewards Points'),
92
+ 'index' => 'points_current',
93
+ ));
94
+ $this->addExportType('*/*/exportCsv',Mage::helper('imedia_rewardpoints')->__('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/RewardPoints/Block/Adminhtml/Sales/Creditmemo.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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/RewardPoints/Block/Adminhtml/Sales/Invoice.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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/RewardPoints/Block/Adminhtml/Sales/Order.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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/RewardPoints/Block/Reward/Points.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Featured Product List block
4
+ */
5
+ class Imedia_RewardPoints_Block_Reward_Points extends Mage_Catalog_Block_Product_Abstract
6
+ {
7
+
8
+ }
app/code/community/Imedia/RewardPoints/Block/Sales/Creditmemo.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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/RewardPoints/Block/Sales/Order.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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/RewardPoints/Block/Sales/Order/Total.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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/RewardPoints/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reward points data helper
4
+ */
5
+ class Imedia_RewardPoints_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+
8
+ }
app/code/community/Imedia/RewardPoints/Model/Account.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Account extends Mage_Core_Model_Abstract
3
+ {
4
+
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('imedia_rewardpoints/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('rewardpoints_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('rewardpoints_account', $fields, $where);
36
+ }
37
+ else {
38
+ $connection->insert('rewardpoints_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('rewardpoints_read');
57
+ $select = $connection->select()->from('rewardpoints_account')->where('rewardpoints_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('rewardpoints/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('rewardpoints/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/RewardPoints/Model/Creditmemo.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Creditmemo extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract {
3
+
4
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) {
5
+ /*$order = $creditmemo->getOrder();
6
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $order->getFeeAmount());
7
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $order->getBaseFeeAmount());
8
+ $creditmemo->setFeeAmount($order->getFeeAmount());
9
+ $creditmemo->setBaseFeeAmount($order->getBaseFeeAmount());*/
10
+
11
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $creditmemo->getFeeAmount());
12
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $creditmemo->getBaseFeeAmount());
13
+ $creditmemo->setFeeAmount($creditmemo->getFeeAmount());
14
+ $creditmemo->setBaseFeeAmount($creditmemo->getBaseFeeAmount());
15
+
16
+ return $this;
17
+ }
18
+
19
+ }
app/code/community/Imedia/RewardPoints/Model/Discount.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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->getFeeAmount();
23
+ $fee = Mage::getSingleton('customer/session')->getDisc(); //your discount
24
+ $discount = $fee - $exist_amount ;
25
+
26
+ $address->setFeeAmount($discount);
27
+ $address->setBaseFeeAmount($discount);
28
+
29
+ $grandTotal = $address->getGrandTotal();
30
+ $baseGrandTotal = $address->getBaseGrandTotal();
31
+ $quote->setFeeAmount($discount);
32
+
33
+ $address->setGrandTotal($grandTotal - $address->getFeeAmount());
34
+ $address->setBaseGrandTotal($baseGrandTotal - $address->getBaseFeeAmount());
35
+
36
+ return $this;
37
+ }
38
+
39
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
40
+ {
41
+ $rewards1 = $address->getFeeAmount();
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/RewardPoints/Model/Invoice.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_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->getFeeAmount());
7
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $invoice->getBaseFeeAmount());
8
+
9
+ $invoice->setFeeAmount($invoice->getFeeAmount());
10
+ $invoice->setBaseFeeAmount($invoice->getBaseFeeAmount());
11
+
12
+ //Mage::log('invoice11: ');
13
+ return $this;
14
+
15
+ }
16
+
17
+ }
app/code/community/Imedia/RewardPoints/Model/Mysql4/Account.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Mysql4_Account extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('imedia_rewardpoints/account', 'id');
7
+ }
8
+ }
app/code/community/Imedia/RewardPoints/Model/Mysql4/Account/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Mysql4_Account_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('imedia_rewardpoints/account');
8
+ }
9
+ }
app/code/community/Imedia/RewardPoints/Model/Mysql4/Rewardpoints.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Mysql4_Rewardpoints extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('imedia_rewardpoints/rewardpoints', 'id');
7
+ }
8
+ }
app/code/community/Imedia/RewardPoints/Model/Mysql4/Rewardpoints/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Mysql4_Rewardpoints_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('imedia_rewardpoints/rewardpoints');
8
+ }
9
+ }
app/code/community/Imedia/RewardPoints/Model/Observer.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reward points Observer
4
+ *
5
+ */
6
+
7
+ class Imedia_RewardPoints_Model_Observer extends Mage_Core_Model_Abstract {
8
+
9
+ public function rewardpoints($observer)
10
+ {
11
+ if(Mage::getStoreConfig('rewardpoints/rewardpoints/enabled')&&
12
+ Mage::getStoreConfig('rewardpoints/display/signup'))
13
+ {
14
+ //Mage::log('testfornewsletter:'.Mage::getStoreConfig('rewardpoints/display/signup_points'));
15
+ $customer = $observer->getCustomer();
16
+ $customerId = $customer->getEntityId();
17
+ $rewardPoints = 0;
18
+ //$customerId = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getCustomerId();
19
+ //Mage::log('customer id for register:'.$customerId);
20
+ $rewardPoints = Mage::getStoreConfig('rewardpoints/display/signup_points');
21
+ $this->recordPoints($rewardPoints, $customerId);
22
+ }
23
+
24
+ }
25
+
26
+
27
+ public function subscribedToNewsletter(Varien_Event_Observer $observer)
28
+ {
29
+
30
+ if(Mage::getStoreConfig('rewardpoints/rewardpoints/enabled') &&
31
+ Mage::getStoreConfig('rewardpoints/display/newsletter_signup'))
32
+ {
33
+ //Mage::log('testfornewsletter:'.Mage::getStoreConfig('rewardpoints/display/newsletter_signup_points'));
34
+ $event = $observer->getEvent();
35
+ $subscriber = $event->getDataObject();
36
+ $data = $subscriber->getData();
37
+ $email = $data['subscriber_email'];
38
+ $rewardPoints = 0;
39
+ //Mage::log('email get subs:'.$email);
40
+ $customer = Mage::getModel('customer/customer');
41
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
42
+ $customer->loadByEmail($email); //load customer by email id
43
+ $customerid = $customer->getId();
44
+ $subscribed = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
45
+ if($subscribed->getId())
46
+ {
47
+ $alreadysubscribed = $subscribed->getStatus();
48
+ }
49
+ else{$alreadysubscribed = 5;}
50
+ //Mage::log('customer subscriptin status:'.$alreadysubscribed);
51
+
52
+ $statusChange = $subscriber->getIsStatusChanged();
53
+ if($customerid && $alreadysubscribed==5){
54
+ if ($data['subscriber_status'] == "1" && $statusChange == true) {
55
+ //Mage::log('customer id for newsletter subscription:'.$customerid);
56
+ $rewardPoints = Mage::getStoreConfig('rewardpoints/display/newsletter_signup_points');
57
+ $this->recordPoints($rewardPoints, $customerid);
58
+
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+
65
+ /*
66
+ public function invoiceSaveAfter(Varien_Event_Observer $observer)
67
+ {
68
+ $invoice = $observer->getEvent()->getInvoice();
69
+ if ($invoice->getBaseFeeAmount()) {
70
+ $order = $invoice->getOrder();
71
+ $order->setFeeAmountInvoiced($order->getFeeAmountInvoiced() - $invoice->getFeeAmount());
72
+ $order->setBaseFeeAmountInvoiced($order->getBaseFeeAmountInvoiced() - $invoice->getBaseFeeAmount());
73
+ }
74
+ return $this;
75
+ }
76
+ public function creditmemoSaveAfter(Varien_Event_Observer $observer)
77
+ {
78
+ /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
79
+ /*$creditmemo = $observer->getEvent()->getCreditmemo();
80
+ if ($creditmemo->getFeeAmount()) {
81
+ $order = $creditmemo->getOrder();
82
+ $order->setFeeAmountRefunded($order->getFeeAmountRefunded() - $creditmemo->getFeeAmount());
83
+ $order->setBaseFeeAmountRefunded($order->getBaseFeeAmountRefunded() - $creditmemo->getBaseFeeAmount());
84
+ }
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Record the points for each product.
90
+ *
91
+ * @triggeredby: sales_order_place_after
92
+ * @param $eventArgs array "order"=>$order
93
+ */
94
+ public function recordPointsForOrderEvent($observer) {
95
+
96
+ if(Mage::getStoreConfig('rewardpoints/rewardpoints/enabled')&&
97
+ Mage::getStoreConfig('rewardpoints/display/product_rewards'))
98
+ {
99
+ $order = $observer->getEvent()->getOrder();
100
+ $items =$order->getItemsCollection();
101
+ //load all products for each sales item
102
+ //sum up points per product per quantity
103
+ //record points for item into db
104
+ //grab the customerId
105
+ $customer_id_from_event = $order->getCustomerId();
106
+ //Mage::log('customer id from order event:'.$customer_id_from_event);
107
+ $customerId = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getCustomerId();
108
+ //load all products for each sales item
109
+ $rewardPoints = 0;
110
+ $prodIds = array();
111
+ foreach ($items as $_item) {
112
+ $prodIds[] = $_item->getProductId();
113
+ }
114
+ //load products from quote IDs to get the points
115
+ //(this won’t work if points were set dynamically
116
+ // in the addToCart process)
117
+ $prod = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('reward_points')->addIdFilter($prodIds);
118
+ //sum up points per product per quantity
119
+ foreach ($items as $_item) {
120
+ $rewardPoints += $prod->getItemById($_item->getProductId())->getRewardPoints() * $_item->getQtyOrdered();
121
+ }
122
+ //record points for item into db
123
+ $this->recordPoints($rewardPoints, $customerId);
124
+
125
+ $discounted = Mage::getSingleton('customer/session')->getDisc();
126
+ //subtract points for this order
127
+ $this->useCouponPoints($discounted, $customerId);
128
+
129
+ }
130
+ Mage::getSingleton('customer/session')->setdisc(0);
131
+ }
132
+
133
+ public function recordPoints($pointsInt, $customerId) {
134
+ $points = Mage::getModel('rewardpoints/account')->load($customerId);
135
+ $points->addPoints($pointsInt, $customerId);
136
+ $points->save();
137
+
138
+ }
139
+
140
+ //this completely new method should be placed outside
141
+ // recordPointsForOrderEvent(), but inside the class
142
+ public function useCouponPoints($discounted, $customerId) {
143
+ $pointsAmt = $discounted;
144
+ $points = Mage::getModel('rewardpoints/account')->load($customerId);
145
+ $points->subtractPoints($pointsAmt, $customerId);
146
+ $points->save();
147
+ }
148
+
149
+
150
+
151
+ }
app/code/community/Imedia/RewardPoints/Model/Resource/Setup.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FeaturedProduct Setup Resource class
4
+ */
5
+ class Imedia_RewardPoints_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
6
+ {
7
+ }
app/code/community/Imedia/RewardPoints/Model/Rewardpoints.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Imedia_RewardPoints_Model_Rewardpoints extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('imedia_rewardpoints/rewardpoints');
8
+ }
9
+ }
app/code/community/Imedia/RewardPoints/controllers/Adminhtml/RewardpointsController.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin manage Reward points controller
4
+ */
5
+ class Imedia_RewardPoints_Adminhtml_RewardpointsController 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_points')
18
+ ->_addBreadcrumb(Mage::helper('imedia_rewardpoints')->__('Reward Points')
19
+ , Mage::helper('imedia_rewardpoints')->__('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_rewardpoints/adminhtml_rewardpoints_grid')->toHtml()
41
+ );
42
+ }
43
+ public function exportCsvAction()
44
+ {
45
+ $fileName = 'rewardpoints.csv';
46
+ $content = $this->getLayout()->createBlock('imedia_rewardpoints/adminhtml_rewardpoints_grid')->getCsvFile();
47
+ $this->_prepareDownloadResponse($fileName, $content);
48
+ }
49
+
50
+ }
app/code/community/Imedia/RewardPoints/controllers/CartController.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_RewardPoints_CartController extends Mage_Checkout_CartController
33
+ {
34
+
35
+ public function applypointsAction()
36
+ {
37
+
38
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
39
+ $customerPoints = Mage::getModel('rewardpoints/account')->load($customerId);
40
+ $leftpoints = $customerPoints->getPointsCurrent();
41
+
42
+ if (!$this->_getCart()->getQuote()->getItemsCount()) {
43
+ $this->_goBack();
44
+ return;
45
+ }
46
+
47
+ $myrewards = (string) $this->getRequest()->getParam('reward_code');
48
+ if ($this->getRequest()->getParam('removepoints') == 1) {
49
+ $myrewards = '';
50
+ Mage::getSingleton('customer/session')->setdisc($myrewards);
51
+ $this->_getSession()->addSuccess($this->__('Reward points was canceled.'));
52
+ $this->_goBack();
53
+ }
54
+
55
+ else{
56
+ //$myrewards = $post['reward_code'];
57
+ $codeLength1 = strlen($myrewards);
58
+
59
+ $validtotal = Mage::helper('checkout/cart')->getQuote()->getSubtotal();
60
+ //$isCodeLengthValid = $codeLength1 && $codeLength1 <= Mage_Checkout_Helper_Cart::COUPON_CODE_MAX_LENGTH;
61
+ //$this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
62
+ //$this->_getQuote()->setCouponCode($isCodeLengthValid ? $couponCode : '')
63
+ //->collectTotals()
64
+ //->save();
65
+
66
+ if ($codeLength1 && $myrewards <=$leftpoints && $myrewards > 0 && $myrewards <= $validtotal) {
67
+ Mage::getSingleton('customer/session')->setdisc($myrewards);
68
+ $this->_getSession()->addSuccess(
69
+ $this->__('Reward Points "%s" was applied.', Mage::helper('core')->escapeHtml($myrewards))
70
+ );
71
+ }
72
+ else{
73
+
74
+
75
+ if ($leftpoints==0 or ($leftpoints < $myrewards and $leftpoints <= $validtotal)) {
76
+ $this->_getSession()->addError(
77
+ $this->__('You do not have enough points to redeem.', Mage::helper('core')->escapeHtml($myrewards))
78
+ );
79
+ }
80
+ else{
81
+ $this->_getSession()->addError(
82
+ $this->__('reward Points "%s" is not valid.', Mage::helper('core')->escapeHtml($myrewards))
83
+ );
84
+ }
85
+
86
+
87
+ }
88
+
89
+
90
+
91
+ }
92
+
93
+ $this->_goBack();
94
+ }
95
+
96
+
97
+
98
+
99
+ }
app/code/community/Imedia/RewardPoints/controllers/IndexController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Imedia_RewardPoints_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/RewardPoints/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_points>
11
+ <title>Reward Points</title>
12
+ <sort_order>9999</sort_order>
13
+ <children>
14
+ <rewardpoints translate="title" module="imedia_rewardpoints">
15
+ <title>Manage Reward Points</title>
16
+ <sort_order>210</sort_order>
17
+ <action>adminhtml/rewardpoints</action>
18
+ </rewardpoints>
19
+ </children>
20
+ </imedia_rewards_points>
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_points translate="title" module="imedia_rewardpoints">
34
+ <title>Manage reward points</title>
35
+ <sort_order>31</sort_order>
36
+ </reward_points>
37
+ </children>
38
+ </customer>
39
+
40
+ <system>
41
+ <children>
42
+ <config>
43
+ <children>
44
+ <rewardpoints translate="title" module="imedia_rewardpoints">
45
+ <title>Reward Points</title>
46
+ </rewardpoints>
47
+ </children>
48
+ </config>
49
+ </children>
50
+ </system>
51
+
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ </config>
app/code/community/Imedia/RewardPoints/etc/config.xml ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Configuration file
5
+ */
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <Imedia_RewardPoints>
10
+ <version>0.1.0</version>
11
+ <depends>
12
+ <Mage_Customer />
13
+ <Mage_Checkout />
14
+ </depends>
15
+ </Imedia_RewardPoints>
16
+ </modules>
17
+
18
+ <frontend>
19
+ <routers>
20
+ <imedia_rewardpoints>
21
+ <use>standard</use>
22
+ <args>
23
+ <module>Imedia_RewardPoints</module>
24
+ <frontName>rewardpoints</frontName>
25
+ </args>
26
+ </imedia_rewardpoints>
27
+
28
+ <checkout>
29
+ <args>
30
+ <modules>
31
+ <imedia_rewardpoints before="Mage_Checkout_CartController">
32
+ Imedia_RewardPoints
33
+ </imedia_rewardpoints>
34
+ </modules>
35
+ </args>
36
+ </checkout>
37
+
38
+ </routers>
39
+
40
+ <!-- set frontend layout file-->
41
+ <layout>
42
+ <updates>
43
+ <imedia_rewardpoints>
44
+ <file>imedia/imedia_rewardpoints.xml</file>
45
+ </imedia_rewardpoints>
46
+ </updates>
47
+ </layout>
48
+
49
+ <events>
50
+ <sales_order_place_after>
51
+ <observers>
52
+ <imedia_rewardpoints_model_observer>
53
+ <type>singleton</type>
54
+ <class>imedia_rewardpoints/observer</class>
55
+ <method>recordPointsForOrderEvent</method>
56
+ </imedia_rewardpoints_model_observer>
57
+ </observers>
58
+ </sales_order_place_after>
59
+ </events>
60
+
61
+
62
+ </frontend>
63
+
64
+
65
+
66
+ <global>
67
+
68
+ <events>
69
+ <customer_register_success>
70
+ <observers>
71
+ <imedia_rewardpoints_model_observer>
72
+ <type>singleton</type>
73
+ <class>imedia_rewardpoints/observer</class>
74
+ <method>rewardpoints</method>
75
+ </imedia_rewardpoints_model_observer>
76
+ </observers>
77
+ </customer_register_success>
78
+
79
+ <newsletter_subscriber_save_before>
80
+ <observers>
81
+ <imedia_rewardpoints_model_observer>
82
+ <type>singleton</type>
83
+ <class>imedia_rewardpoints/observer</class>
84
+ <method>subscribedToNewsletter</method>
85
+ </imedia_rewardpoints_model_observer>
86
+ </observers>
87
+ </newsletter_subscriber_save_before>
88
+ </events>
89
+
90
+ <fieldsets>
91
+ <sales_convert_quote_address>
92
+ <fee_amount><to_order>*</to_order></fee_amount>
93
+ <base_fee_amount><to_order>*</to_order></base_fee_amount>
94
+ </sales_convert_quote_address>
95
+ <sales_convert_order>
96
+ <fee_amount><to_invoice>*</to_invoice></fee_amount>
97
+ <base_fee_amount><to_invoice>*</to_invoice></base_fee_amount>
98
+ </sales_convert_order>
99
+ </fieldsets>
100
+ <pdf>
101
+ <totals>
102
+ <rewards translate="title">
103
+ <title>Rewards points discount</title>
104
+ <source_field>fee_amount</source_field>
105
+ <font_size>7</font_size>
106
+ <display_zero>0</display_zero>
107
+ <sort_order>650</sort_order>
108
+ <amount_prefix>-</amount_prefix>
109
+ </rewards>
110
+ </totals>
111
+ </pdf>
112
+
113
+
114
+ <sales>
115
+             <quote>
116
+                 <totals>
117
+                     <discount>
118
+                         <class>Imedia_RewardPoints_Model_Discount</class>
119
+                         <after>subtotal</after>
120
+                     </discount>
121
+                 </totals>
122
+             </quote>
123
+              
124
+             <order_invoice>
125
+                 <totals>
126
+                     <discount>
127
+                         <class>Imedia_RewardPoints_Model_Invoice</class>
128
+                         <after>subtotal</after>
129
+                     </discount>
130
+                 </totals>
131
+             </order_invoice>
132
+              
133
+             <order_creditmemo>
134
+                 <totals>
135
+                     <discount>
136
+                         <class>Imedia_RewardPoints_Model_Creditmemo</class>
137
+                         <after>subtotal</after>
138
+                     </discount>
139
+                 </totals>
140
+             </order_creditmemo>
141
+         </sales>
142
+
143
+
144
+ <models>
145
+
146
+ <rewardpoints>
147
+ <class>Imedia_RewardPoints_Model</class>
148
+ <resourceModel>imedia_rewardpoints_mysql4</resourceModel>
149
+ </rewardpoints>
150
+
151
+ <imedia_rewardpoints>
152
+ <class>Imedia_RewardPoints_Model</class>
153
+ <resourceModel>imedia_rewardpoints_mysql4</resourceModel>
154
+ </imedia_rewardpoints>
155
+
156
+ <imedia_rewardpoints_mysql4>
157
+ <class>Imedia_RewardPoints_Model_Mysql4</class>
158
+ <entities>
159
+ <rewardpoints>
160
+ <table>rewardpoints_rewardpoints</table>
161
+ <table>rewardpoints_account</table>
162
+ </rewardpoints>
163
+ <!--<item>
164
+ <table>rewardpoints_account_item</table>
165
+ </item> -->
166
+ </entities>
167
+ </imedia_rewardpoints_mysql4>
168
+
169
+ <rewardpoints_mysql4>
170
+ <class>Imedia_RewardPoints_Model_Mysql4</class>
171
+ <entities>
172
+ <rewardpoints>
173
+ <table>rewardpoints_account</table>
174
+ </rewardpoints>
175
+ <!--<item>
176
+ <table>rewardpoints_account_item</table>
177
+ </item> -->
178
+ </entities>
179
+ </rewardpoints_mysql4>
180
+
181
+ </models>
182
+
183
+ <helpers>
184
+ <imedia_rewardpoints>
185
+ <class>Imedia_RewardPoints_Helper</class>
186
+ </imedia_rewardpoints>
187
+ </helpers>
188
+
189
+ <blocks>
190
+ <imedia_rewardpoints>
191
+ <class>Imedia_RewardPoints_Block</class>
192
+ </imedia_rewardpoints>
193
+
194
+ <adminhtml>
195
+ <rewrite>
196
+ <sales_order_totals>Imedia_RewardPoints_Block_Adminhtml_Sales_Order</sales_order_totals> <sales_order_invoice_totals>Imedia_RewardPoints_Block_Adminhtml_Sales_Invoice</sales_order_invoice_totals>
197
+ <!-- <sales_order_creditmemo_totals>Imedia_RewardPoints_Block_Adminhtml_Sales_Creditmemo</sales_order_creditmemo_totals> -->
198
+ </rewrite>
199
+ </adminhtml>
200
+
201
+ </blocks>
202
+ <!-- Setup Resource -->
203
+ <resources>
204
+ <imedia_rewardpoints_setup>
205
+ <setup>
206
+ <module>Imedia_RewardPoints</module>
207
+ <class>Imedia_RewardPoints_Model_Resource_Setup</class>
208
+ </setup>
209
+ </imedia_rewardpoints_setup>
210
+ </resources>
211
+
212
+
213
+ </global>
214
+
215
+ <!-- Adminhtml layout xml configuration -->
216
+ <adminhtml>
217
+ <layout>
218
+ <updates>
219
+ <imedia_rewardpoints>
220
+ <file>imedia/imedia_rewardpoints.xml</file>
221
+ </imedia_rewardpoints>
222
+ </updates>
223
+ </layout>
224
+ </adminhtml>
225
+
226
+ <!-- Admin router configuration-->
227
+ <admin>
228
+ <routers>
229
+ <adminhtml>
230
+ <args>
231
+ <modules>
232
+ <Imedia_RewardPoints after="Mage_Adminhtml">Imedia_RewardPoints_Adminhtml</Imedia_RewardPoints>
233
+ </modules>
234
+ </args>
235
+ </adminhtml>
236
+ </routers>
237
+ </admin>
238
+
239
+ <default>
240
+
241
+ </default>
242
+ </config>
app/code/community/Imedia/RewardPoints/etc/system.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * System configuration file
5
+ */
6
+ -->
7
+ <config>
8
+
9
+ <tabs>
10
+ <imedia translate="label" module="imedia_rewardpoints">
11
+ <label>Imedia Extentions</label>
12
+ <sort_order>11</sort_order>
13
+ </imedia>
14
+ </tabs>
15
+
16
+
17
+ <sections>
18
+ <rewardpoints translate="label" module="imedia_rewardpoints">
19
+ <class>separator-top</class>
20
+ <label>Reward Points</label>
21
+ <tab>imedia</tab>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>13</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+
28
+
29
+ <groups>
30
+ <rewardpoints translate="label">
31
+ <label>Reward Points</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <fields>
38
+ <enabled translate="label">
39
+ <label>Enable Reward Points</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>1</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </enabled>
47
+ </fields>
48
+ </rewardpoints>
49
+ <display translate="label">
50
+ <label>Display Options</label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>2</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ <fields>
57
+
58
+ <signup translate="label">
59
+ <label>Enable reward points on sign up</label>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>1</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </signup>
67
+ <signup_points translate="label">
68
+ <label>Sign up points</label>
69
+ <frontend_type>text</frontend_type>
70
+ <validate>required-entry validate-digits</validate>
71
+ <sort_order>2</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment>Enter rewards points for signup</comment>
76
+ </signup_points>
77
+
78
+ <newsletter_signup translate="label">
79
+ <label>Enable reward points on newsletter</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>3</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </newsletter_signup>
87
+ <newsletter_signup_points translate="label">
88
+ <label>Newsletter Sign up points</label>
89
+ <frontend_type>text</frontend_type>
90
+ <validate>required-entry validate-digits</validate>
91
+ <sort_order>4</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ <comment>Enter rewards points for news letter signup</comment>
96
+ </newsletter_signup_points>
97
+
98
+ <product_rewards translate="label">
99
+ <label>Enable reward points on products</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>5</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </product_rewards>
107
+
108
+
109
+ </fields>
110
+ </display>
111
+ </groups>
112
+
113
+ </rewardpoints>
114
+ </sections>
115
+ </config>
app/code/community/Imedia/RewardPoints/sql/imedia_rewardpoints_setup/install-0.1.0.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('rewardpoints_rewardpoints')};
11
+ CREATE TABLE {$this->getTable('rewardpoints_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` DECIMAL( 10, 2 ) NOT NULL;
19
+ ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
20
+
21
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
22
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
23
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_invoiced` DECIMAL( 10, 2 ) NOT NULL;
24
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_invoiced` DECIMAL( 10, 2 ) NOT NULL;
25
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_refunded` DECIMAL( 10, 2 ) NOT NULL;
26
+ ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_refunded` DECIMAL( 10, 2 ) NOT NULL;
27
+
28
+ ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
29
+ ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
30
+
31
+
32
+
33
+ ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
34
+ ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
35
+
36
+
37
+
38
+ -- DROP TABLE IF EXISTS {$this->getTable('rewardpoints_account')};
39
+ CREATE TABLE {$this->getTable('rewardpoints_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', array(
54
+ 'group' => 'General',
55
+ 'type' => 'int',
56
+ 'backend' => '',
57
+ 'frontend' => '',
58
+ 'label' => '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' => 0, //0 For All Product Types
73
+ 'is_configurable' => false,
74
+ ));
75
+
76
+
77
+
78
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/imedia/imedia_rewardpoints.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+
3
+ <layout version="0.1.0">
4
+ <adminhtml_rewardpoints_index>
5
+ <reference name="content">
6
+ <block type="imedia_rewardpoints/adminhtml_rewardpoints" name="rewardpoints.grid.container" />
7
+ </reference>
8
+ </adminhtml_rewardpoints_index>
9
+
10
+ </layout>
app/design/frontend/base/default/layout/imedia/imedia_rewardpoints.xml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_rewards.css</stylesheet></action>
9
+ </reference>
10
+ </default>
11
+ <imedia_rewardpoints_index_index>
12
+ <reference name="content">
13
+ <block type="imedia_rewardpoints/reward_points" name="myrewardpoints">
14
+ <action method="setTemplate" ifconfig="rewardpoints/rewardpoints/enabled">
15
+ <template>imedia/rewardform.phtml</template></action>
16
+ </block>
17
+ </reference>
18
+ </imedia_rewardpoints_index_index>
19
+
20
+ <checkout_cart_index>
21
+ <reference name="checkout.cart">
22
+ <block type="core/text_list" name="coupon.and.discount" as="coupon" >
23
+ <block type="imedia_rewardpoints/reward_points" name="myrewardpoints">
24
+ <action method="setTemplate" ifconfig="rewardpoints/rewardpoints/enabled">
25
+ <template>imedia/rewardform.phtml</template></action>
26
+ </block>
27
+ <action method="insert"><block>checkout.cart.coupon</block></action>
28
+ </block>
29
+ </reference>
30
+ </checkout_cart_index>
31
+
32
+ <customer_account_index>
33
+ <reference name="customer_account_dashboard">
34
+ <action method="setTemplate" ifconfig="rewardpoints/rewardpoints/enabled">
35
+ <template>rewardpoints/my_dashboard.phtml</template>
36
+ </action>
37
+ <block type="core/template" name="customer_account_points" as="points" template="rewardpoints/dashboard_points.phtml"/>
38
+ </reference>
39
+ </customer_account_index>
40
+
41
+
42
+ <sales_email_order_items>
43
+ <reference name="order_totals">
44
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
45
+ </reference>
46
+ </sales_email_order_items>
47
+
48
+ <sales_email_order_invoice_items>
49
+ <reference name="invoice_totals">
50
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
51
+ </reference>
52
+ </sales_email_order_invoice_items>
53
+
54
+
55
+ <sales_order_view>
56
+ <reference name="order_totals">
57
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
58
+ </reference>
59
+ </sales_order_view>
60
+ <sales_order_print>
61
+ <reference name="order_totals">
62
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
63
+ </reference>
64
+ </sales_order_print>
65
+ <sales_order_invoice>
66
+ <reference name="invoice_totals">
67
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
68
+ </reference>
69
+ </sales_order_invoice>
70
+ <sales_order_printinvoice>
71
+ <reference name="invoice_totals">
72
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
73
+ </reference>
74
+ </sales_order_printinvoice>
75
+ <sales_order_creditmemo>
76
+ <reference name="creditmemo_totals">
77
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
78
+ </reference>
79
+ </sales_order_creditmemo>
80
+ <sales_order_printcreditmemo>
81
+ <reference name="creditmemo_totals">
82
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
83
+ </reference>
84
+ </sales_order_printcreditmemo>
85
+ <sales_email_order_creditmemo_items>
86
+ <reference name="creditmemo_totals">
87
+ <block type="imedia_rewardpoints/sales_order_total" name="imedia.sales.order.total" />
88
+ </reference>
89
+ </sales_email_order_creditmemo_items>
90
+
91
+
92
+
93
+ </layout>
app/design/frontend/base/default/template/imedia/rewardform.phtml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('rewardpoints/account')->load($customerId);
31
+ ?>
32
+
33
+ <div class="discount">
34
+ <h2>Reward Points</h2>
35
+ <?php $r_disc = Mage::getSingleton('customer/session')->getDisc(); ?>
36
+ <form action="<?php echo Mage::getUrl('rewardpoints/cart/applypoints') ?>" id="rewardpoint" method="post">
37
+
38
+ <div class="discount-form">
39
+ <label for="coupon_code"><?php echo $this->__('Points') ?></label>
40
+ <input type="hidden" name="removepoints" id="remove-points" value="0" />
41
+ <div class="field-wrapper">
42
+ <input class="input-text" type="text" id="reward_code" name="reward_code" value="<?php echo $r_disc; ?>" />
43
+ <div class="button-wrapper">
44
+ <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>
45
+
46
+ <?php if(strlen($r_disc > 0)): ?>
47
+ <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>
48
+ </button>
49
+ <?php endif;?>
50
+
51
+ </div>
52
+ </div><br>
53
+ <div style="padding-top:20px;"><?php echo $this->__('Balance Available') ?> : <?= sprintf('%d',$customerPoints->getPointsCurrent()); ?> </div>
54
+ </div>
55
+ </form>
56
+
57
+ </div>
58
+
59
+ <script type="text/javascript">
60
+ //<![CDATA[
61
+ var rewardForm = new VarienForm('rewardpoint');
62
+ rewardForm.submit = function (isRemove) {
63
+ if (isRemove) {
64
+ $('reward_code').removeClassName('required-entry');
65
+ $('remove-points').value = "1";
66
+ } else {
67
+ $('reward_code').addClassName('required-entry');
68
+ $('remove-points').value = "0";
69
+ }
70
+ return VarienForm.prototype.submit.bind(rewardForm)();
71
+ }
72
+ //]]>
73
+ </script>
app/design/frontend/base/default/template/rewardpoints/dashboard_points.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $customerId = Mage::getModel('customer/session')->getCustomerId();
3
+ $customerPoints = Mage::getModel('rewardpoints/account')->load($customerId);
4
+ ?>
5
+ Your Points: <?= sprintf('%d',$customerPoints->getPointsCurrent()); ?>
6
+ <br/>
7
+ Total Points Accumulated: <?= sprintf('%d',$customerPoints->getPointsReceived()); ?>
8
+ <br/>
9
+ Total Points Spent: <?= sprintf('%d',$customerPoints->getPointsSpent()); ?>
10
+ <br/>
app/design/frontend/base/default/template/rewardpoints/my_dashboard.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/etc/modules/Imedia_RewardPoints.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Imedia_RewardPoints>
6
+ <active>true</active>
7
+ <codePool>community</codePool>
8
+ </Imedia_RewardPoints>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Imedia_RewardPoints</name>
4
+ <version>1.0.0.1</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</summary>
10
+ <description>Customer reward points on newsletter signups, customer register and on products. Rewards points are manageable from admin. </description>
11
+ <notes>First Preview release</notes>
12
+ <authors><author><name>iMedia inc.</name><user>imedia</user><email>sachin@imediadesigns.org</email></author></authors>
13
+ <date>2015-07-07</date>
14
+ <time>07:43:21</time>
15
+ <contents><target name="magecommunity"><dir name="Imedia"><dir name="RewardPoints"><dir name="Block"><dir name="Adminhtml"><dir name="Renderer"><file name="CustomerName.php" hash="1d3686ffa23969e823f5f3a62ee6a6e7"/></dir><dir name="Rewardpoints"><file name="Grid.php" hash="65be4094ba8c21f306166a289dba06e2"/></dir><file name="Rewardpoints.php" hash="aa06b896aeda706b7474ed3fc90bcdd7"/><dir name="Sales"><file name="Creditmemo.php" hash="f457702478b6ffaa6401f9cf50ca3888"/><file name="Invoice.php" hash="5e3dd8fcdaa63ec51b45752b93dd99cb"/><file name="Order.php" hash="6fdc3f62ecc6ce13a7eba767e11d583d"/></dir></dir><dir name="Reward"><file name="Points.php" hash="8c2c102b939f9fd5d64c263d9a9da671"/></dir><dir name="Sales"><file name="Creditmemo.php" hash="12fb433034890b5a1495d3ceb618b102"/><dir name="Order"><file name="Total.php" hash="ad9e0f1ef8b3d1378f303d0cd486cdd1"/></dir><file name="Order.php" hash="a369fe6c67e18f2e253a8d0446be4d10"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6a8200d40f9c9de36084186140538a2e"/></dir><dir name="Model"><file name="Account.php" hash="8af96dae4a238c8d2a3ed4a5d681cd66"/><file name="Creditmemo.php" hash="7d196c7bb383f30b1f0b9d9e4676fd57"/><file name="Discount.php" hash="c252ef56ee000f7e8e0f9260cdf6f670"/><file name="Invoice.php" hash="6c2ff88b23b3ba138d4ce75cb9290903"/><dir name="Mysql4"><dir name="Account"><file name="Collection.php" hash="809b0c358b07607353043c253ccf10c7"/></dir><file name="Account.php" hash="a94d228af5884c8841bd3ea16aacc430"/><dir name="Rewardpoints"><file name="Collection.php" hash="396a09f06e597cf88be677932a5f5646"/></dir><file name="Rewardpoints.php" hash="53239e56b63c57ccc009c60700b0fd7a"/></dir><file name="Observer.php" hash="4992b52784713b7b77cf2cabce53dddc"/><dir name="Resource"><file name="Setup.php" hash="9bacc9656819820cfbb4815e5047d3e0"/></dir><file name="Rewardpoints.php" hash="67cad1215d167a7886cf7798041e4145"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="RewardpointsController.php" hash="c6dcb14454885de85fa6448308ffaa55"/></dir><file name="CartController.php" hash="5ed95d3cc949e4111e5f2621c48b505d"/><file name="IndexController.php" hash="8437c896a10f6423c9e1d10e8bd12f26"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4655329822042186ecf77504ae5478cf"/><file name="config.xml" hash="f91ea860ca1303010c50390bb2b9fdc2"/><file name="system.xml" hash="3cbee3860104656de41b0a555ad491d9"/></dir><dir name="sql"><dir name="imedia_rewardpoints_setup"><file name="install-0.1.0.php" hash="f3fedd117cf71677ef2c8af30d921919"/></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_rewardpoints.xml" hash="14d84befe3e35dadc246bebfc6348db7"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="imedia"><file name="imedia_rewardpoints.xml" hash="70e03b308459f4d2d746a8bf28d5133a"/></dir></dir><dir name="template"><dir name="imedia"><file name="rewardform.phtml" hash="9427368df1e66c43a2c5a653726117c9"/></dir><dir name="rewardpoints"><file name="dashboard_points.phtml" hash="e18b142b335ae36f2e6a42347b3d6a46"/><file name="my_dashboard.phtml" hash="e4e93745a6a9978074488f7d9448e669"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Imedia_RewardPoints.xml" hash="3dd51d312ca98b779da323dd0f96742f"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="imedia"><file name="im_rewards.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_rewards.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
+ }