GCMC_GiveChange - Version 0.0.1

Version Notes

Initial Release

Download this release

Release Info

Developer Magento Core Team
Extension GCMC_GiveChange
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (28) hide show
  1. app/code/community/GCMC/GiveChange/Block/Info.php +256 -0
  2. app/code/community/GCMC/GiveChange/Helper/Data.php +305 -0
  3. app/code/community/GCMC/GiveChange/LICENSE.txt +48 -0
  4. app/code/community/GCMC/GiveChange/Model/Api/Abstract.php +188 -0
  5. app/code/community/GCMC/GiveChange/Model/Api/Log.php +99 -0
  6. app/code/community/GCMC/GiveChange/Model/Api/Standard.php +209 -0
  7. app/code/community/GCMC/GiveChange/Model/Mysql4/Setup.php +27 -0
  8. app/code/community/GCMC/GiveChange/Model/Observer.php +92 -0
  9. app/code/community/GCMC/GiveChange/Model/Product/Type/Donation.php +101 -0
  10. app/code/community/GCMC/GiveChange/Model/Product/Type/Donation/Price.php +69 -0
  11. app/code/community/GCMC/GiveChange/controllers/CartController.php +164 -0
  12. app/code/community/GCMC/GiveChange/etc/adminhtml.xml +40 -0
  13. app/code/community/GCMC/GiveChange/etc/config.xml +161 -0
  14. app/code/community/GCMC/GiveChange/etc/system.xml +167 -0
  15. app/code/community/GCMC/GiveChange/sql/givechange_setup/mysql4-install-0.0.0.1.php +20 -0
  16. app/code/community/GCMC/GiveChange/sql/givechange_setup/mysql4-upgrade-0.0.0.1-0.0.0.2.php +21 -0
  17. app/design/frontend/base/default/layout/givechange.xml +32 -0
  18. app/design/frontend/base/default/template/givechange/info.phtml +128 -0
  19. app/etc/modules/GCMC_GiveChange.xml +26 -0
  20. app/locale/en_US/GCMC_GiveChange.csv +43 -0
  21. app/locale/en_US/template/email/givechange_log.html +10 -0
  22. js/givechange/givechange.js +74 -0
  23. js/givechange/modalbox.js +40 -0
  24. media/import/givechange.jpg +0 -0
  25. package.xml +18 -0
  26. skin/frontend/base/default/css/givechange.css +175 -0
  27. skin/frontend/base/default/images/givechange/close-button.gif +0 -0
  28. skin/frontend/base/default/images/givechange/givechange.gif +0 -0
app/code/community/GCMC/GiveChange/Block/Info.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @copyright Copyright (c) 2011 GCMC (http://www.GCMC.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Give change info block
21
+ *
22
+ * @category GCMC
23
+ * @package GCMC_GiveChange
24
+ * @author Andrew Freeborn <magento-dev@GCMC.com>
25
+ */
26
+ class GCMC_GiveChange_Block_Info extends Mage_Core_Block_Template
27
+ {
28
+ /**
29
+ * Get API instance
30
+ *
31
+ * @return GCMC_GiveChange_Model_Api_Abstract
32
+ */
33
+ public function getApi()
34
+ {
35
+ return $this->helper('givechange')->getApi();
36
+ }
37
+
38
+ /**
39
+ * Get cart model
40
+ *
41
+ * @return Mage_Checkout_Model_Cart
42
+ */
43
+ public function getCart()
44
+ {
45
+ return Mage::getSingleton('checkout/cart');
46
+ }
47
+
48
+ /**
49
+ * Get quote object
50
+ *
51
+ * @return Mage_Sales_Model_Quote
52
+ */
53
+ public function getQuote()
54
+ {
55
+ return $this->getCart()->getQuote();
56
+ }
57
+
58
+ /**
59
+ * Get add donation URL
60
+ *
61
+ * @return string
62
+ */
63
+ public function getAddUrl()
64
+ {
65
+ return $this->getUrl('givechange/cart/add');
66
+ }
67
+
68
+ /**
69
+ * Get array of charities to display
70
+ *
71
+ * @return array
72
+ */
73
+ public function getCharities()
74
+ {
75
+ return (array) $this->getApi()->getCharities();
76
+ }
77
+
78
+ /**
79
+ * Use give change
80
+ *
81
+ * @return boolean
82
+ */
83
+ public function useGiveChange()
84
+ {
85
+ return (bool) (
86
+ $this->helper('givechange')->useGiveChange() &&
87
+ $this->getCart()->getSummaryQty()
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Do we want to use gift aid?
93
+ *
94
+ * @return boolean
95
+ */
96
+ public function useGiftAid()
97
+ {
98
+ return (bool) $this->helper('givechange')->useGiftAid();
99
+ }
100
+
101
+ /**
102
+ * Allow custom donation values
103
+ *
104
+ * @return boolean
105
+ */
106
+ public function allowCustomDonations()
107
+ {
108
+ return (bool) $this->helper('givechange')->allowCustomDonations();
109
+ }
110
+
111
+ /**
112
+ * Get Donation item
113
+ *
114
+ * @return Mage_Sales_Model_Quote_Item
115
+ */
116
+ public function getDonationItem()
117
+ {
118
+ return $this->helper('givechange')->getDonationItem();
119
+ }
120
+
121
+ /**
122
+ * Has Donation item
123
+ *
124
+ * @return boolean
125
+ */
126
+ public function hasDonationItem()
127
+ {
128
+ return !is_null($this->getDonationItem());
129
+ }
130
+
131
+ /**
132
+ * Get Donation amount
133
+ *
134
+ * @return float
135
+ */
136
+ public function getDonationValue()
137
+ {
138
+ return number_format($this->helper('givechange')->getDonationValue(), 2, '.', '');
139
+ }
140
+
141
+ /**
142
+ * Get has Gift Aid option from Donation item
143
+ *
144
+ * @return boolean
145
+ */
146
+ public function hasGiftAid()
147
+ {
148
+ $options = $this->helper('givechange')
149
+ ->getDonationItemBuyOptions();
150
+
151
+ return $options->getGiftaid();
152
+ }
153
+
154
+ /**
155
+ * Get has Roundup option from Donation item
156
+ *
157
+ * @return boolean
158
+ */
159
+ public function isRoundup()
160
+ {
161
+ $options = $this->helper('givechange')
162
+ ->getDonationItemBuyOptions();
163
+
164
+ return (GCMC_GiveChange_Helper_Data::DONATION_TYPE_ROUNDUP == $options->getRoundup());
165
+ }
166
+
167
+ /**
168
+ * Get has Roundup option from Donation item
169
+ *
170
+ * @return boolean
171
+ */
172
+ public function isCustom()
173
+ {
174
+ $options = $this->helper('givechange')
175
+ ->getDonationItemBuyOptions();
176
+
177
+ return (GCMC_GiveChange_Helper_Data::DONATION_TYPE_CUSTOM == $options->getRoundup());
178
+ }
179
+
180
+ /**
181
+ * Get donation type code
182
+ *
183
+ * @param string $type
184
+ * @return string
185
+ */
186
+ public function getDonationTypeCode($type)
187
+ {
188
+ $code = '';
189
+
190
+ switch($type) {
191
+
192
+ case 'roundup':
193
+ $code = GCMC_GiveChange_Helper_Data::DONATION_TYPE_ROUNDUP;
194
+ break;
195
+ default:
196
+ $code = GCMC_GiveChange_Helper_Data::DONATION_TYPE_CUSTOM;
197
+ }
198
+
199
+ return $code;
200
+ }
201
+
202
+ /**
203
+ * Get current currency symbol
204
+ *
205
+ * @return string
206
+ */
207
+ public function getCurrencySymbol()
208
+ {
209
+ return Mage::app()->getLocale()
210
+ ->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
211
+ }
212
+
213
+ /**
214
+ * Get roundup value
215
+ *
216
+ * @return float
217
+ */
218
+ public function getRoundupValue()
219
+ {
220
+ return number_format($this->helper('givechange')->getRoundupValue(), 2, '.', '');
221
+ }
222
+
223
+ /**
224
+ * Get grand total plus roundup value
225
+ *
226
+ * @return int
227
+ */
228
+ public function getTotalPlusRoundup()
229
+ {
230
+ return number_format($this->helper('givechange')->getTotalPlusRoundup(), 2, '.', '');
231
+ }
232
+
233
+ /**
234
+ * Get grand total minus donation value
235
+ *
236
+ * @return int
237
+ */
238
+ public function getTotalMinusDonation()
239
+ {
240
+ return number_format($this->helper('givechange')->getTotalMinusDonation(), 2, '.', '');
241
+ }
242
+
243
+ /**
244
+ * Override parent toHtml method
245
+ *
246
+ * @return string
247
+ */
248
+ protected function _toHtml()
249
+ {
250
+ if(!$this->useGiveChange()) {
251
+ return '';
252
+ }
253
+
254
+ return parent::_toHtml();
255
+ }
256
+ }
app/code/community/GCMC/GiveChange/Helper/Data.php ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Give Change default data helper
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Helper_Data extends Mage_Core_Helper_Abstract
25
+ {
26
+ const PRICE_UNIT_1 = 1;
27
+ const PRICE_UNIT_5 = 5;
28
+ const PRICE_UNIT_10 = 10;
29
+ const PRICE_TIER_100 = 100;
30
+ const PRICE_TIER_500 = 500;
31
+
32
+ const DONATION_TYPE_CUSTOM = 'custom';
33
+ const DONATION_TYPE_ROUNDUP = 'roundup';
34
+
35
+ /**
36
+ * Donation item cache
37
+ *
38
+ * @var array
39
+ */
40
+ protected $_donationItem = array();
41
+
42
+ /**
43
+ * Donation item options cache
44
+ *
45
+ * @var array
46
+ */
47
+ protected $_donationItemBuyOptions = array();
48
+
49
+ /**
50
+ * Get Round Up value
51
+ *
52
+ * @var float
53
+ */
54
+ protected $_roundupValue;
55
+
56
+ /**
57
+ * Get API instance
58
+ *
59
+ * @return GCMC_GiveChange_Model_Api_Abstract
60
+ */
61
+ public function getApi()
62
+ {
63
+ return Mage::getSingleton('givechange/api_standard');
64
+ }
65
+
66
+ /**
67
+ * Get use give change
68
+ *
69
+ * @reutrn boolean
70
+ */
71
+ public function useGiveChange()
72
+ {
73
+ return Mage::getStoreConfigFlag('givechange/settings/is_enabled');
74
+ }
75
+
76
+ /**
77
+ * Get use Gift Aid config flag
78
+ *
79
+ * @reutrn boolean
80
+ */
81
+ public function useGiftAid()
82
+ {
83
+ return Mage::getStoreConfigFlag('givechange/settings/gift_aid');
84
+ }
85
+
86
+ /**
87
+ * Get use Roundup config flag
88
+ *
89
+ * @return boolean
90
+ */
91
+ public function useRoundupService()
92
+ {
93
+ return Mage::getStoreConfigFlag('givechange/settings/use_roundup');
94
+ }
95
+
96
+ /**
97
+ * Allow custom donations
98
+ *
99
+ * @reutrn boolean
100
+ */
101
+ public function allowCustomDonations()
102
+ {
103
+ return Mage::getStoreConfigFlag('givechange/settings/allow_custom');
104
+ }
105
+
106
+ /**
107
+ * Get default product sku
108
+ *
109
+ * @return string
110
+ */
111
+ public function getProductSku()
112
+ {
113
+ return Mage::getStoreConfig('givechange/settings/sku');
114
+ }
115
+
116
+ /**
117
+ * Get default product sku
118
+ *
119
+ * @return string
120
+ */
121
+ public function getProductLabel()
122
+ {
123
+ return Mage::getStoreConfig('givechange/settings/label');
124
+ }
125
+
126
+ /**
127
+ * Get default product sku
128
+ *
129
+ * @return string
130
+ */
131
+ public function getProductPrice()
132
+ {
133
+ return Mage::getStoreConfig('givechange/settings/price');
134
+ }
135
+
136
+ /**
137
+ * Get default product sku
138
+ *
139
+ * @return string
140
+ */
141
+ public function getProductWeight()
142
+ {
143
+ return Mage::getStoreConfig('givechange/settings/weight');
144
+ }
145
+
146
+ /**
147
+ * Get donation item
148
+ *
149
+ * @param Mage_Sales_Model_Quote $quote
150
+ * @return Mage_Sales_Model_Quote_Item
151
+ */
152
+ public function getDonationItem($quote = false)
153
+ {
154
+ if(!$quote) {
155
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
156
+ }
157
+
158
+ if(!isset($this->_donationItem[$quote->getId()])) {
159
+
160
+ $discountItem = false;
161
+
162
+ foreach($quote->getAllItems() as $item) {
163
+
164
+ if($item->getProductType() == GCMC_GiveChange_Model_Product_Type_Donation::TYPE_CODE) {
165
+
166
+ $discountItem = $item;
167
+ break;
168
+ }
169
+ }
170
+
171
+ $this->_donationItem[$quote->getId()] = $discountItem;
172
+ }
173
+
174
+ return $this->_donationItem[$quote->getId()];
175
+ }
176
+
177
+ /**
178
+ * Get Donation amount
179
+ *
180
+ * @return float
181
+ */
182
+ public function getDonationValue()
183
+ {
184
+ $item = $this->getDonationItem();
185
+
186
+ if($item) {
187
+ return number_format($item->getRowTotal(), 2, '.', '');
188
+ }
189
+
190
+ return 0;
191
+ }
192
+
193
+ /**
194
+ * Get donation item buy options
195
+ *
196
+ * @param Mage_Sales_Model_Quote $quote
197
+ * @return Varien_Object
198
+ */
199
+ public function getDonationItemBuyOptions($quote = false)
200
+ {
201
+ $options = new Varien_Object();
202
+ $item = $this->getDonationItem($quote);
203
+
204
+ // No quote item present
205
+ if(!$item) {
206
+ return $options;
207
+ }
208
+
209
+ // Cache options by item ID
210
+ if(!isset($this->_donationItemBuyOptions[$item->getId()])) {
211
+
212
+ $option = $item->getOptionByCode('info_buyRequest');
213
+
214
+ if($option) {
215
+ $options->setData(unserialize($option->getValue()));
216
+ }
217
+
218
+ $this->_donationItemBuyOptions[$item->getId()] = $options;
219
+ }
220
+
221
+ return $this->_donationItemBuyOptions[$item->getId()];
222
+ }
223
+
224
+ /**
225
+ * Get grand total value
226
+ *
227
+ * @return int
228
+ */
229
+ public function getQuoteTotal()
230
+ {
231
+ return Mage::getSingleton('checkout/cart')->getQuote()
232
+ ->getGrandTotal();
233
+ }
234
+
235
+ /**
236
+ * Get grand total plus roundup value
237
+ *
238
+ * @return int
239
+ */
240
+ public function getTotalPlusRoundup()
241
+ {
242
+ return ($this->getTotalMinusDonation()+$this->getRoundupValue());
243
+ }
244
+
245
+ /**
246
+ * Get grand total minus donation value
247
+ *
248
+ * @return int
249
+ */
250
+ public function getTotalMinusDonation()
251
+ {
252
+ return ($this->getQuoteTotal()-$this->getDonationValue());
253
+ }
254
+
255
+ /**
256
+ * Get roundup value
257
+ *
258
+ * @return float
259
+ */
260
+ public function getRoundupValue()
261
+ {
262
+ if(is_null($this->_roundupValue)) {
263
+
264
+ $value = $this->getTotalMinusDonation();
265
+
266
+ // Use the roundup service
267
+ if($this->useRoundupService()) {
268
+ $value = $this->getApi()->getRoundupValue($value);
269
+ }
270
+ // Use internal algorithm
271
+ else{
272
+ $value = $this->getManualRoundup($value);
273
+ }
274
+
275
+ $this->_roundupValue = $value;
276
+ }
277
+
278
+ return $this->_roundupValue;
279
+ }
280
+
281
+ /**
282
+ * Round up value using internal algorithm.
283
+ *
284
+ * @todo This should probably be configurable at some point
285
+ * @param int $value
286
+ * @return int
287
+ */
288
+ public function getManualRoundup($value)
289
+ {
290
+ // Nearest 1
291
+ if($value < self::PRICE_TIER_100){
292
+ $unit = self::PRICE_UNIT_1;
293
+ }
294
+ // Nearest 5
295
+ elseif($value < self::PRICE_TIER_500){
296
+ $unit = self::PRICE_UNIT_5;
297
+ }
298
+ // Nearest 10
299
+ else{
300
+ $unit = self::PRICE_UNIT_10;
301
+ }
302
+
303
+ return round(($value+$unit/2)/$unit)*$unit;
304
+ }
305
+ }
app/code/community/GCMC/GiveChange/LICENSE.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Open Software License ("OSL") v. 3.0
3
+
4
+ This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
5
+
6
+ Licensed under the Open Software License version 3.0
7
+
8
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
9
+
10
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
11
+
12
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
13
+
14
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
15
+
16
+ 4. to perform the Original Work publicly; and
17
+
18
+ 5. to display the Original Work publicly.
19
+
20
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
21
+
22
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
23
+
24
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
25
+
26
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
27
+
28
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
29
+
30
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
31
+
32
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
33
+
34
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
35
+
36
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
37
+
38
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
39
+
40
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
41
+
42
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
43
+
44
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
45
+
46
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
47
+
48
+ 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
app/code/community/GCMC/GiveChange/Model/Api/Abstract.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Abstract API class
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ abstract class GCMC_GiveChange_Model_Api_Abstract extends Varien_Object
25
+ {
26
+ const LOG_LEVEL_ERROR = 'ERROR';
27
+ const DEFAULT_VALUE = 'NONE';
28
+
29
+ /**
30
+ * Config path
31
+ *
32
+ * @var stirng
33
+ */
34
+ protected $_configPath = 'givechange/settings/%s';
35
+
36
+ /**
37
+ * Get config values
38
+ *
39
+ * @param string $var
40
+ * @param boolean $flag
41
+ * @param mixed $default
42
+ * @return mixed
43
+ */
44
+ protected function _getConfig($var, $flag = false, $default = null)
45
+ {
46
+ if(!$this->hasData($var)) {
47
+
48
+ if(!$flag) {
49
+ $value = Mage::getStoreConfig(sprintf($this->_configPath, $var));
50
+ }
51
+ else {
52
+ $value = Mage::getStoreConfigFlag(sprintf($this->_configPath, $var));
53
+ }
54
+
55
+ if(is_null($value)) {
56
+ $value = $default;
57
+ }
58
+
59
+ $this->setData($var, $value);
60
+ }
61
+
62
+ return $this->_getData($var);
63
+ }
64
+
65
+ /**
66
+ * Is application in test mode?
67
+ *
68
+ * @return boolean
69
+ */
70
+ protected function _isTestMode()
71
+ {
72
+ return (bool) $this->_getConfig('is_test', true);
73
+ }
74
+
75
+ /**
76
+ * Get Merchant ID
77
+ *
78
+ * @return string
79
+ */
80
+ protected function _getMerchantId()
81
+ {
82
+ return (string) $this->_getConfig('merchant_id');
83
+ }
84
+
85
+ /**
86
+ * Get Merchant URN
87
+ *
88
+ * @return string
89
+ */
90
+ protected function _getMerchantUrn()
91
+ {
92
+ return (string) $this->_getConfig('merchant_urn');
93
+ }
94
+
95
+ /**
96
+ * Format string to length
97
+ *
98
+ * @param string $string
99
+ * @param string $default
100
+ * @param int $length
101
+ * @return string
102
+ */
103
+ protected function _format($string, $default, $length = 20)
104
+ {
105
+ // Set default value
106
+ if(!trim($string)) {
107
+ $string = $default;
108
+ }
109
+
110
+ // Set system default
111
+ if(!trim($string)) {
112
+ $string = self::DEFAULT_VALUE;
113
+ }
114
+
115
+ return substr($string, 0, $length);
116
+ }
117
+
118
+ /**
119
+ * Get API URL
120
+ *
121
+ * @return string
122
+ */
123
+ protected function _getApiUrl()
124
+ {
125
+ if($this->_isTestMode()){
126
+ $url = $this->_getConfig('test_url');
127
+ }
128
+ else{
129
+ $url = $this->_getConfig('live_url');
130
+ }
131
+
132
+ return (string) $url;
133
+ }
134
+
135
+ /**
136
+ * Log events
137
+ *
138
+ * @param mixed $data
139
+ * @param boolean $email
140
+ * @return GCMC_GiveChange_Model_Api_Abstract
141
+ */
142
+ protected function _log($data, $email = false)
143
+ {
144
+ Mage::getModel('givechange/api_log')->log($data, $email);
145
+
146
+ return $this;
147
+ }
148
+
149
+ /**
150
+ * Before Call Actions
151
+ *
152
+ * @param array $params
153
+ * @return array
154
+ */
155
+ protected function _beforeCall(Array $params)
156
+ {
157
+ $params['merchant_id'] = $this->_getMerchantId();
158
+ $params['merchant_urn'] = $this->_getMerchantUrn();
159
+
160
+ return $params;
161
+ }
162
+
163
+ /**
164
+ * After Call Actions
165
+ *
166
+ * @param Zend_Http_Response
167
+ * @return Varien_Simplexml_Element
168
+ */
169
+ protected function _afterCall(Zend_Http_Response $response)
170
+ {
171
+ $xmlObj = false;
172
+
173
+ if(false !== stripos($response->getBody(), '<?xml')) {
174
+ $xmlObj = new Varien_Simplexml_Element(utf8_encode($response->getBody()));
175
+ }
176
+
177
+ return $xmlObj;
178
+ }
179
+
180
+ /**
181
+ * Abstract API call class
182
+ *
183
+ * @param string $method
184
+ * @param array $params
185
+ * @return mixed
186
+ */
187
+ abstract protected function _call($method, Array $params = array());
188
+ }
app/code/community/GCMC/GiveChange/Model/Api/Log.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * API log class
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Model_Api_Log extends Mage_Core_Model_Abstract
25
+ {
26
+ const XML_PATH_EMAIL_TEMPLATE = 'givechange/email_logs/template';
27
+ const XML_PATH_EMAIL_IDENTITY = 'givechange/email_logs/identity';
28
+ const XML_PATH_EMAIL_RECIPIENT = 'givechange/email_logs/recipient';
29
+ const XML_PATH_EMAIL_LOGS = 'givechange/email_logs/enabled';
30
+
31
+ /**
32
+ * Log data
33
+ *
34
+ * @param mixe $data
35
+ * @return GCMC_GiveChange_Model_Api_Log
36
+ */
37
+ public function log($data, $email = false)
38
+ {
39
+ Mage::log($data, null, 'givechange.log');
40
+
41
+ if($email) {
42
+ $this->emailLog((array) $data);
43
+ }
44
+
45
+ return $this;
46
+ }
47
+
48
+ /**
49
+ * Email error log
50
+ *
51
+ * @param Array $data
52
+ * @return GCMC_GiveChange_Model_Api_Log
53
+ */
54
+ public function emailLog(Array $data)
55
+ {
56
+ if(Mage::getStoreConfigFlag(self::XML_PATH_EMAIL_LOGS)) {
57
+
58
+ $translate = Mage::getSingleton('core/translate');
59
+ $translate->setTranslateInline(false);
60
+
61
+ $template = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE);
62
+ $recipient = Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT);
63
+ $identity = Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY);
64
+
65
+ if(!$recipient) {
66
+ $recipient = $identity;
67
+ }
68
+
69
+ $error = '';
70
+
71
+ // Concatenate error data
72
+ foreach($data as $field => $value) {
73
+ $error .= sprintf('<b>%s:</b> %s<br />', $field, $value);
74
+ }
75
+
76
+ try {
77
+
78
+ Mage::getModel('core/email_template')
79
+ ->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))
80
+ ->sendTransactional(
81
+ $template,
82
+ $identity,
83
+ $recipient,
84
+ $recipient,
85
+ array(
86
+ 'error' => $error
87
+ )
88
+ );
89
+ }
90
+ catch(Exception $e) {}
91
+
92
+ $translate->setTranslateInline(true);
93
+ }
94
+
95
+ return $this;
96
+ }
97
+ }
98
+
99
+
app/code/community/GCMC/GiveChange/Model/Api/Standard.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Standard API class
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Model_Api_Standard extends GCMC_GiveChange_Model_Api_Abstract
25
+ {
26
+ const REQUEST_METHOD_ROUNDUP = 'roundup';
27
+ const REQUEST_METHO_CHARITYINFO = 'charityinfo';
28
+ const REQUEST_METHOD_NOTIFICATION = 'notification';
29
+
30
+ const GIFT_AID_YES = 'Y';
31
+ const GIFT_AID_NO = 'N';
32
+ const CHARITY_ID_DEFAULT = 9999;
33
+
34
+ const RESPONSE_CODE_SUCCESS = 0;
35
+ const RESPONSE_CODE_INVALID_PAYMENT_METHOD = 10;
36
+ const RESPONSE_CODE_INVALID_DONATION = 12;
37
+ const RESPONSE_CODE_INVALID_COUNTY = 15;
38
+ const RESPONSE_CODE_INVALID_SOURCE = 21;
39
+
40
+ const PAYMENT_METHOD_OTHER = 'OTHER';
41
+
42
+ /**
43
+ * Get list of charities
44
+ *
45
+ * @return array
46
+ */
47
+ public function getCharities()
48
+ {
49
+ $response = $this->_call(self::REQUEST_METHO_CHARITYINFO);
50
+ $charitys = array();
51
+
52
+ if($response && count($response->charity)) {
53
+
54
+ foreach($response->charity as $charity) {
55
+ $charitys[] = new Varien_Object($charity->asArray());
56
+ }
57
+ }
58
+
59
+ return $charitys;
60
+ }
61
+
62
+ /**
63
+ * Get calculated roundup amount
64
+ *
65
+ * @param string $value
66
+ * @return int
67
+ */
68
+ public function getRoundupValue($value)
69
+ {
70
+ $response = $this->_call(self::REQUEST_METHOD_ROUNDUP, array('purchase' => number_format($value, 2, '.', '')));
71
+ $roundup = null;
72
+
73
+ if($response && count($response->roundup)) {
74
+ $roundup = (float) $response->roundup[0];
75
+ }
76
+
77
+ return $roundup;
78
+ }
79
+
80
+ /**
81
+ * Notify give change system of donation
82
+ *
83
+ * @todo Currently we are always setting payment method to OTHER. We need to
84
+ * make this dynamic. Give Change will only accept a specified list of
85
+ * payment types.
86
+ *
87
+ * @param Mage_Sales_Model_Order_Item $item
88
+ * @param Mage_Sales_Model_Order $order
89
+ * @return Varien_Simplexml_Element
90
+ */
91
+ public function notify(Mage_Sales_Model_Order_Item $item, Mage_Sales_Model_Order $order)
92
+ {
93
+ $billingAddress = $order->getBillingAddress();
94
+
95
+ // Init request
96
+ $request = array(
97
+ 'currency' => $this->_format(strtoupper(Mage::app()->getStore()->getCurrentCurrencyCode()), '', 3),
98
+ 'donation' => number_format($item->getRowTotal(), 2, '.', ''),
99
+ 'paymethod' => self::PAYMENT_METHOD_OTHER,
100
+ //'paymethod' => $this->_format(strtoupper($order->getPayment()->getMethodInstance()->getCode())),
101
+ 'txamount' => number_format($order->getGrandTotal(), 2, '.', ''),
102
+ 'sugdonation' => number_format($item->getRowTotal(), 2, '.', ''),
103
+ 'forename' => $this->_format($billingAddress->getFirstname()),
104
+ 'surname' => $this->_format($billingAddress->getLastname()),
105
+ 'email' => $this->_format($billingAddress->getEmail()),
106
+ 'landline' => $this->_format($billingAddress->getTelephone()),
107
+ 'charity_id' => self::CHARITY_ID_DEFAULT,
108
+ 'giftaid' => self::GIFT_AID_NO
109
+ );
110
+
111
+ $quote = $order->getQuote();
112
+
113
+ // Load quote
114
+ if(!$quote) {
115
+
116
+ $quote = Mage::getModel('sales/quote')
117
+ ->setSharedStoreIds(array($order->getStoreId()))
118
+ ->load($order->getQuoteId());
119
+ }
120
+
121
+ // Get options used when buying quote item
122
+ $options = Mage::helper('givechange')->getDonationItemBuyOptions($quote);
123
+
124
+ // Add Gift Aid specific data
125
+ if($options->getGiftaid()) {
126
+
127
+ $request['giftaid'] = self::GIFT_AID_YES;
128
+ $request['house_no'] = $this->_format($billingAddress->getStreet(1));
129
+ $request['address1'] = $this->_format($billingAddress->getStreet(2));
130
+ $request['town'] = $this->_format($billingAddress->getCity());
131
+ $request['county'] = $this->_format($billingAddress->getRegion(), $billingAddress->getCity());
132
+ $request['postcode'] = $this->_format($billingAddress->getPostcode());
133
+ $request['country'] = $this->_format($billingAddress->getCountry());
134
+ }
135
+
136
+ $response = $this->_call(self::REQUEST_METHOD_NOTIFICATION, (array) $request);
137
+
138
+ // Need to add actual repsonse code
139
+ if(!$response || (int) $response->responsecode !== self::RESPONSE_CODE_SUCCESS) {
140
+
141
+ // Log response data
142
+ if($response instanceof Varien_Simplexml_Element) {
143
+
144
+ // Log in file
145
+ $this->_log('+++ GIVE CHANGE API ERROR +++');
146
+ $this->_log(array(
147
+ 'Order number' => (int) $order->getIncrementId(),
148
+ 'Order ID' => (int) $order->getid(),
149
+ 'Response code' => (int) $response->responsecode,
150
+ 'Response message' => (string) $response->responsetext
151
+ ), true);
152
+ $this->_log('++++++');
153
+ }
154
+
155
+ // Throw exception
156
+ Mage::throwException(
157
+ Mage::helper('givechange')->__('An error occurred in the Give Change system. Please try again.')
158
+ );
159
+ }
160
+
161
+ return true;
162
+ }
163
+
164
+ /**
165
+ * Call API
166
+ *
167
+ * @param string $method
168
+ * @param array $params
169
+ * @return Varien_Simplexml_Element
170
+ */
171
+ protected function _call($method, Array $params = array())
172
+ {
173
+ // Set up request parameters
174
+ $params = $this->_beforeCall($params);
175
+ $params['request'] = $method;
176
+
177
+ $response = false;
178
+
179
+ try {
180
+
181
+ $this->_log('+++ GIVE CHANGE API REQUEST +++');
182
+ $this->_log($params);
183
+ $this->_log('++++++');
184
+
185
+ // Do request
186
+ $client = new Varien_Http_Client();
187
+ $client->setUri($this->_getApiUrl())
188
+ ->setConfig(array('timeout' => 300))
189
+ ->setParameterPost($params)
190
+ ->setMethod(Zend_Http_Client::POST);
191
+
192
+ // Process response
193
+ $response = $client->request();
194
+ $response = $this->_afterCall($response);
195
+
196
+ $this->_log('+++ GIVE CHANGE API RESPONSE +++');
197
+ $this->_log($response);
198
+ $this->_log('++++++');
199
+ }
200
+ catch(Exception $e) {
201
+
202
+ $this->_log('+++ GIVE CHANGE API ERROR +++');
203
+ $this->_log(array('Message' => $e->getMessage()), true);
204
+ $this->_log('++++++');
205
+ }
206
+
207
+ return $response;
208
+ }
209
+ }
app/code/community/GCMC/GiveChange/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Setup model
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
25
+ {
26
+
27
+ }
app/code/community/GCMC/GiveChange/Model/Observer.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Observer
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Model_Observer
25
+ {
26
+ /**
27
+ * Get API instance
28
+ *
29
+ * @return GCMC_GiveChange_Model_Api_Abstract
30
+ */
31
+ protected function _getApi()
32
+ {
33
+ return Mage::helper('givechange')->getApi();
34
+ }
35
+
36
+ /**
37
+ * Send donation to Give Change system
38
+ *
39
+ * @param Varien_Event_Observer $observer
40
+ * @return GCMC_GiveChange_Model_Sales_Observer
41
+ */
42
+ public function sendDonation(Varien_Event_Observer $observer)
43
+ {
44
+ $order = $observer->getEvent()->getOrder();
45
+
46
+ if(Mage::helper('givechange')->useGiveChange() && !$order->getData('givechange_exported')) {
47
+
48
+ $donationItem = false;
49
+
50
+ // Get donation items that have been paid for
51
+ foreach($order->getAllItems() as $item) {
52
+
53
+ if($item->getProductType() == GCMC_GiveChange_Model_Product_Type_Donation::TYPE_CODE) {
54
+
55
+ $invoiceItemCollection = Mage::getResourceModel('sales/order_invoice_item_collection')
56
+ ->addFieldToFilter('order_item_id', $item->getId());
57
+
58
+ foreach($invoiceItemCollection as $invoiceItem) {
59
+
60
+ $invoice = Mage::getModel('sales/order_invoice')
61
+ ->load($invoiceItem->getParentId());
62
+
63
+ // Check, if this order item has been paid
64
+ if($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID) {
65
+
66
+ $donationItem = $item;
67
+ break;
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ // Perform donation
74
+ if($donationItem){
75
+
76
+ try {
77
+
78
+ $this->_getApi()->notify($donationItem, $order);
79
+
80
+ $order->setData('givechange_exported', 1)
81
+ ->save();
82
+ }
83
+ // We are failing silently here as the API
84
+ // is logging faults. We could add extra
85
+ // error handling here if desired
86
+ catch(Exception $e) {}
87
+ }
88
+ }
89
+
90
+ return $this;
91
+ }
92
+ }
app/code/community/GCMC/GiveChange/Model/Product/Type/Donation.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Donation product type model
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Model_Product_Type_Donation extends Mage_Catalog_Model_Product_Type_Abstract
25
+ {
26
+ const TYPE_CODE = 'donation';
27
+
28
+ /**
29
+ * Overload cart prepare method
30
+ *
31
+ * @param Varien_Object $buyRequest
32
+ * @param Mage_Catalog_Model_Product $product
33
+ * @return array
34
+ */
35
+ public function prepareForCart(Varien_Object $buyRequest, $product = null)
36
+ {
37
+ if(!$buyRequest->getData('value')) {
38
+ $buyRequest->setData('value', $product->getFinalPrice());
39
+ }
40
+
41
+ return parent::prepareForCart($buyRequest, $product);
42
+ }
43
+
44
+ /**
45
+ * Set default data on product instance
46
+ *
47
+ * @param Mage_Catalog_Model_Product $product
48
+ * @return Mage_Catalog_Model_Product
49
+ */
50
+ public function addDefaultData($product = null)
51
+ {
52
+ $helper = Mage::helper('givechange');
53
+
54
+ // Add default data to product
55
+ $product = $this->getProduct($product)
56
+ ->addData(
57
+ array(
58
+ 'type_id' => self::TYPE_CODE,
59
+ 'status' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED,
60
+ 'visibility' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE,
61
+ 'sku' => $helper->getProductSku(),
62
+ 'name' => $helper->getProductLabel(),
63
+ 'description' => $helper->getProductLabel(),
64
+ 'short_description' => $helper->getProductLabel(),
65
+ 'weight' => $helper->getProductWeight(),
66
+ 'price' => $helper->getProductPrice(),
67
+ 'attribute_set_id' => Mage::getModel('catalog/config')->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default'),
68
+ 'store_id' => Mage::app()->getDefaultStoreView()->getId(),
69
+ 'website_ids' => array(Mage::app()->getDefaultStoreView()->getWebsiteId()),
70
+ 'tax_class_id' => 0,
71
+ 'stock_data' => array(
72
+ 'is_in_stock' => 1,
73
+ 'manage_stock' => 0,
74
+ 'use_config_manage_stock' => 0
75
+ )
76
+ )
77
+ );
78
+
79
+ try {
80
+
81
+ // Add image data to product
82
+ $product->addImageToMediaGallery(Mage::getBaseDir('media').DS.'import'.DS.'givechange.jpg', 'thumbnail');
83
+ $product->addImageToMediaGallery(Mage::getBaseDir('media').DS.'import'.DS.'givechange.jpg', 'image');
84
+ $product->addImageToMediaGallery(Mage::getBaseDir('media').DS.'import'.DS.'givechange.jpg', 'small_image');
85
+ }
86
+ catch(Exception $e) {}
87
+
88
+ return $product;
89
+ }
90
+
91
+ /**
92
+ * Check is virtual product
93
+ *
94
+ * @param Mage_Catalog_Model_Product $product
95
+ * @return bool
96
+ */
97
+ public function isVirtual($product = null)
98
+ {
99
+ return true;
100
+ }
101
+ }
app/code/community/GCMC/GiveChange/Model/Product/Type/Donation/Price.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Donation product type price model
20
+ *
21
+ * @category GCMC
22
+ * @package GCMC_GiveChange
23
+ */
24
+ class GCMC_GiveChange_Model_Product_Type_Donation_Price extends Mage_Catalog_Model_Product_Type_Price
25
+ {
26
+ /**
27
+ * Get product final price
28
+ *
29
+ * @param double $qty
30
+ * @param Mage_Catalog_Model_Product $product
31
+ * @return double
32
+ */
33
+ public function getFinalPrice($qty = null, $product)
34
+ {
35
+ if(is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
36
+ return $product->getCalculatedFinalPrice();
37
+ }
38
+
39
+ $value = $product->getDonationValue();
40
+
41
+ // Get donation value from buy options. This creates a dependency
42
+ // on the quote item which isn't good as a quote item should contain
43
+ // a product, a a product shouldn't contain a quote item. A more elegant
44
+ // solution is required here at some point.
45
+ if(!$value) {
46
+ $value = Mage::helper('givechange')->getDonationItemBuyOptions()->getData('value');
47
+ }
48
+
49
+ // Get roundup value
50
+ if(!$value) {
51
+ $value = $this->_getRoundupValue();
52
+ }
53
+
54
+ $product->setDonationValue($value)
55
+ ->setFinalPrice($value);
56
+
57
+ return $product->getData('final_price');
58
+ }
59
+
60
+ /**
61
+ * Get roundup value
62
+ *
63
+ * @return int
64
+ */
65
+ protected function _getRoundupValue()
66
+ {
67
+ return Mage::helper('givechange')->getRoundupValue();
68
+ }
69
+ }
app/code/community/GCMC/GiveChange/controllers/CartController.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChange extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ require_once 'Mage/Checkout/controllers/CartController.php';
19
+
20
+ /**
21
+ * Index controller
22
+ *
23
+ * @category GCMC
24
+ * @package GCMC_GiveChange
25
+ */
26
+ class GCMC_GiveChange_CartController extends Mage_Checkout_CartController
27
+ {
28
+ /**
29
+ * Load discount product instance
30
+ *
31
+ * @return Mage_Catalog_Model_Product
32
+ */
33
+ protected function _loadProduct()
34
+ {
35
+ $product = Mage::getModel('catalog/product');
36
+ $id = $product->getIdBySku(Mage::helper('givechange')->getProductSku());
37
+
38
+ if($id) {
39
+
40
+ $product->setStoreId(Mage::app()->getStore()->getId())
41
+ ->load($id);
42
+
43
+ if($product->getId()) {
44
+ return $product;
45
+ }
46
+ }
47
+
48
+ return $this->_createProduct();
49
+ }
50
+
51
+ /**
52
+ * Create default donation product. This will
53
+ * happen the first time someone adds a Give Change
54
+ * donation. Ideally we would want to do this in
55
+ * a resource setup file however the store and website
56
+ * instances aren't initialized then. This means that
57
+ * the entity attributes will not save correctly
58
+ *
59
+ * @todo Move this logic to install process
60
+ * @return Mage_Catalog_Model_Product
61
+ */
62
+ protected function _createProduct()
63
+ {
64
+ // Create default product
65
+ $product = Mage::getModel('catalog/product');
66
+
67
+ // Add default product data
68
+ Mage::getSingleton('givechange/product_type_donation')
69
+ ->addDefaultData($product);
70
+
71
+ // Save product
72
+ $product->save()
73
+ ->load();
74
+
75
+ return $product;
76
+ }
77
+
78
+ /**
79
+ * Add discount product action
80
+ *
81
+ * @return void
82
+ */
83
+ public function addAction()
84
+ {
85
+ try {
86
+
87
+ $cart = $this->_getCart();
88
+ $quote = $cart->getQuote();
89
+
90
+ // Remove existing cart discount items
91
+ foreach($quote->getAllVisibleItems() as $item) {
92
+
93
+ if($item->getProductType() == GCMC_GiveChange_Model_Product_Type_Donation::TYPE_CODE) {
94
+
95
+ $cart->removeItem($item->getId());
96
+ $quote->removeItem($item->getId());
97
+ }
98
+ }
99
+
100
+ // Recollect the totals after deleting any items
101
+ $quote->collectTotals();
102
+
103
+ $product = $this->_loadProduct();
104
+
105
+ if(!$product) {
106
+
107
+ $this->_getSession()->addError($this->__('Cannot add the Give Change donation to your shopping cart.'));
108
+ $this->_goBack();
109
+ return;
110
+ }
111
+
112
+ // Set donation value only if custom selected
113
+ if($this->getRequest()->getParam('roundup', null) == GCMC_GiveChange_Helper_Data::DONATION_TYPE_CUSTOM) {
114
+ $product->setDonationValue($this->getRequest()->getParam('custom', null));
115
+ }
116
+
117
+ $params = array(
118
+ 'qty' => 1,
119
+ 'giftaid' => $this->getRequest()->getParam('giftaid', false),
120
+ 'roundup' => $this->getRequest()->getParam('roundup', GCMC_GiveChange_Helper_Data::DONATION_TYPE_CUSTOM),
121
+ 'value' => $product->getDonationValue()
122
+ );
123
+
124
+ $cart->addProduct($product, $params);
125
+ $cart->save();
126
+
127
+ $this->_getSession()->setCartWasUpdated(true);
128
+
129
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
130
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
131
+ );
132
+
133
+ if(!$cart->getQuote()->getHasError()){
134
+
135
+ $this->_getSession()->addSuccess(
136
+ $this->__('%s was added to your shopping cart.', Mage::helper('givechange')->htmlEscape($product->getName()))
137
+ );
138
+ }
139
+
140
+ $this->_goBack();
141
+ }
142
+ catch (Mage_Core_Exception $e) {
143
+
144
+ if ($this->_getSession()->getUseNotice(true)) {
145
+ $this->_getSession()->addNotice($e->getMessage());
146
+ }
147
+ else {
148
+
149
+ $messages = array_unique(explode("\n", $e->getMessage()));
150
+
151
+ foreach ($messages as $message) {
152
+ $this->_getSession()->addError($message);
153
+ }
154
+ }
155
+
156
+ $this->_goBack();
157
+ }
158
+ catch(Exception $e) {
159
+
160
+ $this->_getSession()->addException($e, $this->__('Cannot add the Give Change donation to your shopping cart.'));
161
+ $this->_goBack();
162
+ }
163
+ }
164
+ }
app/code/community/GCMC/GiveChange/etc/adminhtml.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * GCMC GiveChange extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ *
14
+ * @category GCMC
15
+ * @package GCMC_GiveChange
16
+ * @license http://opensource.oGCMCrg/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <givechange translate="title">
29
+ <title>Give Change</title>
30
+ <sort_order>1000</sort_order>
31
+ </givechange>
32
+ </children>
33
+ </config>
34
+ </children>
35
+ </system>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </config>
app/code/community/GCMC/GiveChange/etc/config.xml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * GCMC GiveChange extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ *
14
+ * @category GCMC
15
+ * @package GCMC_GiveChange
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <GCMC_GiveChange>
22
+ <version>0.0.1</version>
23
+ </GCMC_GiveChange>
24
+ </modules>
25
+ <global>
26
+ <models>
27
+ <givechange>
28
+ <class>GCMC_GiveChange_Model</class>
29
+ <resourceModel>givechange_mysql4</resourceModel>
30
+ </givechange>
31
+ <givechange_mysql4>
32
+ <class>GCMC_GiveChange_Model_Mysql4</class>
33
+ </givechange_mysql4>
34
+ </models>
35
+ <resources>
36
+ <givechange_setup>
37
+ <setup>
38
+ <module>GCMC_GiveChange</module>
39
+ <class>GCMC_GiveChange_Model_Mysql4_Setup</class>
40
+ <connection>
41
+ <use>core_setup</use>
42
+ </connection>
43
+ </setup>
44
+ </givechange_setup>
45
+ <givechange_write>
46
+ <connection>
47
+ <use>core_write</use>
48
+ </connection>
49
+ </givechange_write>
50
+ <givechange_read>
51
+ <connection>
52
+ <use>core_read</use>
53
+ </connection>
54
+ </givechange_read>
55
+ </resources>
56
+ <helpers>
57
+ <givechange>
58
+ <class>GCMC_GiveChange_Helper</class>
59
+ </givechange>
60
+ </helpers>
61
+ <blocks>
62
+ <givechange>
63
+ <class>GCMC_GiveChange_Block</class>
64
+ </givechange>
65
+ </blocks>
66
+ <catalog>
67
+ <product>
68
+ <type>
69
+ <donation translate="label" module="givechange">
70
+ <label>Donation Product</label>
71
+ <model>givechange/product_type_donation</model>
72
+ <price_model>givechange/product_type_donation_price</price_model>
73
+ <composite>0</composite>
74
+ <index_priority>40</index_priority>
75
+ </donation>
76
+ </type>
77
+ </product>
78
+ </catalog>
79
+ <events>
80
+ <sales_order_save_after>
81
+ <observers>
82
+ <givechange_sales_observer>
83
+ <type>singleton</type>
84
+ <class>GCMC_GiveChange_Model_Observer</class>
85
+ <method>sendDonation</method>
86
+ </givechange_sales_observer>
87
+ </observers>
88
+ </sales_order_save_after>
89
+ </events>
90
+ <template>
91
+ <email>
92
+ <givechange_email_logs_template translate="label" module="givechange">
93
+ <label>Give Change Log</label>
94
+ <file>givechange_log.html</file>
95
+ <type>html</type>
96
+ </givechange_email_logs_template>
97
+ </email>
98
+ </template>
99
+ </global>
100
+ <frontend>
101
+ <routers>
102
+ <givechange>
103
+ <use>standard</use>
104
+ <args>
105
+ <module>GCMC_GiveChange</module>
106
+ <frontName>givechange</frontName>
107
+ </args>
108
+ </givechange>
109
+ </routers>
110
+ <layout>
111
+ <updates>
112
+ <givechange>
113
+ <file>givechange.xml</file>
114
+ </givechange>
115
+ </updates>
116
+ </layout>
117
+ <translate>
118
+ <modules>
119
+ <GCMC_GiveChange>
120
+ <files>
121
+ <default>GCMC_GiveChange.csv</default>
122
+ </files>
123
+ </GCMC_GiveChange>
124
+ </modules>
125
+ </translate>
126
+ </frontend>
127
+ <adminhtml>
128
+ <translate>
129
+ <modules>
130
+ <GCMC_GiveChange>
131
+ <files>
132
+ <default>GCMC_GiveChange.csv</default>
133
+ </files>
134
+ </GCMC_GiveChange>
135
+ </modules>
136
+ </translate>
137
+ </adminhtml>
138
+ <default>
139
+ <givechange>
140
+ <settings>
141
+ <is_enabled>0</is_enabled>
142
+ <is_test>1</is_test>
143
+ <test_url>https://rsm5.rsmsecure.com/demo/gcmc/submit.php</test_url>
144
+ <live_url>https://rsm5.rsmsecure.com/demo/gcmc/submit.php</live_url>
145
+ <merchant_urn>Magento</merchant_urn>
146
+ <use_roundup>1</use_roundup>
147
+ <allow_custom>1</allow_custom>
148
+ <!--<gift_aid>1</gift_aid>-->
149
+ <sku>GIVECHANGE</sku>
150
+ <label>Give Change Donation</label>
151
+ <price>0.00</price>
152
+ <weight>0.00</weight>
153
+ </settings>
154
+ <email_logs>
155
+ <enabled>1</enabled>
156
+ <template>givechange_email_logs_template</template>
157
+ <identity>owner</identity>
158
+ </email_logs>
159
+ </givechange>
160
+ </default>
161
+ </config>
app/code/community/GCMC/GiveChange/etc/system.xml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * GCMC GiveChange extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ *
14
+ * @category GCMC
15
+ * @package GCMC_GiveChange
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
21
+ <givechange translate="label" module="givechange">
22
+ <label>Give Change</label>
23
+ <tab>sales</tab>
24
+ <sort_order>1000</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <groups>
29
+ <settings translate="label" module="givechange">
30
+ <label>Settings</label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>200</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <fields>
37
+ <is_enabled translate="label" module="givechange">
38
+ <label>Enabled</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </is_enabled>
46
+ <merchant_id translate="label" module="givechange">
47
+ <label>Merchant ID</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>20</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </merchant_id>
54
+ <merchant_urn translate="label" module="givechange">
55
+ <label>Merchant URN</label>
56
+ <comment>A key which identifies transactions with Magento.</comment>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>30</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </merchant_urn>
63
+ <is_test translate="label" module="givechange">
64
+ <label>Test Mode</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>adminhtml/system_config_source_yesno</source_model>
67
+ <sort_order>40</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </is_test>
72
+ <test_url translate="label" module="givechange">
73
+ <label>Test URL</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>50</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </test_url>
80
+ <live_url translate="label" module="givechange">
81
+ <label>Live URL</label>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>60</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </live_url>
88
+ <use_roundup translate="label" module="givechange">
89
+ <label>Use Round-Up</label>
90
+ <comment>Gets round up donation amount from Give Change.</comment>
91
+ <frontend_type>select</frontend_type>
92
+ <source_model>adminhtml/system_config_source_yesno</source_model>
93
+ <sort_order>70</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </use_roundup>
98
+ <allow_custom translate="label comment" module="givechange">
99
+ <label>Allow Custom Donations</label>
100
+ <comment>Enables the free text donation field.</comment>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>adminhtml/system_config_source_yesno</source_model>
103
+ <sort_order>80</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </allow_custom>
108
+ <!--<gift_aid translate="label" module="givechange">
109
+ <label>Allow Gift Aid</label>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>adminhtml/system_config_source_yesno</source_model>
112
+ <sort_order>90</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </gift_aid>-->
117
+ </fields>
118
+ </settings>
119
+ <email_logs translate="label" module="givechange">
120
+ <label>Email Logs</label>
121
+ <frontend_type>text</frontend_type>
122
+ <sort_order>300</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ <fields>
127
+ <enabled translate="label" module="givechange">
128
+ <label>Enabled</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_yesno</source_model>
131
+ <sort_order>10</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ </enabled>
136
+ <recipient translate="label" module="givechange">
137
+ <label>Recipient Email</label>
138
+ <frontend_type>text</frontend_type>
139
+ <sort_order>20</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ </recipient>
144
+ <identity translate="label">
145
+ <label>Email Sender</label>
146
+ <frontend_type>select</frontend_type>
147
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
148
+ <sort_order>30</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </identity>
153
+ <template translate="label">
154
+ <label>Email Template</label>
155
+ <frontend_type>select</frontend_type>
156
+ <source_model>adminhtml/system_config_source_email_template</source_model>
157
+ <sort_order>40</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>1</show_in_store>
161
+ </template>
162
+ </fields>
163
+ </email_logs>
164
+ </groups>
165
+ </givechange>
166
+ </sections>
167
+ </config>
app/code/community/GCMC/GiveChange/sql/givechange_setup/mysql4-install-0.0.0.1.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChnage extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ $installer = $this;
19
+ $installer->startSetup();
20
+ $installer->endSetup();
app/code/community/GCMC/GiveChange/sql/givechange_setup/mysql4-upgrade-0.0.0.1-0.0.0.2.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC GiveChnage extension
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
+ *
12
+ *
13
+ * @category GCMC
14
+ * @package GCMC_GiveChange
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ $installer = $this;
19
+ $installer->startSetup();
20
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'givechange_exported', 'int(1) default 0');
21
+ $installer->endSetup();
app/design/frontend/base/default/layout/givechange.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * GCMC GiveChange extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ *
14
+ * @category design_base
15
+ * @package GCMC_GiveChange
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <layout>
20
+
21
+ <checkout_cart_index>
22
+ <reference name="head">
23
+ <action method="addJs"><script>givechange/givechange.js</script></action>
24
+ <action method="addJs"><script>givechange/modalbox.js</script></action>
25
+ <action method="addCss"><stylesheet>css/givechange.css</stylesheet></action>
26
+ </reference>
27
+ <reference name="checkout.cart.form.before">
28
+ <block type="givechange/info" name="givechange.info" as="givechange_info" template="givechange/info.phtml"/>
29
+ </reference>
30
+ </checkout_cart_index>
31
+
32
+ </layout>
app/design/frontend/base/default/template/givechange/info.phtml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GCMC SagePay extension
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
+ *
12
+ *
13
+ * @category design_base
14
+ * @package GCMC_SagePay
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ ?>
18
+
19
+ <?php
20
+ $charities = $this->getCharities();
21
+ $item = $this->getDonationItem();
22
+ ?>
23
+
24
+ <div id="givechange">
25
+ <form name="donation" action="<?php echo $this->getAddUrl() ?>" method="post" id="givechange-form">
26
+ <div class="left" id="givechange-logo">
27
+
28
+ <img src="<?php echo $this->getSkinUrl('images/givechange/givechange.gif') ?>" alt="Give Change Make Change" />
29
+ </div>
30
+ <div class="right" id="givechange-form">
31
+ <p>
32
+ <input type="radio" name="roundup" id="roundup" value="<?php echo $this->getDonationTypeCode('roundup') ?>"<?php echo ($this->isRoundup() ? 'checked="checked"' : '') ?> />
33
+ <label for="roundup"><?php echo $this->__('I would like to round up my purchase to %s%s donating %s%s to charity', $this->getCurrencySymbol(), $this->getTotalPlusRoundup(), $this->getCurrencySymbol(), $this->getRoundupValue()) ?></label>
34
+ </p>
35
+
36
+ <?php if($this->allowCustomDonations()): ?>
37
+
38
+ <p><strong>OR</strong></p>
39
+ <p>
40
+ <input type="radio" name="roundup" id="ownvalue" value="<?php echo $this->getDonationTypeCode('custom') ?>"<?php echo ($this->isCustom() ? 'checked="checked"' : '') ?> />
41
+ <label for="ownvalue"><?php echo $this->__('I would like to add my own amount to give to charity %s', $this->getCurrencySymbol()) ?></label>
42
+ <input type="text" name="custom" id="custom" value="<?php echo $this->isCustom() ? $this->getDonationValue() : '' ?>" />
43
+ </p>
44
+
45
+ <?php endif; ?>
46
+
47
+ </div>
48
+ <div class="bottom">
49
+ <?php if(count($charities)): ?>
50
+
51
+ <ul id="givechange-charities" class="left">
52
+ <?php foreach($this->getCharities() as $charity): ?>
53
+ <li class="item">
54
+
55
+ <a onclick="Modalbox.show($('givechange-<?php echo $charity->getCharityId() ?>'), {title:'&nbsp;', width: 600}); return false;" title="" href="#">
56
+ <img src="<?php echo $charity->getImage() ?>" alt="<?php echo $charity->getName() ?>" />
57
+ </a>
58
+
59
+ <div id="givechange-<?php echo $charity->getCharityId() ?>" class="givechange-charity-info" style="display: none">
60
+
61
+
62
+ <img src="<?php echo $charity->getImage() ?>" alt="<?php echo $charity->getName() ?>" />
63
+ <p><?php echo $charity->getText() ?></p>
64
+
65
+ </div>
66
+
67
+ </li>
68
+ <?php endforeach ?>
69
+ </ul>
70
+
71
+ <?php endif; ?>
72
+ <a onclick="Modalbox.show($('givechange-info'), {title: '&nbsp;', width: 600}); return false;" title="" href="#" class="left" id="givechange-how">How does it work?</a>
73
+ <?php if($item): ?>
74
+ <button type="submit" title="<?php echo $this->__('Update donation') ?>" class="button btn-checkout" id="donation-btn"><span><span><?php echo $this->__('Update donation') ?></span></span></button>
75
+ <?php else: ?>
76
+ <button type="submit" title="<?php echo $this->__('Add donation') ?>" class="button btn-checkout" id="donation-btn"><span><span><?php echo $this->__('Add donation') ?></span></span></button>
77
+ <?php endif; ?>
78
+ </div>
79
+ </form>
80
+
81
+ <div id="givechange-info" style="display: none">
82
+
83
+ <div id="givechange-logo-modal"><img src="<?php echo $this->getSkinUrl('images/givechange/givechange.gif') ?>" alt="Give Change Make Change" /></div>
84
+
85
+ <p><?php echo $this->__('Give Change Make Change is a fundraising initiative by four of the UK&rsquo;s best known charities - British Red Cross, Great Ormond Street Hospital Childrens Charity, WWF and Cancer Research UK.') ?></p>
86
+ <p><?php echo $this->__('By clicking the button you can round-up your purchase to the nearest &pound;1 e.g. if it&rsquo;s &pound118.80 you can round-up &pound;0.20 to £119. Alternatively you can select your own amount to donate.') ?></p>
87
+ <p><?php echo $this->__('All donations are divided equally between the charities with a transaction charge coverd by them of 0.85p(less that 1p) fo each donation, so rest assured your small change will add up to make big change to these fantastic causes.') ?></p>
88
+ <p><?php echo $this->__('Thank you!') ?></p>
89
+
90
+ <ul id="givechange-charities-modal">
91
+ <?php foreach($this->getCharities() as $charity): ?>
92
+ <li class="item">
93
+
94
+ <a onclick="Modalbox.show($('givechange-<?php echo $charity->getCharityId() ?>'), {title: this.title, width: 600}); return false;" title="" href="#">
95
+ <img src="<?php echo $charity->getImage() ?>" alt="<?php echo $charity->getName() ?>" />
96
+ </a>
97
+
98
+ <div id="givechange-<?php echo $charity->getCharityId() ?>" class="givechange-charity-info" style="display: none">
99
+
100
+ <h2><?php echo $charity->getName() ?></h2>
101
+
102
+ <img src="<?php echo $charity->getImage() ?>" alt="<?php echo $charity->getName() ?>" />
103
+ <p><?php echo $charity->getText() ?></p>
104
+
105
+ </div>
106
+
107
+ </li>
108
+ <?php endforeach ?>
109
+ </ul>
110
+ <p id="smallprint"><?php echo $this->__('The British Red Cross Society(Reg. Charity No.220949), Cancer Research UK (Reg. Charity No. in England &amp; Wales (1089464) and in Scotland (SC041666), Great Ormond Street Hospital Chlidren&rsquo;s Charity (Reg. Charity No. 235825) and WWF-UK (Reg. Charity No. in England &amp; Wales(4016725) and in Scotland(SC039593))') ?></p>
111
+ </div>
112
+
113
+ </div>
114
+
115
+
116
+ <script type="text/javascript">
117
+ //<![CDATA[
118
+
119
+ var givechange = new GiveChange(
120
+ '#roundup',
121
+ '#ownvalue',
122
+ '#custom',
123
+ '#donation-btn',
124
+ '<?php echo $this->getDonationValue() ?>',
125
+ '<?php echo $this->getRoundupValue() ?>'
126
+ );
127
+ //]]>
128
+ </script>
app/etc/modules/GCMC_GiveChange.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * GCMC GiveChange extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ *
14
+ * @category design_base
15
+ * @package GCMC_GiveChange
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <GCMC_GiveChange>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ </GCMC_GiveChange>
25
+ </modules>
26
+ </config>
app/locale/en_US/GCMC_GiveChange.csv ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Give Change","Give Change"
2
+ "Settings","Settings"
3
+ "Enabled","Enabled"
4
+ "Merchant ID","Merchant ID"
5
+ "Merchant URN","Merchant URN"
6
+ "Test Mode","Test Mode"
7
+ "Test URL","Test URL"
8
+ "Live URL","Live URL"
9
+ "Use Round-Up","Use Round-Up"
10
+ "Allow Custom Donations","Allow Custom Donations"
11
+ "Enables the free text donation field.","Enables the free text donation field."
12
+ "Allow Gift Aid","Allow Gift Aid"
13
+ "Email Logs","Email Logs"
14
+ "Recipient Email","Recipient Email"
15
+ "Email Sender","Email Sender"
16
+ "Email Template","Email Template"
17
+ "Give Change Donation","Give Change Donation"
18
+ "Cannot add the Give Change donation to your shopping cart.","Cannot add the Give Change donation to your shopping cart."
19
+ "%s was added to your shopping cart.","%s was added to your shopping cart."
20
+ "An error occurred in the Give Change system. Please try again.","An error occurred in the Give Change system. Please try again."
21
+ "Update your donation to Give Change","Update your donation to Give Change"
22
+ "Add your donation to Give Change","Add your donation to Give Change"
23
+ "Round up your cart total","Round up your cart total"
24
+ "Enter your own amount","Enter your own amount"
25
+ "If you are a UK taxpayer, the value of your donation to the 4 Give Change charities can increase by 25% under the Gift Aid scheme at no additional cost to you!","If you are a UK taxpayer, the value of your donation to the 4 Give Change charities can increase by 25% under the Gift Aid scheme at no additional cost to you!"
26
+ "I am a UK taxpayer. Please treat my donation as a","I am a UK taxpayer. Please treat my donation as a"
27
+ "Gift Aid","Gift Aid"
28
+ "donation.","donation."
29
+ "Update donation","Update donation"
30
+ "Add donation","Add donation"
31
+ "Gift Aid Information","Gift Aid Information"
32
+ "If you are a UK taxpayer, please tick the Gift Aid box and make your donation worth much more! As long as you pay an amount of UK income and/or capital gains tax for each tax year (6th April one year to 5th April the next) that is at least equal to the value of the basic rate tax that we will claim on your donation made in that tax year, you can Gift Aid your donation.","If you are a UK taxpayer, please tick the Gift Aid box and make your donation worth much more! As long as you pay an amount of UK income and/or capital gains tax for each tax year (6th April one year to 5th April the next) that is at least equal to the value of the basic rate tax that we will claim on your donation made in that tax year, you can Gift Aid your donation."
33
+ "For every £1 you donate, Gift Aid will allow Cancer Research UK, WWF, British Red Cross and Great Ormond Street Hospital Children\'s Charity to claim 25p from HM Revenue &amp; Customs - increasing the value of your gift at no additional cost to you. Please note that your donation and the Gift Aid claimed on it will be split equally between these charities.","For every £1 you donate, Gift Aid will allow Cancer Research UK, WWF, British Red Cross and Great Ormond Street Hospital Children\'s Charity to claim 25p from HM Revenue &amp; Customs - increasing the value of your gift at no additional cost to you. Please note that your donation and the Gift Aid claimed on it will be split equally between these charities."
34
+ "Most people pay some form of income and/or capital gains tax on their income, pension savings or investments.","Most people pay some form of income and/or capital gains tax on their income, pension savings or investments."
35
+ "If you are unsure whether you can Gift Aid your donations please contact your local tax office.","If you are unsure whether you can Gift Aid your donations please contact your local tax office."
36
+ "I would like to round up my purchase to %s%s donating %s%s to charity","I would like to round up my purchase to %s%s donating %s%s to charity"
37
+ "OR","OR"
38
+ "I would like to add my own amount to give to charity %s","I would like to add my own amount to give to charity %s"
39
+ "Give Change Make Change is a fundraising initiative by four of the UK&rsquo;s best known charities - British Red Cross, Great Ormond Street Hospital Childrens Charity, WWF and Cancer Research UK.","Give Change Make Change is a fundraising initiative by four of the UK&rsquo;s best known charities - British Red Cross, Great Ormond Street Hospital Childrens Charity, WWF and Cancer Research UK."
40
+ "By clicking the button you can round-up your purchase to the nearest &pound;1 e.g. if it&rsquo;s &pound118.80 you can round-up &pound;0.20 to £119. Alternatively you can select your own amount to donate.","By clicking the button you can round-up your purchase to the nearest &pound;1 e.g. if it&rsquo;s &pound118.80 you can round-up &pound;0.20 to £119. Alternatively you can select your own amount to donate."
41
+ "All donations are divided equally between the charities with a transaction charge coverd by them of 0.85p(less that 1p) fo each donation, so rest assured your small change will add up to make big change to these fantastic causes.","All donations are divided equally between the charities with a transaction charge coverd by them of 0.85p(less that 1p) fo each donation, so rest assured your small change will add up to make big change to these fantastic causes."
42
+ "Thank you!","Thank you!"
43
+ "The British Red Cross Society(Reg. Charity No.220949), Cancer Research UK (Reg. Charity No. in England &amp; Wales (1089464) and in Scotland (SC041666), Great Ormond Street Hospital Chlidren&rsquo;s Charity (Reg. Charity No. 235825) and WWF-UK (Reg. Charity No. in England &amp; Wales(4016725) and in Scotland(SC039593))","The British Red Cross Society(Reg. Charity No.220949), Cancer Research UK (Reg. Charity No. in England &amp; Wales (1089464) and in Scotland (SC041666), Great Ormond Street Hospital Chlidren&rsquo;s Charity (Reg. Charity No. 235825) and WWF-UK (Reg. Charity No. in England &amp; Wales(4016725) and in Scotland(SC039593))"
app/locale/en_US/template/email/givechange_log.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Give Change donation failure @-->
2
+ <!--@vars
3
+ {"var error":"Error"}
4
+ @-->
5
+
6
+ <p>An order has failed to send the donation value to the Give Change system. This means that Give Change have not received an indication of a donation in which the payment has been already been taken for.</p>
7
+
8
+ <p>We recommend that you process this order manually in the Give Change system using the details below.</p>
9
+
10
+ <p>{{var error}}</p>
js/givechange/givechange.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * GCMC GiveChange extension
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ *
12
+ * @category GCMC
13
+ * @package GCMC_GiveChange
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ GiveChange = Class.create();
18
+ GiveChange.prototype = {
19
+
20
+ initialize: function(roundup, custom, input, button, donationValue, roundupValue){
21
+ this.roundup = $$(roundup)[0];
22
+ this.custom = $$(custom)[0];
23
+ this.input = $$(input)[0];
24
+ this.button = $$(button)[0];
25
+ this.donationValue = donationValue;
26
+ this.roundupValue = roundupValue;
27
+ if(this.input) {
28
+ Event.observe(this.input, 'focus', this.toggleRoundup.bindAsEventListener(this));
29
+ Event.observe(this.input, 'focus', this.updateForm.bindAsEventListener(this));
30
+ Event.observe(this.input, 'blur', this.updateForm.bindAsEventListener(this));
31
+ this.updateForm();
32
+ }
33
+ if(this.roundup) {
34
+ Event.observe(this.roundup, 'click', this.updateForm.bindAsEventListener(this));
35
+ }
36
+ if(this.custom) {
37
+ Event.observe(this.custom, 'click', this.updateForm.bindAsEventListener(this));
38
+ }
39
+ },
40
+
41
+ disableForm: function(){
42
+ if(this.button) {
43
+ this.button.disabled = 'disabled';
44
+ this.button.addClassName('disabled');
45
+ }
46
+ },
47
+
48
+ enableForm: function(){
49
+ if(this.button) {
50
+ this.button.disabled = null;
51
+ this.button.removeClassName('disabled');
52
+ }
53
+ },
54
+
55
+ updateForm: function(event){
56
+ if(this.roundup && this.roundup.checked) {
57
+ this.enableForm();
58
+ return;
59
+ }
60
+ if(this.custom && this.custom.checked && this.input && this.input.value > 0) {
61
+ this.enableForm();
62
+ return;
63
+ }
64
+ this.disableForm();
65
+ },
66
+
67
+ toggleRoundup: function(event){
68
+ var element = Event.findElement(event, 'input');
69
+ if(this.roundup && this.roundup.checked) {
70
+ this.roundup.checked = null;
71
+ this.custom.checked = 'checked';
72
+ }
73
+ }
74
+ }
js/givechange/modalbox.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // ModalBox - The pop-up window thingie with AJAX, based on Prototype JS framework.
3
+ //
4
+ // Created by Andrew Okonetchnikov
5
+ // Copyright 2006-2010 okonet.ru. All rights reserved.
6
+ //
7
+ // Licensed under MIT license.
8
+ //
9
+
10
+ if(Object.isUndefined(Prototype.Browser.IE6)){Prototype.Browser.IE6=(navigator.appName.indexOf("Microsoft Internet Explorer")!=-1&&navigator.appVersion.indexOf("MSIE 6.0")!=-1&&!window.XMLHttpRequest);}
11
+ if(!window.Modalbox)
12
+ var Modalbox={};Modalbox.Methods={overrideAlert:false,focusableElements:[],currFocused:0,initialized:false,active:true,options:{title:"ModalBox Window",overlayClose:true,width:500,height:90,overlayOpacity:0.65,overlayDuration:0.25,slideDownDuration:0.5,slideUpDuration:0.5,resizeDuration:0.25,inactiveFade:true,transitions:true,loadingString:"Please wait. Loading...",closeString:"Close window",closeValue:"×",params:{},method:'get',autoFocusing:true,aspnet:false,resizeCSSID:''},_options:{},setOptions:function(options){Object.extend(this.options,options||{});},_init:function(options){Object.extend(this._options,this.options);this.setOptions(options);this.MBoverlay=new Element("div",{id:"MB_overlay",style:"opacity: 0"});this.MBwindowwrapper=new Element("div",{id:"MB_windowwrapper"}).update(this.MBwindow=new Element("div",{id:"MB_window",style:"display: none"}).update(this.MBframe=new Element("div",{id:"MB_frame"}).update(this.MBheader=new Element("div",{id:"MB_header"}).update(this.MBcaption=new Element("div",{id:"MB_caption"})))));this.MBclose=new Element("a",{id:"MB_close",title:this.options.closeString,href:"#"}).update("<span>"+this.options.closeValue+"</span>");this.MBheader.insert({'bottom':this.MBclose});this.MBcontent=new Element("div",{id:"MB_content"}).update(this.MBloading=new Element("div",{id:"MB_loading"}).update(this.options.loadingString));this.MBframe.insert({'bottom':this.MBcontent});var injectToEl=this.options.aspnet?$(document.body).down('form'):$(document.body);injectToEl.insert({'top':this.MBwindowwrapper});injectToEl.insert({'top':this.MBoverlay});var scrollOffsets=document.viewport.getScrollOffsets();if(scrollOffsets[1]>0){$('MB_window').setStyle({top:scrollOffsets[1]+'px'});}
13
+ Event.observe(window,'scroll',function(){scrollOffsets=document.viewport.getScrollOffsets();$('MB_window').setStyle({top:scrollOffsets[1]+'px'});});this.initScrollX=window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft;this.initScrollY=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;this.hideObserver=this._hide.bindAsEventListener(this);this.kbdObserver=this._kbdHandler.bindAsEventListener(this);this.resizeObserver=this._setWidthAndPosition.bindAsEventListener(this);this._initObservers();this.initialized=true;},show:function(content,options){if(!this.initialized)this._init(options);this._cleanUpContentIDs();this.content=content;this.setOptions(options);if(this.options.title){this.MBcaption.update(this.options.title);}else{this.MBheader.hide();this.MBcaption.hide();}
14
+ if(this.MBwindow.style.display=="none"){this._appear();this.event("onShow");}else{this._update();this.event("onUpdate");}},hide:function(options){if(this.initialized){if(options&&!Object.isFunction(options.element))
15
+ Object.extend(this.options,options);this.event("beforeHide");if(this.options.transitions){Effect.SlideUp(this.MBwindow,{duration:this.options.slideUpDuration,transition:Effect.Transitions.sinoidal,afterFinish:this._deinit.bind(this)});}else{this.MBwindow.hide();this._deinit();}
16
+ Event.stopObserving(window,'scroll');}else{throw("Modalbox is not initialized.");}},_hide:function(event){event.stop();if(event.element().id=='MB_overlay'&&!this.options.overlayClose)return false;this.hide();},alert:function(message){var html='<div class="MB_alert"><p>'+message+'</p><input type="button" onclick="Modalbox.hide()" value="OK" /></div>';Modalbox.show(html,{title:'Alert: '+document.title,width:300});},_appear:function(){if(Prototype.Browser.IE6){window.scrollTo(0,0);this._prepareIEHtml("100%","hidden");this._prepareIESelects("hidden");}
17
+ this._setWidth();if(this.options.transitions){this.MBoverlay.setOpacity(0);new Effect.Fade(this.MBoverlay,{from:0,to:this.options.overlayOpacity,duration:this.options.overlayDuration,afterFinish:(function(){new Effect.SlideDown(this.MBwindow,{duration:this.options.slideDownDuration,transition:Effect.Transitions.sinoidal,afterFinish:this.loadContent.bind(this)});}).bind(this)});}else{this.MBoverlay.setOpacity(this.options.overlayOpacity);this.MBwindow.show();this.loadContent();}
18
+ Event.observe(window,"resize",this.resizeObserver);},resize:function(byWidth,byHeight,options){var oWidth=$(this.MBoverlay).getWidth();var wHeight=$(this.MBwindow).getHeight();var wWidth=$(this.MBwindow).getWidth();var hHeight=$(this.MBheader).getHeight();var cHeight=$(this.MBcontent).getHeight();var newHeight=((wHeight-hHeight+byHeight)<cHeight)?(cHeight+hHeight):(wHeight+byHeight);var el=$(this.MBwindow);var contentEl=$(this.MBcontent);var windowBottomMargin=10;newHeight+=windowBottomMargin;var windowOffset=(parseInt(el.getStyle('margin-top'),0)+parseInt(el.getStyle('margin-bottom'),0)+parseInt(el.getStyle('border-top-width'),0)+parseInt(el.getStyle('border-bottom-width'),0))+windowBottomMargin;var contentPadding=(parseInt(contentEl.getStyle('padding-top'))+parseInt(contentEl.getStyle('padding-bottom')));if((newHeight+windowOffset+contentPadding)>document.viewport.getHeight()){newHeight=document.viewport.getHeight()-windowOffset-windowBottomMargin;newcHeight=newHeight-hHeight-parseInt($(this.MBframe).getStyle('padding-bottom'),0)-parseInt($(this.MBcontent).getStyle('padding-bottom'),0);$(this.MBcontent).setStyle({height:newcHeight+'px'});}else if($(this.MBcontent).getStyle('height')){$(this.MBcontent).setStyle({height:''});}
19
+ var newWidth=wWidth+byWidth;var newStyle={width:newWidth+"px",height:newHeight+"px"};this.options.width=newWidth;if(options)this.setOptions(options);if(this.options.transitions&&!Modalbox.animating){Modalbox.animating=true;new Effect.Morph(this.MBwindow,{style:newStyle,duration:this.options.resizeDuration,beforeStart:function(fx){fx.element.setStyle({overflow:"hidden"});},afterFinish:(function(fx){fx.element.setStyle({overflow:"visible"});this.event("_afterResize");this.event("afterResize");Modalbox.animating=false;}).bind(this)});}else{this.MBwindow.setStyle(newStyle);(function(){this.event("_afterResize");this.event("afterResize");}).bind(this).defer();}},resizeToContent:function(options){if(typeof options=="undefined"){options={};}
20
+ var mbimages=$('MB_content').select('img');var totalimages=mbimages.length;if(mbimages[0]){if(typeof options.imagesloaded=="undefined"){var loadedImages=$A();var loadedImageTotal=0;mbimages.each(function(o,idx){loadedImages[idx]=new Image();loadedImages[idx].src=o.src;loadedImages[idx].onload=function(){loadedImageTotal++;if(loadedImageTotal==totalimages){var imageincomplete=false;mbimages.each(function(i){if(i.height==0){imageincomplete=true;}});if(imageincomplete||Modalbox.animating){Modalbox.resizeToContent();}else{options.imagesloaded=true;Modalbox.resizeToContent(options);}}}})}}
21
+ var byWidth=0,byHeight=this.options.height-this.MBwindow.getHeight();if(options.resizeCSSID&&$(options.resizeCSSID)){byWidth=$(options.resizeCSSID).getWidth()-$(this.MBwindow).getWidth()+(parseInt($(this.MBcontent).getStyle('padding-left'),0)+parseInt($(this.MBcontent).getStyle('padding-right'),0))+15;}
22
+ if(byHeight!=0){this.resize(byWidth,byHeight,options);}},resizeToInclude:function(element,options){var el=$(element);var elHeight=el.getHeight()+parseInt(el.getStyle('margin-top'),0)+parseInt(el.getStyle('margin-bottom'),0)+parseInt(el.getStyle('border-top-width'),0)+parseInt(el.getStyle('border-bottom-width'),0);if(elHeight>0){this.resize(0,elHeight,options);}},_update:function(){this.MBcontent.update($(this.MBloading).update(this.options.loadingString));this.loadContent();},loadContent:function(){if(this.event("beforeLoad")!=false){if(typeof this.content=='string'){var htmlRegExp=new RegExp(/<\/?[^>]+>/gi);if(htmlRegExp.test(this.content)){this._processContent(this.content);}else{new Ajax.Request(this.content,{method:this.options.method.toLowerCase(),parameters:this.options.params,onComplete:(function(response){this._processContent(response.responseText);}).bind(this),onException:function(instance,exception){Modalbox.hide();throw('Modalbox Loading Error: '+exception);}});}}else if(typeof this.content=='object'){this._insertContent(this.content);}else{this.hide();throw('Modalbox Parameters Error: Please specify correct URL or HTML element (plain HTML or object)');}}},_processContent:function(content){var html=content.stripScripts(),scripts=content.extractScripts();this._insertContent(html,function(){scripts.map(function(script){return eval(script.replace("<!--","").replace("// -->",""));},window);});},_insertContent:function(content,callback){this.MBcontent.hide().update();if(typeof content=='string'){this.MBcontent.insert(new Element("div",{style:"display: none"}).update(content)).down().show();}else if(typeof content=='object'){var _htmlObj=content.cloneNode(true);if(content.id)content.id="MB_"+content.id;$(content).select('*[id]').each(function(el){el.id="MB_"+el.id;});this.MBcontent.insert(_htmlObj).down('div').show();if(Prototype.Browser.IE6){this._prepareIESelects("","#MB_content ");}}
23
+ if(this.options.height==this._options.height){this.resize((this.options.width-$(this.MBwindow).getWidth()),this.MBcontent.getHeight()-$(this.MBwindow).getHeight()+this.MBheader.getHeight(),{afterResize:(function(){this._putContent.bind(this,callback).defer();}).bind(this)});}else{this._setWidth();this.MBcontent.setStyle({overflow:'auto',height:this.MBwindow.getHeight()-this.MBheader.getHeight()-13+'px'});this._putContent.bind(this,callback).defer();}},_putContent:function(callback){this.MBcontent.show();this._findFocusableElements();this._setFocus();if(Object.isFunction(callback))
24
+ callback();this.event("afterLoad");},activate:function(options){this.setOptions(options);this.active=true;if(this.options.overlayClose)
25
+ this.MBoverlay.observe("click",this.hideObserver);this.MBclose.observe("click",this.hideObserver).show();if(this.options.transitions&&this.options.inactiveFade)
26
+ new Effect.Appear(this.MBwindow,{duration:this.options.slideUpDuration});},deactivate:function(options){this.setOptions(options);this.active=false;if(this.options.overlayClose)
27
+ this.MBoverlay.stopObserving("click",this.hideObserver);this.MBclose.stopObserving("click",this.hideObserver).hide();if(this.options.transitions&&this.options.inactiveFade)
28
+ new Effect.Fade(this.MBwindow,{duration:this.options.slideUpDuration,to:0.75});},_initObservers:function(){this.MBclose.observe("click",this.hideObserver);if(this.options.overlayClose)
29
+ this.MBoverlay.observe("click",this.hideObserver);var kbdEvent=(Prototype.Browser.Gecko||Prototype.Browser.Opera)?"keypress":"keydown";Event.observe(document,kbdEvent,this.kbdObserver);},_removeObservers:function(){this.MBclose.stopObserving("click",this.hideObserver);if(this.options.overlayClose)
30
+ this.MBoverlay.stopObserving("click",this.hideObserver);var kbdEvent=(Prototype.Browser.Gecko||Prototype.Browser.Opera)?"keypress":"keydown";Event.stopObserving(document,kbdEvent,this.kbdObserver);},_setFocus:function(){if(this.focusableElements.length>0&&this.options.autoFocusing==true){var firstEl=this.focusableElements.find(function(el){return el.tabIndex==1;})||this.focusableElements.first();this.currFocused=this.focusableElements.toArray().indexOf(firstEl);firstEl.focus();}else if(this.MBclose.visible()){this.MBclose.focus();}},_findFocusableElements:function(){if(this.options.autoFocusing===true){this.MBcontent.select('input:not([type=hidden]):enabled, select, textarea, button, a[href]').invoke('addClassName','MB_focusable');this.focusableElements=this.MBcontent.select('.MB_focusable');}},_kbdHandler:function(event){var node=event.element();switch(event.keyCode){case Event.KEY_TAB:event.stop();if(node!=this.focusableElements[this.currFocused])
31
+ this.currFocused=this.focusableElements.indexOf(node);if(!event.shiftKey){if(this.currFocused>=this.focusableElements.length-1){this.currFocused=0;}else{this.currFocused++;}}else{if(this.currFocused<=0){this.currFocused=this.focusableElements.length-1;}else{this.currFocused--;}}
32
+ this.focusableElements[this.currFocused].focus();break;case Event.KEY_ESC:if(this.active)this._hide(event);break;case 32:this._preventScroll(event);break;case 0:if(event.which==32)this._preventScroll(event);break;case Event.KEY_UP:case Event.KEY_DOWN:case Event.KEY_PAGEDOWN:case Event.KEY_PAGEUP:case Event.KEY_HOME:case Event.KEY_END:var tagName=node.tagName.toLowerCase();if(Prototype.Browser.WebKit&&!["textarea","select"].include(tagName)){event.stop();}else if((tagName=="input"&&["submit","button"].include(node.type))||(tagName=="a")){event.stop();}
33
+ break;}},_preventScroll:function(event){if(!["input","textarea","select","button"].include(event.element().tagName.toLowerCase()))
34
+ event.stop();},_deinit:function(){this._removeObservers();Event.stopObserving(window,"resize",this.resizeObserver);if(this.options.transitions){Effect.toggle(this.MBoverlay,'appear',{duration:this.options.overlayDuration,afterFinish:this._removeElements.bind(this)});}else{this.MBoverlay.hide();this._removeElements();}
35
+ this.MBcontent.setStyle({overflow:'',height:''});},_cleanUpContentIDs:function(){if(typeof this.content=='object'){if(this.content.id&&this.content.id.match(/MB_/)){this.content.id=this.content.id.replace(/MB_/,"");}
36
+ this.content.select('*[id]').each(function(el){el.id=el.id.replace(/MB_/,"");});}},_removeElements:function(){if(Prototype.Browser.Opera){window.scrollBy(0,0);}
37
+ this.MBoverlay.remove();$(this.MBwindowwrapper).remove();if(Prototype.Browser.IE6){this._prepareIEHtml("","");this._prepareIESelects("");window.scrollTo(this.initScrollX,this.initScrollY);}
38
+ this._cleanUpContentIDs();this.initialized=false;this.event("afterHide");this.setOptions(this._options);},_setWidth:function(){this.MBwindow.setStyle({width:this.options.width+"px",height:this.options.height+"px"});},_setWidthAndPosition:function(){this.MBwindow.setStyle({width:this.options.width+"px"});},_prepareIEHtml:function(height,overflow){$$('html, body').invoke('setStyle',{width:height,height:height,overflow:overflow});},_prepareIESelects:function(visibility,prefix){$$((prefix||"")+"select").invoke('setStyle',{'visibility':visibility});},event:function(eventName){var r=true;if(this.options[eventName]){var returnValue=this.options[eventName]();this.options[eventName]=null;if(!Object.isUndefined(returnValue))
39
+ r=returnValue;}
40
+ return r;}};Object.extend(Modalbox,Modalbox.Methods);if(Modalbox.overrideAlert)window.alert=Modalbox.alert;
media/import/givechange.jpg ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>GCMC_GiveChange</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/OSL-3.0">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Give Change Make Change is a virtual collection tin for retailers to enable their shoppers to round-up purchases and make donations to charity.</summary>
10
+ <description>Give Change Make Change is a virtual collection tin for retailers to enable their shoppers to round-up purchases and make donations to four of the UK's best loved and trusted charities, British Red Cross, Great Ormond Street Hospital Children's Charity, WWF</description>
11
+ <notes>Initial Release</notes>
12
+ <authors><author><name>Give Change Make Change</name><user>auto-converted</user><email>denise.bailey@cancer.org.uk</email></author></authors>
13
+ <date>2012-02-22</date>
14
+ <time>14:41:33</time>
15
+ <contents><target name="magecommunity"><dir name="GCMC"><dir name="GiveChange"><dir name="Block"><file name="Info.php" hash="4eb78a8dd0fbed78e3ce2ba109b4bac8"/></dir><dir name="Helper"><file name="Data.php" hash="64a667a0a70f91a57e0c7f6836286b1e"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="053a9499a0ed6349d11a72cb630972cb"/><file name="Log.php" hash="ea6cf67840d73bd298b54f7e65f5cc8d"/><file name="Standard.php" hash="5d802accfac8d570cd40b0a81007117e"/></dir><dir name="Mysql4"><file name="Setup.php" hash="d515c8772ba89be88cadac32284d0f13"/></dir><dir name="Product"><dir name="Type"><dir name="Donation"><file name="Price.php" hash="63dcc13d8cc56260cc765b6b0c81a550"/></dir><file name="Donation.php" hash="95dcd39beeb269229cf12fb4f1e64a72"/></dir></dir><file name="Observer.php" hash="6dcb51330ad32e10dc581e5e5b4fdb14"/></dir><dir name="controllers"><file name="CartController.php" hash="704f40f9488adf27a7aa5721cafe4bf7"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3eb86df273aa317da1bb0cb9dc1e9dff"/><file name="config.xml" hash="9f23aa53f62b9a186a4c2b8932ac0df2"/><file name="system.xml" hash="699881b328d31d2f8c34e8594e76d93b"/></dir><dir name="sql"><dir name="givechange_setup"><file name="mysql4-install-0.0.0.1.php" hash="0b2a8b5725dca16a724c22248b7beeb1"/><file name="mysql4-upgrade-0.0.0.1-0.0.0.2.php" hash="82b863dab8496e8aae00095fb3cd37ab"/></dir></dir><file name="LICENSE.txt" hash="929c804472775b581f633bbe67e5a70a"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GCMC_GiveChange.xml" hash="d3d8935a395f18294d566bc044ff0959"/></dir></target><target name="magemedia"><dir name="import"><file name="givechange.jpg" hash="05f9b3d6d20df1aeb034913c45de81ee"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="givechange_log.html" hash="cb2848caf85ca252277e903ef26f8a00"/></dir></dir><file name="GCMC_GiveChange.csv" hash="aedc33620d98976c88526ed52dd65c52"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="givechange.css" hash="6e6e290d1f72f389292400317097cdb4"/></dir><dir name="images"><dir name="givechange"><file name="close-button.gif" hash="47c6c4dd5bd72d18f7450117e3fe6a54"/><file name="givechange.gif" hash="85148bdb3c7f4e074b308b213912d157"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="givechange"><file name="givechange.js" hash="e0f0d932fe29ddfcdc07024e97c15083"/><file name="modalbox.js" hash="9d66fc6ab1d92b5b45669235c1e1b23f"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="givechange.xml" hash="f2f1846ed14f76f029609a75c0ddf126"/></dir><dir name="template"><dir name="givechange"><file name="info.phtml" hash="3124e37908df3b7ac10802e43f030fcd"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/frontend/base/default/css/givechange.css ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** GIVE CHANGE **/
2
+
3
+ #givechange {
4
+ background:#fefbfd;
5
+ border: 2px solid #DC6809;
6
+ margin-bottom: 10px;
7
+ clear: both;
8
+ padding:15px 70px 15px 70px;
9
+ }
10
+
11
+ #givechange #givechange-logo{
12
+ width:160px;
13
+ }
14
+
15
+ #givechange #givechange-form{
16
+ width:550px;
17
+ }
18
+
19
+ #givechange-how{
20
+ margin:10px 20px;
21
+ color:#DC6809;
22
+ }
23
+
24
+ #givechange .bottom{
25
+ clear:both;
26
+ overflow:hidden;
27
+ }
28
+
29
+ #givechange label{
30
+ font-weight:bold;
31
+ }
32
+
33
+ #givechange-charities{
34
+ background:#fff;
35
+ overflow:hidden;
36
+ border:solid 1px #e8e4e5;
37
+ display: block;
38
+ width:425px;
39
+ float:left;
40
+ padding:5px;
41
+ }
42
+
43
+ #givechange-charities li.item,
44
+ #givechange-charities-modal li.item{
45
+ border-right: 1px dotted #d0cbc0;
46
+ padding: 0px 5px;
47
+ float: left;
48
+ }
49
+
50
+ #givechange-charities li.item:last-child,
51
+ #givechange-chariites-modal li.item:last-child{
52
+ border:0;
53
+ padding-right: 0;
54
+ }
55
+
56
+ #givechange-charities li.item img,
57
+ #givechange-charities-modal li.item img{
58
+ height:40px;
59
+ }
60
+
61
+ #givechange-logo-modal{
62
+ margin:0 0 20px 0;
63
+ }
64
+
65
+ #givechange-charities-modal{
66
+ overflow:hidden;
67
+ padding:5px;
68
+ margin:10px 0 10px 0;
69
+ }
70
+
71
+
72
+
73
+ p#smallprint{
74
+ font-weight:bold;
75
+ display: block;
76
+ clear:both;
77
+ font-size:11px;
78
+ }
79
+
80
+
81
+ /** MODAL BOX **/
82
+
83
+ #MB_overlay {
84
+ position: absolute;
85
+ margin: auto;
86
+ top: 0; left: 0;
87
+ width: 100%; height: 100%;
88
+ z-index: 9999;
89
+ border: 0;
90
+ background-color: #000!important;
91
+ }
92
+ #MB_overlay[id] { position: fixed; }
93
+ #MB_windowwrapper {
94
+ position:absolute;
95
+ /*top:0;*/
96
+ top:25%;
97
+ width:100%;
98
+ z-index:10000;
99
+ }
100
+ #MB_window {
101
+ position:relative;
102
+ margin-left:auto;
103
+ margin-right:auto;
104
+ top:0;
105
+ left:0;
106
+ border: 0 solid;
107
+ text-align: left;
108
+ z-index: 10000;
109
+ border:solid 2px #DC6809;
110
+ }
111
+ #MB_window[id] { position: relative; }
112
+ #MB_frame {
113
+ position: relative;
114
+ height: 100%;
115
+ }
116
+ #MB_header {
117
+ margin: 0;
118
+ padding: 0;
119
+ }
120
+ #MB_content {
121
+ position: relative;
122
+ padding: 0 20px 20px 20px;
123
+ overflow: auto;
124
+ }
125
+ #MB_caption {
126
+ font: bold 100% "Lucida Grande", Arial, sans-serif;
127
+ text-shadow: #FFF 0 1px 0;
128
+ padding: .5em 2em .5em .75em;
129
+ margin: 0;
130
+ text-align: left;
131
+ }
132
+ #MB_close {
133
+ display: block;
134
+ position: absolute;
135
+ right: 5px; top: 4px;
136
+ padding: 2px 3px;
137
+ font-weight: bold;
138
+ text-decoration: none;
139
+ font-size: 13px;
140
+ color: #777;
141
+ background: url(../images/givechange/close-button.gif) top left no-repeat;
142
+ width:62px;
143
+ height:26px;
144
+ text-indent:-9999px;
145
+
146
+ }
147
+
148
+ #MB_loading {
149
+ padding: 1.5em;
150
+ text-indent: -10000px;
151
+ background: transparent url(spinner.gif) 50% 0 no-repeat;
152
+ }
153
+ #MB_window {
154
+ background-color: #fff;
155
+ color: #000;
156
+ -webkit-box-shadow: 0 0 64px #000;
157
+ -moz-box-shadow: #000 0 0 64px;
158
+ box-shadow: 0 0 64px #000;
159
+ }
160
+ #MB_frame {
161
+ -webkit-border-bottom-left-radius: 4px;
162
+ -webkit-border-bottom-right-radius: 4px;
163
+ -moz-border-radius-bottomleft: 4px;
164
+ -moz-border-radius-bottomright: 4px;
165
+
166
+ }
167
+
168
+ #MB_content p{
169
+ margin:10px 0 10px 0;
170
+ }
171
+
172
+ .MB_alert {
173
+ margin: 10px 0;
174
+ text-align: center;
175
+ }
skin/frontend/base/default/images/givechange/close-button.gif ADDED
Binary file
skin/frontend/base/default/images/givechange/givechange.gif ADDED
Binary file