abcv_pay - Version 1.0.0

Version Notes

Prepare for publish

Download this release

Release Info

Developer ABCV Company
Extension abcv_pay
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (105) hide show
  1. app/code/local/Abcv/AbcPay/Model/AbcPay/Source/PaymentAction.php +42 -0
  2. app/code/local/Abcv/AbcPay/Model/PaymentMethod.php +516 -0
  3. app/code/local/Abcv/AbcPay/etc/config.xml +76 -0
  4. app/code/local/Abcv/AbcPay/etc/system.xml +123 -0
  5. app/code/local/Abcv/AbcPay/keys/childKeyQA1 +1 -0
  6. app/code/local/Abcv/AbcPay/keys/parentKeyQA1 +1 -0
  7. app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny.php +14 -0
  8. app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit.php +32 -0
  9. app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit/Form.php +19 -0
  10. app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit/Tab/Form.php +88 -0
  11. app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit/Tabs.php +22 -0
  12. app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Grid.php +122 -0
  13. app/code/local/Abcv/Bigfunny/Helper/Data.php +4 -0
  14. app/code/local/Abcv/Bigfunny/Model/Bigfunny.php +8 -0
  15. app/code/local/Abcv/Bigfunny/controllers/Adminhtml/BigfunnyController.php +130 -0
  16. app/code/local/Abcv/Bigfunny/etc/adminhtml.xml +36 -0
  17. app/code/local/Abcv/Bigfunny/etc/config.xml +82 -0
  18. app/code/local/Abcv/Catalog/Model/Price/Observer.php +99 -0
  19. app/code/local/Abcv/Catalog/etc/config.xml +21 -0
  20. app/code/local/Abcv/Custom/Block/Adminhtml/Custom/Order.php +7 -0
  21. app/code/local/Abcv/Custom/Block/Custom/Order.php +11 -0
  22. app/code/local/Abcv/Custom/Helper/Data.php +6 -0
  23. app/code/local/Abcv/Custom/Model/Custom/Order.php +14 -0
  24. app/code/local/Abcv/Custom/Model/Custom/Quote.php +14 -0
  25. app/code/local/Abcv/Custom/Model/Mysql4/Custom/Order.php +27 -0
  26. app/code/local/Abcv/Custom/Model/Mysql4/Custom/Order/Collection.php +10 -0
  27. app/code/local/Abcv/Custom/Model/Mysql4/Custom/Quote.php +27 -0
  28. app/code/local/Abcv/Custom/Model/Mysql4/Custom/Quote/Collection.php +10 -0
  29. app/code/local/Abcv/Custom/Model/Observer.php +61 -0
  30. app/code/local/Abcv/Custom/Model/Sales/Order.php +16 -0
  31. app/code/local/Abcv/Custom/controllers/IndexController.php +47 -0
  32. app/code/local/Abcv/Custom/etc/config.xml +147 -0
  33. app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions.php +14 -0
  34. app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit.php +32 -0
  35. app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit/Form.php +19 -0
  36. app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit/Tab/Form.php +88 -0
  37. app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit/Tabs.php +22 -0
  38. app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Grid.php +122 -0
  39. app/code/local/Abcv/Dimensions/Helper/Data.php +4 -0
  40. app/code/local/Abcv/Dimensions/Model/Dimensions.php +8 -0
  41. app/code/local/Abcv/Dimensions/Model/Mysql4/Dimensions.php +8 -0
  42. app/code/local/Abcv/Dimensions/Model/Mysql4/Dimensions/Collection.php +8 -0
  43. app/code/local/Abcv/Dimensions/controllers/Adminhtml/DimensionsController.php +130 -0
  44. app/code/local/Abcv/Dimensions/etc/adminhtml.xml +41 -0
  45. app/code/local/Abcv/Dimensions/etc/config.xml +82 -0
  46. app/code/local/Abcv/Editor/Block/Adminhtml/Customdyotab.php +26 -0
  47. app/code/local/Abcv/Editor/Block/Adminhtml/Dyotab.php +26 -0
  48. app/code/local/Abcv/Editor/Block/Adminhtml/Editor.php +12 -0
  49. app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit.php +45 -0
  50. app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit/Form.php +19 -0
  51. app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit/Tab/Form.php +58 -0
  52. app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit/Tabs.php +24 -0
  53. app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Grid.php +116 -0
  54. app/code/local/Abcv/Editor/Block/Cart/Item/Renderer.php +14 -0
  55. app/code/local/Abcv/Editor/Block/Choosetemplate.php +17 -0
  56. app/code/local/Abcv/Editor/Block/Editor.php +88 -0
  57. app/code/local/Abcv/Editor/Block/Product.php +117 -0
  58. app/code/local/Abcv/Editor/Helper/Data.php +137 -0
  59. app/code/local/Abcv/Editor/Model/Editor.php +10 -0
  60. app/code/local/Abcv/Editor/Model/Mysql4/Editor.php +10 -0
  61. app/code/local/Abcv/Editor/Model/Mysql4/Editor/Collection.php +10 -0
  62. app/code/local/Abcv/Editor/Model/Mysql4/Product.php +10 -0
  63. app/code/local/Abcv/Editor/Model/Mysql4/Product/Collection.php +10 -0
  64. app/code/local/Abcv/Editor/Model/Observer.php +431 -0
  65. app/code/local/Abcv/Editor/Model/Product.php +10 -0
  66. app/code/local/Abcv/Editor/Model/Quote/Item.php +55 -0
  67. app/code/local/Abcv/Editor/Model/Status.php +15 -0
  68. app/code/local/Abcv/Editor/controllers/Adminhtml/AjaxController.php +46 -0
  69. app/code/local/Abcv/Editor/controllers/Adminhtml/AjaxController_2014.06.04.php +46 -0
  70. app/code/local/Abcv/Editor/controllers/Adminhtml/CategoryController.php +125 -0
  71. app/code/local/Abcv/Editor/controllers/Adminhtml/CategoryController_2014.06.04.php +125 -0
  72. app/code/local/Abcv/Editor/controllers/Adminhtml/EditorController.php +250 -0
  73. app/code/local/Abcv/Editor/controllers/Adminhtml/EditorController_2014.06.04.php +250 -0
  74. app/code/local/Abcv/Editor/controllers/AjaxLoginController.php +430 -0
  75. app/code/local/Abcv/Editor/controllers/IndexController.php +510 -0
  76. app/code/local/Abcv/Editor/controllers/ProductController.php +195 -0
  77. app/code/local/Abcv/Editor/controllers/ProductDialogController.php +190 -0
  78. app/code/local/Abcv/Editor/etc/adminhtml.xml +49 -0
  79. app/code/local/Abcv/Editor/etc/config.xml +275 -0
  80. app/code/local/Abcv/Editor/etc/config.xml.bak +181 -0
  81. app/code/local/Abcv/Editor/etc/config.xml_03.06.2015 +286 -0
  82. app/code/local/Abcv/Editor/etc/config_12.15.2014.xml +286 -0
  83. app/code/local/Abcv/Editor/etc/system.xml +216 -0
  84. app/code/local/Abcv/Editor/sql/editor_setup/mysql4-install-0.1.0.php +49 -0
  85. app/code/local/Abcv/ManageCustomer/Block/Adminhtml/Customer/Savedtemplatetab.php +83 -0
  86. app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/AjaxsavedtemplateController.php +94 -0
  87. app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/html/_paging.php +54 -0
  88. app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/html/_pattern.php +113 -0
  89. app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/html/_table.php +46 -0
  90. app/code/local/Abcv/ManageCustomer/etc/adminhtml.xml +16 -0
  91. app/code/local/Abcv/ManageCustomer/etc/config.xml +34 -0
  92. app/code/local/Abcv/Managecustom/Block/Adminhtml/Custom.php +12 -0
  93. app/code/local/Abcv/Managecustom/Block/Adminhtml/Custom/Grid.php +72 -0
  94. app/code/local/Abcv/Managecustom/Helper/Data.php +4 -0
  95. app/code/local/Abcv/Managecustom/Model/Custom.php +8 -0
  96. app/code/local/Abcv/Managecustom/Model/Mysql4/Custom.php +8 -0
  97. app/code/local/Abcv/Managecustom/Model/Mysql4/Custom/Collection.php +8 -0
  98. app/code/local/Abcv/Managecustom/controllers/Adminhtml/CustomController.php +38 -0
  99. app/code/local/Abcv/Managecustom/etc/adminhtml.xml +35 -0
  100. app/code/local/Abcv/Managecustom/etc/config.xml +81 -0
  101. app/code/local/Abcv/Tabcustom/Helper/Data.php +4 -0
  102. app/code/local/Abcv/Tabcustom/etc/config.xml +49 -0
  103. app/code/local/Abcv/Tabcustom/etc/system.xml +85 -0
  104. app/etc/modules/Abcv_AbcPay.xml +16 -0
  105. package.xml +25 -0
app/code/local/Abcv/AbcPay/Model/AbcPay/Source/PaymentAction.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Mage
16
+ * @package Mage_Paygate
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ *
23
+ * AbcPay Payment Action Dropdown source
24
+ *
25
+ * @author Magento Core Team <core@magentocommerce.com>
26
+ */
27
+ class Abcv_AbcPay_Model_AbcPay_Source_PaymentAction
28
+ {
29
+ public function toOptionArray()
30
+ {
31
+ return array(
32
+ array(
33
+ 'value' => Mage_Linkpoint_Model_Linkpoint::ACTION_AUTHORIZE,
34
+ 'label' => Mage::helper('paygate')->__('Authorize Only')
35
+ ),
36
+ array(
37
+ 'value' => Mage_Linkpoint_Model_Linkpoint::ACTION_AUTHORIZE_CAPTURE,
38
+ 'label' => Mage::helper('paygate')->__('Authorize and Capture')
39
+ ),
40
+ );
41
+ }
42
+ }
app/code/local/Abcv/AbcPay/Model/PaymentMethod.php ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Our test CC module adapter
5
+ */
6
+ /* PAYMENT */
7
+ define('CHILD_KEY_LOCATION', __DIR__.'/../keys/childKeyQA1');
8
+ define('PARENT_KEY_LOCATION',__DIR__.'/../keys/parentKeyQA1');
9
+
10
+
11
+ class Abcv_AbcPay_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
12
+ {
13
+ // const CGI_URL = 'https://staging.linkpt.net:1129/LSGSXML';
14
+
15
+ const REQUEST_METHOD_CC = 'CC';
16
+ const REQUEST_METHOD_ECHECK = 'ECHECK';
17
+
18
+ const REQUEST_TYPE_AUTH_CAPTURE = 'AUTH_CAPTURE';
19
+ const REQUEST_TYPE_AUTH_ONLY = 'AUTH_ONLY';
20
+ const REQUEST_TYPE_CAPTURE_ONLY = 'CAPTURE_ONLY';
21
+ const REQUEST_TYPE_CREDIT = 'CREDIT';
22
+ const REQUEST_TYPE_VOID = 'VOID';
23
+ const REQUEST_TYPE_PRIOR_AUTH_CAPTURE = 'PRIOR_AUTH_CAPTURE';
24
+
25
+ const ECHECK_ACCT_TYPE_CHECKING = 'CHECKING';
26
+ const ECHECK_ACCT_TYPE_BUSINESS = 'BUSINESSCHECKING';
27
+ const ECHECK_ACCT_TYPE_SAVINGS = 'SAVINGS';
28
+
29
+ const ECHECK_TRANS_TYPE_CCD = 'CCD';
30
+ const ECHECK_TRANS_TYPE_PPD = 'PPD';
31
+ const ECHECK_TRANS_TYPE_TEL = 'TEL';
32
+ const ECHECK_TRANS_TYPE_WEB = 'WEB';
33
+
34
+ const RESPONSE_DELIM_CHAR = ',';
35
+
36
+ const RESPONSE_CODE_APPROVED = 1;
37
+ const RESPONSE_CODE_DECLINED = 2;
38
+ const RESPONSE_CODE_ERROR = 3;
39
+ const RESPONSE_CODE_HELD = 4;
40
+
41
+
42
+
43
+ protected $_authorize = '';
44
+
45
+ /**
46
+ * unique internal payment method identifier
47
+ *
48
+ * @var string [a-z0-9_]
49
+ */
50
+ protected $_code = 'AbcPay';
51
+
52
+ /**
53
+ * Here are examples of flags that will determine functionality availability
54
+ * of this module to be used by frontend and backend.
55
+ *
56
+ * @see all flags and their defaults in Mage_Payment_Model_Method_Abstract
57
+ *
58
+ * It is possible to have a custom dynamic logic by overloading
59
+ * public function can* for each flag respectively
60
+ */
61
+
62
+ /**
63
+ * Is this payment method a gateway (online auth/charge) ?
64
+ */
65
+ protected $_isGateway = true;
66
+
67
+ /**
68
+ * Can authorize online?
69
+ */
70
+ protected $_canAuthorize = true;
71
+
72
+ /**
73
+ * Can capture funds online?
74
+ */
75
+ protected $_canCapture = true;
76
+
77
+ /**
78
+ * Can capture partial amounts online?
79
+ */
80
+ protected $_canCapturePartial = false;
81
+
82
+ /**
83
+ * Can refund online?
84
+ */
85
+ protected $_canRefund = true;
86
+
87
+ /**
88
+ * Can void transactions online?
89
+ */
90
+ protected $_canVoid = true;
91
+
92
+ /**
93
+ * Can use this payment method in administration panel?
94
+ */
95
+ protected $_canUseInternal = true;
96
+
97
+ /**
98
+ * Can show this payment method as an option on checkout payment page?
99
+ */
100
+ protected $_canUseCheckout = true;
101
+
102
+ /**
103
+ * Is this payment method suitable for multi-shipping checkout?
104
+ */
105
+ protected $_canUseForMultishipping = true;
106
+
107
+ /**
108
+ * Can save credit card information for future processing?
109
+ */
110
+ protected $_canSaveCc = true;
111
+
112
+ /**
113
+ * Here you will need to implement authorize, capture and void public methods
114
+ *
115
+ * @see examples of transaction specific public methods such as
116
+ * authorize, capture and void in Mage_Paygate_Model_Authorizenet
117
+ */
118
+
119
+
120
+ public function authorize(Varien_Object $payment, $amount){
121
+
122
+
123
+
124
+ }
125
+
126
+ public function capture(Varien_Object $payment, $amount){
127
+
128
+
129
+
130
+ $order = $payment->getOrder();
131
+
132
+
133
+ $billing = $order->getBillingAddress();
134
+
135
+
136
+ $cardNum = $this->encrypt($payment->getCcNumber());
137
+
138
+
139
+ $creditCardLast4Digits = substr($payment->getCcNumber(),strlen($payment->getCcNumber())-4,4);
140
+
141
+ $creditCardInfo = array(
142
+
143
+ 'cardNum' => $cardNum,
144
+ 'creditCardLast4Digits' => $creditCardLast4Digits,
145
+
146
+ 'expYear' => $payment->getCcExpYear(),
147
+ 'expMonth' => $payment->getCcExpMonth(),
148
+ 'cardCodePresent' => 'ValuePresent',
149
+ 'cardCode' => $payment->getCcCid(),
150
+ 'cardholderFirstName' => $billing->getFirstname(),
151
+ 'cardholderLastName' => $billing->getLastname(),
152
+ 'cardHolderCompanyName' => null,
153
+ 'cardHolderFullName' => $billing->getFirstname() . ' ' . $billing->getLastname(),
154
+ 'track1' => null,
155
+ 'track2' => null,
156
+ 'streetAddressLine1' => $billing->getStreet(1),
157
+ 'zip' => $billing->getPostcode(),
158
+ 'ext' => '',
159
+ 'cardType' => 'Visa',
160
+ 'entryMode' => 'Manual',
161
+ 'signature' => null,
162
+ 'cardPresent' => 'NO',
163
+ );
164
+
165
+
166
+ $response = $this->makePayment(
167
+ array(
168
+ "creditCardInfo" => $creditCardInfo,
169
+ 'paymentAccountId' => '0',
170
+ 'amount' => $amount,
171
+ 'action' => 'payment',
172
+
173
+ 'useTestMode' => $this->getConfigData('test') ? 'YES' : 'NO'
174
+
175
+ ), $payment->getOrder()->getEntityId());
176
+
177
+
178
+ if ($response->success){
179
+
180
+ $payment_engine_id = $response->merchantReferenceNumber;
181
+
182
+
183
+
184
+ // create transaction
185
+ if ($payment->getParentTransactionId()) {
186
+ $payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE);
187
+ } else {
188
+ $payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE);
189
+ }
190
+
191
+ $payment->setStatus(self::STATUS_APPROVED);
192
+ $payment->setCcTransId($payment_engine_id);
193
+ $payment->setLastTransId($payment_engine_id);
194
+ if ($payment_engine_id != $payment->getParentTransactionId()) {
195
+ $payment->setTransactionId($payment_engine_id);
196
+ }
197
+ $payment
198
+ ->setIsTransactionClosed(0)
199
+ ->setTransactionAdditionalInfo('real_transaction_id', $payment_engine_id);
200
+ // end create
201
+
202
+ // update last transaction id
203
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
204
+ $write->query("UPDATE sales_flat_order_payment SET last_trans_id ='".$payment_engine_id."' WHERE entity_id =".$payment->getOrder()->getEntityId());
205
+
206
+ // end update
207
+
208
+ $order->addStatusToHistory(
209
+ $order->getStatus(),
210
+ 'Captured amount of $'.$amount.' online at ABC Pay. Trans ID: ' . $payment_engine_id,
211
+ 'Captured amount of $'.$amount.' online from ABC Pay. Trans ID: ' . $payment_engine_id
212
+ );
213
+
214
+ }
215
+ else{
216
+
217
+ $order->addStatusToHistory(
218
+ $order->getStatus(),
219
+ $response->commonResponse->errorDescription.' at ABC Pay',
220
+ $response->commonResponse->errorDescription.' from ABC Pay'
221
+ );
222
+
223
+ Mage::throwException($response->commonResponse->errorDescription);
224
+
225
+
226
+ }
227
+
228
+ return $this;
229
+
230
+ }
231
+ function makePayment($options, $clientRequestNumber){
232
+
233
+ $response = new stdClass();
234
+ $response->success = false;
235
+ $response->commonResponse = new stdClass();
236
+
237
+
238
+ if ($this->url_exists($this->getConfigData('payment_gateway_wsdl_path'))){
239
+
240
+ $payment = array('clientRequestNumber' => $clientRequestNumber,
241
+ 'credentials' => array(
242
+ 'username' => $this->getConfigData('payment_username'),
243
+ 'password' => $this->getConfigData('payment_pass'),
244
+ 'merchantID' => $this->getConfigData('payment_merchant_ide'),
245
+ 'channelID1' => $this->getConfigData('payment_merchant_cha'),
246
+
247
+ 'useTestMode' => $this->getConfigData('test') ? 'YES' : 'NO'
248
+
249
+ ),
250
+ 'creditCard' => $options['creditCardInfo'],
251
+ 'consecutiveCount' => 'ONE',
252
+ 'merchantRequest1' => array(
253
+ 'description' => null,
254
+ 'amount' => round($options['amount'],2)
255
+ )
256
+ );
257
+
258
+ //submit request
259
+ $payment_options = array(
260
+ 'location' => $this->getConfigData('payment_gateway_path')
261
+ );
262
+
263
+
264
+
265
+ $soapClient = new SoapClient($this->getConfigData('payment_gateway_wsdl_path'), $payment_options);
266
+
267
+ try {
268
+
269
+ $response = $soapClient->submitCreditCardPayment($payment);
270
+
271
+ } catch (SoapFault $exception) {
272
+ $response->commonResponse->errorDescription = "Couldn't process the request - Error code: $exception->faultcode";
273
+ }
274
+
275
+
276
+ }else{
277
+ $response->commonResponse->errorDescription = "Couldn't connect to MerchantService.";
278
+ }
279
+
280
+ if (isset($clientRequestNumber) && isset($response)){
281
+ if($response->success == false && isset($response->commonResponse)
282
+ && isset($response->commonResponse)){
283
+ if(isset($response->commonResponse->errorDescription)){
284
+ $response->commonResponse->errorDescription = $response->commonResponse->errorDescription;
285
+ }else if(isset($response->commonResponse->displayMessages)){
286
+ $response->commonResponse->errorDescription = $response->commonResponse->displayMessages;
287
+ }
288
+
289
+ }
290
+ }
291
+
292
+
293
+
294
+ return $response;
295
+ }
296
+
297
+
298
+ public function void(){
299
+
300
+ $file=fopen("text.txt", "a");
301
+ $write=fwrite($file, ' void ');
302
+ fclose($file);
303
+
304
+
305
+ // $payment = array(
306
+ // 'authenticationInfo' => array('clientID' => "Client34349821758574"),
307
+ // 'authorizationInfo' =>
308
+ // array(
309
+ // 'adminUser' => $adminUserForVoidRefund,
310
+ // 'adminPwd' => $adminPwdForVoidRefund),
311
+ // 'transactionDetails' =>
312
+ // array(
313
+ // 'creditCardInfo' =>
314
+ // array(
315
+ // 'cardCodePresent' => 'ValuePresent',
316
+ // 'entryMode' => 'Manual',
317
+ // 'cardPresent' => 'NO'),
318
+ // 'paymentMethod' => 'CC',
319
+ // 'amount' => "9.99",
320
+ // 'requestType' => 'VOID'
321
+ // ),
322
+ // 'requestID' => "ORDER_ID",
323
+ // 'previousTransactionId' => 'paymentEngineId',
324
+ // );
325
+
326
+ // $options = array(
327
+ // 'location' => $this->getConfigData('payment_gateway_path')
328
+ // );
329
+ // $soapClient = new SoapClient($this->getConfigData('payment_gateway_wsdl_path'), $options);
330
+
331
+ // try {
332
+ // $response = $soapClient->submitPayment($payment);
333
+ // $response->clientRequestNumber = $clientRequestNumber;
334
+ // } catch (SoapFault $exception) {
335
+ // //handle exception
336
+ // }
337
+
338
+ }
339
+ public function refund(Varien_Object $payment, $amount){
340
+
341
+
342
+ $order_id = $payment->getOrder()->getEntityId();
343
+
344
+
345
+ if ($payment->getRefundTransactionId() && $amount>0) {
346
+
347
+ $payment_engine_id = '';
348
+
349
+
350
+
351
+ if ($order_id){
352
+
353
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
354
+ $order_payment = $read->fetchAll("SELECT * from sales_flat_order_payment WHERE entity_id =".$order_id);
355
+
356
+ $payment_engine_id = isset($order_payment[0]['last_trans_id']) ? $order_payment[0]['last_trans_id'] : '';
357
+
358
+ }
359
+ $description = isset($_REQUEST['creditmemo']['comment_text']) ? $_REQUEST['creditmemo']['comment_text'] : '';
360
+
361
+
362
+
363
+ $refundRequest = array(
364
+ 'clientRequestNumber' => $payment->getOrder()->getEntityId(),
365
+ 'credentials' =>
366
+ array(
367
+ 'username' => $this->getConfigData('payment_username'),
368
+ 'password' => $this->getConfigData('payment_pass'),
369
+ 'merchantID' => $this->getConfigData('payment_merchant_ide'),
370
+ 'channelID1' => $this->getConfigData('payment_merchant_cha'),
371
+
372
+ 'useTestMode' => $this->getConfigData('test') ? 'YES' : 'NO'
373
+ ),
374
+ 'merchantReferenceNumber' => $payment_engine_id,
375
+ 'consecutiveCount' => 'ONE',
376
+ 'merchantRequest1' =>
377
+ array(
378
+ 'description' => empty($description) ? null : $description,
379
+ 'amount' => round($amount,2)
380
+ )
381
+ );
382
+
383
+ try {
384
+ $options = array(
385
+ 'location' => $this->getConfigData('payment_gateway_path')
386
+ );
387
+ $soapClient = new SoapClient($this->getConfigData('payment_gateway_wsdl_path'), $options);
388
+ $responseRefund = $soapClient->submitCreditCardRefund($refundRequest);
389
+ } catch (SoapFault $exception) {
390
+ //handle exception
391
+
392
+ $responseRefund->success = false;
393
+
394
+
395
+ $order->addStatusToHistory(
396
+ $order->getStatus(),
397
+ $exception->__toString().' at ABC Pay',
398
+ $exception->__toString().' from ABC Pay'
399
+ );
400
+
401
+ Mage::throwException($exception->__toString());
402
+
403
+ }
404
+
405
+
406
+ if ($responseRefund->success){
407
+
408
+ $payment->setStatus(self::STATUS_SUCCESS);
409
+ if ($payment_engine_id != $payment->getParentTransactionId()) {
410
+ $payment->setTransactionId($payment_engine_id);
411
+ }
412
+ $shouldCloseCaptureTransaction = $payment->getOrder()->canCreditmemo() ? 0 : 1;
413
+ $payment
414
+ ->setIsTransactionClosed(1)
415
+ ->setShouldCloseParentTransaction($shouldCloseCaptureTransaction)
416
+ ->setTransactionAdditionalInfo('real_transaction_id', $payment_engine_id);
417
+
418
+ $order->addStatusToHistory(
419
+ $order->getStatus(),
420
+ 'Refunded amount of $'.$amount.' online at ABC Pay. Trans ID: ' . $payment_engine_id,
421
+ 'Refunded amount of $'.$amount.' online from ABC Pay. Trans ID: ' . $payment_engine_id
422
+ );
423
+
424
+ }
425
+ else {
426
+
427
+ $order->addStatusToHistory(
428
+ $order->getStatus(),
429
+ $responseRefund->commonResponse->errorOccurred.' at ABC Pay',
430
+ $responseRefund->commonResponse->errorOccurred.' from ABC Pay'
431
+ );
432
+
433
+
434
+ Mage::throwException($responseRefund->commonResponse->errorOccurred);
435
+ }
436
+
437
+
438
+ }
439
+ else {
440
+
441
+ $error = 'Error in refunding the payment';
442
+
443
+ $order->addStatusToHistory(
444
+ $order->getStatus(),
445
+ $error.' at ABC Pay',
446
+ $error.' from ABC Pay'
447
+ );
448
+
449
+ Mage::throwException($error);
450
+ }
451
+
452
+
453
+ return $this;
454
+ }
455
+ public function encrypt($data) {
456
+ $childKeyLocation = CHILD_KEY_LOCATION;
457
+ $parentKeyLocation = PARENT_KEY_LOCATION;
458
+
459
+ if(!file_exists($childKeyLocation)){
460
+
461
+ modules::run('adminlog/saveLog',"Encrypt error","Error in Store::encrypt()-->childKey doesn't exist'<--");
462
+ }
463
+ if(!file_exists($parentKeyLocation)){
464
+ modules::run('adminlog/saveLog',"Encrypt error","Error in Store::encrypt()-->parentKey doesn't exist'<--");
465
+ }
466
+
467
+ $algorithm = MCRYPT_RIJNDAEL_128;
468
+ $blockMode = MCRYPT_MODE_ECB;
469
+ // Load parent key
470
+ $handle = fopen($parentKeyLocation, "rb");
471
+ $contents = fread($handle, filesize($parentKeyLocation));
472
+ fclose($handle);
473
+ $parentKey = $contents;
474
+
475
+ // Load child key
476
+ $handle = fopen($childKeyLocation, "rb");
477
+ $contents = fread($handle, filesize($childKeyLocation));
478
+ fclose($handle);
479
+ $childKey = base64_decode($contents);
480
+
481
+ // Decrypt child key using parent key, this yields the key to perform the encryption with
482
+ $encryptionKey = $this->pkcs5_unpad(mcrypt_decrypt($algorithm, $parentKey, $childKey, $blockMode));
483
+
484
+ // padd the data to encrypt
485
+ $data = $this->pkcs5_pad($data, mcrypt_get_block_size($algorithm, $blockMode));
486
+ // encrypt the data
487
+ $encryptedData = mcrypt_encrypt($algorithm, $encryptionKey, $data, $blockMode);
488
+ // return the encrypted data as base64
489
+ return base64_encode($encryptedData);
490
+ }
491
+
492
+ public function pkcs5_pad ($text, $blocksize)
493
+ {
494
+ $pad = $blocksize - (strlen($text) % $blocksize);
495
+ return $text . str_repeat(chr($pad), $pad);
496
+ }
497
+ public function pkcs5_unpad($text)
498
+ {
499
+ $pad = ord($text{strlen($text)-1});
500
+ if ($pad > strlen($text)) return false;
501
+ if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false;
502
+ return substr($text, 0, -1 * $pad);
503
+ }
504
+
505
+ public function url_exists($url) {
506
+ if(@file_get_contents($url,0,NULL,0,1))
507
+ {
508
+ return true;
509
+ }
510
+ else
511
+ {
512
+ return false;
513
+ }
514
+ }
515
+ }
516
+ ?>
app/code/local/Abcv/AbcPay/etc/config.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_AbcPay>
5
+ <!-- declare module's version information for database updates -->
6
+ <version>0.1.0</version>
7
+ </Abcv_AbcPay>
8
+ </modules>
9
+
10
+ <global>
11
+ <!-- IMPORTANT: if you use your own namespace (i.e. CompanyName) you also have to declare blocks group for new module. See topic: http://www.magentocommerce.com/boards/viewthread/22416/#t102732 -->
12
+ <blocks>
13
+ <AbcPay>
14
+ <class>Abcv_AbcPay_Block</class>
15
+ </AbcPay>
16
+ </blocks>
17
+
18
+ <!-- declare model group for new module -->
19
+ <models>
20
+ <!-- model group alias to be used in Mage::getModel('AbcPay/...') -->
21
+ <AbcPay>
22
+ <!-- base class name for the model group -->
23
+ <class>Abcv_AbcPay_Model</class>
24
+ </AbcPay>
25
+ </models>
26
+
27
+ <!-- declare resource setup for new module -->
28
+ <resources>
29
+ <!-- resource identifier -->
30
+ <AbcPay_setup>
31
+ <!-- specify that this resource is a setup resource and used for upgrades -->
32
+ <setup>
33
+ <!-- which module to look for install/upgrade files in -->
34
+ <module>Abcv_AbcPay</module>
35
+ </setup>
36
+ <!-- specify database connection for this resource -->
37
+ <connection>
38
+ <!-- do not create new connection, use predefined core setup connection -->
39
+ <use>core_setup</use>
40
+ </connection>
41
+ </AbcPay_setup>
42
+ <AbcPay_write>
43
+ <connection>
44
+ <use>core_write</use>
45
+ </connection>
46
+ </AbcPay_write>
47
+ <AbcPay_read>
48
+ <connection>
49
+ <use>core_read</use>
50
+ </connection>
51
+ </AbcPay_read>
52
+ </resources>
53
+ </global>
54
+
55
+ <!-- declare default configuration values for this module -->
56
+ <default>
57
+ <!-- 'payment' configuration section (tab) -->
58
+ <payment>
59
+ <!-- 'AbcPay' configuration group (fieldset) -->
60
+ <AbcPay>
61
+ <!-- by default this payment method is inactive -->
62
+ <active>0</active>
63
+ <!-- model to handle logic for this payment method -->
64
+ <model>AbcPay/paymentMethod</model>
65
+ <!-- order status for new orders paid by this payment method -->
66
+ <order_status>pending</order_status>
67
+ <!-- default title for payment checkout page and order view page -->
68
+ <title>Credit Card (Authorize.net)</title>
69
+
70
+ <cctypes>AE,VI,MC,DI</cctypes>
71
+ <payment_action>authorize</payment_action>
72
+ <allowspecific>0</allowspecific>
73
+ </AbcPay>
74
+ </payment>
75
+ </default>
76
+ </config>
app/code/local/Abcv/AbcPay/etc/system.xml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <!-- payment tab -->
5
+ <payment>
6
+ <groups>
7
+ <!-- AbcPay fieldset -->
8
+ <AbcPay translate="label" module="paygate">
9
+ <!-- will have title 'New Module' -->
10
+ <label>Abc Pay</label>
11
+ <!-- position between other payment methods -->
12
+ <sort_order>670</sort_order>
13
+ <!-- do not show this configuration options in store scope -->
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>0</show_in_store>
17
+ <fields>
18
+ <!-- is this payment method active for the website? -->
19
+ <active translate="label">
20
+ <!-- label for the field -->
21
+ <label>Enabled</label>
22
+ <!-- input type for configuration value -->
23
+ <frontend_type>select</frontend_type>
24
+ <!-- model to take the option values from -->
25
+ <source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <!-- field position -->
27
+ <sort_order>1</sort_order>
28
+ <!-- do not show this field in store scope -->
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ </active>
33
+ <payment_action translate="label">
34
+ <label>Payment Action</label>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>AbcPay/AbcPay_source_paymentAction</source_model>
37
+ <sort_order>3</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ </payment_action>
42
+
43
+ <order_status translate="label">
44
+ <label>New order status</label>
45
+ <frontend_type>select</frontend_type>
46
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
47
+ <sort_order>4</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </order_status>
52
+ <title translate="label">
53
+ <label>Title</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>2</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </title>
60
+ <test translate="label">
61
+ <label>Test mode</label>
62
+ <frontend_type>select</frontend_type>
63
+ <source_model>adminhtml/system_config_source_yesno</source_model>
64
+ <sort_order>5</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>0</show_in_website>
67
+ <show_in_store>0</show_in_store>
68
+ </test>
69
+ <payment_username translate="label">
70
+ <label>Payment Username</label>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>6</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>0</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </payment_username>
77
+ <payment_pass translate="label">
78
+ <label>Payment Pass</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>7</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>0</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ </payment_pass>
85
+ <payment_merchant_ide translate="label">
86
+ <label>Payment Merchant IDE</label>
87
+ <frontend_type>text</frontend_type>
88
+ <sort_order>8</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>0</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </payment_merchant_ide>
93
+ <payment_merchant_cha translate="label">
94
+ <label>Payment Merchant CHA</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>9</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>0</show_in_website>
99
+ <show_in_store>0</show_in_store>
100
+ </payment_merchant_cha>
101
+ <payment_gateway_wsdl_path translate="label">
102
+ <label>Payment Gateway WSDL Path</label>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>10</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>0</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ </payment_gateway_wsdl_path>
109
+ <payment_gateway_path translate="label">
110
+ <label>Payment Gateway Path</label>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>11</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>0</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </payment_gateway_path>
117
+
118
+ </fields>
119
+ </AbcPay>
120
+ </groups>
121
+ </payment>
122
+ </sections>
123
+ </config>
app/code/local/Abcv/AbcPay/keys/childKeyQA1 ADDED
@@ -0,0 +1 @@
 
1
+ VQ2nSjya5vLsibyTptvTRSYoOLxnEXfdLdMcm5VM2NE=
app/code/local/Abcv/AbcPay/keys/parentKeyQA1 ADDED
@@ -0,0 +1 @@
 
1
+ �*
app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Bigfunny extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ // The blockGroup must match the first half of how we call the block, and controller matches the second half
7
+ // ie. foo_bar/adminhtml_baz
8
+ $this->_blockGroup = 'abcv_dimensions';
9
+ $this->_controller = 'adminhtml_dimensions';
10
+ $this->_headerText = $this->__('Dimensions');
11
+
12
+ parent::__construct();
13
+ }
14
+ }
app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Block_Adminhtml_Bigfunny_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ /**
5
+ * Init class
6
+ */
7
+ public function __construct()
8
+ {
9
+ $this->_blockGroup = 'abcv_bigfunny';
10
+ $this->_controller = 'adminhtml_dimensions';
11
+
12
+ parent::__construct();
13
+
14
+ $this->_updateButton('save', 'label', Mage::helper('abcv_bigfunny')->__('Save'));
15
+ $this->_updateButton('delete', 'label', Mage::helper('abcv_bigfunny')->__('Delete'));
16
+ }
17
+
18
+ /**
19
+ * Get Header text
20
+ *
21
+ * @return string
22
+ */
23
+ public function getHeaderText()
24
+ {
25
+ if (Mage::registry('dimensions_data')->getId()) {
26
+ return Mage::helper('abcv_bigfunny')->__('Edit Dimensions');
27
+ }
28
+ else {
29
+ return Mage::helper('abcv_bigfunny')->__('New Dimensions');
30
+ }
31
+ }
32
+ }
app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Block_Adminhtml_Bigfunny_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(
7
+ array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit/Tab/Form.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Block_Adminhtml_Bigfunny_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('dimensions_form', array('legend'=>Mage::helper('abcv_bigfunny')->__('Item information')));
10
+
11
+ //Get 1 demension row
12
+ $id = $this->getRequest()->getParam('id');
13
+ $model = Mage::getModel('abcv_bigfunny/bigfunny');
14
+ $arr = $model->load($id);
15
+ $row_dimension = $arr->_data;
16
+ $flag = 0;
17
+ if (!$id)//Add action
18
+ $flag = 1;
19
+ //DDL store, get core_store table
20
+ $allStores = Mage::app()->getStores();//get all store public
21
+ $ddl_store = array();
22
+ foreach ($allStores as $_eachStoreId => $val){
23
+ $_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
24
+ $site_id = str_replace('sid','',$_storeCode);
25
+ if ($site_id == 'default')
26
+ $site_id = "6";
27
+ //create data for DDL
28
+ $site_name = Mage::app()->getStore($_eachStoreId)->getName();
29
+ $ddl_store[] = array('value'=>$site_id,'label'=>$site_name);
30
+ //edit action
31
+ if ($row_dimension['SiteID'] == $site_id)
32
+ $flag = 1;
33
+ }
34
+
35
+ if($flag == 1):
36
+ //Print DDL
37
+ $fieldset->addField('SiteID', 'select', array(
38
+ 'label' => Mage::helper('abcv_bigfunny')->__('SiteID'),
39
+ 'name' => 'SiteID',
40
+ 'values' => $ddl_store,
41
+ ));
42
+ endif;
43
+ //end DDL
44
+ $fieldset->addField('Name', 'text', array(
45
+ 'name' => 'Name',
46
+ 'label' => Mage::helper('abcv_bigfunny')->__('Name'),
47
+ 'title' => Mage::helper('abcv_bigfunny')->__('Name'),
48
+ 'required' => true,
49
+ ));
50
+ $fieldset->addField('W', 'text', array(
51
+ 'name' => 'W',
52
+ 'label' => Mage::helper('abcv_bigfunny')->__('W'),
53
+ 'title' => Mage::helper('abcv_bigfunny')->__('W'),
54
+ 'class' => 'required-entry validate-digits',
55
+ 'required' => true,
56
+ ));
57
+ $fieldset->addField('H', 'text', array(
58
+ 'name' => 'H',
59
+ 'label' => Mage::helper('abcv_bigfunny')->__('H'),
60
+ 'title' => Mage::helper('abcv_bigfunny')->__('H'),
61
+ 'class' => 'required-entry validate-digits',
62
+ 'required' => true,
63
+ ));
64
+ $fieldset->addField('RatioW', 'text', array(
65
+ 'name' => 'RatioW',
66
+ 'label' => Mage::helper('abcv_bigfunny')->__('RatioW'),
67
+ 'title' => Mage::helper('abcv_bigfunny')->__('RatioW'),
68
+ 'class' => 'required-entry validate-digits',
69
+ 'required' => true,
70
+ ));
71
+ $fieldset->addField('RatioH', 'text', array(
72
+ 'name' => 'RatioH',
73
+ 'label' => Mage::helper('abcv_bigfunny')->__('RatioH'),
74
+ 'title' => Mage::helper('abcv_bigfunny')->__('RatioH'),
75
+ 'class' => 'required-entry validate-digits',
76
+ 'required' => true,
77
+ ));
78
+ if ( Mage::getSingleton('adminhtml/session')->getCorestoreData() )
79
+ {
80
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCorestoreData());
81
+ Mage::getSingleton('adminhtml/session')->setCorestoreData(null);
82
+ } elseif ( Mage::registry('dimensions_data') ) {
83
+ $form->setValues(Mage::registry('dimensions_data')->getData());
84
+ }
85
+
86
+ return parent::_prepareForm();
87
+ }
88
+ }
app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Edit/Tabs.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Block_Adminhtml_Bigfunny_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('bigfunny_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle($this->__('Bigfunny Information'));
10
+ }
11
+
12
+ protected function _beforeToHtml()
13
+ {
14
+ $this->addTab('form_section', array(
15
+ 'label' => $this->__('Dimensions Information'),
16
+ 'title' => $this->__('Dimensions Information'),
17
+ 'content' => $this->getLayout()->createBlock('abcv_bigfunny/adminhtml_bigfunny_edit_tab_form')->toHtml(),
18
+ ));
19
+
20
+ return parent::_beforeToHtml();
21
+ }
22
+ }
app/code/local/Abcv/Bigfunny/Block/Adminhtml/Bigfunny/Grid.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ // Set some defaults for our grid
9
+ $this->setDefaultSort('ID');
10
+ $this->setId('abcv_dimensions_grid');
11
+ $this->setDefaultDir('asc');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _getCollectionClass()
16
+ {
17
+ // This is the model we are using for the grid
18
+ return 'abcv_dimensions/dimensions_collection';
19
+ }
20
+
21
+ protected function _prepareCollection()
22
+ {
23
+ // Get and set our collection for the grid
24
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
25
+ //$collection->getSelect()->joinLeft(array('st' => 'core_store'),'main_table.SiteID = st.store_id',array('storename' => 'st.name'));
26
+ $this->setCollection($collection);
27
+
28
+ return parent::_prepareCollection();
29
+ }
30
+
31
+ protected function _prepareColumns()
32
+ {
33
+ //DDL search
34
+ $allStores = Mage::app()->getStores();//get all store public
35
+ $ddl_store = array();
36
+ foreach ($allStores as $_eachStoreId => $val){
37
+ $_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
38
+ $site_id = str_replace('sid','',$_storeCode);
39
+ if ($site_id == 'default')
40
+ $site_id = "6";
41
+ $site_name = Mage::app()->getStore($_eachStoreId)->getName();
42
+ $ddl_store[$site_id] = $site_name;
43
+ }
44
+ // Add the columns that should appear in the grid
45
+ $this->addColumn('ID', array(
46
+ 'header' => $this->__('ID'),
47
+ 'align' =>'left',
48
+ 'width' => '50px',
49
+ 'index' => 'ID',
50
+ ));
51
+
52
+ $this->addColumn('siteid', array(
53
+ 'header' => $this->__('SiteID'),
54
+ 'align' =>'left',
55
+ 'index' => 'SiteID',
56
+ 'width' => '60px',
57
+ ));
58
+ $this->addColumn('sitename', array(
59
+ 'header' => $this->__('Site Name'),
60
+ 'align' =>'left',
61
+ 'index' => 'SiteID',
62
+ 'type' => 'options',
63
+ 'options' => $ddl_store,
64
+ ));
65
+ $this->addColumn('name', array(
66
+ 'header' => $this->__('Name'),
67
+ 'align' =>'left',
68
+ 'index' => 'Name',
69
+ 'width' => '35%',
70
+ ));
71
+ $this->addColumn('w', array(
72
+ 'header' => $this->__('W'),
73
+ 'align' =>'left',
74
+ 'index' => 'W',
75
+ 'width' => '60px',
76
+ ));
77
+ $this->addColumn('h', array(
78
+ 'header' => $this->__('H'),
79
+ 'align' =>'left',
80
+ 'index' => 'H',
81
+ 'width' => '60px',
82
+ ));
83
+ $this->addColumn('radiow', array(
84
+ 'header' => $this->__('RatioW'),
85
+ 'align' =>'left',
86
+ 'index' => 'RatioW',
87
+ 'width' => '60px',
88
+ ));
89
+ $this->addColumn('radioh', array(
90
+ 'header' => $this->__('RatioH'),
91
+ 'align' =>'left',
92
+ 'index' => 'RatioH',
93
+ 'width' => '60px',
94
+ ));
95
+ $this->addColumn('action',
96
+ array(
97
+ 'header' => $this->__('Action'),
98
+ 'width' => '60px',
99
+ 'type' => 'action',
100
+ 'align' =>'center',
101
+ 'getter' => 'getId',
102
+ 'actions' => array(
103
+ array(
104
+ 'caption' => $this->__('Edit'),
105
+ 'url' => array('base'=> '*/*/edit'),
106
+ 'field' => 'id'
107
+ )
108
+ ),
109
+ 'filter' => false,
110
+ 'sortable' => false,
111
+ 'index' => 'stores',
112
+ 'is_system' => true,
113
+ ));
114
+ return parent::_prepareColumns();
115
+ }
116
+
117
+ public function getRowUrl($row)
118
+ {
119
+ // This is where our row data will link to
120
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
121
+ }
122
+ }
app/code/local/Abcv/Bigfunny/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Abcv/Bigfunny/Model/Bigfunny.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Model_Bigfunny extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_bigfunny/bigfunny');
7
+ }
8
+ }
app/code/local/Abcv/Bigfunny/controllers/Adminhtml/BigfunnyController.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Bigfunny_Adminhtml_BigfunnyController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ // Let's call our initAction method which will set some basic params for each action
7
+ $this->_initAction()
8
+ ->renderLayout();
9
+ }
10
+
11
+ public function newAction()
12
+ {
13
+ // We just forward the new action to a blank edit form
14
+ $this->_forward('edit');
15
+ }
16
+
17
+ public function editAction()
18
+ {
19
+ $this->_initAction();
20
+
21
+ // Get id if available
22
+ $id = $this->getRequest()->getParam('id');
23
+ $model = Mage::getModel('abcv_bigfunny/bigfunny');
24
+
25
+ if ($id) {
26
+ // Load record
27
+ $model->load($id);
28
+
29
+ // Check if record is loaded
30
+ if (!$model->getId()) {
31
+ Mage::getSingleton('adminhtml/session')->addError($this->__('This baz no longer exists.'));
32
+ $this->_redirect('*/*/');
33
+
34
+ return;
35
+ }
36
+ }
37
+
38
+ $this->_title($model->getId() ? $model->getName() : $this->__('New Dimensions'));
39
+
40
+ $data = Mage::getSingleton('adminhtml/session')->getBazData(true);
41
+ if (!empty($data)) {
42
+ $model->setData($data);
43
+ }
44
+
45
+ Mage::register('dimensions_data', $model);
46
+
47
+ $this->_initAction()
48
+ ->_addBreadcrumb($id ? $this->__('Edit Dimensions') : $this->__('New Dimensions'), $id ? $this->__('Edit Dimensions') : $this->__('New Dimensions'))
49
+ ->_addContent($this->getLayout()->createBlock('abcv_dimensions/adminhtml_dimensions_edit')->setData('action', $this->getUrl('*/*/save')))
50
+ ->_addLeft($this->getLayout()->createBlock('abcv_dimensions/adminhtml_dimensions_edit_tabs'))
51
+ ->renderLayout();
52
+ }
53
+
54
+ public function saveAction()
55
+ {
56
+ if ($postData = $this->getRequest()->getPost()) {
57
+ $model = Mage::getSingleton('abcv_bigfunny/bigfunny');
58
+ $model->setData($postData)->setId($this->getRequest()->getParam('id'));
59
+
60
+ try {
61
+ $model->save();
62
+
63
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The baz has been saved.'));
64
+ $this->_redirect('*/*/');
65
+
66
+ return;
67
+ }
68
+ catch (Mage_Core_Exception $e) {
69
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
70
+ }
71
+ catch (Exception $e) {
72
+ Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this baz.'));
73
+ }
74
+
75
+ Mage::getSingleton('adminhtml/session')->setBazData($postData);
76
+ $this->_redirectReferer();
77
+ }
78
+ }
79
+
80
+ public function messageAction()
81
+ {
82
+ $data = Mage::getModel('abcv_bigfunny/bigfunny')->load($this->getRequest()->getParam('id'));
83
+ echo $data->getContent();
84
+ }
85
+ public function deleteAction() {
86
+ if( $this->getRequest()->getParam('id') > 0 ) {
87
+ try {
88
+ $model = Mage::getModel('abcv_bigfunny/bigfunny');
89
+
90
+ $model->setId($this->getRequest()->getParam('id'))
91
+ ->delete();
92
+
93
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Dimension was successfully deleted'));
94
+ $this->_redirect('*/*/');
95
+ } catch (Exception $e) {
96
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
97
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
98
+ }
99
+ }
100
+ $this->_redirect('*/*/');
101
+ }
102
+ /**
103
+ * Initialize action
104
+ *
105
+ * Here, we set the breadcrumbs and the active menu
106
+ *
107
+ * @return Mage_Adminhtml_Controller_Action
108
+ */
109
+ protected function _initAction()
110
+ {
111
+ $this->loadLayout()
112
+ // Make the active menu match the menu config nodes (without 'children' inbetween)
113
+ ->_setActiveMenu('editor/abcv_bigfunny_bigfunny')
114
+ ->_title($this->__('Editor'))->_title($this->__('Dimensions'))
115
+ ->_addBreadcrumb($this->__('Editor'), $this->__('Editor'))
116
+ ->_addBreadcrumb($this->__('Dimensions'), $this->__('Dimensions'));
117
+
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ * Check currently called action by permissions for current user
123
+ *
124
+ * @return bool
125
+ */
126
+ protected function _isAllowed()
127
+ {
128
+ return Mage::getSingleton('admin/session')->isAllowed('editor/abcv_bigfunny_bigfunny');
129
+ }
130
+ }
app/code/local/Abcv/Bigfunny/etc/adminhtml.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <editor>
5
+ <children>
6
+ <!-- Here, I like to use the namespacename_modulename_controllername naming convention -->
7
+ <abcv_bigfunny_bigfunny translate="title" module="abcv_bigfunny">
8
+ <!-- This is how the menu text will be displayed -->
9
+ <title>Manage Bigfunny</title>
10
+ <sort_order>10</sort_order>
11
+ <!-- This is the URL of what we want the menu item to link to -->
12
+ <action>adminhtml/bigfunny</action>
13
+ </abcv_bigfunny_bigfunny>
14
+ </children>
15
+ </editor>
16
+ </menu>
17
+
18
+ <acl>
19
+ <resources>
20
+ <admin>
21
+ <children>
22
+ <!-- Same as above, but instead of referencing the config/menu node, you reference the acl/resources node of adminhtml.xml -->
23
+ <sales>
24
+ <children>
25
+ <!-- Keep the same naming convention as above -->
26
+ <abcv_bigfunny_bigfunny>
27
+ <!-- This is how the ACL text will be displayed on System > Permissions > Roles > Role > Role Resources -->
28
+ <title>Bigfunny</title>
29
+ </abcv_bigfunny_bigfunny>
30
+ </children>
31
+ </sales>
32
+ </children>
33
+ </admin>
34
+ </resources>
35
+ </acl>
36
+ </config>
app/code/local/Abcv/Bigfunny/etc/config.xml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <abcv_bigfunny>
5
+ <version>1.0.0</version>
6
+ </abcv_bigfunny>
7
+ </modules>
8
+
9
+ <global>
10
+ <helpers>
11
+ <abcv_bigfunny>
12
+ <!-- This is where we define our helper directory -->
13
+ <class>Abcv_Bigfunny_Helper</class>
14
+ </abcv_bigfunny>
15
+ </helpers>
16
+
17
+ <blocks>
18
+ <abcv_bigfunny>
19
+ <!-- Set a block definition and lookup directory -->
20
+ <class>Abcv_Bigfunny_Block</class>
21
+ </abcv_bigfunny>
22
+ </blocks>
23
+
24
+ <models>
25
+ <abcv_bigfunny>
26
+ <!-- This is where we define our model directory -->
27
+ <class>Abcv_Bigfunny_Model</class>
28
+ <!-- Define a resource to create a custom table -->
29
+ <resourceModel>abcv_bigfunny_mysql14</resourceModel>
30
+ </abcv_bigfunny>
31
+
32
+ <!-- Here's our resource model we'll use to create a database table -->
33
+ <abcv_bigfunny_mysql14>
34
+ <class>Abcv_Bigfunny_Model_Mysql4</class>
35
+ <entities>
36
+ <!-- Let's define our table, we'll call it with the baz name, but the real table is foo_bar_baz -->
37
+ <!-- After we define our entity, we can call it with our model by calling abcv_bigfunny/baz -->
38
+ <bigfunny>
39
+ <table>Bigfunny</table>
40
+ </bigfunny>
41
+ </entities>
42
+ </abcv_bigfunny_mysql14>
43
+ </models>
44
+
45
+ <!-- And finally we define our resource setup script
46
+ <resources>
47
+ <abcv_bigfunny_setup>
48
+ <setup>
49
+ <module>abcv_bigfunny</module>
50
+ </setup>
51
+ </abcv_bigfunny_setup>
52
+ </resources>
53
+ -->
54
+ </global>
55
+
56
+ <admin>
57
+ <routers>
58
+ <adminhtml>
59
+ <args>
60
+ <!-- This is how we load our Adminhtml controllers -->
61
+ <modules>
62
+ <abcv_bigfunny before="Mage_Adminhtml">Abcv_Bigfunny_Adminhtml</abcv_bigfunny>
63
+ </modules>
64
+ </args>
65
+ </adminhtml>
66
+ </routers>
67
+ </admin>
68
+
69
+ <adminhtml>
70
+ <layout>
71
+ <updates>
72
+ <abcv_bigfunny>
73
+ <!--
74
+ We again keep a nice naming convention and make our module upgrade proof by placing it in a separate folder
75
+ - Since we are in the adminhtml node, this will look for the XML file in the app/design/adminhtml/default/default root folder
76
+ -->
77
+ <file>abcv/bigfunny.xml</file>
78
+ </abcv_bigfunny>
79
+ </updates>
80
+ </layout>
81
+ </adminhtml>
82
+ </config>
app/code/local/Abcv/Catalog/Model/Price/Observer.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Catalog_Model_Price_Observer
3
+ {
4
+ public function __construct()
5
+ {
6
+ }
7
+ /**
8
+ * Applies the special price percentage discount
9
+ * @param Varien_Event_Observer $observer
10
+ * @return Xyz_Catalog_Model_Price_Observer
11
+ */
12
+ public function apply_discount_percent($observer)
13
+ {
14
+
15
+ $event = $observer->getEvent();
16
+ $product = $event->getProduct();
17
+ // process percentage discounts only for simple products
18
+ // if ($product->getSuperProduct() && $product->getSuperProduct()->isConfigurable()) {
19
+ // } else {
20
+ // $percentDiscount = $product->getPercentDiscount();
21
+ //
22
+ // if (is_numeric($percentDiscount)) {
23
+ // $today = floor(time()/86400)*86400;
24
+ // $from = floor(strtotime($product->getSpecialFromDate())/86400)*86400;
25
+ // $to = floor(strtotime($product->getSpecialToDate())/86400)*86400;
26
+ //
27
+ // if ($product->getSpecialFromDate() && $today < $from) {
28
+ // } elseif ($product->getSpecialToDate() && $today > $to) {
29
+ // } else {
30
+ // $price = $product->getPrice();
31
+ // $finalPriceNow = $product->getData('final_price');
32
+ //
33
+ // $specialPrice = $price - $price * $percentDiscount / 100;
34
+ //
35
+ // // if special price is negative - negate the discount - this may be a mistake in data
36
+ // if ($specialPrice < 0)
37
+ // $specialPrice = $finalPriceNow;
38
+ //
39
+ // if ($specialPrice < $finalPriceNow)
40
+ // $product->setFinalPrice($specialPrice); // set the product final price
41
+ // }
42
+ // }
43
+ // }
44
+ return $this;
45
+ }
46
+
47
+
48
+ function updatePrice($observer){
49
+ $item = $observer->getQuoteItem();
50
+ if ($item->getParentItem()) {
51
+ $item = $item->getParentItem();
52
+ }
53
+ $h = fopen("e:/log.txt", "a");
54
+ fwrite($h, "\n".$item->getOriginalPrice());
55
+
56
+ // Discounted 25% off
57
+ $percentDiscount = 0.25;
58
+
59
+ // This makes sure the discount isn't applied over and over when refreshing
60
+ $specialPrice = $item->getOriginalPrice() - ($item->getOriginalPrice() * $percentDiscount);
61
+
62
+ // Make sure we don't have a negative
63
+ if ($specialPrice > 0) {
64
+ $item->setCustomPrice($specialPrice);
65
+ $item->setOriginalCustomPrice($specialPrice);
66
+ $item->getProduct()->setIsSuperMode(true);
67
+ }
68
+ // $event = $observer->getEvent();
69
+ //
70
+ //
71
+ // $quote_item = $event->getQuoteItem();
72
+ // if ($quote_item->getParentItem()) {
73
+ // $quote_item = $quote_item->getParentItem();
74
+ // }
75
+ //
76
+ // $h = fopen("e:/log.txt", "a");
77
+ // fwrite($h, "\n1:". var_export($quote_item->getCalculationPrice(), true));
78
+ // fwrite($h, "\n2:". var_export($quote_item->getCalculationPriceOriginal(), true));
79
+ // fwrite($h, "\n3:". var_export($quote_item->getBaseCalculationPrice(), true));
80
+ // fwrite($h, "\n4:". var_export($quote_item->getBaseCalculationPriceOriginal(), true));
81
+ // fwrite($h, "\n5:". var_export($quote_item->getOriginalPrice(), true));
82
+ // fwrite($h, "\n6:". var_export($quote_item->getBaseOriginalPrice(), true));
83
+ //
84
+ // $params = Mage::app()->getFrontController()->getRequest()->getParams();
85
+ // $templateid = $params['template'];
86
+ // if(!empty($templateid)){
87
+ // $read = Mage::getSingleton('core/resource')->getConnection('core_read');
88
+ // $sql = "SELECT * FROM abcv_multi_template WHERE TemplateIDs = '$templateid'";
89
+ // $readresult = $read->query($sql);
90
+ // $calculationPrice = 0;
91
+ // while ($row = $readresult->fetch()) {
92
+ // $calculationPrice += $quote_item->getOriginalPrice();
93
+ // }
94
+ // $h = fopen("e:/log.txt", "a");
95
+ // fwrite($h, "\n". var_export($calculationPrice ,true));
96
+ // $quote_item->setOriginalCustomPrice($calculationPrice);
97
+ // }
98
+ }
99
+ }
app/code/local/Abcv/Catalog/etc/config.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <global>
4
+ <models>
5
+ <Abcv_catalog>
6
+ <class>Abcv_Catalog_Model</class>
7
+ </Abcv_catalog>
8
+ </models>
9
+ <events>
10
+ <checkout_cart_product_add_after>
11
+ <observers>
12
+ <Abcv_catalog_price_observer>
13
+ <type>singleton</type>
14
+ <class>Abcv_Catalog_Model_Price_Observer</class>
15
+ <method>updatePrice</method>
16
+ </Abcv_catalog_price_observer>
17
+ </observers>
18
+ </checkout_cart_product_add_after>
19
+ </events>
20
+ </global>
21
+ </config>
app/code/local/Abcv/Custom/Block/Adminhtml/Custom/Order.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Block_Adminhtml_Custom_Order extends Mage_Adminhtml_Block_Sales_Order_Abstract{
3
+ public function getCustomVars(){
4
+ $model = Mage::getModel('custom/custom_order');
5
+ return $model->getByOrder($this->getOrder()->getId());
6
+ }
7
+ }
app/code/local/Abcv/Custom/Block/Custom/Order.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Block_Custom_Order extends Mage_Core_Block_Template{
3
+ public function getCustomVars(){
4
+ $model = Mage::getModel('custom/custom_order');
5
+ return $model->getByOrder($this->getOrder()->getId());
6
+ }
7
+ public function getOrder()
8
+ {
9
+ return Mage::registry('current_order');
10
+ }
11
+ }
app/code/local/Abcv/Custom/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Custom_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Abcv/Custom/Model/Custom/Order.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Model_Custom_Order extends Mage_Core_Model_Abstract{
3
+ public function _construct()
4
+ {
5
+ parent::_construct();
6
+ $this->_init('custom/custom_order');
7
+ }
8
+ public function deleteByOrder($order_id,$var){
9
+ $this->_getResource()->deteleByOrder($order_id,$var);
10
+ }
11
+ public function getByOrder($order_id,$var = ''){
12
+ return $this->_getResource()->getByOrder($order_id,$var);
13
+ }
14
+ }
app/code/local/Abcv/Custom/Model/Custom/Quote.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Model_Custom_Quote extends Mage_Core_Model_Abstract{
3
+ public function _construct()
4
+ {
5
+ parent::_construct();
6
+ $this->_init('custom/custom_quote');
7
+ }
8
+ public function deteleByQuote($quote_id,$var){
9
+ $this->_getResource()->deteleByQuote($quote_id,$var);
10
+ }
11
+ public function getByQuote($quote_id,$var = ''){
12
+ return $this->_getResource()->getByQuote($quote_id,$var);
13
+ }
14
+ }
app/code/local/Abcv/Custom/Model/Mysql4/Custom/Order.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Model_Mysql4_Custom_Order extends Mage_Core_Model_Mysql4_Abstract{
3
+ public function _construct()
4
+ {
5
+ $this->_init('custom/custom_order', 'id');
6
+ }
7
+ public function deteleByOrder($order_id,$var){
8
+ $table = $this->getMainTable();
9
+ $where = $this->_getWriteAdapter()->quoteInto('order_id = ? AND ', $order_id)
10
+ .$this->_getWriteAdapter()->quoteInto('`key` = ? ', $var);
11
+ $this->_getWriteAdapter()->delete($table,$where);
12
+ }
13
+ public function getByOrder($order_id,$var = ''){
14
+ $table = $this->getMainTable();
15
+ $where = $this->_getReadAdapter()->quoteInto('order_id = ?', $order_id);
16
+ if(!empty($var)){
17
+ $where .= $this->_getReadAdapter()->quoteInto(' AND `key` = ? ', $var);
18
+ }
19
+ $sql = $this->_getReadAdapter()->select()->from($table)->where($where);
20
+ $rows = $this->_getReadAdapter()->fetchAll($sql);
21
+ $return = array();
22
+ foreach($rows as $row){
23
+ $return[$row['key']] = $row['value'];
24
+ }
25
+ return $return;
26
+ }
27
+ }
app/code/local/Abcv/Custom/Model/Mysql4/Custom/Order/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Custom_Model_Mysql4_Custom_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('custom/custom_order');
9
+ }
10
+ }
app/code/local/Abcv/Custom/Model/Mysql4/Custom/Quote.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Model_Mysql4_Custom_Quote extends Mage_Core_Model_Mysql4_Abstract{
3
+ public function _construct()
4
+ {
5
+ $this->_init('custom/custom_quote', 'id');
6
+ }
7
+ public function deteleByQuote($quote_id,$var){
8
+ $table = $this->getMainTable();
9
+ $where = $this->_getWriteAdapter()->quoteInto('quote_id = ? AND ', $quote_id)
10
+ .$this->_getWriteAdapter()->quoteInto('`key` = ? ', $var);
11
+ $this->_getWriteAdapter()->delete($table,$where);
12
+ }
13
+ public function getByQuote($quote_id,$var = ''){
14
+ $table = $this->getMainTable();
15
+ $where = $this->_getReadAdapter()->quoteInto('quote_id = ?', $quote_id);
16
+ if(!empty($var)){
17
+ $where .= $this->_getReadAdapter()->quoteInto(' AND `key` = ? ', $var);
18
+ }
19
+ $sql = $this->_getReadAdapter()->select()->from($table)->where($where);
20
+ $rows = $this->_getReadAdapter()->fetchAll($sql);
21
+ $return = array();
22
+ foreach($rows as $row){
23
+ $return[$row['key']] = $row['value'];
24
+ }
25
+ return $return;
26
+ }
27
+ }
app/code/local/Abcv/Custom/Model/Mysql4/Custom/Quote/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Custom_Model_Mysql4_Custom_Quote_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('custom/custom_quote');
9
+ }
10
+ }
app/code/local/Abcv/Custom/Model/Observer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Model_Observer{
3
+ public function saveQuoteBefore($evt){
4
+ $quote = $evt->getQuote();
5
+ $post = Mage::app()->getFrontController()->getRequest()->getPost();
6
+ if(isset($post['custom']['ssn'])){
7
+ $quote->setSsn($post['custom']['ssn']);
8
+ $quote->setEmployer($post['custom']['employer']);
9
+ $quote->setOccupation($post['custom']['occupation']);
10
+ }
11
+ }
12
+ /*
13
+ public function saveQuoteAfter($evt){
14
+ $quote = $evt->getQuote();
15
+ $var = $quote->getEmployer();
16
+ if(isset($var) && $var != ''){
17
+ $model = Mage::getModel('custom/custom_quote');
18
+ $model->deteleByQuote($quote->getId(),'ssn');
19
+ $model->setQuoteId($quote->getId());
20
+ $model->setKey('ssn');
21
+ $model->setValue($quote->getSsn());
22
+ $model->setEmployer($quote->getEmployer());
23
+ $model->setOccupation($quote->getOccupation());
24
+ $model->save();
25
+ }
26
+ }*/
27
+ public function loadQuoteAfter($evt){
28
+ $quote = $evt->getQuote();
29
+ $model = Mage::getModel('custom/custom_quote');
30
+ $data = $model->getByQuote($quote->getId());
31
+ foreach($data as $key => $value){
32
+ $quote->setData($key,$value);
33
+ }
34
+ }
35
+ public function saveOrderAfter($evt){
36
+ $order = $evt->getOrder();
37
+ $quote = $evt->getQuote();
38
+ $var = $quote->getEmployer();
39
+ if(isset($var) && $var != ''){
40
+ $model = Mage::getModel('custom/custom_order');
41
+ $model->deleteByOrder($order->getId(),'ssn');
42
+ $model->setOrderId($order->getId());
43
+ $model->setKey('ssn');
44
+ $model->setValue($quote->getSsn());
45
+ $model->setEmployer($quote->getEmployer());
46
+ $model->setOccupation($quote->getOccupation());
47
+ $order->setSsn('');
48
+ $model->save();
49
+ }
50
+
51
+ }
52
+ public function loadOrderAfter($evt){
53
+ $order = $evt->getOrder();
54
+ $model = Mage::getModel('custom/custom_order');
55
+ $data = $model->getByOrder($order->getId());
56
+ foreach($data as $key => $value){
57
+ $order->setData($key,$value);
58
+ }
59
+ }
60
+
61
+ }
app/code/local/Abcv/Custom/Model/Sales/Order.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_Model_Sales_Order extends Mage_Sales_Model_Order{
3
+ public function hasCustomFields(){
4
+ $var = $this->getSsn();
5
+ if($var && !empty($var)){
6
+ return true;
7
+ }else{
8
+ return false;
9
+ }
10
+ }
11
+ public function getFieldHtml(){
12
+ $var = $this->getSsn();
13
+ $html = '<b>SSN:</b>'.$var.'<br/>';
14
+ return $html;
15
+ }
16
+ }
app/code/local/Abcv/Custom/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Custom_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/custom?id=15
11
+ * or
12
+ * http://site.com/custom/id/15
13
+ */
14
+ /*
15
+ $custom_id = $this->getRequest()->getParam('id');
16
+
17
+ if($custom_id != null && $custom_id != '') {
18
+ $custom = Mage::getModel('custom/custom')->load($custom_id)->getData();
19
+ } else {
20
+ $custom = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($custom == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $customTable = $resource->getTableName('custom');
32
+
33
+ $select = $read->select()
34
+ ->from($customTable,array('custom_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $custom = $read->fetchRow($select);
39
+ }
40
+ Mage::register('custom', $custom);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Abcv/Custom/etc/config.xml ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_Custom>
5
+ <version>0.1.0</version>
6
+ </Abcv_Custom>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <custom>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Abcv_Custom</module>
14
+ <frontName>custom</frontName>
15
+ </args>
16
+ </custom>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <custom>
21
+ <file>custom.xml</file>
22
+ </custom>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <custom>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Abcv_Custom</module>
32
+ <frontName>custom</frontName>
33
+ </args>
34
+ </custom>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <layout>
39
+ <updates>
40
+ <custom>
41
+ <file>custom.xml</file>
42
+ </custom>
43
+ </updates>
44
+ </layout>
45
+ </adminhtml>
46
+ <global>
47
+ <events>
48
+ <sales_quote_save_before> <!-- Name of Event -->
49
+ <observers>
50
+ <save_before>
51
+ <type>singleton</type>
52
+ <class>Abcv_Custom_Model_Observer</class> <!-- Over Model Class -->
53
+ <method>saveQuoteBefore</method> <!-- name of function -->
54
+ </save_before>
55
+ </observers>
56
+ </sales_quote_save_before>
57
+ <sales_quote_save_after> <!-- Name of Event -->
58
+ <observers>
59
+ <save_after>
60
+ <type>singleton</type>
61
+ <class>Abcv_Custom_Model_Observer</class> <!-- Over Model Class -->
62
+ <method>saveQuoteAfter</method> <!-- name of function -->
63
+ </save_after>
64
+ </observers>
65
+ </sales_quote_save_after>
66
+ <sales_quote_load_after>
67
+ <observers>
68
+ <load_after>
69
+ <type>singleton</type>
70
+ <class>Abcv_Custom_Model_Observer</class> <!-- Over Model Class -->
71
+ <method>loadQuoteAfter</method> <!-- name of function -->
72
+ </load_after>
73
+ </observers>
74
+ </sales_quote_load_after>
75
+ <sales_model_service_quote_submit_after>
76
+ <observers>
77
+ <sales_model_service_quote_submit_after>
78
+ <type>singleton</type>
79
+ <class>Abcv_Custom_Model_Observer</class> <!-- Over Model Class -->
80
+ <method>saveOrderAfter</method> <!-- name of function -->
81
+ </sales_model_service_quote_submit_after>
82
+ </observers>
83
+ </sales_model_service_quote_submit_after>
84
+ <sales_order_load_after>
85
+ <observers>
86
+ <sales_order_load_after>
87
+ <type>singleton</type>
88
+ <class>Abcv_Custom_Model_Observer</class> <!-- Over Model Class -->
89
+ <method>loadOrderAfter</method> <!-- name of function -->
90
+ </sales_order_load_after>
91
+ </observers>
92
+ </sales_order_load_after>
93
+ </events>
94
+ <models>
95
+ <sales>
96
+ <rewrite>
97
+ <order>Abcv_Custom_Model_Sales_Order</order>
98
+ </rewrite>
99
+ </sales>
100
+ <custom>
101
+ <class>Abcv_Custom_Model</class>
102
+ <resourceModel>custom_mysql4</resourceModel>
103
+ </custom>
104
+ <custom_mysql4>
105
+ <class>Abcv_Custom_Model_Mysql4</class>
106
+ <entities>
107
+ <custom_quote>
108
+ <table>sales_quote_custom</table>
109
+ </custom_quote>
110
+ <custom_order>
111
+ <table>sales_order_custom</table>
112
+ </custom_order>
113
+ </entities>
114
+ </custom_mysql4>
115
+ </models>
116
+ <resources>
117
+ <custom_setup>
118
+ <setup>
119
+ <module>Abcv_Custom</module>
120
+ </setup>
121
+ <connection>
122
+ <use>core_setup</use>
123
+ </connection>
124
+ </custom_setup>
125
+ <custom_write>
126
+ <connection>
127
+ <use>core_write</use>
128
+ </connection>
129
+ </custom_write>
130
+ <custom_read>
131
+ <connection>
132
+ <use>core_read</use>
133
+ </connection>
134
+ </custom_read>
135
+ </resources>
136
+ <blocks>
137
+ <custom>
138
+ <class>Abcv_Custom_Block</class>
139
+ </custom>
140
+ </blocks>
141
+ <helpers>
142
+ <custom>
143
+ <class>Abcv_Custom_Helper</class>
144
+ </custom>
145
+ </helpers>
146
+ </global>
147
+ </config>
app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ // The blockGroup must match the first half of how we call the block, and controller matches the second half
7
+ // ie. foo_bar/adminhtml_baz
8
+ $this->_blockGroup = 'abcv_dimensions';
9
+ $this->_controller = 'adminhtml_dimensions';
10
+ $this->_headerText = $this->__('Dimensions');
11
+
12
+ parent::__construct();
13
+ }
14
+ }
app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ /**
5
+ * Init class
6
+ */
7
+ public function __construct()
8
+ {
9
+ $this->_blockGroup = 'abcv_dimensions';
10
+ $this->_controller = 'adminhtml_dimensions';
11
+
12
+ parent::__construct();
13
+
14
+ $this->_updateButton('save', 'label', Mage::helper('abcv_dimensions')->__('Save Dimensions'));
15
+ $this->_updateButton('delete', 'label', Mage::helper('abcv_dimensions')->__('Delete Dimensions'));
16
+ }
17
+
18
+ /**
19
+ * Get Header text
20
+ *
21
+ * @return string
22
+ */
23
+ public function getHeaderText()
24
+ {
25
+ if (Mage::registry('dimensions_data')->getId()) {
26
+ return Mage::helper('abcv_dimensions')->__('Edit Dimensions');
27
+ }
28
+ else {
29
+ return Mage::helper('abcv_dimensions')->__('New Dimensions');
30
+ }
31
+ }
32
+ }
app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(
7
+ array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit/Tab/Form.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('dimensions_form', array('legend'=>Mage::helper('abcv_dimensions')->__('Item information')));
10
+
11
+ //Get 1 demension row
12
+ $id = $this->getRequest()->getParam('id');
13
+ $model = Mage::getModel('abcv_dimensions/dimensions');
14
+ $arr = $model->load($id);
15
+ $row_dimension = $arr->_data;
16
+ $flag = 0;
17
+ if (!$id)//Add action
18
+ $flag = 1;
19
+ //DDL store, get core_store table
20
+ $allStores = Mage::app()->getStores();//get all store public
21
+ $ddl_store = array();
22
+ foreach ($allStores as $_eachStoreId => $val){
23
+ $_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
24
+ $site_id = str_replace('sid','',$_storeCode);
25
+ if ($site_id == 'default')
26
+ $site_id = "6";
27
+ //create data for DDL
28
+ $site_name = Mage::app()->getStore($_eachStoreId)->getName();
29
+ $ddl_store[] = array('value'=>$site_id,'label'=>$site_name);
30
+ //edit action
31
+ if ($row_dimension['SiteID'] == $site_id)
32
+ $flag = 1;
33
+ }
34
+
35
+ if($flag == 1):
36
+ //Print DDL
37
+ $fieldset->addField('SiteID', 'select', array(
38
+ 'label' => Mage::helper('abcv_dimensions')->__('SiteID'),
39
+ 'name' => 'SiteID',
40
+ 'values' => $ddl_store,
41
+ ));
42
+ endif;
43
+ //end DDL
44
+ $fieldset->addField('Name', 'text', array(
45
+ 'name' => 'Name',
46
+ 'label' => Mage::helper('abcv_dimensions')->__('Name'),
47
+ 'title' => Mage::helper('abcv_dimensions')->__('Name'),
48
+ 'required' => true,
49
+ ));
50
+ $fieldset->addField('W', 'text', array(
51
+ 'name' => 'W',
52
+ 'label' => Mage::helper('abcv_dimensions')->__('W'),
53
+ 'title' => Mage::helper('abcv_dimensions')->__('W'),
54
+ 'class' => 'required-entry validate-digits',
55
+ 'required' => true,
56
+ ));
57
+ $fieldset->addField('H', 'text', array(
58
+ 'name' => 'H',
59
+ 'label' => Mage::helper('abcv_dimensions')->__('H'),
60
+ 'title' => Mage::helper('abcv_dimensions')->__('H'),
61
+ 'class' => 'required-entry validate-digits',
62
+ 'required' => true,
63
+ ));
64
+ $fieldset->addField('RatioW', 'text', array(
65
+ 'name' => 'RatioW',
66
+ 'label' => Mage::helper('abcv_dimensions')->__('RatioW'),
67
+ 'title' => Mage::helper('abcv_dimensions')->__('RatioW'),
68
+ 'class' => 'required-entry validate-digits',
69
+ 'required' => true,
70
+ ));
71
+ $fieldset->addField('RatioH', 'text', array(
72
+ 'name' => 'RatioH',
73
+ 'label' => Mage::helper('abcv_dimensions')->__('RatioH'),
74
+ 'title' => Mage::helper('abcv_dimensions')->__('RatioH'),
75
+ 'class' => 'required-entry validate-digits',
76
+ 'required' => true,
77
+ ));
78
+ if ( Mage::getSingleton('adminhtml/session')->getCorestoreData() )
79
+ {
80
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCorestoreData());
81
+ Mage::getSingleton('adminhtml/session')->setCorestoreData(null);
82
+ } elseif ( Mage::registry('dimensions_data') ) {
83
+ $form->setValues(Mage::registry('dimensions_data')->getData());
84
+ }
85
+
86
+ return parent::_prepareForm();
87
+ }
88
+ }
app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Edit/Tabs.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('dimensions_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle($this->__('Dimensions Information'));
10
+ }
11
+
12
+ protected function _beforeToHtml()
13
+ {
14
+ $this->addTab('form_section', array(
15
+ 'label' => $this->__('Dimensions Information'),
16
+ 'title' => $this->__('Dimensions Information'),
17
+ 'content' => $this->getLayout()->createBlock('abcv_dimensions/adminhtml_dimensions_edit_tab_form')->toHtml(),
18
+ ));
19
+
20
+ return parent::_beforeToHtml();
21
+ }
22
+ }
app/code/local/Abcv/Dimensions/Block/Adminhtml/Dimensions/Grid.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Block_Adminhtml_Dimensions_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ // Set some defaults for our grid
9
+ $this->setDefaultSort('ID');
10
+ $this->setId('abcv_dimensions_grid');
11
+ $this->setDefaultDir('asc');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _getCollectionClass()
16
+ {
17
+ // This is the model we are using for the grid
18
+ return 'abcv_dimensions/dimensions_collection';
19
+ }
20
+
21
+ protected function _prepareCollection()
22
+ {
23
+ // Get and set our collection for the grid
24
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
25
+ //$collection->getSelect()->joinLeft(array('st' => 'core_store'),'main_table.SiteID = st.store_id',array('storename' => 'st.name'));
26
+ $this->setCollection($collection);
27
+
28
+ return parent::_prepareCollection();
29
+ }
30
+
31
+ protected function _prepareColumns()
32
+ {
33
+ //DDL search
34
+ $allStores = Mage::app()->getStores();//get all store public
35
+ $ddl_store = array();
36
+ foreach ($allStores as $_eachStoreId => $val){
37
+ $_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
38
+ $site_id = str_replace('sid','',$_storeCode);
39
+ if ($site_id == 'default')
40
+ $site_id = "6";
41
+ $site_name = Mage::app()->getStore($_eachStoreId)->getName();
42
+ $ddl_store[$site_id] = $site_name;
43
+ }
44
+ // Add the columns that should appear in the grid
45
+ $this->addColumn('ID', array(
46
+ 'header' => $this->__('ID'),
47
+ 'align' =>'left',
48
+ 'width' => '50px',
49
+ 'index' => 'ID',
50
+ ));
51
+
52
+ $this->addColumn('siteid', array(
53
+ 'header' => $this->__('SiteID'),
54
+ 'align' =>'left',
55
+ 'index' => 'SiteID',
56
+ 'width' => '60px',
57
+ ));
58
+ $this->addColumn('sitename', array(
59
+ 'header' => $this->__('Site Name'),
60
+ 'align' =>'left',
61
+ 'index' => 'SiteID',
62
+ 'type' => 'options',
63
+ 'options' => $ddl_store,
64
+ ));
65
+ $this->addColumn('name', array(
66
+ 'header' => $this->__('Name'),
67
+ 'align' =>'left',
68
+ 'index' => 'Name',
69
+ 'width' => '35%',
70
+ ));
71
+ $this->addColumn('w', array(
72
+ 'header' => $this->__('W'),
73
+ 'align' =>'left',
74
+ 'index' => 'W',
75
+ 'width' => '60px',
76
+ ));
77
+ $this->addColumn('h', array(
78
+ 'header' => $this->__('H'),
79
+ 'align' =>'left',
80
+ 'index' => 'H',
81
+ 'width' => '60px',
82
+ ));
83
+ $this->addColumn('radiow', array(
84
+ 'header' => $this->__('RatioW'),
85
+ 'align' =>'left',
86
+ 'index' => 'RatioW',
87
+ 'width' => '60px',
88
+ ));
89
+ $this->addColumn('radioh', array(
90
+ 'header' => $this->__('RatioH'),
91
+ 'align' =>'left',
92
+ 'index' => 'RatioH',
93
+ 'width' => '60px',
94
+ ));
95
+ $this->addColumn('action',
96
+ array(
97
+ 'header' => $this->__('Action'),
98
+ 'width' => '60px',
99
+ 'type' => 'action',
100
+ 'align' =>'center',
101
+ 'getter' => 'getId',
102
+ 'actions' => array(
103
+ array(
104
+ 'caption' => $this->__('Edit'),
105
+ 'url' => array('base'=> '*/*/edit'),
106
+ 'field' => 'id'
107
+ )
108
+ ),
109
+ 'filter' => false,
110
+ 'sortable' => false,
111
+ 'index' => 'stores',
112
+ 'is_system' => true,
113
+ ));
114
+ return parent::_prepareColumns();
115
+ }
116
+
117
+ public function getRowUrl($row)
118
+ {
119
+ // This is where our row data will link to
120
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
121
+ }
122
+ }
app/code/local/Abcv/Dimensions/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Abcv/Dimensions/Model/Dimensions.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Model_Dimensions extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_dimensions/dimensions');
7
+ }
8
+ }
app/code/local/Abcv/Dimensions/Model/Mysql4/Dimensions.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Model_Mysql4_Dimensions extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_dimensions/dimensions', 'ID');
7
+ }
8
+ }
app/code/local/Abcv/Dimensions/Model/Mysql4/Dimensions/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Model_Mysql4_Dimensions_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_dimensions/dimensions');
7
+ }
8
+ }
app/code/local/Abcv/Dimensions/controllers/Adminhtml/DimensionsController.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Dimensions_Adminhtml_DimensionsController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ // Let's call our initAction method which will set some basic params for each action
7
+ $this->_initAction()
8
+ ->renderLayout();
9
+ }
10
+
11
+ public function newAction()
12
+ {
13
+ // We just forward the new action to a blank edit form
14
+ $this->_forward('edit');
15
+ }
16
+
17
+ public function editAction()
18
+ {
19
+ $this->_initAction();
20
+
21
+ // Get id if available
22
+ $id = $this->getRequest()->getParam('id');
23
+ $model = Mage::getModel('abcv_dimensions/dimensions');
24
+
25
+ if ($id) {
26
+ // Load record
27
+ $model->load($id);
28
+
29
+ // Check if record is loaded
30
+ if (!$model->getId()) {
31
+ Mage::getSingleton('adminhtml/session')->addError($this->__('This baz no longer exists.'));
32
+ $this->_redirect('*/*/');
33
+
34
+ return;
35
+ }
36
+ }
37
+
38
+ $this->_title($model->getId() ? $model->getName() : $this->__('New Dimensions'));
39
+
40
+ $data = Mage::getSingleton('adminhtml/session')->getBazData(true);
41
+ if (!empty($data)) {
42
+ $model->setData($data);
43
+ }
44
+
45
+ Mage::register('dimensions_data', $model);
46
+
47
+ $this->_initAction()
48
+ ->_addBreadcrumb($id ? $this->__('Edit Dimensions') : $this->__('New Dimensions'), $id ? $this->__('Edit Dimensions') : $this->__('New Dimensions'))
49
+ ->_addContent($this->getLayout()->createBlock('abcv_dimensions/adminhtml_dimensions_edit')->setData('action', $this->getUrl('*/*/save')))
50
+ ->_addLeft($this->getLayout()->createBlock('abcv_dimensions/adminhtml_dimensions_edit_tabs'))
51
+ ->renderLayout();
52
+ }
53
+
54
+ public function saveAction()
55
+ {
56
+ if ($postData = $this->getRequest()->getPost()) {
57
+ $model = Mage::getSingleton('abcv_dimensions/dimensions');
58
+ $model->setData($postData)->setId($this->getRequest()->getParam('id'));
59
+
60
+ try {
61
+ $model->save();
62
+
63
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The baz has been saved.'));
64
+ $this->_redirect('*/*/');
65
+
66
+ return;
67
+ }
68
+ catch (Mage_Core_Exception $e) {
69
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
70
+ }
71
+ catch (Exception $e) {
72
+ Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this baz.'));
73
+ }
74
+
75
+ Mage::getSingleton('adminhtml/session')->setBazData($postData);
76
+ $this->_redirectReferer();
77
+ }
78
+ }
79
+
80
+ public function messageAction()
81
+ {
82
+ $data = Mage::getModel('abcv_dimensions/dimensions')->load($this->getRequest()->getParam('id'));
83
+ echo $data->getContent();
84
+ }
85
+ public function deleteAction() {
86
+ if( $this->getRequest()->getParam('id') > 0 ) {
87
+ try {
88
+ $model = Mage::getModel('abcv_dimensions/dimensions');
89
+
90
+ $model->setId($this->getRequest()->getParam('id'))
91
+ ->delete();
92
+
93
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Dimension was successfully deleted'));
94
+ $this->_redirect('*/*/');
95
+ } catch (Exception $e) {
96
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
97
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
98
+ }
99
+ }
100
+ $this->_redirect('*/*/');
101
+ }
102
+ /**
103
+ * Initialize action
104
+ *
105
+ * Here, we set the breadcrumbs and the active menu
106
+ *
107
+ * @return Mage_Adminhtml_Controller_Action
108
+ */
109
+ protected function _initAction()
110
+ {
111
+ $this->loadLayout()
112
+ // Make the active menu match the menu config nodes (without 'children' inbetween)
113
+ ->_setActiveMenu('editor/abcv_dimensions_dimensions')
114
+ ->_title($this->__('Editor'))->_title($this->__('Dimensions'))
115
+ ->_addBreadcrumb($this->__('Editor'), $this->__('Editor'))
116
+ ->_addBreadcrumb($this->__('Dimensions'), $this->__('Dimensions'));
117
+
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ * Check currently called action by permissions for current user
123
+ *
124
+ * @return bool
125
+ */
126
+ protected function _isAllowed()
127
+ {
128
+ return Mage::getSingleton('admin/session')->isAllowed('editor/abcv_dimensions_dimensions');
129
+ }
130
+ }
app/code/local/Abcv/Dimensions/etc/adminhtml.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <!--
5
+ This item will be created in the Admin menu under Sales
6
+ - If you want another section, reference the appropriate adminhtml.xml file in app/code/core/Mage/Modulename/etc
7
+ - For example, we found out this was 'sales' by referencing the config/menu node of app/code/core/Mage/Sales/etc/adminhtml.xml
8
+ -->
9
+ <editor>
10
+ <children>
11
+ <!-- Here, I like to use the namespacename_modulename_controllername naming convention -->
12
+ <abcv_dimensions_dimensions translate="title" module="abcv_dimensions">
13
+ <!-- This is how the menu text will be displayed -->
14
+ <title>Manage Dimensions</title>
15
+ <sort_order>10</sort_order>
16
+ <!-- This is the URL of what we want the menu item to link to -->
17
+ <action>adminhtml/dimensions</action>
18
+ </abcv_dimensions_dimensions>
19
+ </children>
20
+ </editor>
21
+ </menu>
22
+
23
+ <acl>
24
+ <resources>
25
+ <admin>
26
+ <children>
27
+ <!-- Same as above, but instead of referencing the config/menu node, you reference the acl/resources node of adminhtml.xml -->
28
+ <sales>
29
+ <children>
30
+ <!-- Keep the same naming convention as above -->
31
+ <abcv_dimensions_dimensions>
32
+ <!-- This is how the ACL text will be displayed on System > Permissions > Roles > Role > Role Resources -->
33
+ <title>Dimensions</title>
34
+ </abcv_dimensions_dimensions>
35
+ </children>
36
+ </sales>
37
+ </children>
38
+ </admin>
39
+ </resources>
40
+ </acl>
41
+ </config>
app/code/local/Abcv/Dimensions/etc/config.xml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <abcv_dimensions>
5
+ <version>1.0.0</version>
6
+ </abcv_dimensions>
7
+ </modules>
8
+
9
+ <global>
10
+ <helpers>
11
+ <abcv_dimensions>
12
+ <!-- This is where we define our helper directory -->
13
+ <class>Abcv_Dimensions_Helper</class>
14
+ </abcv_dimensions>
15
+ </helpers>
16
+
17
+ <blocks>
18
+ <abcv_dimensions>
19
+ <!-- Set a block definition and lookup directory -->
20
+ <class>Abcv_Dimensions_Block</class>
21
+ </abcv_dimensions>
22
+ </blocks>
23
+
24
+ <models>
25
+ <abcv_dimensions>
26
+ <!-- This is where we define our model directory -->
27
+ <class>Abcv_Dimensions_Model</class>
28
+ <!-- Define a resource to create a custom table -->
29
+ <resourceModel>abcv_dimensions_mysql14</resourceModel>
30
+ </abcv_dimensions>
31
+
32
+ <!-- Here's our resource model we'll use to create a database table -->
33
+ <abcv_dimensions_mysql14>
34
+ <class>Abcv_Dimensions_Model_Mysql4</class>
35
+ <entities>
36
+ <!-- Let's define our table, we'll call it with the baz name, but the real table is foo_bar_baz -->
37
+ <!-- After we define our entity, we can call it with our model by calling abcv_dimensions/baz -->
38
+ <dimensions>
39
+ <table>Dimensions</table>
40
+ </dimensions>
41
+ </entities>
42
+ </abcv_dimensions_mysql14>
43
+ </models>
44
+
45
+ <!-- And finally we define our resource setup script
46
+ <resources>
47
+ <abcv_dimensions_setup>
48
+ <setup>
49
+ <module>abcv_dimensions</module>
50
+ </setup>
51
+ </abcv_dimensions_setup>
52
+ </resources>
53
+ -->
54
+ </global>
55
+
56
+ <admin>
57
+ <routers>
58
+ <adminhtml>
59
+ <args>
60
+ <!-- This is how we load our Adminhtml controllers -->
61
+ <modules>
62
+ <abcv_dimensions before="Mage_Adminhtml">Abcv_Dimensions_Adminhtml</abcv_dimensions>
63
+ </modules>
64
+ </args>
65
+ </adminhtml>
66
+ </routers>
67
+ </admin>
68
+
69
+ <adminhtml>
70
+ <layout>
71
+ <updates>
72
+ <abcv_dimensions>
73
+ <!--
74
+ We again keep a nice naming convention and make our module upgrade proof by placing it in a separate folder
75
+ - Since we are in the adminhtml node, this will look for the XML file in the app/design/adminhtml/default/default root folder
76
+ -->
77
+ <file>abcv/dimensions.xml</file>
78
+ </abcv_dimensions>
79
+ </updates>
80
+ </layout>
81
+ </adminhtml>
82
+ </config>
app/code/local/Abcv/Editor/Block/Adminhtml/Customdyotab.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_Adminhtml_CustomDyotab extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
3
+ {
4
+ public function __construct(){
5
+ $this->setTemplate('editor/custom_dyotab.phtml');
6
+ parent::__construct();
7
+ }
8
+
9
+ //Label to be shown in the tab
10
+ public function getTabLabel(){
11
+ return Mage::helper('core')->__('Custom DYO');
12
+ }
13
+
14
+ //Title for contact
15
+ public function getTabTitle(){
16
+ return Mage::helper('core')->__('Custom DYO');
17
+ }
18
+
19
+ public function canShowTab(){
20
+ return true;
21
+ }
22
+
23
+ public function isHidden(){
24
+ return false;
25
+ }
26
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Dyotab.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_Adminhtml_Dyotab extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
3
+ {
4
+ public function __construct(){
5
+ $this->setTemplate('editor/dyotab.phtml');
6
+ parent::__construct();
7
+ }
8
+
9
+ //Label to be shown in the tab
10
+ public function getTabLabel(){
11
+ return Mage::helper('core')->__('DYO');
12
+ }
13
+
14
+ //Title for contact
15
+ public function getTabTitle(){
16
+ return Mage::helper('core')->__('DYO');
17
+ }
18
+
19
+ public function canShowTab(){
20
+ return true;
21
+ }
22
+
23
+ public function isHidden(){
24
+ return false;
25
+ }
26
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Editor.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_Adminhtml_Editor extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_editor';
7
+ $this->_blockGroup = 'editor';
8
+ $this->_headerText = Mage::helper('editor')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('editor')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Block_Adminhtml_Editor_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'editor';
11
+ $this->_controller = 'adminhtml_editor';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('editor')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('editor')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('editor_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'editor_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'editor_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('editor_data') && Mage::registry('editor_data')->getId() ) {
40
+ return Mage::helper('editor')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('editor_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('editor')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Block_Adminhtml_Editor_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Block_Adminhtml_Editor_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('editor_form', array('legend'=>Mage::helper('editor')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('editor')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('editor')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('editor')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('editor')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('editor')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('editor')->__('Content'),
43
+ 'title' => Mage::helper('editor')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getEditorData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getEditorData());
52
+ Mage::getSingleton('adminhtml/session')->setEditorData(null);
53
+ } elseif ( Mage::registry('editor_data') ) {
54
+ $form->setValues(Mage::registry('editor_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Block_Adminhtml_Editor_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('editor_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('editor')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('editor')->__('Item Information'),
18
+ 'title' => Mage::helper('editor')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('editor/adminhtml_editor_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Abcv/Editor/Block/Adminhtml/Editor/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Block_Adminhtml_Editor_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('editorGrid');
9
+ $this->setDefaultSort('editor_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('editor/editor')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('editor_id', array(
24
+ 'header' => Mage::helper('editor')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'editor_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('editor')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('editor')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('editor')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('editor')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('editor')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('editor')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('editor')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('editor_id');
84
+ $this->getMassactionBlock()->setFormFieldName('editor');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('editor')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('editor')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('editor/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('editor')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('editor')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/local/Abcv/Editor/Block/Cart/Item/Renderer.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
3
+ {
4
+ public function getLoadedProduct()
5
+ {
6
+ return $this->getProduct()->load($this->getProduct()->getId());
7
+ }
8
+
9
+ public function getSetupFee()
10
+ {
11
+ return $this->getLoadedProduct()->getSetupFee();
12
+ }
13
+ }
14
+ ?>
app/code/local/Abcv/Editor/Block/Choosetemplate.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_ChooseTemplate extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getChooseTemplate()
10
+ {
11
+ if (!$this->hasData('chooseTemplate')) {
12
+ $this->setData('chooseTemplate', Mage::registry('chooseTemplate'));
13
+ }
14
+ return $this->getData('chooseTemplate');
15
+
16
+ }
17
+ }
app/code/local/Abcv/Editor/Block/Editor.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_Editor extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getEditor()
10
+ {
11
+ if (!$this->hasData('editor')) {
12
+ $this->setData('editor', Mage::registry('editor'));
13
+ }
14
+ return $this->getData('editor');
15
+
16
+ }
17
+
18
+ function savingPrice($price, $unitPrice)
19
+ {
20
+ //if ($product->getFinalPrice() != $product->getPrice())
21
+ //if ($qty*$price != $product->getPrice())
22
+ //{
23
+ //$saving = $product->getPrice() - $product->getFinalPrice();
24
+ $saving = $price*100/$unitPrice;
25
+ $saving = number_format(100-$saving);
26
+ return $saving.'%';
27
+ //}
28
+ //return $this->__('no save');
29
+ }
30
+
31
+
32
+ function savingPriceTemp($product)
33
+ {
34
+ $_coreHelper = Mage::helper('core');
35
+ $_taxHelper = Mage::helper('tax');
36
+
37
+ //if ($product->getFinalPrice() != $product->getPrice())
38
+ if ($product->getQty()*$product->getPrice() != $product->getPrice())
39
+ {
40
+ $saving = $product->getPrice() - $product->getFinalPrice();
41
+ return $this->__('Save ').$_coreHelper->currency($_taxHelper->getPrice($product, $saving, true), true, false);
42
+ }
43
+ return $this->__('no save');
44
+ }
45
+
46
+ function savingPercent($product)
47
+ {
48
+ if ($product->getFinalPrice() != $product->getPrice())
49
+ {
50
+ $saving = $product->getPrice() - $product->getFinalPrice();
51
+ $saving = number_format($saving / $product->getPrice() * 100);
52
+ return $this->__('Save ').$saving.'%';
53
+ }
54
+ }
55
+ function getProductByDimension(){
56
+
57
+
58
+ //$dbh = new PDO('mysql:host=localhost;dbname=dyo3victory', 'root', '');
59
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
60
+
61
+ $template_id = $this->getRequest()->getParam('id');
62
+
63
+
64
+ $productIds = array();
65
+ $query = "SELECT product_id from abcv_product_sides where dimension_id in (select Dimension as dimension_id from Templates where ID = '$template_id' and SiteID = 26) and site_id = 26";
66
+ //echo $query;
67
+ $result = $read->fetchAll($query);
68
+ //print_r($result);
69
+ //foreach ($dbh->query($query) as $row) {
70
+ foreach ($result as $row) {
71
+ $productIds[] = (int)$row['product_id'];
72
+ }
73
+
74
+
75
+ $products = Mage::getModel('catalog/product')->getCollection()
76
+ ->addAttributeToSelect('*')
77
+ ->addAttributeToFilter('entity_id', array('in' => $productIds));
78
+ return $products;
79
+
80
+ }
81
+ public function getPriceHtml($product)
82
+ {
83
+ $this->setTemplate('catalog/product/price.phtml');
84
+ $this->setProduct($product);
85
+ return $this->toHtml();
86
+ }
87
+
88
+ }
app/code/local/Abcv/Editor/Block/Product.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Block_Product extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct() {
5
+ parent::__construct();
6
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
7
+
8
+ if ($customerData->getId() == 0)
9
+ {
10
+ $save_ids = array();
11
+ $objCookie = Mage::getModel('core/cookie')->get('dyo3st');
12
+ if ($objCookie)
13
+ foreach ($objCookie as $id => $pass)
14
+ array_push($save_ids, $id);
15
+ else
16
+ $save_ids = "-1";
17
+ $collection_cookie = Mage::getModel('editor/product')->getCollection()->addFieldToFilter('save_id', $save_ids)->addfieldtofilter('customer_id', $customerData->getId());
18
+ $this->setCollection($collection_cookie);
19
+ }
20
+ else
21
+ {
22
+ $collection_customer = Mage::getModel('editor/product')->getCollection()->addfieldtofilter('customer_id', $customerData->getId());
23
+ $this->setCollection($collection_customer);
24
+ }
25
+ }
26
+
27
+ public function _prepareLayout()
28
+ {
29
+ parent::_prepareLayout();
30
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
31
+ $pager->setAvailableLimit(array(20=>20,30=>30,50=>50));
32
+ $pager->setCollection($this->getCollection());
33
+ $this->setChild('pager', $pager);
34
+ $this->getCollection()->load();
35
+ return $this;
36
+ }
37
+ public function getPagerHtml() {
38
+ return $this->getChildHtml('pager');
39
+ }
40
+ public function getContentHtml(){
41
+ $collection = $this->getCollection();
42
+ $productsDesigns = array();
43
+ foreach ($collection as $record) {
44
+ $t = $record->toArray();
45
+ $productsDesigns[] = $t;
46
+ }
47
+ $html = "<script><!-- \$jquery('.dyo_gridCell_footer').find('input[type=checkbox]').change(function () {
48
+ \$jquery('.error-msg').hide(200);
49
+ \$jquery('.success-msg').hide(200);
50
+ });
51
+ -->
52
+ </script>";
53
+ $html .= "<div class='dyo_gridShell'>";
54
+ foreach($productsDesigns as $design)
55
+ {
56
+ $pos = strpos($design['product_id'], 'quote_');
57
+ if ($pos === false) //no quote, new template
58
+ {
59
+ $product_id = str_replace("product_", "", $design['product_id']);
60
+ $url = '/editor/index/template/template/'.$design['template_id'].'/product/'.$product_id.'/productstyle/'.$design['productstyle_id'].'/save/'.$design['save_id'];
61
+ }
62
+ else//quote
63
+ {
64
+ $product_id = str_replace("quote_", "", $design['product_id']);
65
+ $url = '/editor/index/template/template/'.$design['template_id'].'/product/'.$product_id.'/productstyle/'.$design['productstyle_id'].'/save/'.$design['save_id'].'/editor/'.rand();
66
+ }
67
+ $html .= "<div class=dyo_gridCell id='cell_".$design['save_id']."'>";
68
+
69
+
70
+ $html .= "<a class='open' href='#' onclick='\$jquery(\"#hiddenSaveId\").val(".$design['save_id'].");\$jquery(\"#dialog-confirm\").dialog(\"open\");'>delete</a>";
71
+
72
+ $html .= "<div class='dyo_gridCell_content'>";
73
+ $images = json_decode($design['image'], true);
74
+ $html .= "<script type='text/javascript'><!-- var imagesDYO = new Array();";
75
+ $html .="if (typeof imagesDYO === 'undefined') var imagesDYO = {};";
76
+ $html .="imagesDYO[".$design['save_id']."] = new Array();";
77
+ for($index=0; $index< count($images); $index++)
78
+
79
+ $html.= 'imagesDYO['.$design['save_id'].'].push("'.$images[$index]['imageData'].'");';
80
+
81
+ $html .= "--> </script>";
82
+
83
+
84
+ $tip = "Tip('Click to continue design');switchImages(this,imagesDYO[".$design['save_id']."]);";
85
+ $html .= "<a href=\"".$url."\" onmouseover=\"".$tip."\" onmouseout='UnTip();outTagImages(this,imagesDYO[".$design['save_id']."]);'>";
86
+
87
+ for ($index=0; $index < count($images); $index++)
88
+ {
89
+ if ($index != 0)
90
+ $html .= '<img alt='. $index.' style="display:none;" src="'.$images[$index]['imageData'].'" />';
91
+ else
92
+ $html .= '<img alt='. $index.' src="'.$images[$index]['imageData'].'" />';
93
+ }
94
+ //$html .= '<img src="'.$images[0]['imageData'].'" />';
95
+
96
+ //$html .= "<img src='".$design['image']."' />";
97
+ $html .= "</a> ";
98
+ $html .= "</div>";
99
+ $html .= "<div class='dyo_gridCell_footer'>";
100
+ $html .= "<input type='checkbox' value=".$design['save_id']." /><span>".$design['date_at']."</span>";
101
+ $html .= "</div>";
102
+
103
+ $html .= "</div>";
104
+ }
105
+ $html .= "</div>";
106
+ return $html;
107
+ }
108
+ public function getProduct()
109
+ {
110
+ if (!$this->hasData('product')) {
111
+ $this->setData('product', Mage::registry('product'));
112
+ }
113
+ return $this->getData('product');
114
+
115
+ }
116
+
117
+ }
app/code/local/Abcv/Editor/Helper/Data.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ function getDYOImages($dyo_product_id, $get_first_image = false){
6
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
7
+ $readresult = $read->query("SELECT * FROM abcv_product_sides WHERE product_id='$dyo_product_id'");
8
+ $_images_array = array();
9
+ while ($rows = $readresult->fetch()) //each sides
10
+ {
11
+ $side_id_db = $rows['side_id'];
12
+ $side_name = $rows['side_name'];
13
+ $default_template_id = $rows['default_template_id'];
14
+ //Showing ProductStyles in database
15
+ $readProductStyles = $read->query("SELECT * FROM ProductStyles WHERE productside_id ='$side_id_db' AND is_deleted = '0' AND is_show = 1 ORDER BY sortorder ASC");
16
+ while ($rowsProductStyle = $readProductStyles->fetch())
17
+ {
18
+ $imageObj = new stdClass();
19
+ $productstyle_name = $rowsProductStyle['StyleName'];
20
+ $productstyle_id = $rowsProductStyle['ID'];
21
+ $is_overlay = $rowsProductStyle['is_overlay'];
22
+ $sortorder = $rowsProductStyle['sortorder'];
23
+ $is_hidden = $rowsProductStyle['is_show'];
24
+ $url_product_style = "/image.php?ID=".$productstyle_id."&style";
25
+ $url_template = '/image.php?ID='.$default_template_id.'&template';
26
+ $url_full = '/images/dyotab/dyotab_'.$productstyle_id.'.png';
27
+ $rowPath = '';
28
+ if ($is_overlay==0)
29
+ $imageObj->image_url = $url_product_style;
30
+ else
31
+ $imageObj->image_url = $url_full;
32
+ $name = ($productstyle_name=='')?$side_name:$side_name.' : '.$productstyle_name;
33
+ $imageObj->image_name = $name;
34
+ Array_push($_images_array, $imageObj);
35
+ if($get_first_image) break;
36
+ }
37
+ if($get_first_image && count($_images_array) > 0) break;
38
+ }
39
+ return $_images_array;
40
+ }
41
+
42
+ function rebuildTemplateCategory($site_id = 6){
43
+ //require_once("/dyo3-functions/f_ShowTemplates.php");
44
+ //if($site_id == null)
45
+ $cache = Mage::app()->getCache();
46
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
47
+ $sql= "SELECT ID FROM Dimensions";
48
+ if(!empty($site_id)) $sql .= " WHERE SiteID = '$site_id'";
49
+ $result = $read->query($sql);
50
+ while($row = $result->fetch()){
51
+ $key = "f_ShowTemplates_". $site_id. "_". $row['ID'];
52
+ $cache->remove($key);
53
+ //$cache->clean(array("tplAssociateCate"));
54
+ }
55
+ }
56
+
57
+ function isAccessFromMobile() {
58
+ // $browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone") || strpos($_SERVER['HTTP_USER_AGENT'],"iPod") || strpos($_SERVER['HTTP_USER_AGENT'],"Android");
59
+ // if ($browser == true && $ci->config->item('fullsize')==0 ) {
60
+ // return true;
61
+ // }
62
+ // return false;
63
+ $regex_match = "/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"
64
+ . "htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"
65
+ . "blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"
66
+ . "symbian|smartphone|mmp|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"
67
+ . "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"
68
+ . ")/i";
69
+
70
+ if (preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']))) {
71
+ return TRUE;
72
+ }
73
+
74
+ if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
75
+ return TRUE;
76
+ }
77
+
78
+ $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
79
+ $mobile_agents = array(
80
+ 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
81
+ 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
82
+ 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
83
+ 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
84
+ 'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
85
+ 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
86
+ 'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
87
+ 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
88
+ 'wapr','webc','winw','winw','xda ','xda-');
89
+
90
+ if (in_array($mobile_ua,$mobile_agents)) {
91
+ return TRUE;
92
+ }
93
+
94
+ if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {
95
+ return TRUE;
96
+ }
97
+
98
+ return FALSE;
99
+ }
100
+
101
+ function getCustomizePrice($productid, $site_id, $is_not_customize){
102
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
103
+ $customize_price = 0;
104
+ $is_notCustomize_template = false;
105
+ //Customer desgin template
106
+ if ($is_not_customize != null && $is_not_customize == 0)
107
+ {
108
+ $query = "SELECT * FROM abcv_product_options_checkbox WHERE site_id='$site_id' And product_id = '$productid' And attr = 'AllowCustomizeTemplate'";
109
+ $customize_template = $read->fetchRow($query);
110
+ if ($customize_template != null && $customize_template['value'] == 'true')
111
+ $is_notCustomize_template = true;
112
+ if ($is_notCustomize_template)
113
+ {
114
+ $query = "SELECT * FROM abcv_product_options_checkbox WHERE site_id='$site_id' And product_id = '$productid' And attr = 'Price'";
115
+ $customize_price = $read->fetchRow($query);
116
+ $customize_price = ($customize_price==null)?0:$customize_price['value'];
117
+ }
118
+ }
119
+ return $customize_price;
120
+ }
121
+
122
+ function getApparelAdditionalCharge($quote){
123
+ $apparelOptions = $quote->getBuyRequest()->getData('apparel');
124
+ $apparelAdditionalCharge = 0;
125
+ foreach($apparelOptions as $appOptionKey => $appOptionValue){
126
+ $optionApparelObject = $quote->getProduct()->getOptionById($appOptionKey);
127
+ foreach($appOptionValue as $appKey => $appValue){
128
+ if(empty($appValue)) continue;
129
+ $itemApparelObject = $optionApparelObject->getValueById($appKey);
130
+ if($itemApparelObject->getPrice() > 0){
131
+ $apparelAdditionalCharge += $appValue * $itemApparelObject->getPrice();
132
+ }
133
+ }
134
+ }
135
+ return $apparelAdditionalCharge;
136
+ }
137
+ }
app/code/local/Abcv/Editor/Model/Editor.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Editor extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('editor/editor');
9
+ }
10
+ }
app/code/local/Abcv/Editor/Model/Mysql4/Editor.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Mysql4_Editor extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the editor_id refers to the key field in your database table.
8
+ $this->_init('editor/editor', 'editor_id');
9
+ }
10
+ }
app/code/local/Abcv/Editor/Model/Mysql4/Editor/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Mysql4_Editor_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('editor/editor');
9
+ }
10
+ }
app/code/local/Abcv/Editor/Model/Mysql4/Product.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Mysql4_Product extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the editor_id refers to the key field in your database table.
8
+ $this->_init('editor/product', 'save_id');
9
+ }
10
+ }
app/code/local/Abcv/Editor/Model/Mysql4/Product/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Mysql4_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('editor/product');
9
+ }
10
+ }
app/code/local/Abcv/Editor/Model/Observer.php ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Model_Observer
3
+ {
4
+
5
+ public function setCartCondition(Varien_Event_Observer $observer){
6
+
7
+ $curr_time = time();
8
+ $quote_time = Mage::getSingleton('core/session')->quote_time;
9
+ if($quote_time == null || $curr_time > $quote_time){
10
+ Mage::getSingleton('core/session')->setCustomshippingcostAmount(0);
11
+ Mage::getSingleton('core/session')->setCustomshippingcostDescription(null);
12
+ Mage::getSingleton('core/session')->proposal_quote_id = null;
13
+
14
+ Mage::getSingleton('core/session')->shippingcostAmount = 0;
15
+ Mage::getSingleton('core/session')->shippingcostDescription = '';
16
+
17
+ }
18
+
19
+
20
+ }
21
+ public function modifyPrice(Varien_Event_Observer $observer)
22
+ {
23
+
24
+
25
+
26
+
27
+ $customPrice = Mage::registry('customPrice');
28
+ if (!empty($customPrice) && $customPrice > 0) {
29
+
30
+ $event = $observer->getEvent();
31
+ $quote_item = $event->getQuoteItem();
32
+
33
+
34
+ //Abcv_Editor_Model_Quote_Item
35
+ $quote_item->setCustomPrice($customPrice)->setOriginalCustomPrice($customPrice);
36
+ }
37
+
38
+
39
+ }
40
+
41
+ public function getPriceFromTierPricesQty ($item_qty, $tierPrices)
42
+ {
43
+ if ($tierPrices == null || count($tierPrices) == 0 || $item_qty == 1)
44
+ return 0;
45
+ $price = 0;
46
+ $previous_tierPrices = null;
47
+ foreach ($tierPrices as $_index => $item_tierPrices)
48
+ {
49
+ $_qty = $item_tierPrices['qty'];
50
+ if($item_qty > $_qty){
51
+ //don't thing
52
+ }
53
+ elseif ($item_qty < $_qty)
54
+ {
55
+ $price = $previous_tierPrices['price'];
56
+ }
57
+ elseif ($item_qty == $_qty)
58
+ {
59
+ $price += $item_tierPrices['price'];
60
+ break;
61
+ }
62
+ $previous_tierPrices = $item_tierPrices;
63
+ }
64
+ if ($price == 0 && $previous_tierPrices != null && $item_qty > $previous_tierPrices['qty'])
65
+ {
66
+ $price += $previous_tierPrices['price'];
67
+ }
68
+ return $price;
69
+ }
70
+ public function updatePrice($e)
71
+ {
72
+
73
+ /*
74
+ * <!-- 2014-05-14 DANG COMMENT- change to use rewrite method
75
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
76
+
77
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
78
+ $site_id = str_replace('sid','',Mage::app()->getStore()->getCode());
79
+ if ($site_id == "default") $site_id = 6;
80
+ $params = null;
81
+ if ($e->getRequest() != null)
82
+ $params = $e->getRequest()->getParams();
83
+ foreach($quote->getAllVisibleItems() as $item) {
84
+
85
+ $item_id = $item->getBuyRequest()->getData('id');
86
+ if (!isset($params['id']))
87
+ {
88
+ $params['id'] = $item_id;
89
+ $params['is_not_customize'] = $item->getBuyRequest()->getData('is_not_customize');
90
+ $params['options'] = $item->getBuyRequest()->getData('options');
91
+
92
+ }
93
+ if ($params['id'] == $item_id){
94
+ $is_not_customize = $params['is_not_customize'];
95
+ if ($is_not_customize != null && $is_not_customize == 0) //Customer desgin template
96
+ {
97
+ $product = $item->getProduct();
98
+ $item_qty = $item->getQty();
99
+ $price = (double)($product->getPrice());
100
+ $options= $params['options'];
101
+ $productoption = $product->getOptions();
102
+ foreach($productoption as $optionKey => $optionVal)
103
+ {
104
+ //get is_color_option
105
+ $optionArr = $optionVal->toArray();
106
+ foreach ($options as $key_group_id => $option_id){
107
+ if ($key_group_id == $optionVal->getId()){
108
+ $is_color_option = $optionArr['dyo_option'] == 'dyocolor';
109
+ foreach($optionVal->getValues() as $valuesKey => $valuesVal)
110
+ {
111
+ if($option_id ==$valuesVal->getId())
112
+ {
113
+ //$flag_price = true;
114
+ //getting tier Prices
115
+ if($is_color_option){ //color
116
+ $price -= (double)($product->getPrice());
117
+ $value = $valuesVal->toArray();
118
+ $tierPrices = $value['tiers'];
119
+ if ($item_qty != 1 && $tierPrices != null){
120
+ $price += $this->getPriceFromTierPricesQty($item_qty, $tierPrices);
121
+ }
122
+ else
123
+ {
124
+ $price += $valuesVal->getPrice();
125
+ }
126
+ }
127
+ else
128
+ {
129
+ $price += $valuesVal->getPrice();
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ }
136
+ }
137
+ //getting tier price
138
+ if ($item_qty != 1)
139
+ {
140
+ $_tierPrices = $product->getTierPrice();
141
+ Mage::helper('weee')->processTierPrices($product, $_tierPrices);
142
+ $tierPricesArr = array();
143
+ foreach ($_tierPrices as $_index => $_price){
144
+ $tierPrice = array(
145
+ 'qty' => $_price['price_qty'],
146
+ 'price' => $_price['price'],
147
+ );
148
+ $tierPricesArr[] = $tierPrice;
149
+ }
150
+ if (count($tierPricesArr) != 0)
151
+ {
152
+ $price -= (double)($product->getPrice());
153
+ $price += $this->getPriceFromTierPricesQty($item_qty, $tierPricesArr);
154
+ }
155
+ }
156
+
157
+ $productid = $product->getId();
158
+
159
+ $query = "SELECT * FROM abcv_product_options_checkbox WHERE site_id='$site_id' And product_id = '$productid' And attr = 'AllowCustomizeTemplate'";
160
+ $customize_template = $read->fetchRow($query);
161
+ $is_notCustomize_template = false;
162
+ //missed: check stock product
163
+ if ($customize_template != null && $customize_template['value'] == 'true')
164
+ $is_notCustomize_template = true;
165
+
166
+ if ($is_notCustomize_template)
167
+ {
168
+ $query = "SELECT * FROM abcv_product_options_checkbox WHERE site_id='$site_id' And product_id = '$productid' And attr = 'Price'";
169
+ $customize_price = $read->fetchRow($query);
170
+ $customize_price = ($customize_price==null)?0:$customize_price['value'];
171
+ $price += (double)($customize_price);
172
+ }
173
+ // Set the custom price
174
+ $item->setCustomPrice($price);
175
+ $item->setOriginalCustomPrice($price);
176
+ // Enable super mode on the product.
177
+ $item->getProduct()->setIsSuperMode(true);
178
+ }
179
+ }
180
+ }
181
+ $quote->save();
182
+ //fclose($file);
183
+
184
+ <!-- 2014-05-14 END DANG COMMENT- change to use rewrite method*/
185
+ }
186
+
187
+ public function hookToControllerActionPreDispatch(Varien_Event_Observer $observer)
188
+ {
189
+
190
+
191
+ if($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')
192
+ {
193
+
194
+
195
+ Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
196
+ }
197
+ }
198
+
199
+ public function hookToAddToCartBefore(Varien_Event_Observer $observer)
200
+ {
201
+
202
+
203
+
204
+ $params = $observer->getEvent()->getRequest()->getParams();
205
+
206
+
207
+ /** HUY: begin 2014-04-16 **/
208
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
209
+ $site_id = str_replace('sid','',Mage::app()->getStore()->getCode());
210
+ if ($site_id == "default") $site_id = 6;
211
+ $productid = $params['product'];
212
+ $query = "SELECT * FROM abcv_product_options_checkbox WHERE site_id='$site_id' And product_id = '$productid' And attr = 'AllowCustomizeTemplate'";
213
+ $customize_template = $read->fetchRow($query);
214
+ $is_has_allow_customize = '0';
215
+ if ($customize_template != null && $customize_template['value'] == 'true')
216
+ $is_has_allow_customize = '1';
217
+
218
+
219
+ /** HUY: end 2014-04-16 **/
220
+
221
+ Mage::app()->getRequest()->setParam('is_has_allow_customize', $is_has_allow_customize);
222
+ Mage::app()->getRequest()->setParam('add_to_cart_from', 'the_product_page');
223
+ }
224
+
225
+ public function hookToQquoteadvControllerActionPreDispatch(Varien_Event_Observer $observer)
226
+ {
227
+ $action_name = $observer->getEvent()->getControllerAction()->getFullActionName();
228
+ if($action_name == 'qquoteadv_view_history' || $action_name == 'qquoteadv_index_gotoquote')
229
+ {
230
+
231
+
232
+ Mage::dispatchEvent("view_qquoteadv_history_before", array('request' => $observer->getControllerAction()->getRequest()));
233
+ }
234
+ }
235
+
236
+
237
+ public function hookToViewQquoteadvHistoryBefore(Varien_Event_Observer $observer){
238
+
239
+ $params = $observer->getEvent()->getRequest()->getParams();
240
+
241
+ Mage::log(var_export($params, true), null, 'mylogfile.log');
242
+
243
+
244
+ if(isset($params['key']) && isset($params['quote'])
245
+ //&& Mage::getModel('qquoteadv/qqadvcustomer')->load($params['quote'])->status != Ophirah_Qquoteadv_Model_Status::STATUS_CONFIRMED
246
+ ){
247
+ // new data
248
+
249
+ $quoteId = $params['quote'];
250
+
251
+ // Mage::getSingleton('core/session')->proposal_quote_id = $quoteId;
252
+ Mage::getSingleton('core/session')->setProposalQuoteId($quoteId);
253
+
254
+ $encrypt_email = str_replace("abcvirtual",'/', $params['key']);
255
+
256
+ $encrypt_email = str_replace(" ",'+', $encrypt_email);
257
+
258
+ $a_received_email = explode('-', $this->fnDecrypt($encrypt_email, 'abcv'));
259
+
260
+ $received_email = isset($a_received_email['1']) ? $a_received_email['1'] : '';
261
+
262
+
263
+ $quote_status = Mage::getModel('qquoteadv/qqadvcustomer')->load($params['quote'])->status;
264
+
265
+ if (Mage::getSingleton('customer/session')->isLoggedIn()){
266
+ // login
267
+
268
+ $email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
269
+
270
+
271
+ if ($email == $received_email){
272
+ //same
273
+ $add_to_checkout = true;
274
+
275
+ }else{
276
+ //not same
277
+ $add_to_checkout = false;
278
+ Mage::getSingleton('core/session')->setMyReceivedEmailVariable($received_email);
279
+
280
+ if (
281
+ $quote_status != Ophirah_Qquoteadv_Model_Status::STATUS_ORDERED &&
282
+ $quote_status != Ophirah_Qquoteadv_Model_Status::STATUS_PROPOSAL_EXPIRED &&
283
+ $quote_status != Ophirah_Qquoteadv_Model_Status::STATUS_CANCELED
284
+
285
+ ){
286
+ // status not ordered, expired, canceled
287
+
288
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl("qquoteadv/view/account", array('quote'=>$quoteId)));
289
+ }
290
+
291
+ }
292
+
293
+ }else{
294
+ // no login
295
+ $add_to_checkout = true;
296
+
297
+ $customer = Mage::getModel('customer/customer');
298
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
299
+ $customer->loadByEmail(trim($received_email));
300
+
301
+ Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer)
302
+ ->renewSession();
303
+
304
+
305
+ }
306
+
307
+ if ($quote_status == Ophirah_Qquoteadv_Model_Status:: STATUS_ORDERED ||
308
+
309
+ $quote_status == Ophirah_Qquoteadv_Model_Status:: STATUS_PROPOSAL_EXPIRED ||
310
+ $quote_status == Ophirah_Qquoteadv_Model_Status:: STATUS_CANCELED
311
+ ){
312
+
313
+
314
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl("qquoteadv/view/history"));
315
+ $add_to_checkout = false;
316
+ }
317
+ Mage::log(var_export($params, true), null, 'mylogfile.log');
318
+ Mage::log("1". $add_to_checkout, null, 'mylogfile.log');
319
+ if ($add_to_checkout){
320
+
321
+ // update quotation status
322
+
323
+ $data = array(
324
+ 'updated_at' => NOW(),
325
+ 'status' => Ophirah_Qquoteadv_Model_Status::STATUS_CONFIRMED
326
+ );
327
+ Mage::getModel('qquoteadv/qqadvcustomer')->updateQuote($quoteId, $data)->save();
328
+
329
+
330
+ $cart = Mage::getModel('checkout/cart');
331
+ $cart->truncate(); // remove all active items in cart page
332
+
333
+
334
+ $quote = Mage::getSingleton('qquoteadv/qqadvcustomer')->load($quoteId);
335
+
336
+
337
+
338
+ $resource = Mage::getSingleton('core/resource');
339
+ $read = $resource->getConnection('core_read');
340
+ $tblProduct = $resource->getTableName('quoteadv_product');
341
+ $tblRequestItem = $resource->getTableName('quoteadv_request_item');
342
+
343
+ $sql = "select * from $tblProduct p INNER JOIN $tblRequestItem i
344
+ ON p.quote_id=i.quote_id
345
+ AND i.quoteadv_product_id=p.id AND p.quote_id=$quoteId";
346
+
347
+ $data = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($sql);
348
+
349
+ //add items from quote to cart
350
+ // $cart = Mage::getSingleton('checkout/cart')->init();
351
+ $cart = Mage::getModel('checkout/cart')->init();
352
+
353
+
354
+ foreach ($data as $item) {
355
+ $productId = $item['product_id'];
356
+
357
+ $product = Mage::getModel('catalog/product')->load($productId);
358
+
359
+
360
+
361
+ //observer will check customPrice after add item to card/quote
362
+
363
+ Mage::register('customPrice', $item['owner_cur_price']);
364
+
365
+ if ($product->getTypeId() == 'bundle') {
366
+ $attr = array();
367
+ $attr[$productId] = @unserialize($item['attribute']);
368
+ $attr[$productId]['qty'] = (int)$item['request_qty'];
369
+ $cart->addProduct($attr);
370
+ } else {
371
+ $params = @unserialize($item['attribute']);
372
+ $params['qty'] = (int)$item['request_qty'];
373
+
374
+ try {
375
+ $cart->addProduct($product, $params);
376
+ } catch (Exception $e) {
377
+ Mage::log($e->getMessage());
378
+ }
379
+ }
380
+ Mage::unregister('customPrice');
381
+ }
382
+ $cart->save();
383
+ //Set cusstom shipping method
384
+ Mage::getSingleton('core/session')->quote_time = time() + 30;
385
+ Mage::getSingleton('core/session')->shippingcostAmount = $quote->getData('shipping_price');
386
+ Mage::getSingleton('core/session')->shippingcostDescription = $quote->getData('shipping_method_title');
387
+
388
+ Mage::getSingleton('core/session')->proposal_quote_id = $quoteId;
389
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl("checkout/onepage", array('quoteadv' => $quoteId)));
390
+ }
391
+
392
+ }else{
393
+ // old data
394
+ // do nothing
395
+ }
396
+
397
+ }
398
+
399
+ public function setC2qRefNumberAndStatus(Varien_Event_Observer $observer){
400
+ $order = $observer->getOrder();
401
+ if ($quoteId = Mage::getSingleton('core/session')->proposal_quote_id) {
402
+ $order->setData('c2q_internal_quote_id', $quoteId);
403
+ }
404
+ $data = array(
405
+ 'updated_at' => NOW(),
406
+ 'status' => Ophirah_Qquoteadv_Model_Status::STATUS_ORDERED
407
+ );
408
+ Mage::getModel('qquoteadv/qqadvcustomer')->updateQuote($quoteId, $data)->save();
409
+ Mage::getSingleton('core/session')->proposal_quote_id = null;
410
+ }
411
+
412
+ public function fnDecrypt($sValue, $sSecretKey)
413
+ {
414
+ return rtrim(
415
+ mcrypt_decrypt(
416
+ MCRYPT_RIJNDAEL_256,
417
+ $sSecretKey,
418
+ base64_decode($sValue),
419
+ MCRYPT_MODE_ECB,
420
+ mcrypt_create_iv(
421
+ mcrypt_get_iv_size(
422
+ MCRYPT_RIJNDAEL_256,
423
+ MCRYPT_MODE_ECB
424
+ ),
425
+ MCRYPT_RAND
426
+ )
427
+ ), "\0"
428
+ );
429
+ }
430
+
431
+ }
app/code/local/Abcv/Editor/Model/Product.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Product extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('editor/product');
9
+ }
10
+ }
app/code/local/Abcv/Editor/Model/Quote/Item.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Model_Quote_Item extends Mage_Sales_Model_Quote_Item
3
+ {
4
+ public function calcRowTotal()
5
+ {
6
+ parent::calcRowTotal();
7
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
8
+
9
+ $product = $this->getProduct();
10
+ $product->load($product->getId());
11
+
12
+ //addtional fee
13
+ $addtional_fee = 0;
14
+ $apparelOptionId = 0;
15
+ $apparelOption = $this->getBuyRequest()->getData('apparel');
16
+ if(!empty($apparelOption)){
17
+ foreach($apparelOption as $apparelKey => $apparelValue){
18
+ $apparelOptionId = $apparelKey;
19
+ break;
20
+ }
21
+ }
22
+
23
+ $productoption = $product->getOptions();
24
+ foreach($productoption as $optionKey => $optionVal)
25
+ {
26
+ if($optionVal->getId() == $apparelOptionId){
27
+ foreach($optionVal->getValues() as $valuesKey => $valuesVal){
28
+ $itemArray = $valuesVal->toArray();
29
+ if(isset($apparelOption[$itemArray['option_id']])
30
+ && !empty($apparelOption[$itemArray['option_id']][$itemArray['option_type_id']])){
31
+ $itemArray['value'] = $apparelOption[$itemArray['option_id']][$itemArray['option_type_id']];
32
+ $addtional_fee += $itemArray['price'] * $itemArray['value'];
33
+ }
34
+ }
35
+ break;
36
+ }
37
+ }
38
+
39
+ //customize_template fee
40
+ $is_not_customize = $this->getBuyRequest()->getData('is_not_customize');
41
+ $site_id = str_replace('sid','',Mage::app()->getStore()->getCode());
42
+ if ($site_id == "default") $site_id = 6;
43
+ $productid = $product->getId();
44
+ $customize_price = Mage::helper('editor')->getCustomizePrice($productid, $site_id, $is_not_customize);
45
+
46
+ // add fee
47
+ $baseTotal = $this->getBaseRowTotal() + $addtional_fee + $customize_price;
48
+
49
+ $total = $this->getStore()->convertPrice($baseTotal);
50
+ $this->setRowTotal($this->getStore()->roundPrice($total));
51
+ $this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));
52
+
53
+ return $this;
54
+ }
55
+ }
app/code/local/Abcv/Editor/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('editor')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('editor')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Abcv/Editor/controllers/Adminhtml/AjaxController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Adminhtml_AjaxController extends Mage_Adminhtml_Controller_action
3
+ {
4
+ public function getProductsAction()
5
+ {
6
+ $attributeCode = $this->getRequest()->getPost('attributeCode');
7
+ echo $attributeCode;
8
+ return;
9
+ $result = array();
10
+ if ($this->getRequest()->isPost()) {
11
+ $attributeCode = $this->getRequest()->getPost('attributeCode');
12
+ /*$product = Mage::getModel('catalog/product')->load(27);
13
+ $attributeNames = array_keys($product->getData());
14
+ echo $product->getData('attribute_set_id'); //gia tri nhan ben trong attribute
15
+ */
16
+ $collection = Mage::getModel('catalog/product')->getCollection();
17
+ $collection->addAttributeToSelect('name');
18
+ $collection->addAttributeToSelect('image');
19
+ $collection->addAttributeToSelect('productstyle');
20
+ $collection->addAttributeToSelect('description');
21
+ $collection->addAttributeToSelect('price');
22
+ $collection->addAttributeToSelect('special_price');
23
+ $collection->addAttributeToSelect('templateid');
24
+ $support_product_ids = array();
25
+ while($row = mysql_fetch_array($result)) {
26
+ $support_product_ids[] = array('attribute'=>'attribute_set_id','eq'=>$attributeCode);
27
+ }
28
+ $collection->addFieldToFilter($support_product_ids);
29
+ $collection->setPage(1, 10);//set khoang 10 trang dau, va lay trang so 1
30
+
31
+ $html = "<table>";
32
+ foreach ($collection as $product) {
33
+ $html .= "<tr><td>";
34
+ $html.=" Iowa State iPad 2 &amp; 3 Cover - Cy on a Red Patterned Background - Protective Leather and Suede Case";
35
+ $html.=" <p><span id='spanTemplate'>Template: </span>";
36
+ $html.=" <span id='spanProductStyle'>Style: </span></p>";
37
+ $html.="</td></tr>";
38
+ }
39
+ $html.= "</table>";
40
+ $result['body'] = $html;
41
+ }
42
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
43
+ }
44
+
45
+ }
46
+ ?>
app/code/local/Abcv/Editor/controllers/Adminhtml/AjaxController_2014.06.04.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Adminhtml_AjaxController extends Mage_Adminhtml_Controller_action
3
+ {
4
+ public function getProductsAction()
5
+ {
6
+ $attributeCode = $this->getRequest()->getPost('attributeCode');
7
+ echo $attributeCode;
8
+ return;
9
+ $result = array();
10
+ if ($this->getRequest()->isPost()) {
11
+ $attributeCode = $this->getRequest()->getPost('attributeCode');
12
+ /*$product = Mage::getModel('catalog/product')->load(27);
13
+ $attributeNames = array_keys($product->getData());
14
+ echo $product->getData('attribute_set_id'); //gia tri nhan ben trong attribute
15
+ */
16
+ $collection = Mage::getModel('catalog/product')->getCollection();
17
+ $collection->addAttributeToSelect('name');
18
+ $collection->addAttributeToSelect('image');
19
+ $collection->addAttributeToSelect('productstyle');
20
+ $collection->addAttributeToSelect('description');
21
+ $collection->addAttributeToSelect('price');
22
+ $collection->addAttributeToSelect('special_price');
23
+ $collection->addAttributeToSelect('templateid');
24
+ $support_product_ids = array();
25
+ while($row = mysql_fetch_array($result)) {
26
+ $support_product_ids[] = array('attribute'=>'attribute_set_id','eq'=>$attributeCode);
27
+ }
28
+ $collection->addFieldToFilter($support_product_ids);
29
+ $collection->setPage(1, 10);//set khoang 10 trang dau, va lay trang so 1
30
+
31
+ $html = "<table>";
32
+ foreach ($collection as $product) {
33
+ $html .= "<tr><td>";
34
+ $html.=" Iowa State iPad 2 &amp; 3 Cover - Cy on a Red Patterned Background - Protective Leather and Suede Case";
35
+ $html.=" <p><span id='spanTemplate'>Template: </span>";
36
+ $html.=" <span id='spanProductStyle'>Style: </span></p>";
37
+ $html.="</td></tr>";
38
+ }
39
+ $html.= "</table>";
40
+ $result['body'] = $html;
41
+ }
42
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
43
+ }
44
+
45
+ }
46
+ ?>
app/code/local/Abcv/Editor/controllers/Adminhtml/CategoryController.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Adminhtml_CategoryController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ protected function _initAction() {
5
+ $this->loadLayout()
6
+ ->_setActiveMenu('editor/items')
7
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
8
+
9
+ return $this;
10
+ }
11
+ public function indexAction() {
12
+ $this->_initAction()
13
+ ->renderLayout();
14
+ }
15
+ public function testAction() {
16
+ $this->_initAction()
17
+ ->renderLayout();
18
+ }
19
+
20
+ public function saveAction() {
21
+ //print_r($this->getRequest()->getPost());
22
+
23
+ $cateInfo=$this->getRequest()->getPost("general");
24
+ //print_r($cateInfo);
25
+ $cate_ids="";$cate_num="";
26
+
27
+ try{
28
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
29
+ //print_r($cateInfo);
30
+ if (empty($cateInfo["id"]))//add
31
+ {
32
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
33
+ //get category'll be changed
34
+ $readresult=$read->query("SELECT IFNULL(MAX(sortorder)+1,1) sortorder
35
+ FROM TemplateDirectories tem
36
+ WHERE tem.Parent=".$cateInfo["Parent"]);
37
+ $row = $readresult->fetch();
38
+ $cateInfo["sortorder"] = $row["sortorder"];
39
+ $write->insert("TemplateDirectories", $cateInfo);
40
+ $cateInfo["id"] = $write->lastInsertId();
41
+ if(isset($_FILES["thumbnail"]))
42
+ {
43
+ $fileName=Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"].".png";
44
+ move_uploaded_file( $_FILES["thumbnail"]["tmp_name"],$fileName );
45
+ }
46
+ //move_uploaded_file( $_FILES["thumbnail"]["tmp_name"], Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"]".png");
47
+ }
48
+ else//update
49
+ {
50
+ $query=" update TemplateDirectories set
51
+ Name='".$cateInfo["name"]."',
52
+ description='".$cateInfo["description"]."',
53
+ view='".$cateInfo["view"]."',
54
+ status=".$cateInfo["status"]." ";
55
+ if(isset($cateInfo["thumbnail"]["delete"]))//delete image
56
+ {
57
+ $fileName=Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"].".png";
58
+ if(file_exists($fileName))
59
+ unlink($fileName);
60
+ }
61
+ elseif(isset($_FILES["thumbnail"])&&!empty($_FILES["thumbnail"]["name"]))
62
+ {
63
+ //print_r($_FILES);
64
+ $fileName=Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"].".png";
65
+ if(file_exists($fileName))
66
+ unlink($fileName);
67
+ move_uploaded_file( $_FILES["thumbnail"]["tmp_name"],$fileName );
68
+ }
69
+ $query.=" where ID=".$cateInfo["id"];
70
+ $write->query($query);
71
+ }
72
+ //set template for category
73
+ $in_template_add=$this->getRequest()->getPost('in_template_add');
74
+ if(!empty($in_template_add))
75
+ {
76
+ $in_template_add=str_replace(",,", ",", $in_template_add);
77
+
78
+ /*$read = Mage::getSingleton('core/resource')->getConnection('core_read');
79
+ //get category'll be changed
80
+ $readresult=$read->query("SELECT DISTINCT `Directory` from Templates
81
+ WHERE ID in(-1 $in_template_add -1) ORDER BY `Directory` ");
82
+ $row = $readresult->fetch();
83
+ $cate_ids=$row["Directory"];
84
+ while ($row = $readresult->fetch() ) {
85
+ $cate_ids.=",".$row["Directory"];
86
+ }
87
+ $write->query("UPDATE Templates
88
+ SET `Directory` = ".$cateInfo["id"]."
89
+ WHERE ID in(0 $in_template_add 0)");
90
+ $readresult=$read->query("SELECT DISTINCT Name,(select count(*) from Templates tem1 where tem.ID=tem1.`Directory`) number
91
+ from TemplateDirectories tem
92
+ WHERE ID in($cate_ids)
93
+ ORDER BY ID ");
94
+ $row = $readresult->fetch();
95
+ $cate_num=$row["Name"]."(".$row["number"].")";
96
+ while ($row = $readresult->fetch() ) {
97
+ $cate_num.=",".$row["Name"]."(".$row["number"].")";
98
+ }*/
99
+ $write->query("INSERT INTO TemplatesOfCategory (`TemplateID`,`CategoryID`)
100
+ SELECT ID,".$cateInfo["id"]."
101
+ FROM Templates
102
+ WHERE ID in(0 $in_template_add 0)");
103
+ }
104
+ $in_template_delete=$this->getRequest()->getPost('in_template_delete');
105
+ if(!empty($in_template_delete))
106
+ {
107
+ $in_template_delete=str_replace(",,", ",", $in_template_delete);
108
+ $write->query("DELETE FROM TemplatesOfCategory
109
+ WHERE CategoryID=".$cateInfo["id"]." AND TemplateID in(0 $in_template_delete 0)");
110
+ }
111
+ // ABCV DANG - remove cache
112
+ Mage::helper('editor')->rebuildTemplateCategory();
113
+ // END ABCV
114
+ }
115
+ catch (Exception $e)
116
+ {
117
+ echo $e;
118
+ }
119
+ //call javascript to refresh tree
120
+ $this->getResponse()->setBody(
121
+ '<script type="text/javascript">parent.updateContent("'.$cate_ids.'","'.$cate_num.'","'.$cateInfo["id"].'");</script>'
122
+ );
123
+ }
124
+ }
125
+ ?>
app/code/local/Abcv/Editor/controllers/Adminhtml/CategoryController_2014.06.04.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_Adminhtml_CategoryController extends Mage_Adminhtml_Controller_action
3
+ {
4
+ protected function _initAction() {
5
+ $this->loadLayout()
6
+ ->_setActiveMenu('editor/items')
7
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
8
+
9
+ return $this;
10
+ }
11
+ public function indexAction() {
12
+ $this->_initAction()
13
+ ->renderLayout();
14
+ }
15
+ public function testAction() {
16
+ $this->_initAction()
17
+ ->renderLayout();
18
+ }
19
+
20
+ public function saveAction() {
21
+ //print_r($this->getRequest()->getPost());
22
+
23
+ $cateInfo=$this->getRequest()->getPost("general");
24
+ //print_r($cateInfo);
25
+ $cate_ids="";$cate_num="";
26
+
27
+ try{
28
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
29
+ //print_r($cateInfo);
30
+ if (empty($cateInfo["id"]))//add
31
+ {
32
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
33
+ //get category'll be changed
34
+ $readresult=$read->query("SELECT IFNULL(MAX(sortorder)+1,1) sortorder
35
+ FROM TemplateDirectories tem
36
+ WHERE tem.Parent=".$cateInfo["Parent"]);
37
+ $row = $readresult->fetch();
38
+ $cateInfo["sortorder"] = $row["sortorder"];
39
+ $write->insert("TemplateDirectories", $cateInfo);
40
+ $cateInfo["id"] = $write->lastInsertId();
41
+ if(isset($_FILES["thumbnail"]))
42
+ {
43
+ $fileName=Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"].".png";
44
+ move_uploaded_file( $_FILES["thumbnail"]["tmp_name"],$fileName );
45
+ }
46
+ //move_uploaded_file( $_FILES["thumbnail"]["tmp_name"], Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"]".png");
47
+ }
48
+ else//update
49
+ {
50
+ $query=" update TemplateDirectories set
51
+ Name='".$cateInfo["name"]."',
52
+ description='".$cateInfo["description"]."',
53
+ view='".$cateInfo["view"]."',
54
+ status=".$cateInfo["status"]." ";
55
+ if(isset($cateInfo["thumbnail"]["delete"]))//delete image
56
+ {
57
+ $fileName=Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"].".png";
58
+ if(file_exists($fileName))
59
+ unlink($fileName);
60
+ }
61
+ elseif(isset($_FILES["thumbnail"])&&!empty($_FILES["thumbnail"]["name"]))
62
+ {
63
+ //print_r($_FILES);
64
+ $fileName=Mage::getBaseDir()."/images"."/templatedirectories"."/templatedirectories_".$cateInfo["id"].".png";
65
+ if(file_exists($fileName))
66
+ unlink($fileName);
67
+ move_uploaded_file( $_FILES["thumbnail"]["tmp_name"],$fileName );
68
+ }
69
+ $query.=" where ID=".$cateInfo["id"];
70
+ $write->query($query);
71
+ }
72
+ //set template for category
73
+ $in_template_add=$this->getRequest()->getPost('in_template_add');
74
+ if(!empty($in_template_add))
75
+ {
76
+ $in_template_add=str_replace(",,", ",", $in_template_add);
77
+
78
+ /*$read = Mage::getSingleton('core/resource')->getConnection('core_read');
79
+ //get category'll be changed
80
+ $readresult=$read->query("SELECT DISTINCT `Directory` from Templates
81
+ WHERE ID in(-1 $in_template_add -1) ORDER BY `Directory` ");
82
+ $row = $readresult->fetch();
83
+ $cate_ids=$row["Directory"];
84
+ while ($row = $readresult->fetch() ) {
85
+ $cate_ids.=",".$row["Directory"];
86
+ }
87
+ $write->query("UPDATE Templates
88
+ SET `Directory` = ".$cateInfo["id"]."
89
+ WHERE ID in(0 $in_template_add 0)");
90
+ $readresult=$read->query("SELECT DISTINCT Name,(select count(*) from Templates tem1 where tem.ID=tem1.`Directory`) number
91
+ from TemplateDirectories tem
92
+ WHERE ID in($cate_ids)
93
+ ORDER BY ID ");
94
+ $row = $readresult->fetch();
95
+ $cate_num=$row["Name"]."(".$row["number"].")";
96
+ while ($row = $readresult->fetch() ) {
97
+ $cate_num.=",".$row["Name"]."(".$row["number"].")";
98
+ }*/
99
+ $write->query("INSERT INTO TemplatesOfCategory (`TemplateID`,`CategoryID`)
100
+ SELECT ID,".$cateInfo["id"]."
101
+ FROM Templates
102
+ WHERE ID in(0 $in_template_add 0)");
103
+ }
104
+ $in_template_delete=$this->getRequest()->getPost('in_template_delete');
105
+ if(!empty($in_template_delete))
106
+ {
107
+ $in_template_delete=str_replace(",,", ",", $in_template_delete);
108
+ $write->query("DELETE FROM TemplatesOfCategory
109
+ WHERE CategoryID=".$cateInfo["id"]." AND TemplateID in(0 $in_template_delete 0)");
110
+ }
111
+ // ABCV DANG - remove cache
112
+ Mage::helper('editor')->rebuildTemplateCategory();
113
+ // END ABCV
114
+ }
115
+ catch (Exception $e)
116
+ {
117
+ echo $e;
118
+ }
119
+ //call javascript to refresh tree
120
+ $this->getResponse()->setBody(
121
+ '<script type="text/javascript">parent.updateContent("'.$cate_ids.'","'.$cate_num.'","'.$cateInfo["id"].'");</script>'
122
+ );
123
+ }
124
+ }
125
+ ?>
app/code/local/Abcv/Editor/controllers/Adminhtml/EditorController.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Adminhtml_EditorController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ //protected function _initAction() {
7
+ // $this->loadLayout()
8
+ // ->_setActiveMenu('editor/items')
9
+ // ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manager Templates'), Mage::helper('adminhtml')->__('Manager Templates'));
10
+ // $key = $this->getRequest()->getParam('key');
11
+ // $block = $this->getLayout()->getBlock('editor');
12
+ // $block->setData('key',$key);
13
+ // return $this;
14
+ // }
15
+ //
16
+ // public function indexAction() {
17
+ // $this->_initAction()->renderLayout();
18
+ // }
19
+
20
+ // Old source
21
+ //
22
+ protected function _initAction() {
23
+ $this->loadLayout()
24
+ ->_setActiveMenu('editor/items')
25
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
26
+
27
+ return $this;
28
+ }
29
+
30
+ public function indexAction() {
31
+ $this->_initAction()
32
+ ->renderLayout();
33
+ }
34
+
35
+ public function editAction() {
36
+ $id = $this->getRequest()->getParam('id');
37
+ $model = Mage::getModel('editor/editor')->load($id);
38
+
39
+ if ($model->getId() || $id == 0) {
40
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
41
+ if (!empty($data)) {
42
+ $model->setData($data);
43
+ }
44
+
45
+ Mage::register('editor_data', $model);
46
+
47
+ $this->loadLayout();
48
+ $this->_setActiveMenu('editor/items');
49
+
50
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
51
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
52
+
53
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
54
+
55
+ $this->_addContent($this->getLayout()->createBlock('editor/adminhtml_editor_edit'))
56
+ ->_addLeft($this->getLayout()->createBlock('editor/adminhtml_editor_edit_tabs'));
57
+
58
+ $this->renderLayout();
59
+ } else {
60
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('editor')->__('Item does not exist'));
61
+ $this->_redirect('*/*/');
62
+ }
63
+ }
64
+
65
+ public function newAction() {
66
+ $this->_forward('edit');
67
+ }
68
+
69
+ public function saveAction() {
70
+ if ($data = $this->getRequest()->getPost()) {
71
+
72
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
73
+ try {
74
+ // /* Starting upload */
75
+ $uploader = new Varien_File_Uploader('filename');
76
+
77
+ // // Any extention would work
78
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
79
+ $uploader->setAllowRenameFiles(false);
80
+ //
81
+ // // Set the file upload mode
82
+ // // false -> get the file directly in the specified folder
83
+ // // true -> get the file in the product like folders
84
+ // // (file.jpg will go in something like /media/f/i/file.jpg)
85
+ $uploader->setFilesDispersion(false);
86
+ //
87
+ // // We set media as the upload dir
88
+ $path = Mage::getBaseDir('media') . DS ;
89
+ $uploader->save($path, $_FILES['filename']['name'] );
90
+
91
+ } catch (Exception $e) {
92
+
93
+ }
94
+
95
+ //this way the name is saved in DB
96
+ $data['filename'] = $_FILES['filename']['name'];
97
+ }
98
+ //
99
+ //
100
+ $model = Mage::getModel('editor/editor');
101
+ $model->setData($data)
102
+ ->setId($this->getRequest()->getParam('id'));
103
+
104
+ try {
105
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
106
+ $model->setCreatedTime(now())
107
+ ->setUpdateTime(now());
108
+ } else {
109
+ $model->setUpdateTime(now());
110
+ }
111
+
112
+ $model->save();
113
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('editor')->__('Item was successfully saved'));
114
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
115
+
116
+ if ($this->getRequest()->getParam('back')) {
117
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
118
+ return;
119
+ }
120
+ $this->_redirect('*/*/');
121
+ return;
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
125
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
126
+ return;
127
+ }
128
+ }
129
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('editor')->__('Unable to find item to save'));
130
+ $this->_redirect('*/*/');
131
+ }
132
+
133
+ public function deleteAction() {
134
+ if( $this->getRequest()->getParam('id') > 0 ) {
135
+ try {
136
+ $model = Mage::getModel('editor/editor');
137
+
138
+ $model->setId($this->getRequest()->getParam('id'))
139
+ ->delete();
140
+
141
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
142
+ $this->_redirect('*/*/');
143
+ } catch (Exception $e) {
144
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
145
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
146
+ }
147
+ }
148
+ $this->_redirect('*/*/');
149
+ }
150
+
151
+ public function massDeleteAction() {
152
+ $editorIds = $this->getRequest()->getParam('editor');
153
+ if(!is_array($editorIds)) {
154
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
155
+ } else {
156
+ try {
157
+ foreach ($editorIds as $editorId) {
158
+ $editor = Mage::getModel('editor/editor')->load($editorId);
159
+ $editor->delete();
160
+ }
161
+ Mage::getSingleton('adminhtml/session')->addSuccess(
162
+ Mage::helper('adminhtml')->__(
163
+ 'Total of %d record(s) were successfully deleted', count($editorIds)
164
+ )
165
+ );
166
+ } catch (Exception $e) {
167
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
168
+ }
169
+ }
170
+ $this->_redirect('*/*/index');
171
+ }
172
+
173
+ public function massStatusAction()
174
+ {
175
+ $editorIds = $this->getRequest()->getParam('editor');
176
+ if(!is_array($editorIds)) {
177
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
178
+ } else {
179
+ try {
180
+ foreach ($editorIds as $editorId) {
181
+ $editor = Mage::getSingleton('editor/editor')
182
+ ->load($editorId)
183
+ ->setStatus($this->getRequest()->getParam('status'))
184
+ ->setIsMassupdate(true)
185
+ ->save();
186
+ }
187
+ $this->_getSession()->addSuccess(
188
+ $this->__('Total of %d record(s) were successfully updated', count($editorIds))
189
+ );
190
+ } catch (Exception $e) {
191
+ $this->_getSession()->addError($e->getMessage());
192
+ }
193
+ }
194
+ $this->_redirect('*/*/index');
195
+ }
196
+
197
+ public function exportCsvAction()
198
+ {
199
+ $fileName = 'editor.csv';
200
+ $content = $this->getLayout()->createBlock('editor/adminhtml_editor_grid')
201
+ ->getCsv();
202
+
203
+ $this->_sendUploadResponse($fileName, $content);
204
+ }
205
+
206
+ public function exportXmlAction()
207
+ {
208
+ $fileName = 'editor.xml';
209
+ $content = $this->getLayout()->createBlock('editor/adminhtml_editor_grid')
210
+ ->getXml();
211
+
212
+ $this->_sendUploadResponse($fileName, $content);
213
+ }
214
+
215
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
216
+ {
217
+ $response = $this->getResponse();
218
+ $response->setHeader('HTTP/1.1 200 OK','');
219
+ $response->setHeader('Pragma', 'public', true);
220
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
221
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
222
+ $response->setHeader('Last-Modified', date('r'));
223
+ $response->setHeader('Accept-Ranges', 'bytes');
224
+ $response->setHeader('Content-Length', strlen($content));
225
+ $response->setHeader('Content-type', $contentType);
226
+ $response->setBody($content);
227
+ $response->sendResponse();
228
+ die;
229
+ }
230
+
231
+ /**
232
+ * HUY: 2014-03-11
233
+ * WYSIWYG editor action for ajax request
234
+ *
235
+ */
236
+ public function wysiwygAction()
237
+ {
238
+ $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
239
+ $storeId = $this->getRequest()->getParam('store_id', 0);
240
+ $storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
241
+
242
+ $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
243
+ 'editor_element_id' => $elementId,
244
+ 'store_id' => $storeId,
245
+ 'store_media_url' => $storeMediaUrl,
246
+ ));
247
+
248
+ $this->getResponse()->setBody($content->toHtml());
249
+ }
250
+ }
app/code/local/Abcv/Editor/controllers/Adminhtml/EditorController_2014.06.04.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Abcv_Editor_Adminhtml_EditorController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ //protected function _initAction() {
7
+ // $this->loadLayout()
8
+ // ->_setActiveMenu('editor/items')
9
+ // ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manager Templates'), Mage::helper('adminhtml')->__('Manager Templates'));
10
+ // $key = $this->getRequest()->getParam('key');
11
+ // $block = $this->getLayout()->getBlock('editor');
12
+ // $block->setData('key',$key);
13
+ // return $this;
14
+ // }
15
+ //
16
+ // public function indexAction() {
17
+ // $this->_initAction()->renderLayout();
18
+ // }
19
+
20
+ // Old source
21
+ //
22
+ protected function _initAction() {
23
+ $this->loadLayout()
24
+ ->_setActiveMenu('editor/items')
25
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
26
+
27
+ return $this;
28
+ }
29
+
30
+ public function indexAction() {
31
+ $this->_initAction()
32
+ ->renderLayout();
33
+ }
34
+
35
+ public function editAction() {
36
+ $id = $this->getRequest()->getParam('id');
37
+ $model = Mage::getModel('editor/editor')->load($id);
38
+
39
+ if ($model->getId() || $id == 0) {
40
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
41
+ if (!empty($data)) {
42
+ $model->setData($data);
43
+ }
44
+
45
+ Mage::register('editor_data', $model);
46
+
47
+ $this->loadLayout();
48
+ $this->_setActiveMenu('editor/items');
49
+
50
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
51
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
52
+
53
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
54
+
55
+ $this->_addContent($this->getLayout()->createBlock('editor/adminhtml_editor_edit'))
56
+ ->_addLeft($this->getLayout()->createBlock('editor/adminhtml_editor_edit_tabs'));
57
+
58
+ $this->renderLayout();
59
+ } else {
60
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('editor')->__('Item does not exist'));
61
+ $this->_redirect('*/*/');
62
+ }
63
+ }
64
+
65
+ public function newAction() {
66
+ $this->_forward('edit');
67
+ }
68
+
69
+ public function saveAction() {
70
+ if ($data = $this->getRequest()->getPost()) {
71
+
72
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
73
+ try {
74
+ // /* Starting upload */
75
+ $uploader = new Varien_File_Uploader('filename');
76
+
77
+ // // Any extention would work
78
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
79
+ $uploader->setAllowRenameFiles(false);
80
+ //
81
+ // // Set the file upload mode
82
+ // // false -> get the file directly in the specified folder
83
+ // // true -> get the file in the product like folders
84
+ // // (file.jpg will go in something like /media/f/i/file.jpg)
85
+ $uploader->setFilesDispersion(false);
86
+ //
87
+ // // We set media as the upload dir
88
+ $path = Mage::getBaseDir('media') . DS ;
89
+ $uploader->save($path, $_FILES['filename']['name'] );
90
+
91
+ } catch (Exception $e) {
92
+
93
+ }
94
+
95
+ //this way the name is saved in DB
96
+ $data['filename'] = $_FILES['filename']['name'];
97
+ }
98
+ //
99
+ //
100
+ $model = Mage::getModel('editor/editor');
101
+ $model->setData($data)
102
+ ->setId($this->getRequest()->getParam('id'));
103
+
104
+ try {
105
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
106
+ $model->setCreatedTime(now())
107
+ ->setUpdateTime(now());
108
+ } else {
109
+ $model->setUpdateTime(now());
110
+ }
111
+
112
+ $model->save();
113
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('editor')->__('Item was successfully saved'));
114
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
115
+
116
+ if ($this->getRequest()->getParam('back')) {
117
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
118
+ return;
119
+ }
120
+ $this->_redirect('*/*/');
121
+ return;
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
125
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
126
+ return;
127
+ }
128
+ }
129
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('editor')->__('Unable to find item to save'));
130
+ $this->_redirect('*/*/');
131
+ }
132
+
133
+ public function deleteAction() {
134
+ if( $this->getRequest()->getParam('id') > 0 ) {
135
+ try {
136
+ $model = Mage::getModel('editor/editor');
137
+
138
+ $model->setId($this->getRequest()->getParam('id'))
139
+ ->delete();
140
+
141
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
142
+ $this->_redirect('*/*/');
143
+ } catch (Exception $e) {
144
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
145
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
146
+ }
147
+ }
148
+ $this->_redirect('*/*/');
149
+ }
150
+
151
+ public function massDeleteAction() {
152
+ $editorIds = $this->getRequest()->getParam('editor');
153
+ if(!is_array($editorIds)) {
154
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
155
+ } else {
156
+ try {
157
+ foreach ($editorIds as $editorId) {
158
+ $editor = Mage::getModel('editor/editor')->load($editorId);
159
+ $editor->delete();
160
+ }
161
+ Mage::getSingleton('adminhtml/session')->addSuccess(
162
+ Mage::helper('adminhtml')->__(
163
+ 'Total of %d record(s) were successfully deleted', count($editorIds)
164
+ )
165
+ );
166
+ } catch (Exception $e) {
167
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
168
+ }
169
+ }
170
+ $this->_redirect('*/*/index');
171
+ }
172
+
173
+ public function massStatusAction()
174
+ {
175
+ $editorIds = $this->getRequest()->getParam('editor');
176
+ if(!is_array($editorIds)) {
177
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
178
+ } else {
179
+ try {
180
+ foreach ($editorIds as $editorId) {
181
+ $editor = Mage::getSingleton('editor/editor')
182
+ ->load($editorId)
183
+ ->setStatus($this->getRequest()->getParam('status'))
184
+ ->setIsMassupdate(true)
185
+ ->save();
186
+ }
187
+ $this->_getSession()->addSuccess(
188
+ $this->__('Total of %d record(s) were successfully updated', count($editorIds))
189
+ );
190
+ } catch (Exception $e) {
191
+ $this->_getSession()->addError($e->getMessage());
192
+ }
193
+ }
194
+ $this->_redirect('*/*/index');
195
+ }
196
+
197
+ public function exportCsvAction()
198
+ {
199
+ $fileName = 'editor.csv';
200
+ $content = $this->getLayout()->createBlock('editor/adminhtml_editor_grid')
201
+ ->getCsv();
202
+
203
+ $this->_sendUploadResponse($fileName, $content);
204
+ }
205
+
206
+ public function exportXmlAction()
207
+ {
208
+ $fileName = 'editor.xml';
209
+ $content = $this->getLayout()->createBlock('editor/adminhtml_editor_grid')
210
+ ->getXml();
211
+
212
+ $this->_sendUploadResponse($fileName, $content);
213
+ }
214
+
215
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
216
+ {
217
+ $response = $this->getResponse();
218
+ $response->setHeader('HTTP/1.1 200 OK','');
219
+ $response->setHeader('Pragma', 'public', true);
220
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
221
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
222
+ $response->setHeader('Last-Modified', date('r'));
223
+ $response->setHeader('Accept-Ranges', 'bytes');
224
+ $response->setHeader('Content-Length', strlen($content));
225
+ $response->setHeader('Content-type', $contentType);
226
+ $response->setBody($content);
227
+ $response->sendResponse();
228
+ die;
229
+ }
230
+
231
+ /**
232
+ * HUY: 2014-03-11
233
+ * WYSIWYG editor action for ajax request
234
+ *
235
+ */
236
+ public function wysiwygAction()
237
+ {
238
+ $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
239
+ $storeId = $this->getRequest()->getParam('store_id', 0);
240
+ $storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
241
+
242
+ $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
243
+ 'editor_element_id' => $elementId,
244
+ 'store_id' => $storeId,
245
+ 'store_media_url' => $storeMediaUrl,
246
+ ));
247
+
248
+ $this->getResponse()->setBody($content->toHtml());
249
+ }
250
+ }
app/code/local/Abcv/Editor/controllers/AjaxLoginController.php ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_AjaxLoginController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ /**
5
+ * Action list where need check enabled cookie
6
+ *
7
+ * @var array
8
+ */
9
+ protected $_cookieCheckActions = array('loginPost', 'createpost');
10
+
11
+ /**
12
+ * Retrieve customer session model object
13
+ *
14
+ * @return Mage_Customer_Model_Session
15
+ */
16
+ protected function _getSession()
17
+ {
18
+ return Mage::getSingleton('customer/session');
19
+ }
20
+ /**
21
+ * Login post action
22
+ */
23
+ public function loginPostAction()
24
+ {
25
+ //$result = array();
26
+ if ($this->_getSession()->isLoggedIn()) {
27
+ $this->_redirect('*/*/');
28
+ return;
29
+ }
30
+ $session = $this->_getSession();
31
+
32
+ if ($this->getRequest()->isPost()) {
33
+ $login = $this->getRequest()->getPost('login');
34
+ if (!empty($login['username']) && !empty($login['password'])) {
35
+ try {
36
+ $session->login($login['username'], $login['password']);
37
+ if ($session->getCustomer()->getIsJustConfirmed()) {
38
+ $this->_welcomeCustomer($session->getCustomer(), true);
39
+ }
40
+ echo 'success';
41
+ //$result['message'] = '';
42
+ } catch (Mage_Core_Exception $e) {
43
+ switch ($e->getCode()) {
44
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
45
+ $value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
46
+ $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
47
+ break;
48
+ case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
49
+ $message = $e->getMessage();
50
+ break;
51
+ default:
52
+ $message = $e->getMessage();
53
+ }
54
+ //$session->addError($message);
55
+ //$session->setUsername($login['username']);
56
+ //$result['result'] = 'error';
57
+ //$result['message'] = $message;
58
+ if ($message == "Invalid login or password.")
59
+ $message = 'Invalid Email Address or Password.';
60
+ echo $message;
61
+ } catch (Exception $e) {
62
+ // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
63
+ //$result['result'] = 'error';
64
+ //$result['message'] = $e->getMessages();
65
+ echo $e->getMessages();
66
+ }
67
+ } else {
68
+ //$session->addError($this->__('Login and password are required.'));
69
+ //echo 'Login and password are required';
70
+ //$result['result'] = 'error';
71
+ //$result['message'] = 'Login and password are required';
72
+ echo 'Email Address and Password are required';
73
+ }
74
+ }
75
+ //$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
76
+ }
77
+
78
+ public function getCustomerIdAction()
79
+ {
80
+ $this->loadLayout();
81
+ $result = array();
82
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
83
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
84
+ $result['id'] = $customerData->getId();
85
+ $result['name'] = $customerData->getName();
86
+
87
+ $result['header'] = $this->getLayout()->getBlock('header')->toHtml();
88
+
89
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
90
+ }
91
+
92
+ }
93
+ /**
94
+ * Define target URL and redirect customer after logging in
95
+ */
96
+ protected function _loginPostRedirect()
97
+ {
98
+ $session = $this->_getSession();
99
+
100
+ if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
101
+ // Set default URL to redirect customer to
102
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
103
+ // Redirect customer to the last page visited after logging in
104
+ if ($session->isLoggedIn()) {
105
+ if (!Mage::getStoreConfigFlag(
106
+ Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
107
+ )) {
108
+ $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
109
+ if ($referer) {
110
+ // Rebuild referer URL to handle the case when SID was changed
111
+ $referer = Mage::getModel('core/url')
112
+ ->getRebuiltUrl(Mage::helper('core')->urlDecode($referer));
113
+ if ($this->_isUrlInternal($referer)) {
114
+ $session->setBeforeAuthUrl($referer);
115
+ }
116
+ }
117
+ } else if ($session->getAfterAuthUrl()) {
118
+ $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
119
+ }
120
+ } else {
121
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
122
+ }
123
+ } else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
124
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
125
+ } else {
126
+ if (!$session->getAfterAuthUrl()) {
127
+ $session->setAfterAuthUrl($session->getBeforeAuthUrl());
128
+ }
129
+ if ($session->isLoggedIn()) {
130
+ $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
131
+ }
132
+ }
133
+ $this->_redirectUrl($session->getBeforeAuthUrl(true));
134
+ }
135
+ /************************************* REGISTER *********************************/
136
+ /**
137
+ * Create customer account action
138
+ */
139
+ public function createPostAction()
140
+ {
141
+
142
+ $session = $this->_getSession();
143
+ if ($session->isLoggedIn()) {
144
+ $this->_redirect('*/*/');
145
+ return;
146
+ }
147
+ $session->setEscapeMessages(true); // prevent XSS injection in user input
148
+ if ($this->getRequest()->isPost()) {
149
+ $errors = array();
150
+ $result = array();
151
+ if (!$customer = Mage::registry('current_customer')) {
152
+ $customer = Mage::getModel('customer/customer')->setId(null);
153
+ }
154
+
155
+ /* @var $customerForm Mage_Customer_Model_Form */
156
+ $customerForm = Mage::getModel('customer/form');
157
+ $customerForm->setFormCode('customer_account_create')
158
+ ->setEntity($customer);
159
+
160
+ $customerData = $customerForm->extractData($this->getRequest());
161
+
162
+ if ($this->getRequest()->getParam('is_subscribed', false)) {
163
+ $customer->setIsSubscribed(1);
164
+ }
165
+
166
+ /**
167
+ * Initialize customer group id
168
+ */
169
+ $customer->getGroupId();
170
+
171
+ if ($this->getRequest()->getPost('create_address')) {
172
+ /* @var $address Mage_Customer_Model_Address */
173
+ $address = Mage::getModel('customer/address');
174
+ /* @var $addressForm Mage_Customer_Model_Form */
175
+ $addressForm = Mage::getModel('customer/form');
176
+ $addressForm->setFormCode('customer_register_address')
177
+ ->setEntity($address);
178
+
179
+ $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
180
+ $addressErrors = $addressForm->validateData($addressData);
181
+ if ($addressErrors === true) {
182
+ $address->setId(null)
183
+ ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
184
+ ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
185
+ $addressForm->compactData($addressData);
186
+ $customer->addAddress($address);
187
+
188
+ $addressErrors = $address->validate();
189
+ if (is_array($addressErrors)) {
190
+ $errors = array_merge($errors, $addressErrors);
191
+ }
192
+ } else {
193
+ $errors = array_merge($errors, $addressErrors);
194
+ }
195
+ }
196
+
197
+ try {
198
+ $customerErrors = $customerForm->validateData($customerData);
199
+ if ($customerErrors !== true) {
200
+ $errors = array_merge($customerErrors, $errors);
201
+ } else {
202
+ $customerForm->compactData($customerData);
203
+ $customer->setPassword($this->getRequest()->getPost('password'));
204
+ $customer->setConfirmation($this->getRequest()->getPost('confirmation'));
205
+ $customerErrors = $customer->validate();
206
+ if (is_array($customerErrors)) {
207
+ $errors = array_merge($customerErrors, $errors);
208
+ }
209
+ }
210
+
211
+ $validationResult = count($errors) == 0;
212
+
213
+ if (true === $validationResult) {
214
+ $customer->save();
215
+
216
+ Mage::dispatchEvent('customer_register_success',
217
+ array('account_controller' => $this, 'customer' => $customer)
218
+ );
219
+
220
+ if ($customer->isConfirmationRequired()) {
221
+ $customer->sendNewAccountEmail(
222
+ 'confirmation',
223
+ $session->getBeforeAuthUrl(),
224
+ Mage::app()->getStore()->getId()
225
+ );
226
+ //$session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
227
+ //$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
228
+ //echo 'success';
229
+ $result['result'] = 'success';
230
+ $result['message'] = $this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()));
231
+ //return;
232
+ } else {
233
+ $session->setCustomerAsLoggedIn($customer);
234
+ //$url = $this->_welcomeCustomer($customer);
235
+ //$this->_redirectSuccess($url);
236
+ $result['result'] = 'success';
237
+ $result['message'] = 'Successfully registered';
238
+ }
239
+ } else {
240
+ $session->setCustomerFormData($this->getRequest()->getPost());
241
+ if (is_array($errors)) {
242
+ $err = '';
243
+ foreach ($errors as $errorMessage) {
244
+ //$session->addError($errorMessage);
245
+ $err .= $errorMessage . '<br/>';
246
+ }
247
+ //echo $err;
248
+ $result['result'] = 'error';
249
+ $result['message'] = $err;
250
+ } else {
251
+ //$session->addError($this->__('Invalid customer data'));
252
+ $result['result'] = 'error';
253
+ $result['message'] = 'Invalid customer data';
254
+ }
255
+ }
256
+ } catch (Mage_Core_Exception $e) {
257
+ $session->setCustomerFormData($this->getRequest()->getPost());
258
+ if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
259
+ $url = Mage::getUrl('customer/account/forgotpassword');
260
+ $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, click "Forgot Password" to get your password and access your account.', $url);
261
+ $session->setEscapeMessages(false);
262
+ } else {
263
+ $message = $e->getMessage();
264
+ }
265
+ //$session->addError($message);
266
+ $result['result'] = 'error';
267
+ $result['message'] = $message;
268
+ } catch (Exception $e) {
269
+ $session->setCustomerFormData($this->getRequest()->getPost())
270
+ ->addException($e, $this->__('Cannot save the customer.'));
271
+
272
+ $result['result'] = 'error';
273
+ $result['message'] = 'Cannot save the customer';
274
+ }
275
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
276
+ }
277
+
278
+ //$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
279
+ }
280
+
281
+ /**
282
+ * Forgot customer password action
283
+ */
284
+ public function forgotPasswordPostAction()
285
+ {
286
+ $result = array();
287
+ $email = (string) $this->getRequest()->getPost('email');
288
+ if ($email) {
289
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
290
+ $this->_getSession()->setForgottenEmail($email);
291
+ //$this->_getSession()->addError($this->__('Invalid email address.'));
292
+ $result['result'] = 'error';
293
+ $result['message'] = 'Invalid Email Address';
294
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
295
+ return;
296
+ //$this->_redirect('*/*/forgotpassword');
297
+ //return;
298
+ }
299
+
300
+ /** @var $customer Mage_Customer_Model_Customer */
301
+ $customer = Mage::getModel('customer/customer')
302
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
303
+ ->loadByEmail($email);
304
+
305
+ if ($customer->getId()) {
306
+ try {
307
+ $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
308
+ $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
309
+ $customer->sendPasswordResetConfirmationEmail();
310
+ } catch (Exception $exception) {
311
+ //$this->_getSession()->addError($exception->getMessage());
312
+ $result['result'] = 'error';
313
+ $result['message'] = $exception->getMessage();
314
+ //$this->_redirect('*/*/forgotpassword');
315
+ //return;
316
+ }
317
+ }
318
+ //$this->_getSession()->addSuccess(Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email)));
319
+ $result['result'] = 'success';
320
+ $result['message'] = Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email));
321
+ //$this->_redirect('*/*/');
322
+ //return;
323
+ } else {
324
+ //$this->_getSession()->addError($this->__('Please enter your email.'));
325
+ $result['result'] = 'error';
326
+ $result['message'] = 'Please enter your Email Address';
327
+ //$this->_redirect('*/*/forgotpassword');
328
+ //return;
329
+ }
330
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
331
+ }
332
+ public function sendEmailPostAction()
333
+ {
334
+ $result = array();
335
+ //print_r($this->getRequest()->getPost());
336
+ $from_name = (string) $this->getRequest()->getPost('from_name');
337
+ $mail_from = (string) $this->getRequest()->getPost('mail_from');
338
+ $mail_to = (string) $this->getRequest()->getPost('mail_to');
339
+ $mail_to=preg_replace("/ /", "",$mail_to);
340
+ $comments = (string) $this->getRequest()->getPost('comments');
341
+ if ($mail_from && $mail_to) {
342
+ if (!Zend_Validate::is($mail_from, 'EmailAddress')) {
343
+ $this->_getSession()->setForgottenEmail($email);
344
+ //$this->_getSession()->addError($this->__('Invalid email address.'));
345
+ $result['result'] = 'error';
346
+ $result['message'] = 'Your email is Invalid Email Address';
347
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
348
+ return;
349
+ }
350
+ $mail_tos = explode(",", $mail_to);
351
+ //print_r($mail_tos);
352
+ for($i=0;$i<count($mail_tos);$i++)
353
+ {
354
+ if (!Zend_Validate::is($mail_tos[$i], 'EmailAddress')) {
355
+ $this->_getSession()->setForgottenEmail($email);
356
+ $result['result'] = 'error';
357
+ $result['message'] = 'To is Invalid Email Address';
358
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
359
+ return;
360
+ }
361
+ }
362
+
363
+ //$vars['src'] ='http://magento.test.co/skin/frontend/argento/argento/images/victorystore.gif';
364
+ $result= $this->sendEmail('Send mail to friend',$mail_from,$mail_to,$from_name,$comments);
365
+
366
+ }
367
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
368
+ }
369
+ function sendEmail($template_code,$mail_from,$mail_to,$from_name,$comments)
370
+ {
371
+ $templateId = Mage::getModel('core/email_template')->loadByCode($template_code)->getId();
372
+ $sender = Array('name' => $from_name,
373
+ 'email' => $mail_from);
374
+ //recepient
375
+ $mail_to=str_replace(" ", "",$mail_to);
376
+ $mail_tos = explode(",", $mail_to);
377
+ $email = $mail_tos[0];
378
+ unset($mail_tos[0]);
379
+ $emailName = $from_name;
380
+ $linkImage=$this->getRequest()->getPost('linkImage');
381
+ $vars = Array();
382
+ $vars['content'] =$comments;
383
+ $vars['name'] =$from_name;
384
+ $this->loadLayout();
385
+ $a=$this->getLayout()->getBlock('footer')->toHtml();//$this->getLayout()->getChildHtml('footer_links');
386
+ $a=substr($a,strrpos($a,'<div class="footer-container">'));
387
+ $a=substr($a,0,strrpos($a,'</div>'))."</div>";
388
+ //$i=0;
389
+ //$vars["aaaa_".$i++] = $a;
390
+ $vars["logo"]=Mage::getStoreConfig('design/header/logo_src');
391
+ $vars["head"]=$this->getLayout()->createBlock('cms/block')->setBlockId('header_callout')->toHtml();//$this->getLayout()->getBlock('header')->toHtml();
392
+ $a=preg_replace('/class="footer-container"+/',"style='float:left;width:100%'",$a);
393
+ //$vars["aaaa_".$i++] = $a;
394
+ $a=preg_replace('/class="footer"+/',"style='float:left;width:100%'",$a);
395
+ //$vars["aaaa_".$i++] = $a;
396
+ $a=preg_replace('/<address>+/',"<address style='float:left;width:50%'>",$a);
397
+ //$vars["aaaa_".$i++] = $a;
398
+ $a=preg_replace('/<ul class="links">+/',"<div style='float:right;width:50%;text-align:right'>",$a);
399
+ //$vars["aaaa_".$i++] = $a;
400
+ $a=preg_replace('/<\/ul>+/',"</div>",$a);
401
+ //$vars["aaaa_".$i++] = $a;
402
+ $a=preg_replace('/<li+/',"<span",$a);
403
+ //$vars["aaaa_".$i++] = $a;
404
+ $a=preg_replace('/<\/li>+/',"</span>",$a);
405
+
406
+ // $h = fopen("e:/log.txt", "a");
407
+ //fwrite($h, "\n". $a);
408
+ //$vars["aaaa"] = $a;
409
+ $vars["foot"]=$this->getRequest()->getPost('price').$this->getLayout()->createBlock('cms/block')->setBlockId('footer_contacts')->toHtml().$a;
410
+ $vars["img"]="<a href='".$this->getRequest()->getPost('link')."'><img src='".$linkImage["linkTemplate"][0]."' ></a><hr>";
411
+ for($i=0;$i<count($linkImage["linkTemplateFinal"]);$i++)
412
+ {
413
+ $vars["img"].="<a href='".$this->getRequest()->getPost('link')."'><img src='".$linkImage["linkTemplateFinal"][$i]."' alt='Image loading...' ></a><hr>";
414
+ }
415
+ //print_r($vars);
416
+ $storeId = Mage::app()->getStore()->getId();
417
+ $translate = Mage::getSingleton('core/translate');
418
+ try{
419
+ Mage::getModel('core/email_template')->addBcc($mail_tos)
420
+ ->sendTransactional($templateId, $sender, $email, $emailName, $vars, $storeId);
421
+ $translate->setTranslateInline(true);
422
+ return array('result'=>"success",'message'=>'ok');
423
+ }
424
+ catch (Exception $e) {
425
+ return array('result'=>"error",'message'=>$e);
426
+ }
427
+ //$translate->setTranslateInline(true);
428
+ }
429
+ }
430
+ ?>
app/code/local/Abcv/Editor/controllers/IndexController.php ADDED
@@ -0,0 +1,510 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ //design editor html5
5
+ public function templateAction()
6
+ {
7
+ $templateid = $this->getRequest()->getParam('template');
8
+ $productid = $this->getRequest()->getParam('product');
9
+ if(!is_numeric($productid))
10
+ {
11
+ $productid=$productid.".html";
12
+ $dq = "SELECT product_id
13
+ FROM core_url_rewrite
14
+ WHERE request_path='$productid'
15
+ ";
16
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
17
+ $readresult = $read->query($dq);
18
+ $drow = $readresult->fetch();
19
+ if(isset( $drow["product_id"]))
20
+ $productid=$drow["product_id"];
21
+ else
22
+ {
23
+ $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
24
+ $this->getResponse()->setHeader('Status','404 File not found');
25
+
26
+ $pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_NO_ROUTE_PAGE);
27
+ if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
28
+ $this->_forward('defaultNoRoute');
29
+ }
30
+ }
31
+ }
32
+
33
+ $model = Mage::getModel('catalog/product');
34
+ $_product = $model->load($productid);
35
+ $productstyle = $_product->getProductstyle();//get Product Style Attribute
36
+
37
+ $editor = $this->getRequest()->getParam('editor'); //when user edit design
38
+
39
+ //From save template
40
+ $productstyleid = $this->getRequest()->getParam('productstyle');
41
+ if ($productstyleid)
42
+ $productstyle = $productstyleid;
43
+ $saveId = $this->getRequest()->getParam('save');
44
+ if ($saveId == "")
45
+ $saveId = -1;
46
+
47
+ //Reviews by Product ID
48
+ $reviews = Mage::getModel('review/review')
49
+ ->getResourceCollection()
50
+ ->addStoreFilter(Mage::app()->getStore()->getId())
51
+ ->addEntityFilter('product', $productid)
52
+ ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
53
+ ->setDateOrder()
54
+ ->addRateVotes();
55
+ $countReviews = count($reviews);
56
+
57
+ //Rating
58
+ $avg = 0;
59
+ $ratings = array();
60
+ if (count($reviews) > 0) {
61
+ foreach ($reviews->getItems() as $review) {
62
+ foreach( $review->getRatingVotes() as $vote ) {
63
+ $ratings[] = $vote->getPercent();
64
+ }
65
+ }
66
+ $avg = array_sum($ratings)/count($ratings);
67
+ }
68
+
69
+ $this->loadLayout();
70
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Design Your Own'));
71
+ $block = $this->getLayout()->getBlock('editor');
72
+ $block->setData('templateid',$templateid);
73
+ $block->setData('productid',$productid);
74
+ $block->setData('editor',$editor);
75
+
76
+ //$block->setData('productstyleid',$productstyleid);
77
+
78
+ $block->setData('save',$saveId);
79
+ $block->setData('productstyle',$productstyle);
80
+
81
+ $block->setData('countReviews',$countReviews);
82
+ $block->setData('countRating',$avg);
83
+
84
+ $this->renderLayout();
85
+ }
86
+
87
+ //design editor html5
88
+ public function editorAction()
89
+ {
90
+ $templateid = $this->getRequest()->getParam('template');
91
+ $productid = $this->getRequest()->getParam('product');
92
+ $this->loadLayout();
93
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Saved Product Template'));
94
+ $block = $this->getLayout()->getBlock('editor');
95
+ $block->setData('templateid',$templateid);
96
+ $block->setData('productid',$productid);
97
+ $this->renderLayout();
98
+ }
99
+
100
+ /*
101
+ * Select template
102
+ */
103
+ public function choosetemplateAction(){
104
+ $productid = $this->getRequest()->getParam('product');
105
+ $model = Mage::getModel('catalog/product');
106
+ $_product = $model->load($productid);
107
+ $productstyle = $_product->getProductstyle();
108
+
109
+ $this->loadLayout();
110
+ $block = $this->getLayout()->getBlock('choosetemplate');
111
+ $block->setData('productid',$productid);
112
+ $block->setData('productstyle',$productstyle);
113
+ echo $block->toHtml();
114
+ }
115
+
116
+ public function sitepageAction()
117
+ {
118
+ $templateid = $this->getRequest()->getParam('template');
119
+ $sitepage = $this->getRequest()->getParam('sitepage');
120
+ $this->loadLayout();
121
+
122
+ $block = $this->getLayout()->getBlock('editor');
123
+ $block->setData('templateid',$templateid);
124
+ $block->setData('sitepage',$sitepage);
125
+
126
+ $this->renderLayout();
127
+ }
128
+
129
+
130
+
131
+ public function productchooserAction()
132
+ {
133
+ $templateid = $this->getRequest()->getParam('template');
134
+ $sitepage = $this->getRequest()->getParam('sitepage');
135
+ $this->loadLayout();
136
+ $block = $this->getLayout()->getBlock('editor');
137
+ $block->setData('templateid',$templateid);
138
+ $block->setData('sitepage',$sitepage);
139
+ $this->renderLayout();
140
+ }
141
+
142
+ /**
143
+ * Action list where need check enabled cookie
144
+ *
145
+ * @var array
146
+ */
147
+ protected $_cookieCheckActions = array('add');
148
+
149
+ /**
150
+ * Retrieve shopping cart model object
151
+ *
152
+ * @return Mage_Checkout_Model_Cart
153
+ */
154
+ protected function _getCart()
155
+ {
156
+ return Mage::getSingleton('checkout/cart');
157
+ }
158
+
159
+ /**
160
+ * Get checkout session model instance
161
+ *
162
+ * @return Mage_Checkout_Model_Session
163
+ */
164
+ protected function _getSession()
165
+ {
166
+ return Mage::getSingleton('checkout/session');
167
+ }
168
+
169
+ /**
170
+ * Get current active quote instance
171
+ *
172
+ * @return Mage_Sales_Model_Quote
173
+ */
174
+ protected function _getQuote()
175
+ {
176
+ return $this->_getCart()->getQuote();
177
+ }
178
+
179
+ /**
180
+ * Set back redirect url to response
181
+ *
182
+ * @return Mage_Checkout_CartController
183
+ */
184
+ protected function _goBack()
185
+ {
186
+ $returnUrl = $this->getRequest()->getParam('return_url');
187
+ if ($returnUrl) {
188
+
189
+ if (!$this->_isUrlInternal($returnUrl)) {
190
+ throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');
191
+ }
192
+
193
+ $this->_getSession()->getMessages(true);
194
+ $this->getResponse()->setRedirect($returnUrl);
195
+ } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
196
+ && !$this->getRequest()->getParam('in_cart')
197
+ && $backUrl = $this->_getRefererUrl()
198
+ ) {
199
+ $this->getResponse()->setRedirect($backUrl);
200
+ } else {
201
+ if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
202
+ $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
203
+ }
204
+ $this->_redirect('checkout/cart');
205
+ }
206
+ return $this;
207
+ }
208
+
209
+ /**
210
+ * Initialize product instance from request data
211
+ *
212
+ * @return Mage_Catalog_Model_Product || false
213
+ */
214
+ protected function _initProduct()
215
+ {
216
+ $productId = (int) $this->getRequest()->getParam('product');
217
+ if ($productId) {
218
+ $product = Mage::getModel('catalog/product')
219
+ ->setStoreId(Mage::app()->getStore()->getId())
220
+ ->load($productId);
221
+ if ($product->getId()) {
222
+ return $product;
223
+ }
224
+ }
225
+ return false;
226
+ }
227
+
228
+ /**
229
+ * Add product to shopping cart action
230
+ */
231
+ public function addAction()
232
+ {
233
+ $cart = $this->_getCart(); //getting cart
234
+ $params = $this->getRequest()->getParams();
235
+ try {
236
+ if (isset($params['qty'])) { //checking qty
237
+ $filter = new Zend_Filter_LocalizedToNormalized(
238
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
239
+ );
240
+ $params['qty'] = $filter->filter($params['qty']);
241
+ }
242
+ /** HUY: begin 2014-04-16 **/
243
+ //$read = Mage::getSingleton('core/resource')->getConnection('core_read');
244
+ // $site_id = str_replace('sid','',Mage::app()->getStore()->getCode());
245
+ // if ($site_id == "default") $site_id = 6;
246
+ // $productid = $params['product'];
247
+ //$query = "SELECT * FROM abcv_product_options_checkbox WHERE site_id='$site_id' And product_id = '$productid' And attr = 'AllowCustomizeTemplate'";
248
+ // $customize_template = $read->fetchRow($query);
249
+ // $params['is_has_allow_customize'] = '0';
250
+ // if ($customize_template != null && $customize_template['value'] == 'true')
251
+ // $params['is_has_allow_customize'] = '1';
252
+ $params['add_to_cart_from'] = "the_editor_page";
253
+ /** HUY: end 2014-04-16 **/
254
+ $product = $this->_initProduct(); //getting info product
255
+ $related = $this->getRequest()->getParam('related_product');
256
+
257
+ /**
258
+ * Check product availability
259
+ */
260
+ if (!$product) {
261
+ $this->_goBack();
262
+ return;
263
+ }
264
+
265
+ $cart->addProduct($product, $params); //add s?n ph?m d� v�o cart
266
+
267
+ if (!empty($related)) {
268
+ $cart->addProductsByIds(explode(',', $related));
269
+ }
270
+
271
+ $cart->save(); //g?i d?n file App\code\core\mage\checkout\model\cart.php
272
+
273
+ $this->_getSession()->setCartWasUpdated(true);
274
+
275
+ /**
276
+ * @todo remove wishlist observer processAddToCart
277
+ */
278
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
279
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
280
+ );
281
+
282
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
283
+ if (!$cart->getQuote()->getHasError()){
284
+ $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
285
+ $this->_getSession()->addSuccess($message);
286
+ }
287
+
288
+
289
+ }
290
+ echo 'OK';
291
+
292
+ } catch (Mage_Core_Exception $e) {
293
+ if ($this->_getSession()->getUseNotice(true)) {
294
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
295
+ } else {
296
+ $messages = array_unique(explode("\n", $e->getMessage()));
297
+ foreach ($messages as $message) {
298
+ $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
299
+ }
300
+ }
301
+ echo Mage::helper('core')->escapeHtml($message);return;
302
+
303
+ $url = $this->_getSession()->getRedirectUrl(true);
304
+ if ($url) {
305
+ $this->getResponse()->setRedirect($url);
306
+ } else {
307
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
308
+ }
309
+ } catch (Exception $e) {
310
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
311
+ Mage::logException($e);
312
+ echo 'Cannot add the item to shopping cart. ';
313
+ //$this->_goBack();
314
+ }
315
+ }
316
+
317
+
318
+ /**
319
+ * Update product configuration for a cart item
320
+ */
321
+ public function updateItemOptionsAction()
322
+ {
323
+ $cart = $this->_getCart();
324
+ $id = (int) $this->getRequest()->getParam('id');
325
+ $is_multi_design = (int) $this->getRequest()->getParam('is_multi_design');
326
+ $params = $this->getRequest()->getParams();
327
+
328
+ if (!isset($params['options'])) {
329
+ $params['options'] = array();
330
+ }
331
+
332
+ try {
333
+ if (isset($params['qty'])) {
334
+ $filter = new Zend_Filter_LocalizedToNormalized(
335
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
336
+ );
337
+ $params['qty'] = $filter->filter($params['qty']);
338
+ }
339
+ /** HUY: begin 2014-04-16 **/
340
+ $params['add_to_cart_from'] = "the_editor_page";
341
+ /** HUY: end 2014-04-16 **/
342
+ $quoteItem = $cart->getQuote()->getItemById($id);
343
+ if (!$quoteItem) {
344
+ Mage::throwException($this->__('Quote item is not found.'));
345
+ }
346
+
347
+ $item = $cart->updateItem($id, new Varien_Object($params));
348
+
349
+ // exit();
350
+ if (is_string($item)) {
351
+ Mage::throwException($item);
352
+ }
353
+
354
+ //if ($item->getHasError()) {
355
+ // Mage::throwException($item->getMessage());
356
+ // }
357
+
358
+ $related = $this->getRequest()->getParam('related_product');
359
+ if (!empty($related)) {
360
+ $cart->addProductsByIds(explode(',', $related));
361
+ }
362
+
363
+ $cart->save();
364
+
365
+ $this->_getSession()->setCartWasUpdated(true);
366
+
367
+ Mage::dispatchEvent('checkout_cart_update_item_complete',
368
+ array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
369
+ );
370
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
371
+ if (!$cart->getQuote()->getHasError()){
372
+ //$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->htmlEscape($item->getProduct()->getName()));
373
+ $message = $this->__('%s was updated in your shopping cart.',Mage::getModel('checkout/cart')->getQuote()->getItemById($id)->getProduct()->getName());
374
+ $this->_getSession()->addSuccess($message);
375
+ }
376
+ //$this->_goBack();
377
+ }
378
+ } catch (Mage_Core_Exception $e) {
379
+ if ($this->_getSession()->getUseNotice(true)) {
380
+ $this->_getSession()->addNotice($e->getMessage());
381
+ } else {
382
+ $messages = array_unique(explode("\n", $e->getMessage()));
383
+ foreach ($messages as $message) {
384
+ $this->_getSession()->addError($message);
385
+ }
386
+ }
387
+
388
+ $url = $this->_getSession()->getRedirectUrl(true);
389
+ if ($url) {
390
+ $this->getResponse()->setRedirect($url);
391
+ } else {
392
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
393
+ }
394
+ } catch (Exception $e) {
395
+ $this->_getSession()->addException($e, $this->__('Cannot update the item.'));
396
+ Mage::logException($e);
397
+ //$this->_goBack();
398
+ }
399
+ // if ($is_multi_design == 0)
400
+ // $this->_redirect('checkout/cart/');
401
+ // else
402
+ echo 'ok';
403
+ }
404
+
405
+ public function removeQuoteAction()
406
+ {
407
+ //$quoteID = Mage::getSingleton("checkout/session")->getQuote()->getId();
408
+
409
+
410
+
411
+
412
+ $quoteID = $this->getRequest()->getParam('quoteID');
413
+ if(isset($quoteID))
414
+ {
415
+ try {
416
+ $session= Mage::getSingleton('checkout/session');
417
+ $quote = $session->getQuote();
418
+ $quote->removeItem($quoteID)->save();
419
+
420
+ //$quote = Mage::getModel("sales/quote")->load($quoteID);
421
+ // $quote->setIsActive(false);
422
+ // $quote->delete();
423
+ //
424
+ echo "OK";
425
+ } catch(Exception $e) {
426
+ echo $e->getMessage();
427
+ }
428
+ }else{
429
+ echo "no quote found";
430
+ }
431
+ }
432
+
433
+
434
+ /**
435
+ * Update apparel product configuration for a cart item
436
+ */
437
+ public function updateApparelItemOptionsAction()
438
+ {
439
+ $cart = $this->_getCart();
440
+ $params = $this->getRequest()->getParams();
441
+ $id = $this->getRequest()->getPost('id');
442
+ try {
443
+ $item = Mage::getModel('checkout/cart')->getQuote()->getItemById($id);
444
+ if (!$item) {
445
+ Mage::throwException($this->__('Quote item is not found.'));
446
+ }
447
+ $data = $item->getBuyRequest()->getData();
448
+ $data['apparel'] = $params['apparel'];
449
+ $qty = 0;
450
+ if(!empty($data['apparel'])){
451
+ foreach($data['apparel'] as $optionKey => $optionValue){
452
+ foreach($optionValue as $itemOptionKey => $itemOptionValue){
453
+ $qty += $itemOptionValue;
454
+ }
455
+ }
456
+ }
457
+ $data['qty'] = $qty;
458
+
459
+ $item = $cart->updateItem($id, new Varien_Object($data));
460
+
461
+ // exit();
462
+ if (is_string($item)) {
463
+ Mage::throwException($item);
464
+ }
465
+
466
+ $cart->save();
467
+
468
+ Mage::dispatchEvent('checkout_cart_update_item_complete',
469
+ array( 'request' => $this->getRequest(), 'response' => $this->getResponse())
470
+ );
471
+ $this->_getSession()->setCartWasUpdated(true);
472
+
473
+ } catch (Mage_Core_Exception $e) {
474
+ if ($this->_getSession()->getUseNotice(true)) {
475
+ $this->_getSession()->addNotice($e->getMessage());
476
+ } else {
477
+ $messages = array_unique(explode("\n", $e->getMessage()));
478
+ foreach ($messages as $message) {
479
+ $this->_getSession()->addError($message);
480
+ }
481
+ }
482
+
483
+ $url = $this->_getSession()->getRedirectUrl(true);
484
+ if ($url) {
485
+ $this->getResponse()->setRedirect($url);
486
+ } else {
487
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
488
+ }
489
+ } catch (Exception $e) {
490
+ $this->_getSession()->addException($e, $this->__('Cannot update the item.'));
491
+ Mage::logException($e);
492
+ //$this->_goBack();
493
+ }
494
+
495
+ $this->getResponse()->setBody( json_encode(
496
+ array("html" => Mage::app()->
497
+ getLayout()->createBlock('Mage_Checkout_Block_Cart')
498
+ ->toHtml()
499
+ )));
500
+ }
501
+
502
+ public function loadproductsAction()
503
+ {
504
+ $this->loadLayout();
505
+ $this->renderLayout();
506
+ }
507
+
508
+
509
+
510
+ }
app/code/local/Abcv/Editor/controllers/ProductController.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_ProductController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction(){
5
+ $this->loadLayout();
6
+ $this->getLayout()->getBlock('head')->setTitle($this->__('My Templates'));
7
+ //if (!Mage::getSingleton('customer/session')->isLoggedIn())
8
+ // {
9
+ // $this->_redirect("customer/account/login/*");
10
+ // }
11
+ $this->renderLayout();
12
+
13
+ }
14
+
15
+ public function indexAjaxAction(){
16
+ $block = Mage::app()->getLayout()->createBlock('editor/product');
17
+ echo $block->getPagerHtml();
18
+ echo $block->getContentHtml();
19
+ echo $block->getPagerHtml();
20
+ }
21
+
22
+ public function saveProductAction(){
23
+ if ($this->getRequest()->isPost()) {
24
+ $result = array();
25
+ $saveid = $this->getRequest()->getPost('saveid');
26
+ $productid = $this->getRequest()->getPost('productid');
27
+ $templateid = $this->getRequest()->getPost('templateid');
28
+ $customerid = $this->getRequest()->getPost('customerid');
29
+ $json = $this->getRequest()->getPost('json');
30
+ $img = $this->getRequest()->getPost('img');
31
+ $productstyleid = $this->getRequest()->getPost('productstyleid');
32
+
33
+ if ($saveid == -1){//new save
34
+ $model = Mage::getModel('editor/product');
35
+ }
36
+ else //update save
37
+ {
38
+ $model = Mage::getSingleton('editor/product')->load($saveid);
39
+ }
40
+ $model->setData('product_id',$productid);
41
+ $model->setData('template_id',$templateid);
42
+ $model->setData('customer_id',$customerid);
43
+ $model->setData('json',$json);
44
+ $model->setData('image',$img);
45
+ $model->setData('productstyle_id',$productstyleid);
46
+ try {
47
+ $model->save();
48
+ //To Anh
49
+ $arr= explode("_", $productid);
50
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
51
+ //HUY: begined 2014-01-21
52
+ $store = Mage::app()->getStore();
53
+ $query = "select IFNULL((select case name when '' then 'noname' else name end from Templates where id='".$templateid."'),'noname') name,(SELECT request_path from core_url_rewrite
54
+ where target_path = 'catalog/product/view/id/".$arr[count($arr)-1]."' and store_id='".$store->getStoreId()."') request_path";
55
+ //HUY: end 2014-01-21
56
+ $readresult = $read->query($query);
57
+ $rowsTemp = $readresult->fetch();
58
+ $result['link']="/".str_replace(".html", "",$rowsTemp["request_path"])."/editor_save/$templateid/"."$productstyleid/$saveid/".Mage::getModel('catalog/product_url')->formatUrlKey ($rowsTemp["name"]).".html";
59
+ //end To Anh
60
+ $result['id'] = $model->getId();
61
+ $result['message'] = 'Template was '. ($saveid == -1 ? 'added' : 'updated'). ' successfully.';
62
+ //creating cookie
63
+ if ($customerid == 0) //cusomter not login
64
+ {
65
+ //creating random password
66
+ $length = 8;
67
+ $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
68
+ $pass = substr(str_shuffle($chars),0,$length);
69
+
70
+ //setting cookie
71
+ $name_cookie = 'dyo3st['.$result['id'].']';
72
+ $value_cookie = $pass;
73
+ $period_cookie = 86400; //(second) ~ 1 day
74
+ $result['pass_save'] = $value_cookie;
75
+ Mage::getModel('core/cookie')->set($name_cookie, $value_cookie, $period_cookie);
76
+
77
+ }
78
+ else
79
+ {
80
+ $name_cookie = 'dyo3st['.$result['id'].']';
81
+ Mage::getModel('core/cookie')->delete($name_cookie);
82
+ }
83
+ //update path
84
+ if ($saveid == -1)
85
+ {
86
+ $model = Mage::getSingleton('editor/product')->load($result['id']);
87
+ $img = str_replace('{id}',$result['id'],$img);
88
+ $model->setData('image',$img);
89
+ $model->save();
90
+ }
91
+ }
92
+ catch (Exception $e)
93
+ {
94
+ $result['id'] = '-1';
95
+ $result['message'] = $e->getMessage();
96
+ }
97
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
98
+ }
99
+ }
100
+
101
+ public function loadProductAction(){
102
+ if ($this->getRequest()->isPost()) {
103
+ $saveid = $this->getRequest()->getPost('saveid');
104
+ $model = Mage::getSingleton('editor/product')->load($saveid);
105
+ echo $model->getData('json');
106
+ }
107
+ }
108
+
109
+ public function deleteProductAction()
110
+ {
111
+ if( $this->getRequest()->getParam('id') > 0 ) {
112
+ try {
113
+ $model = Mage::getModel('editor/product');
114
+ $model->setId($this->getRequest()->getParam('id'))->delete();
115
+ echo 'Item was successfully deleted';
116
+ } catch (Exception $e) {
117
+ echo $e->getMessage();
118
+ }
119
+ }
120
+ }
121
+
122
+ public function deleteMutiProductAction()
123
+ {
124
+ if( $this->getRequest()->getParam('id') > 0 ) {
125
+ try {
126
+ $saveId = $this->getRequest()->getParam('id');
127
+ for($i = 0; $i< count($saveId); $i++)
128
+ {
129
+ $model = Mage::getModel('editor/product');
130
+ $model->setId($saveId[$i])->delete();
131
+ }
132
+ echo 'Items was successfully deleted';
133
+ } catch (Exception $e) {
134
+ echo $e->getMessage();
135
+ }
136
+ }
137
+ }
138
+
139
+ public function updateProductAction()
140
+ {
141
+ $result = array();
142
+ if ($this->getRequest()->getParam('id') && $this->getRequest()->getParam('pass'))
143
+ {
144
+ //getting param
145
+ $saveid = $this->getRequest()->getParam('id');
146
+ $pass = $this->getRequest()->getParam('pass');
147
+ //check cookie
148
+ $objCookie = Mage::getModel('core/cookie')->get('dyo3st');
149
+
150
+ $check = false;
151
+ foreach ($objCookie as $cookie_id => $cookie_pass) {
152
+ // $result['cooki']["id"][] = $cookie_id;
153
+ // $result['cooki']["pass"][] = $cookie_pass;
154
+ if ($cookie_id == $saveid && $cookie_pass == $pass)
155
+ {
156
+ $check = true;
157
+ //remove cookie
158
+ $name_cookie = 'dyo3st['.$saveid.']';
159
+ Mage::getModel('core/cookie')->delete($name_cookie);
160
+ break;
161
+ }
162
+ }
163
+
164
+ if ($check)
165
+ {
166
+ //get customer
167
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
168
+ $customerid = $customerData->getId();
169
+ //update data
170
+ $model = Mage::getSingleton('editor/product')->load($saveid);
171
+ $model->setData('customer_id',$customerid);
172
+ $model->save();
173
+ $result['id'] = $saveid;
174
+ $result['success'] = 'Saved.';
175
+
176
+ }
177
+ else
178
+ {
179
+ $result['error'] = 'Wrong code.';
180
+ }
181
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
182
+ }
183
+ else
184
+ {
185
+ $result['error'] = 'Error.';
186
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
187
+ }
188
+ }
189
+
190
+ public function nevershowAction()
191
+ {
192
+ Mage::getSingleton('core/session')->setNeverShowSaveTemplateToAccount('nevershow');
193
+ }
194
+
195
+ }
app/code/local/Abcv/Editor/controllers/ProductDialogController.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Editor_ProductDialogController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction(){
5
+ //check method POST
6
+ if ($this->getRequest()->isPost()) {
7
+ $result = array();
8
+ //get Param
9
+ $quoteId = $this->getRequest()->getPost('quoteId');
10
+ $result['quoteId'] = $quoteId;
11
+ //get customer id
12
+ $customerData_id = 0;
13
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
14
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
15
+ $customerData_id = $customerData->getId();
16
+ }
17
+
18
+ $result['customerId'] = $customerData_id;
19
+
20
+ //getting product
21
+ $quoteItem = $cart = Mage::getModel('checkout/cart')->getQuote()->getItemById($quoteId);//getting product of cart
22
+ if ($quoteItem == NULL)
23
+ {
24
+ $result['result'] = 'error';
25
+ $result['message'] = 'Sorry, no quote item.';
26
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
27
+ return;
28
+ }
29
+ $templateid =$quoteItem->getOptionByCode('templateid')->getValue(); //template use to design
30
+ $_product = $quoteItem->getProduct();//getting Product of magento
31
+
32
+ //getting attribute
33
+ $price = $quoteItem->getPrice(); //getting Price
34
+ $productName = $_product->getName(); //getting Product Name
35
+ $qty = $quoteItem->getQty(); //getting Qty
36
+ $specialPrice = $_product->getSpecialPrice(); //getting Special Price
37
+ $model = Mage::getModel('catalog/product'); //getting product model
38
+ $_product = $model->load($_product->getId()); //getting product object for particular product id
39
+ $desription = $_product->getDescription(); //getting Description
40
+ $_tierPrices = $_product->getTierPrice(); //getting tierPrices
41
+
42
+ Mage::helper('weee')->processTierPrices($_product, $_tierPrices);
43
+
44
+ $var_quantities = '';
45
+ $var_prices = '';
46
+ $var_saves = '';
47
+ $var_real_prices = '';
48
+ $countTierPrices = 0;
49
+ foreach ($_tierPrices as $_index => $_price){
50
+ $var_quantities .= round($_price['price_qty']);
51
+ $var_prices .= $_price['formated_price_incl_weee_only'];
52
+ $var_saves .= number_format(100-$_price['price']*100/$price).'%';
53
+ $var_real_prices .= $_price['price'];
54
+ $countTierPrices++;
55
+ if($countTierPrices != count($_tierPrices))
56
+ {
57
+ $var_quantities .= ',';$var_prices .= ',';$var_saves .= ','; $var_real_prices .= ',';
58
+ }
59
+ }
60
+
61
+ //getting product option
62
+ //$helper = Mage::helper('catalog/product_configuration');
63
+ //$opList = $helper->getCustomOptions($quoteItem);
64
+ $qtopList = $quoteItem->getBuyRequest()->getData('options'); //get quote options
65
+ $productoption = $_product->getOptions();
66
+ $colorSelectData = array();
67
+ $colorSelectData['options'] = array();
68
+ foreach($productoption as $optionKey => $optionVal)
69
+ {
70
+ if ($optionVal->getType() == 'drop_down'){
71
+ $optionArr = $optionVal->toArray();
72
+ $is_color_option = $optionArr['dyo_option'] == 'dyocolor';
73
+ $jsFunc = $is_color_option ? "changeColorProductOptions(this.value)" : "changeSelectProductOptions()";
74
+ $optStr .= "<p><label class='productoptionsLabel'><select onchange='javascript:". $jsFunc .";' class='productoptions' id='options_".$optionVal->getId()."_".$optionVal->getIsrequire()."' name='".$optionVal->getTitle()."' title='". $optionVal->getDescription() ."'>";
75
+ foreach($optionVal->getValues() as $valuesKey => $valuesVal)
76
+ {
77
+ if($is_color_option){
78
+ $colorSelectData['id'] = "options_". $optionVal->getId(). "_". $optionVal->getIsrequire();
79
+ $colorSelectData['options'][] = $valuesVal->toArray();
80
+ }
81
+ $optStr .= "<option value='".$valuesVal->getId()."_".$valuesVal->getPrice()."' ";
82
+ foreach($qtopList as $qtopKey => $qtopVal)
83
+ if ($qtopKey == $optionVal->getId() && $qtopVal == $valuesVal->getId())
84
+ $optStr .= " selected ";
85
+ $optStr .= ">";
86
+ $optStr .= $valuesVal->getTitle();
87
+ if ($valuesVal->getPrice() != 0 && !$is_color_option)
88
+ $optStr .= ' +'. Mage::app()->getStore()->formatPrice($valuesVal->getPrice());
89
+ $optStr .= "</option>";
90
+ }
91
+ $optStr .= "</select></label></p>";
92
+ }
93
+ }
94
+
95
+ //get template color
96
+ $id_array = explode("_", $templateid);
97
+ $templateids = "";
98
+ foreach($id_array as $item){
99
+ if(empty($item)) continue;
100
+ $templateids .= $item . ",";
101
+ }
102
+ $templateids = substr($templateids, 0, strlen($templateids) - 1);
103
+ $readConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
104
+ $countColorList = $readConnection->fetchCol('SELECT CountColor FROM Templates where id in ('. $templateids .')');
105
+
106
+ $countColor = 0;
107
+ foreach($countColorList as $item){
108
+ $countColor += $item;
109
+ }
110
+
111
+ $result['templateId'] =$templateid;
112
+ $result['countColor'] =$countColor;
113
+ $result['price'] = Mage::app()->getStore()->formatPrice($price);
114
+ $result['productName'] = $productName;
115
+ $result['qty'] = $qty;
116
+ $result['specialPrice'] = Mage::app()->getStore()->formatPrice($specialPrice);
117
+ if ($specialPrice == 0 || $specialPrice=='')
118
+ $result['numberPrice'] = $price;
119
+ else
120
+ $result['numberPrice'] = $specialPrice;
121
+ $result['productId'] = $_product->getId();
122
+ $result['desription'] = $desription;
123
+ $result['var_quantities'] = $var_quantities;
124
+ $result['var_prices'] = $var_prices;
125
+ $result['var_saves'] = $var_saves;
126
+ $result['var_real_prices'] = $var_real_prices;
127
+ $result['productOptions'] = $optStr;
128
+ $result['one_qty_price'] = $_product->getPrice();
129
+ $result['colorSelectData'] = $colorSelectData;
130
+ $result['site_id'] = str_replace('sid','',Mage::app()->getStore()->getCode());
131
+ $result['currencySymbol'] = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
132
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
133
+ }
134
+ }
135
+
136
+ public function getApparelQuantityAction(){
137
+ $result = array();
138
+ if ($this->getRequest()->isPost()) {
139
+ //get Param
140
+ $quoteId = $this->getRequest()->getPost('quoteId');
141
+ $apparelOptionId = $this->getRequest()->getPost('apparelOptionId');
142
+
143
+ //getting product
144
+ $quoteItem = $cart = Mage::getModel('checkout/cart')->getQuote()->getItemById($quoteId);//getting product of cart
145
+ if ($quoteItem == NULL)
146
+ {
147
+ $result['result'] = 'error';
148
+ $result['message'] = 'Sorry, no quote item.';
149
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
150
+ return;
151
+ }
152
+ $_product = $quoteItem->getProduct();
153
+ $apparelOption = $quoteItem->getBuyRequest()->getData('apparel');
154
+ $productoption = $_product->getOptions();
155
+ $apparelFieldGroupData = array();
156
+ foreach($productoption as $optionKey => $optionVal)
157
+ {
158
+ if($optionVal->getId() == $apparelOptionId){
159
+ $apparelFieldGroupData['id'] = $optionVal->getId();
160
+ $apparelFieldGroupData['title'] = $optionVal->getTitle();
161
+ $apparelFieldGroupData['isRequire'] = $optionVal->getIsrequire();
162
+ foreach($optionVal->getValues() as $valuesKey => $valuesVal){
163
+ $itemArray = $valuesVal->toArray();
164
+ if(isset($apparelOption[$itemArray['option_id']])
165
+ && !empty($apparelOption[$itemArray['option_id']][$itemArray['option_type_id']])){
166
+ $itemArray['value'] = $apparelOption[$itemArray['option_id']][$itemArray['option_type_id']];
167
+ }else{
168
+ $itemArray['value'] = '';
169
+ }
170
+ $apparelFieldGroupData['options'][] = $itemArray;
171
+ }
172
+ break;
173
+ }
174
+ }
175
+ $result['quoteId'] = $quoteId;
176
+ $result['result'] = 'success';
177
+ $result['apparelFieldGroupData'] = $apparelFieldGroupData;
178
+ }else{
179
+ $result['result'] = 'error';
180
+ $result['message'] = 'Invalid request.';
181
+ }
182
+
183
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
184
+
185
+ }
186
+
187
+
188
+
189
+
190
+ }
app/code/local/Abcv/Editor/etc/adminhtml.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Sitemap
24
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <acl>
30
+ <resources>
31
+ <admin>
32
+ <children>
33
+ <system>
34
+ <children>
35
+ <config>
36
+ <children>
37
+ <abcv_section translate="title" module="editor">
38
+ <title>DYO Editor</title>
39
+ <sort_order>100</sort_order>
40
+ </abcv_section>
41
+ </children>
42
+ </config>
43
+ </children>
44
+ </system>
45
+ </children>
46
+ </admin>
47
+ </resources>
48
+ </acl>
49
+ </config>
app/code/local/Abcv/Editor/etc/config.xml ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_Editor>
5
+ <version>0.1.0</version>
6
+ </Abcv_Editor>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <editor>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Abcv_Editor</module>
14
+ <frontName>editor</frontName>
15
+ </args>
16
+ </editor>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <editor>
21
+ <file>editor.xml</file>
22
+ </editor>
23
+ </updates>
24
+ </layout>
25
+ <!-- HUY: begin 2014-02-28 -->
26
+ <events>
27
+ <checkout_cart_product_add_after>
28
+ <observers>
29
+ <abcv_editor_observer>
30
+ <type>model</type>
31
+ <class>abcv_editor_model_observer</class>
32
+ <method>setCartCondition</method>
33
+ </abcv_editor_observer>
34
+ <!--<unique_event_name>
35
+ <class>editor/observer</class>
36
+ <method>modifyPrice</method>
37
+ </unique_event_name>-->
38
+ </observers>
39
+ </checkout_cart_product_add_after>
40
+ <checkout_cart_update_item_complete>
41
+ <observers>
42
+ <abcv_editor_observer>
43
+ <type>model</type>
44
+ <class>abcv_editor_model_observer</class>
45
+ <method>updatePrice</method>
46
+ </abcv_editor_observer>
47
+ </observers>
48
+ </checkout_cart_update_item_complete>
49
+
50
+ <controller_action_predispatch>
51
+ <observers>
52
+ <controller_action_before>
53
+ <class>abcv_editor_model_observer</class>
54
+ <method>hookToControllerActionPreDispatch</method>
55
+ </controller_action_before>
56
+ </observers>
57
+ </controller_action_predispatch>
58
+
59
+
60
+
61
+ <add_to_cart_before>
62
+ <observers>
63
+ <add_to_cart_before>
64
+ <class>abcv_editor_model_observer</class>
65
+ <method>hookToAddToCartBefore</method>
66
+ </add_to_cart_before>
67
+ </observers>
68
+ </add_to_cart_before>
69
+
70
+ <controller_action_predispatch>
71
+ <observers>
72
+ <controller_action_before>
73
+ <class>abcv_editor_model_observer</class>
74
+ <method>hookToQquoteadvControllerActionPreDispatch</method>
75
+ </controller_action_before>
76
+ </observers>
77
+ </controller_action_predispatch>
78
+
79
+
80
+
81
+ <view_qquoteadv_history_before>
82
+ <observers>
83
+ <view_qquoteadv_history_before>
84
+ <class>abcv_editor_model_observer</class>
85
+ <method>hookToViewQquoteadvHistoryBefore</method>
86
+ </view_qquoteadv_history_before>
87
+ </observers>
88
+ </view_qquoteadv_history_before>
89
+
90
+ <!-- 10.09.2014 DANG -->
91
+ <checkout_onepage_controller_success_action>
92
+ <observers>
93
+ <qquoteadv_logout>
94
+ <type>singleton</type>
95
+ <class>abcv_editor_model_observer</class>
96
+ <method>setC2qRefNumberAndStatus</method>
97
+ </qquoteadv_logout>
98
+ </observers>
99
+ </checkout_onepage_controller_success_action>
100
+ <!-- 10.09.2014 END DANG -->
101
+ </events>
102
+ <!-- HUY: end 2014-02-28 -->
103
+ </frontend>
104
+ <admin>
105
+ <routers>
106
+ <editor>
107
+ <use>admin</use>
108
+ <args>
109
+ <module>Abcv_Editor</module>
110
+ <frontName>editor</frontName>
111
+ </args>
112
+ </editor>
113
+ </routers>
114
+ </admin>
115
+ <adminhtml>
116
+ <menu>
117
+ <editor module="editor">
118
+ <title>DYO</title>
119
+ <sort_order>71</sort_order>
120
+ <children>
121
+ <firstitem module="editor">
122
+ <title>Template Editor</title>
123
+ <sort_order>0</sort_order>
124
+ <action>editor/adminhtml_editor</action>
125
+ </firstitem>
126
+ <seconditem module="editor">
127
+ <title>Manage Category</title>
128
+ <sort_order>1</sort_order>
129
+ <action>editor/adminhtml_category/test</action>
130
+ </seconditem>
131
+ <!-- <thirditem module="editor"> <title>Manage Category old</title>
132
+ <sort_order>2</sort_order> <action>editor/adminhtml_category</action> </thirditem> -->
133
+ </children>
134
+ </editor>
135
+ </menu>
136
+ <acl>
137
+ <resources>
138
+ <all>
139
+ <title>Allow Everything</title>
140
+ </all>
141
+ <admin>
142
+ <children>
143
+ <editor translate="title" module="editor">
144
+ <!-- Name in Role Resources -->
145
+ <title>DYO</title>
146
+ <sort_order>10</sort_order>
147
+ <!-- add sub items -->
148
+ <children>
149
+ <firstitem translate="title" module="editor">
150
+ <title>Template Editor</title>
151
+ <sort_order>0</sort_order>
152
+ <action>editor/adminhtml_editor</action>
153
+ </firstitem>
154
+ <seconditem translate="title" module="editor">
155
+ <title>Manage Category</title>
156
+ <sort_order>1</sort_order>
157
+ <action>editor/adminhtml_category</action>
158
+ </seconditem>
159
+ </children>
160
+
161
+ </editor>
162
+ </children>
163
+ </admin>
164
+ </resources>
165
+ </acl>
166
+ <layout>
167
+ <updates>
168
+ <editor>
169
+ <file>editor.xml</file>
170
+ </editor>
171
+ </updates>
172
+ </layout>
173
+ </adminhtml>
174
+ <global>
175
+ <models>
176
+ <editor>
177
+ <class>Abcv_Editor_Model</class>
178
+ <resourceModel>editor_mysql4</resourceModel>
179
+ </editor>
180
+ <editor_mysql4>
181
+ <class>Abcv_Editor_Model_Mysql4</class>
182
+ <entities>
183
+ <editor>
184
+ <table>editor</table>
185
+ </editor>
186
+ </entities>
187
+ </editor_mysql4>
188
+
189
+ <product>
190
+ <class>Abcv_Editor_Model</class>
191
+ <resourceModel>editor_mysql4</resourceModel>
192
+ </product>
193
+ <editor_mysql4>
194
+ <class>Abcv_Editor_Model_Mysql4</class>
195
+ <entities>
196
+ <product>
197
+ <table>abcv_product_save</table>
198
+ </product>
199
+ </entities>
200
+ </editor_mysql4>
201
+ <!--2014.05.13 DANG -->
202
+ <sales>
203
+ <rewrite>
204
+ <quote_item>Abcv_Editor_Model_Quote_Item</quote_item>
205
+ </rewrite>
206
+ </sales>
207
+ <!--END 2014.05.13 DANG -->
208
+ </models>
209
+
210
+
211
+ <resources>
212
+ <editor_setup>
213
+ <setup>
214
+ <module>Abcv_Editor</module>
215
+ </setup>
216
+ <connection>
217
+ <use>core_setup</use>
218
+ </connection>
219
+ </editor_setup>
220
+ <editor_write>
221
+ <connection>
222
+ <use>core_write</use>
223
+ </connection>
224
+ </editor_write>
225
+ <editor_read>
226
+ <connection>
227
+ <use>core_read</use>
228
+ </connection>
229
+ </editor_read>
230
+ </resources>
231
+ <blocks>
232
+ <editor>
233
+ <class>Abcv_Editor_Block</class>
234
+ </editor>
235
+ </blocks>
236
+ <!--2014.05.13 DANG -->
237
+ <blocks>
238
+ <checkout>
239
+ <rewrite>
240
+ <cart_item_renderer>Abcv_Editor_Block_Cart_Item_Renderer</cart_item_renderer>
241
+ </rewrite>
242
+ </checkout>
243
+ </blocks>
244
+ <!--END 2014.05.13 DANG -->
245
+ <helpers>
246
+ <editor>
247
+ <class>Abcv_Editor_Helper</class>
248
+ </editor>
249
+ </helpers>
250
+ <rewrite>
251
+
252
+ <fancy_url><!-- [product_url]/editor/[template_id]/[template_name] -->
253
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor/([0-9._]+)?/?([-\A-Za-z0-9._]+)?$#]]></from>
254
+ <to><![CDATA[/editor/index/template/template/$2/product/$1]]></to>
255
+ <complete>1</complete>
256
+ </fancy_url>
257
+ <cart_url><!-- [product_url]/editor_cart/[quote]/[template_id]/[template_name] -->
258
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_cart/([0-9]+)?/([0-9._]+)?/?(.*)?$#]]></from>
259
+ <to><![CDATA[/editor/index/template/template/$3/product/$2/editor/1]]></to>
260
+ <complete>1</complete>
261
+ </cart_url>
262
+ <save_url><!-- [product_url]/editor_save/[template_id]/[productstyle]/[save]/[template_name] -->
263
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_save/([0-9._]+)?/?([-\A-Za-z0-9._]+)?/?([-\A-Za-z0-9._]+)?/?(.*)?$#]]></from>
264
+ <to><![CDATA[/editor/index/template/template/$2/product/$1/productstyle/$3/save/$4]]></to>
265
+ <complete>1</complete>
266
+ </save_url>
267
+ <editor_url>
268
+ <from><![CDATA[#^/editor/index/template/template/([-\A-Za-z0-9.]+)?/product/?([-\A-Za-z0-9.]+)?$#]]></from>
269
+ <to><![CDATA[/editor/index/template/template/$1/product/$2]]></to>
270
+ <complete>1</complete>
271
+ </editor_url>
272
+
273
+ </rewrite>
274
+ </global>
275
+ </config>
app/code/local/Abcv/Editor/etc/config.xml.bak ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_Editor>
5
+ <version>0.1.0</version>
6
+ </Abcv_Editor>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <editor>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Abcv_Editor</module>
14
+ <frontName>editor</frontName>
15
+ </args>
16
+ </editor>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <editor>
21
+ <file>editor.xml</file>
22
+ </editor>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <editor>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Abcv_Editor</module>
32
+ <frontName>editor</frontName>
33
+ </args>
34
+ </editor>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <editor module="editor">
40
+ <title>DYO</title>
41
+ <sort_order>71</sort_order>
42
+ <children>
43
+ <firstitem module="editor">
44
+ <title>Template Editor</title>
45
+ <sort_order>0</sort_order>
46
+ <action>editor/adminhtml_editor</action>
47
+ </firstitem>
48
+ <seconditem module="editor">
49
+ <title>Manage Category</title>
50
+ <sort_order>1</sort_order>
51
+ <action>editor/adminhtml_category/test</action>
52
+ </seconditem>
53
+ <!-- <thirditem module="editor"> <title>Manage Category old</title>
54
+ <sort_order>2</sort_order> <action>editor/adminhtml_category</action> </thirditem> -->
55
+ </children>
56
+ </editor>
57
+ </menu>
58
+ <acl>
59
+ <resources>
60
+ <all>
61
+ <title>Allow Everything</title>
62
+ </all>
63
+ <admin>
64
+ <children>
65
+ <editor translate="title" module="editor">
66
+ <!-- Name in Role Resources -->
67
+ <title>DYO</title>
68
+ <sort_order>10</sort_order>
69
+ <!-- add sub items -->
70
+ <children>
71
+ <firstitem translate="title" module="editor">
72
+ <title>Template Editor</title>
73
+ <sort_order>0</sort_order>
74
+ <action>editor/adminhtml_editor</action>
75
+ </firstitem>
76
+ <seconditem translate="title" module="editor">
77
+ <title>Manage Category</title>
78
+ <sort_order>1</sort_order>
79
+ <action>editor/adminhtml_category</action>
80
+ </seconditem>
81
+ </children>
82
+
83
+ </editor>
84
+ </children>
85
+ </admin>
86
+ </resources>
87
+ </acl>
88
+ <layout>
89
+ <updates>
90
+ <editor>
91
+ <file>editor.xml</file>
92
+ </editor>
93
+ </updates>
94
+ </layout>
95
+ </adminhtml>
96
+ <global>
97
+ <models>
98
+ <editor>
99
+ <class>Abcv_Editor_Model</class>
100
+ <resourceModel>editor_mysql4</resourceModel>
101
+ </editor>
102
+ <editor_mysql4>
103
+ <class>Abcv_Editor_Model_Mysql4</class>
104
+ <entities>
105
+ <editor>
106
+ <table>editor</table>
107
+ </editor>
108
+ </entities>
109
+ </editor_mysql4>
110
+
111
+ <product>
112
+ <class>Abcv_Editor_Model</class>
113
+ <resourceModel>editor_mysql4</resourceModel>
114
+ </product>
115
+ <editor_mysql4>
116
+ <class>Abcv_Editor_Model_Mysql4</class>
117
+ <entities>
118
+ <product>
119
+ <table>abcv_product_save</table>
120
+ </product>
121
+ </entities>
122
+ </editor_mysql4>
123
+ </models>
124
+
125
+
126
+ <resources>
127
+ <editor_setup>
128
+ <setup>
129
+ <module>Abcv_Editor</module>
130
+ </setup>
131
+ <connection>
132
+ <use>core_setup</use>
133
+ </connection>
134
+ </editor_setup>
135
+ <editor_write>
136
+ <connection>
137
+ <use>core_write</use>
138
+ </connection>
139
+ </editor_write>
140
+ <editor_read>
141
+ <connection>
142
+ <use>core_read</use>
143
+ </connection>
144
+ </editor_read>
145
+ </resources>
146
+ <blocks>
147
+ <editor>
148
+ <class>Abcv_Editor_Block</class>
149
+ </editor>
150
+ </blocks>
151
+ <helpers>
152
+ <editor>
153
+ <class>Abcv_Editor_Helper</class>
154
+ </editor>
155
+ </helpers>
156
+ <rewrite>
157
+
158
+ <fancy_url><!-- [product_url]/editor/[template_id]/[template_name] -->
159
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor/([0-9]+)?/?([-\A-Za-z0-9._]+)?$#]]></from>
160
+ <to><![CDATA[/editor/index/template/template/$2/product/$1]]></to>
161
+ <complete>1</complete>
162
+ </fancy_url>
163
+ <cart_url><!-- [product_url]/editor_cart/[quote]/[template_id]/[template_name] -->
164
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_cart/([0-9]+)?/([0-9_]+)?/?(.*)?$#]]></from>
165
+ <to><![CDATA[/editor/index/template/template/$3/product/$2/editor/1]]></to>
166
+ <complete>1</complete>
167
+ </cart_url>
168
+ <save_url><!-- [product_url]/editor_save/[template_id]/[productstyle]/[save]/[template_name] -->
169
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_save/([0-9]+)?/?([-\A-Za-z0-9._]+)?/?([-\A-Za-z0-9._]+)?/?(.*)?$#]]></from>
170
+ <to><![CDATA[/editor/index/template/template/$2/product/$1/productstyle/$3/save/$4]]></to>
171
+ <complete>1</complete>
172
+ </save_url>
173
+ <editor_url>
174
+ <from><![CDATA[#^/editor/index/template/template/([-\A-Za-z0-9.]+)?/product/?([-\A-Za-z0-9.]+)?$#]]></from>
175
+ <to><![CDATA[/editor/index/template/template/$1/product/$2]]></to>
176
+ <complete>1</complete>
177
+ </editor_url>
178
+
179
+ </rewrite>
180
+ </global>
181
+ </config>
app/code/local/Abcv/Editor/etc/config.xml_03.06.2015 ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_Editor>
5
+ <version>0.1.0</version>
6
+ </Abcv_Editor>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <editor>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Abcv_Editor</module>
14
+ <frontName>editor</frontName>
15
+ </args>
16
+ </editor>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <editor>
21
+ <file>editor.xml</file>
22
+ </editor>
23
+ </updates>
24
+ </layout>
25
+ <!-- HUY: begin 2014-02-28 -->
26
+ <events>
27
+ <checkout_cart_product_add_after>
28
+ <observers>
29
+ <abcv_editor_observer>
30
+ <type>model</type>
31
+ <class>abcv_editor_model_observer</class>
32
+ <method>setCartCondition</method>
33
+ </abcv_editor_observer>
34
+ <!--<unique_event_name>
35
+ <class>editor/observer</class>
36
+ <method>modifyPrice</method>
37
+ </unique_event_name>-->
38
+ </observers>
39
+ </checkout_cart_product_add_after>
40
+ <checkout_cart_update_item_complete>
41
+ <observers>
42
+ <abcv_editor_observer>
43
+ <type>model</type>
44
+ <class>abcv_editor_model_observer</class>
45
+ <method>updatePrice</method>
46
+ </abcv_editor_observer>
47
+ </observers>
48
+ </checkout_cart_update_item_complete>
49
+
50
+ <controller_action_predispatch>
51
+ <observers>
52
+ <controller_action_before>
53
+ <class>abcv_editor_model_observer</class>
54
+ <method>hookToControllerActionPreDispatch</method>
55
+ </controller_action_before>
56
+ </observers>
57
+ </controller_action_predispatch>
58
+
59
+
60
+
61
+ <add_to_cart_before>
62
+ <observers>
63
+ <add_to_cart_before>
64
+ <class>abcv_editor_model_observer</class>
65
+ <method>hookToAddToCartBefore</method>
66
+ </add_to_cart_before>
67
+ </observers>
68
+ </add_to_cart_before>
69
+
70
+ <controller_action_predispatch>
71
+ <observers>
72
+ <controller_action_before>
73
+ <class>abcv_editor_model_observer</class>
74
+ <method>hookToQquoteadvControllerActionPreDispatch</method>
75
+ </controller_action_before>
76
+ </observers>
77
+ </controller_action_predispatch>
78
+
79
+
80
+
81
+ <view_qquoteadv_history_before>
82
+ <observers>
83
+ <view_qquoteadv_history_before>
84
+ <class>abcv_editor_model_observer</class>
85
+ <method>hookToViewQquoteadvHistoryBefore</method>
86
+ </view_qquoteadv_history_before>
87
+ </observers>
88
+ </view_qquoteadv_history_before>
89
+
90
+ <!-- 10.09.2014 DANG -->
91
+ <checkout_onepage_controller_success_action>
92
+ <observers>
93
+ <qquoteadv_logout>
94
+ <type>singleton</type>
95
+ <class>abcv_editor_model_observer</class>
96
+ <method>setC2qRefNumberAndStatus</method>
97
+ </qquoteadv_logout>
98
+ </observers>
99
+ </checkout_onepage_controller_success_action>
100
+
101
+ <checkout_type_onepage_save_order_after>
102
+ <observers>
103
+ <checkout_onepage_controller_success_action>
104
+ <type>singleton</type>
105
+ <class>abcv_editor_model_observer</class>
106
+ <method>setOrderStatus</method>
107
+ </checkout_onepage_controller_success_action>
108
+ </observers>
109
+ </checkout_type_onepage_save_order_after>
110
+
111
+ <!-- 10.09.2014 END DANG -->
112
+ </events>
113
+ <!-- HUY: end 2014-02-28 -->
114
+ </frontend>
115
+ <admin>
116
+ <routers>
117
+ <editor>
118
+ <use>admin</use>
119
+ <args>
120
+ <module>Abcv_Editor</module>
121
+ <frontName>editor</frontName>
122
+ </args>
123
+ </editor>
124
+ </routers>
125
+ </admin>
126
+ <adminhtml>
127
+ <menu>
128
+ <editor module="editor">
129
+ <title>DYO</title>
130
+ <sort_order>71</sort_order>
131
+ <children>
132
+ <firstitem module="editor">
133
+ <title>Template Editor</title>
134
+ <sort_order>0</sort_order>
135
+ <action>editor/adminhtml_editor</action>
136
+ </firstitem>
137
+ <seconditem module="editor">
138
+ <title>Manage Category</title>
139
+ <sort_order>1</sort_order>
140
+ <action>editor/adminhtml_category/test</action>
141
+ </seconditem>
142
+ <!-- <thirditem module="editor"> <title>Manage Category old</title>
143
+ <sort_order>2</sort_order> <action>editor/adminhtml_category</action> </thirditem> -->
144
+ </children>
145
+ </editor>
146
+ </menu>
147
+ <acl>
148
+ <resources>
149
+ <all>
150
+ <title>Allow Everything</title>
151
+ </all>
152
+ <admin>
153
+ <children>
154
+ <editor translate="title" module="editor">
155
+ <!-- Name in Role Resources -->
156
+ <title>DYO</title>
157
+ <sort_order>10</sort_order>
158
+ <!-- add sub items -->
159
+ <children>
160
+ <firstitem translate="title" module="editor">
161
+ <title>Template Editor</title>
162
+ <sort_order>0</sort_order>
163
+ <action>editor/adminhtml_editor</action>
164
+ </firstitem>
165
+ <seconditem translate="title" module="editor">
166
+ <title>Manage Category</title>
167
+ <sort_order>1</sort_order>
168
+ <action>editor/adminhtml_category</action>
169
+ </seconditem>
170
+ </children>
171
+
172
+ </editor>
173
+ </children>
174
+ </admin>
175
+ </resources>
176
+ </acl>
177
+ <layout>
178
+ <updates>
179
+ <editor>
180
+ <file>editor.xml</file>
181
+ </editor>
182
+ </updates>
183
+ </layout>
184
+ </adminhtml>
185
+ <global>
186
+ <models>
187
+ <editor>
188
+ <class>Abcv_Editor_Model</class>
189
+ <resourceModel>editor_mysql4</resourceModel>
190
+ </editor>
191
+ <editor_mysql4>
192
+ <class>Abcv_Editor_Model_Mysql4</class>
193
+ <entities>
194
+ <editor>
195
+ <table>editor</table>
196
+ </editor>
197
+ </entities>
198
+ </editor_mysql4>
199
+
200
+ <product>
201
+ <class>Abcv_Editor_Model</class>
202
+ <resourceModel>editor_mysql4</resourceModel>
203
+ </product>
204
+ <editor_mysql4>
205
+ <class>Abcv_Editor_Model_Mysql4</class>
206
+ <entities>
207
+ <product>
208
+ <table>abcv_product_save</table>
209
+ </product>
210
+ </entities>
211
+ </editor_mysql4>
212
+ <!--2014.05.13 DANG -->
213
+ <sales>
214
+ <rewrite>
215
+ <quote_item>Abcv_Editor_Model_Quote_Item</quote_item>
216
+ </rewrite>
217
+ </sales>
218
+ <!--END 2014.05.13 DANG -->
219
+ </models>
220
+
221
+
222
+ <resources>
223
+ <editor_setup>
224
+ <setup>
225
+ <module>Abcv_Editor</module>
226
+ </setup>
227
+ <connection>
228
+ <use>core_setup</use>
229
+ </connection>
230
+ </editor_setup>
231
+ <editor_write>
232
+ <connection>
233
+ <use>core_write</use>
234
+ </connection>
235
+ </editor_write>
236
+ <editor_read>
237
+ <connection>
238
+ <use>core_read</use>
239
+ </connection>
240
+ </editor_read>
241
+ </resources>
242
+ <blocks>
243
+ <editor>
244
+ <class>Abcv_Editor_Block</class>
245
+ </editor>
246
+ </blocks>
247
+ <!--2014.05.13 DANG -->
248
+ <blocks>
249
+ <checkout>
250
+ <rewrite>
251
+ <cart_item_renderer>Abcv_Editor_Block_Cart_Item_Renderer</cart_item_renderer>
252
+ </rewrite>
253
+ </checkout>
254
+ </blocks>
255
+ <!--END 2014.05.13 DANG -->
256
+ <helpers>
257
+ <editor>
258
+ <class>Abcv_Editor_Helper</class>
259
+ </editor>
260
+ </helpers>
261
+ <rewrite>
262
+
263
+ <fancy_url><!-- [product_url]/editor/[template_id]/[template_name] -->
264
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor/([0-9._]+)?/?([-\A-Za-z0-9._]+)?$#]]></from>
265
+ <to><![CDATA[/editor/index/template/template/$2/product/$1]]></to>
266
+ <complete>1</complete>
267
+ </fancy_url>
268
+ <cart_url><!-- [product_url]/editor_cart/[quote]/[template_id]/[template_name] -->
269
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_cart/([0-9]+)?/([0-9._]+)?/?(.*)?$#]]></from>
270
+ <to><![CDATA[/editor/index/template/template/$3/product/$2/editor/1]]></to>
271
+ <complete>1</complete>
272
+ </cart_url>
273
+ <save_url><!-- [product_url]/editor_save/[template_id]/[productstyle]/[save]/[template_name] -->
274
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_save/([0-9._]+)?/?([-\A-Za-z0-9._]+)?/?([-\A-Za-z0-9._]+)?/?(.*)?$#]]></from>
275
+ <to><![CDATA[/editor/index/template/template/$2/product/$1/productstyle/$3/save/$4]]></to>
276
+ <complete>1</complete>
277
+ </save_url>
278
+ <editor_url>
279
+ <from><![CDATA[#^/editor/index/template/template/([-\A-Za-z0-9.]+)?/product/?([-\A-Za-z0-9.]+)?$#]]></from>
280
+ <to><![CDATA[/editor/index/template/template/$1/product/$2]]></to>
281
+ <complete>1</complete>
282
+ </editor_url>
283
+
284
+ </rewrite>
285
+ </global>
286
+ </config>
app/code/local/Abcv/Editor/etc/config_12.15.2014.xml ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_Editor>
5
+ <version>0.1.0</version>
6
+ </Abcv_Editor>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <editor>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Abcv_Editor</module>
14
+ <frontName>editor</frontName>
15
+ </args>
16
+ </editor>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <editor>
21
+ <file>editor.xml</file>
22
+ </editor>
23
+ </updates>
24
+ </layout>
25
+ <!-- HUY: begin 2014-02-28 -->
26
+ <events>
27
+ <checkout_cart_product_add_after>
28
+ <observers>
29
+ <abcv_editor_observer>
30
+ <type>model</type>
31
+ <class>abcv_editor_model_observer</class>
32
+ <method>setCartCondition</method>
33
+ </abcv_editor_observer>
34
+ <!--<unique_event_name>
35
+ <class>editor/observer</class>
36
+ <method>modifyPrice</method>
37
+ </unique_event_name>-->
38
+ </observers>
39
+ </checkout_cart_product_add_after>
40
+ <checkout_cart_update_item_complete>
41
+ <observers>
42
+ <abcv_editor_observer>
43
+ <type>model</type>
44
+ <class>abcv_editor_model_observer</class>
45
+ <method>updatePrice</method>
46
+ </abcv_editor_observer>
47
+ </observers>
48
+ </checkout_cart_update_item_complete>
49
+
50
+ <controller_action_predispatch>
51
+ <observers>
52
+ <controller_action_before>
53
+ <class>abcv_editor_model_observer</class>
54
+ <method>hookToControllerActionPreDispatch</method>
55
+ </controller_action_before>
56
+ </observers>
57
+ </controller_action_predispatch>
58
+
59
+
60
+
61
+ <add_to_cart_before>
62
+ <observers>
63
+ <add_to_cart_before>
64
+ <class>abcv_editor_model_observer</class>
65
+ <method>hookToAddToCartBefore</method>
66
+ </add_to_cart_before>
67
+ </observers>
68
+ </add_to_cart_before>
69
+
70
+ <controller_action_predispatch>
71
+ <observers>
72
+ <controller_action_before>
73
+ <class>abcv_editor_model_observer</class>
74
+ <method>hookToQquoteadvControllerActionPreDispatch</method>
75
+ </controller_action_before>
76
+ </observers>
77
+ </controller_action_predispatch>
78
+
79
+
80
+
81
+ <view_qquoteadv_history_before>
82
+ <observers>
83
+ <view_qquoteadv_history_before>
84
+ <class>abcv_editor_model_observer</class>
85
+ <method>hookToViewQquoteadvHistoryBefore</method>
86
+ </view_qquoteadv_history_before>
87
+ </observers>
88
+ </view_qquoteadv_history_before>
89
+
90
+ <!-- 10.09.2014 DANG -->
91
+ <checkout_onepage_controller_success_action>
92
+ <observers>
93
+ <qquoteadv_logout>
94
+ <type>singleton</type>
95
+ <class>abcv_editor_model_observer</class>
96
+ <method>setC2qRefNumberAndStatus</method>
97
+ </qquoteadv_logout>
98
+ </observers>
99
+ </checkout_onepage_controller_success_action>
100
+
101
+ <checkout_type_onepage_save_order_after>
102
+ <observers>
103
+ <checkout_onepage_controller_success_action>
104
+ <type>singleton</type>
105
+ <class>abcv_editor_model_observer</class>
106
+ <method>setOrderStatus</method>
107
+ </checkout_onepage_controller_success_action>
108
+ </observers>
109
+ </checkout_type_onepage_save_order_after>
110
+
111
+ <!-- 10.09.2014 END DANG -->
112
+ </events>
113
+ <!-- HUY: end 2014-02-28 -->
114
+ </frontend>
115
+ <admin>
116
+ <routers>
117
+ <editor>
118
+ <use>admin</use>
119
+ <args>
120
+ <module>Abcv_Editor</module>
121
+ <frontName>editor</frontName>
122
+ </args>
123
+ </editor>
124
+ </routers>
125
+ </admin>
126
+ <adminhtml>
127
+ <menu>
128
+ <editor module="editor">
129
+ <title>DYO</title>
130
+ <sort_order>71</sort_order>
131
+ <children>
132
+ <firstitem module="editor">
133
+ <title>Template Editor</title>
134
+ <sort_order>0</sort_order>
135
+ <action>editor/adminhtml_editor</action>
136
+ </firstitem>
137
+ <seconditem module="editor">
138
+ <title>Manage Category</title>
139
+ <sort_order>1</sort_order>
140
+ <action>editor/adminhtml_category/test</action>
141
+ </seconditem>
142
+ <!-- <thirditem module="editor"> <title>Manage Category old</title>
143
+ <sort_order>2</sort_order> <action>editor/adminhtml_category</action> </thirditem> -->
144
+ </children>
145
+ </editor>
146
+ </menu>
147
+ <acl>
148
+ <resources>
149
+ <all>
150
+ <title>Allow Everything</title>
151
+ </all>
152
+ <admin>
153
+ <children>
154
+ <editor translate="title" module="editor">
155
+ <!-- Name in Role Resources -->
156
+ <title>DYO</title>
157
+ <sort_order>10</sort_order>
158
+ <!-- add sub items -->
159
+ <children>
160
+ <firstitem translate="title" module="editor">
161
+ <title>Template Editor</title>
162
+ <sort_order>0</sort_order>
163
+ <action>editor/adminhtml_editor</action>
164
+ </firstitem>
165
+ <seconditem translate="title" module="editor">
166
+ <title>Manage Category</title>
167
+ <sort_order>1</sort_order>
168
+ <action>editor/adminhtml_category</action>
169
+ </seconditem>
170
+ </children>
171
+
172
+ </editor>
173
+ </children>
174
+ </admin>
175
+ </resources>
176
+ </acl>
177
+ <layout>
178
+ <updates>
179
+ <editor>
180
+ <file>editor.xml</file>
181
+ </editor>
182
+ </updates>
183
+ </layout>
184
+ </adminhtml>
185
+ <global>
186
+ <models>
187
+ <editor>
188
+ <class>Abcv_Editor_Model</class>
189
+ <resourceModel>editor_mysql4</resourceModel>
190
+ </editor>
191
+ <editor_mysql4>
192
+ <class>Abcv_Editor_Model_Mysql4</class>
193
+ <entities>
194
+ <editor>
195
+ <table>editor</table>
196
+ </editor>
197
+ </entities>
198
+ </editor_mysql4>
199
+
200
+ <product>
201
+ <class>Abcv_Editor_Model</class>
202
+ <resourceModel>editor_mysql4</resourceModel>
203
+ </product>
204
+ <editor_mysql4>
205
+ <class>Abcv_Editor_Model_Mysql4</class>
206
+ <entities>
207
+ <product>
208
+ <table>abcv_product_save</table>
209
+ </product>
210
+ </entities>
211
+ </editor_mysql4>
212
+ <!--2014.05.13 DANG -->
213
+ <sales>
214
+ <rewrite>
215
+ <quote_item>Abcv_Editor_Model_Quote_Item</quote_item>
216
+ </rewrite>
217
+ </sales>
218
+ <!--END 2014.05.13 DANG -->
219
+ </models>
220
+
221
+
222
+ <resources>
223
+ <editor_setup>
224
+ <setup>
225
+ <module>Abcv_Editor</module>
226
+ </setup>
227
+ <connection>
228
+ <use>core_setup</use>
229
+ </connection>
230
+ </editor_setup>
231
+ <editor_write>
232
+ <connection>
233
+ <use>core_write</use>
234
+ </connection>
235
+ </editor_write>
236
+ <editor_read>
237
+ <connection>
238
+ <use>core_read</use>
239
+ </connection>
240
+ </editor_read>
241
+ </resources>
242
+ <blocks>
243
+ <editor>
244
+ <class>Abcv_Editor_Block</class>
245
+ </editor>
246
+ </blocks>
247
+ <!--2014.05.13 DANG -->
248
+ <blocks>
249
+ <checkout>
250
+ <rewrite>
251
+ <cart_item_renderer>Abcv_Editor_Block_Cart_Item_Renderer</cart_item_renderer>
252
+ </rewrite>
253
+ </checkout>
254
+ </blocks>
255
+ <!--END 2014.05.13 DANG -->
256
+ <helpers>
257
+ <editor>
258
+ <class>Abcv_Editor_Helper</class>
259
+ </editor>
260
+ </helpers>
261
+ <rewrite>
262
+
263
+ <fancy_url><!-- [product_url]/editor/[template_id]/[template_name] -->
264
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor/([0-9._]+)?/?([-\A-Za-z0-9._]+)?$#]]></from>
265
+ <to><![CDATA[/editor/index/template/template/$2/product/$1]]></to>
266
+ <complete>1</complete>
267
+ </fancy_url>
268
+ <cart_url><!-- [product_url]/editor_cart/[quote]/[template_id]/[template_name] -->
269
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_cart/([0-9]+)?/([0-9._]+)?/?(.*)?$#]]></from>
270
+ <to><![CDATA[/editor/index/template/template/$3/product/$2/editor/1]]></to>
271
+ <complete>1</complete>
272
+ </cart_url>
273
+ <save_url><!-- [product_url]/editor_save/[template_id]/[productstyle]/[save]/[template_name] -->
274
+ <from><![CDATA[#^/?([-\A-Za-z0-9.]+)?/editor_save/([0-9._]+)?/?([-\A-Za-z0-9._]+)?/?([-\A-Za-z0-9._]+)?/?(.*)?$#]]></from>
275
+ <to><![CDATA[/editor/index/template/template/$2/product/$1/productstyle/$3/save/$4]]></to>
276
+ <complete>1</complete>
277
+ </save_url>
278
+ <editor_url>
279
+ <from><![CDATA[#^/editor/index/template/template/([-\A-Za-z0-9.]+)?/product/?([-\A-Za-z0-9.]+)?$#]]></from>
280
+ <to><![CDATA[/editor/index/template/template/$1/product/$2]]></to>
281
+ <complete>1</complete>
282
+ </editor_url>
283
+
284
+ </rewrite>
285
+ </global>
286
+ </config>
app/code/local/Abcv/Editor/etc/system.xml ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Sitemap
24
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+
30
+ <sections>
31
+ <abcv_section module="editor" translate="label">
32
+ <label>DYO Editor</label>
33
+ <sort_order>200</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <tab>catalog</tab>
38
+ <groups>
39
+ <editor_option translate="label">
40
+ <label>Editor Options </label>
41
+ <sort_order>1</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
+ <fields>
46
+ <design_online_btn translate="label tooltip comment">
47
+ <label>Design Button Label</label>
48
+ <comment>This text will show in fontend</comment>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>1</sort_order>
54
+ </design_online_btn>
55
+ <warning_mess translate="label tooltip comment">
56
+ <label>Leaving Editor Warning Message</label>
57
+ <comment>This text will show when user in Editor Page and leave it without save.</comment>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <frontend_type>Textarea</frontend_type>
62
+ <sort_order>2</sort_order>
63
+ </warning_mess>
64
+ <undo_redo_limit translate="label tooltip comment">
65
+ <label>Number Of Undo/Redo</label>
66
+ <comment>This is number time undo/redo on Editor Page.</comment>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <frontend_type>Text</frontend_type>
71
+ <validate>validate-number</validate>
72
+ <sort_order>3</sort_order>
73
+ </undo_redo_limit>
74
+ <upload_number_limit translate="label tooltip comment">
75
+ <label>Number Of Upload Images On Editor Page And Manage Template Of Admin</label>
76
+ <comment>This is number of images the user upload one time on Editor Page/ And Manage Template Of Admin.</comment>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ <frontend_type>Text</frontend_type>
81
+ <validate>validate-number</validate>
82
+ <sort_order>4</sort_order>
83
+ </upload_number_limit>
84
+ <google_api_client_id translate="label tooltip comment">
85
+ <label>Google API Client ID</label>
86
+ <comment>Google API Client ID to access Google Drive</comment>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <frontend_type>Text</frontend_type>
91
+ <sort_order>5</sort_order>
92
+ </google_api_client_id>
93
+
94
+ <google_api_client_secret translate="label tooltip comment">
95
+ <label>Google API Client Secret</label>
96
+ <comment>Google API Client Secret to access Google Drive</comment>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <frontend_type>Text</frontend_type>
101
+ <sort_order>6</sort_order>
102
+ </google_api_client_secret>
103
+
104
+ <instagram_api_client_id translate="label tooltip comment">
105
+ <label>Instagram API Client ID</label>
106
+ <comment>Instagram API Client ID to access Instagram</comment>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ <frontend_type>Text</frontend_type>
111
+ <sort_order>7</sort_order>
112
+ </instagram_api_client_id>
113
+
114
+ <instagram_api_client_secret translate="label tooltip comment">
115
+ <label>Instagram API Client Secret</label>
116
+ <comment>Instagram API Client Secret to access Instagram</comment>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ <frontend_type>Text</frontend_type>
121
+ <sort_order>8</sort_order>
122
+ </instagram_api_client_secret>
123
+ </fields>
124
+ </editor_option>
125
+ <image_option translate="label">
126
+ <label>Image Upload Limit</label>
127
+ <sort_order>3</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>1</show_in_store>
131
+ <fields>
132
+ <img_size_limit translate="label tooltip comment">
133
+ <label>Maximum File Size(MB)</label>
134
+ <comment>Maximum image file size per upload.</comment>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ <frontend_type>Text</frontend_type>
139
+ <validate>validate-number</validate>
140
+ <sort_order>1</sort_order>
141
+ </img_size_limit>
142
+ <img_max_w translate="label tooltip comment">
143
+ <label>Maximum Width(pixel)</label>
144
+ <comment>Maximum width of an upload image.</comment>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ <frontend_type>Text</frontend_type>
149
+ <validate>validate-number</validate>
150
+ <sort_order>2</sort_order>
151
+ </img_max_w>
152
+ <img_max_h translate="label tooltip comment">
153
+ <label>Maximum Height(pixel)</label>
154
+ <comment>Maximum height of an upload image.</comment>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>1</show_in_store>
158
+ <frontend_type>Text</frontend_type>
159
+ <validate>validate-number</validate>
160
+ <sort_order>3</sort_order>
161
+ </img_max_h>
162
+ <img_size_min translate="label tooltip comment">
163
+ <label>Minimum File Size(KB)</label>
164
+ <comment>Minimum image file size per upload.</comment>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ <frontend_type>Text</frontend_type>
169
+ <validate>validate-number</validate>
170
+ <sort_order>4</sort_order>
171
+ </img_size_min>
172
+ <img_min_w translate="label tooltip comment">
173
+ <label>Minimum Width(pixel)</label>
174
+ <comment>Minimum width of an upload image.</comment>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>1</show_in_website>
177
+ <show_in_store>1</show_in_store>
178
+ <frontend_type>Text</frontend_type>
179
+ <validate>validate-number</validate>
180
+ <sort_order>5</sort_order>
181
+ </img_min_w>
182
+ <img_min_h translate="label tooltip comment">
183
+ <label>Minimum Height(pixel)</label>
184
+ <comment>Minimum height of an upload image.</comment>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ <frontend_type>Text</frontend_type>
189
+ <validate>validate-number</validate>
190
+ <sort_order>6</sort_order>
191
+ </img_min_h>
192
+ </fields>
193
+ </image_option>
194
+ <product_option translate="label">
195
+ <label>DYO Product Options</label>
196
+ <sort_order>4</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ <fields>
201
+ <show_link translate="label tooltip comment">
202
+ <label>Show "Add Another..." link in cart page</label>
203
+ <comment></comment>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>1</show_in_website>
206
+ <show_in_store>1</show_in_store>
207
+ <frontend_type>select</frontend_type>
208
+ <source_model>adminhtml/system_config_source_yesno</source_model>
209
+ <sort_order>1</sort_order>
210
+ </show_link>
211
+ </fields>
212
+ </product_option>
213
+ </groups>
214
+ </abcv_section>
215
+ </sections>
216
+ </config>
app/code/local/Abcv/Editor/sql/editor_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('editor')};
10
+ CREATE TABLE {$this->getTable('editor')} (
11
+ `editor_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`editor_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ -- DROP TABLE IF EXISTS {$this->getTable('abcv_product_save')};
22
+ create table {$this->getTable('abcv_product_save')}(
23
+ `save_id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'id',
24
+ `customer_id` int(10) NOT NULL COMMENT 'Customer Id',
25
+ `product_id` text NOT NULL COMMENT 'Product Id: product and quote',
26
+ `template_id` varchar(255) NOT NULL COMMENT 'Template Id',
27
+ `productstyle_id` varchar(255) NOT NULL COMMENT 'product style id',
28
+ `json` longtext NOT NULL COMMENT 'Context save',
29
+ `image` longtext NOT NULL COMMENT 'Image template',
30
+ `date_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create or update time for save',
31
+ PRIMARY KEY (`save_id`)
32
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
33
+
34
+ -- ----------------------------
35
+ -- Table structure for `abcv_my_images`
36
+ -- ----------------------------
37
+ DROP TABLE IF EXISTS {$this->getTable('abcv_my_images')};
38
+ CREATE TABLE {$this->getTable('abcv_my_images')} (
39
+ `id` int(11) NOT NULL AUTO_INCREMENT,
40
+ `user_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
41
+ `image_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
42
+ `image_name_saved` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
43
+ `time` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL,
44
+ PRIMARY KEY (`id`)
45
+ ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
46
+
47
+ ");
48
+
49
+ $installer->endSetup();
app/code/local/Abcv/ManageCustomer/Block/Adminhtml/Customer/Savedtemplatetab.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_ManageCustomer_Block_Adminhtml_Customer_Savedtemplatetab
3
+ extends Mage_Adminhtml_Block_Template
4
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
+
6
+ private $read;
7
+ private $write;
8
+
9
+ /**
10
+ * Set the template for the block
11
+ *
12
+ */
13
+ public function _construct()
14
+ {
15
+ parent::_construct();
16
+ $this->setTemplate('abcv/managecustomer/saved_template.phtml');
17
+ $this->read = Mage::getSingleton('core/resource')->getConnection('core_read');
18
+ $this->write = Mage::getSingleton('core/resource')->getConnection('core_write');
19
+ }
20
+
21
+ /**
22
+ * Get Data
23
+ * */
24
+ public function getCurrentCustomer(){
25
+ $customer = Mage::registry('current_customer');
26
+ return $customer;
27
+ }
28
+ /**
29
+ * Get Saved Template
30
+ * */
31
+ public function getSavedTemplate($customer_id)
32
+ {
33
+ $query = "select * from abcv_product_save where customer = 'Value'";
34
+ $result = $this->read->fetchAll();
35
+
36
+
37
+
38
+
39
+ }
40
+
41
+
42
+ /**
43
+ * Retrieve the label used for the tab relating to this block
44
+ *
45
+ * @return string
46
+ */
47
+ public function getTabLabel()
48
+ {
49
+ return $this->__('Saved Templates');
50
+ }
51
+ /**
52
+ * Retrieve the title used by this tab
53
+ *
54
+ * @return string
55
+ */
56
+ public function getTabTitle()
57
+ {
58
+ return $this->__('Click here to view your custom tab content');
59
+ }
60
+ /**
61
+ * Determines whether to display the tab
62
+ * Add logic here to decide whether you want the tab to display
63
+ *
64
+ * @return bool
65
+ */
66
+ public function canShowTab()
67
+ {
68
+ return true;
69
+ }
70
+ /**
71
+ * Stops the tab being hidden
72
+ *
73
+ * @return bool
74
+ */
75
+ public function isHidden()
76
+ {
77
+ return false;
78
+ }
79
+
80
+ public function getHTML(){
81
+ $this->setTemplate('abcv/managecustomer/ajax/_template.phtml');
82
+ }
83
+ }
app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/AjaxsavedtemplateController.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_ManageCustomer_Adminhtml_AjaxsavedtemplateController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+ private $read;
6
+ private $write;
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->read = Mage::getSingleton('core/resource')->getConnection('core_read');
11
+ $this->write = Mage::getSingleton('core/resource')->getConnection('core_write');
12
+ }
13
+
14
+ public function indexAction()
15
+ {
16
+ $postData = $this->getRequest()->getPost();
17
+
18
+ //set data
19
+ $current_page = $postData['page'];
20
+ $itemsPerPage = $postData['item_per_page'];
21
+
22
+ //get data
23
+ $offset = ($postData['page'] - 1) * $postData['item_per_page'];
24
+ $limit = $postData['item_per_page'];
25
+ $query = "select * from abcv_product_save where customer_id = '". $postData['customer_id'] ."' ";
26
+ //where
27
+ $where = "";
28
+ if (!empty($postData['save_id']))
29
+ {
30
+ if ($where != "") $where .= " AND ";
31
+ $where .= " save_id = '". $postData['save_id'] ."'";
32
+ }
33
+ if (!empty($postData['from_date']))
34
+ {
35
+ $d = new DateTime($postData['from_date']);
36
+ if ($where != "") $where .= " AND ";
37
+ $where .= " date_at >= '" . $d->format("Y-m-d") ."'";
38
+ }
39
+ if (!empty($postData['to_date']))
40
+ {
41
+ $d = new DateTime($postData['to_date']);
42
+ if ($where != "") $where .= " AND ";
43
+ $where .= " date_at <= '" . $d->format("Y-m-d") ."'";
44
+ }
45
+ if (!empty($postData['product_id']))
46
+ {
47
+ if ($where != "") $where .= " AND ";
48
+ $where .= " product_id = 'product_". $postData['product_id'] ."'";
49
+ }
50
+ if ($where != "")
51
+ $query .= " AND ";
52
+ $query .= $where;
53
+ //order
54
+ $order_by = "";
55
+ if (!empty($postData['asc']))
56
+ {
57
+ if ($order_by != "") $order_by .= " , ";
58
+ $order_by .= $postData['asc'] ." asc ";
59
+ }
60
+ if (!empty($postData['desc']))
61
+ {
62
+ if ($order_by != "") $order_by .= " , ";
63
+ $order_by .= $postData['desc'] ." desc ";
64
+ }
65
+ if (empty($order_by))
66
+ {
67
+ $order_by .= "date_at desc";
68
+ }
69
+ $order_by = " ORDER BY " . $order_by;
70
+ $query .= $order_by;
71
+ //limmit
72
+ $query .= " LIMIT " . $offset ."," . $limit;
73
+
74
+ $save_template = $this->read->fetchAll($query);
75
+
76
+ //count total template
77
+ // $query = "select * from abcv_product_save where customer_id = '". $postData['customer_id'] ."' ";
78
+ // if ($where != "")
79
+ // $query .= " AND ";
80
+ // $query .= $where;
81
+ // $result = $this->read->fetchAll($query);
82
+ // $total_template = count($result);
83
+ $query = "select count(save_id) count from abcv_product_save where customer_id = '". $postData['customer_id'] ."' ";
84
+ if ($where != "")
85
+ $query .= " AND ";
86
+ $query .= $where;
87
+ $total_template = $this->read->fetchOne($query);
88
+
89
+
90
+ include ('html/_pattern.php');
91
+
92
+ }
93
+
94
+ }
app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/html/_paging.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $total_page = (integer)( $total_template / $itemsPerPage );
3
+ if (( $total_template / $itemsPerPage ) > $total_page)
4
+ $total_page += 1;
5
+ $next_page = ($current_page < $total_page) ? $current_page+1: $total_page;
6
+ $last_page = ($current_page > 1) ? $current_page-1: 1;
7
+ $last_page_disabled = "";
8
+ $next_page_disabled = "";
9
+ $last_page_css = "cursor: pointer;";
10
+ $next_page_css = "cursor: pointer;";
11
+ if ($current_page == 1)
12
+ {
13
+ $last_page_disabled = "_off";
14
+ $last_page_css = "";
15
+ }
16
+ if ($current_page == $total_page)
17
+ {
18
+ $next_page_disabled = "_off";
19
+ $next_page_css = "";
20
+ }
21
+
22
+
23
+ ?>
24
+ <table cellspacing="0" class="actions">
25
+ <tbody><tr>
26
+ <td class="pager">
27
+ <?php if ($total_template != 0): ?>
28
+ Page
29
+ <img style="<?php echo $last_page_css ?>" onclick="javascript:obj_saved_template.get('<?php echo $last_page;?>')" class="arrow" alt="Go to Previous page" src="/skin/adminhtml/default/default/images/pager_arrow_left<?php echo $last_page_disabled?>.gif">
30
+
31
+ <input type="text" class="input-text page" value="<?php echo $current_page?>" name="page">
32
+
33
+ <img style="<?php echo $next_page_css ?>" onclick="javascript:obj_saved_template.get('<?php echo $next_page;?>')" class="arrow" alt="Go to Previous page" src="/skin/adminhtml/default/default/images/pager_arrow_right<?php echo $next_page_disabled?>.gif">
34
+
35
+ of <?php echo $total_page ?> pages <span class="separator">|</span> View
36
+
37
+ <select onchange="javascript:obj_saved_template.changeItemPerPage(this)" name="limit">
38
+ <option <?php echo ($itemsPerPage==20)?"selected":""?> value="20">20</option>
39
+ <option <?php echo ($itemsPerPage==30)?"selected":""?> value="30">30</option>
40
+ <option <?php echo ($itemsPerPage==50)?"selected":""?> value="50">50</option>
41
+ <option <?php echo ($itemsPerPage==100)?"selected":""?> value="100">100</option>
42
+ <option <?php echo ($itemsPerPage==200)?"selected":""?> value="200">200</option>
43
+ </select>
44
+
45
+ per page<span class="separator">|</span>
46
+ <?php endif; ?>
47
+ Total <?php echo $total_template?> templates found
48
+ </td>
49
+ <td class="filter-actions a-right">
50
+ <button onclick="javascript:obj_saved_template.resetFilter(this)" class="scalable " type="button" title="Reset Filter"><span><span><span>Reset Filter</span></span></span></button>
51
+ <button onclick="javascript:obj_saved_template.search(this)" class="scalable task" type="button" title="Search"><span><span><span>Search</span></span></span></button>
52
+ </td>
53
+ </tr>
54
+ </tbody></table>
app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/html/_pattern.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php include('_paging.php'); ?>
2
+ <div class="grid">
3
+ <div class="hor-scroll">
4
+ <table cellspacing="0" id="customer_orders_grid_table" class="data">
5
+ <colgroup>
6
+ <col width="100">
7
+ <col>
8
+ <col>
9
+ <col>
10
+ <col width="500">
11
+ </colgroup><thead>
12
+ <tr class="headings">
13
+ <th>
14
+ <span class="nobr">
15
+ <a
16
+ <?php
17
+ if (!empty($postData['desc']) && $postData['desc'] == 'save_id')
18
+ {
19
+ echo "class=sort-arrow-desc title=desc";
20
+ }
21
+ else if (!empty($postData['asc']) && $postData['asc'] == 'save_id')
22
+ {
23
+ echo "class=sort-arrow-asc title=asc";
24
+ }
25
+ else
26
+ {
27
+ echo "class=not-sort";
28
+ }
29
+ ?>
30
+ title="asc" href="javascript:void(0);" onclick="javascript:obj_saved_template.sort(this,'save_id');">
31
+ <span class="sort-title">Saved #</span></a>
32
+ </span>
33
+ </th>
34
+
35
+ <th>
36
+ <span class="nobr">
37
+ <a <?php
38
+ if (!empty($postData['desc']) && $postData['desc'] == 'date_at')
39
+ {
40
+ echo "class=sort-arrow-desc title=desc";
41
+ }
42
+ else if (!empty($postData['asc']) && $postData['asc'] == 'date_at')
43
+ {
44
+ echo "class=sort-arrow-asc title=asc";
45
+ }
46
+ else
47
+ {
48
+ echo "not-sort";
49
+ }
50
+ ?> href="javascript:void(0);" onclick="javascript:obj_saved_template.sort(this,'date_at');"><span class="sort-title">Created Date</span></a>
51
+ </span>
52
+ </th>
53
+
54
+ <th>
55
+ <span class="nobr">
56
+ <a <?php
57
+ if (!empty($postData['desc']) && $postData['desc'] == 'product_id')
58
+ {
59
+ echo "class=sort-arrow-desc title=desc";
60
+ }
61
+ else if (!empty($postData['asc']) && $postData['asc'] == 'product_id')
62
+ {
63
+ echo "class=sort-arrow-asc title=asc";
64
+ }
65
+ else
66
+ {
67
+ echo "not-sort";
68
+ }
69
+ ?> href="javascript:void(0);" onclick="javascript:obj_saved_template.sort(this,'product_id');"><span class="sort-title">Product Id</span></a></span>
70
+ </th>
71
+
72
+ <th><span class="nobr"> Action</span></th>
73
+ <th class="last"><span class="nobr">Image Template</span></th>
74
+ </tr>
75
+ <tr class="filter">
76
+ <th>
77
+ <div class="field-100">
78
+ <input type="text" onchange="javascript:obj_saved_template.changefeild(this)" class="input-text no-changes" value="<?php echo $postData['save_id'] ?>" id="save_id">
79
+ </div>
80
+ </th>
81
+
82
+ <th>
83
+ <div class="range">
84
+ <div class="range-line date">
85
+ <span class="label">From:</span>
86
+ <input type="text" class="input-text no-changes" value="<?php echo $postData['from_date'] ?>" onchange="javascript:obj_saved_template.changefeild(this)" id="from_date" readonly>
87
+ <img title="Date selector" id="_btn_from_date" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif">
88
+ </div>
89
+
90
+ <div class="range-line date">
91
+ <span class="label">To :</span>
92
+ <input type="text" class="input-text no-changes" value="<?php echo $postData['to_date'] ?>" onchange="javascript:obj_saved_template.changefeild(this)" id="to_date" readonly>
93
+ <img title="Date selector" class="v-middle" id="_btn_to_date" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif">
94
+ </div>
95
+ </div>
96
+ <th>
97
+ <div class="field-100">
98
+ <input type="text" onchange="javascript:obj_saved_template.changefeild(this)" class="input-text no-changes" value="<?php echo $postData['product_id'] ?>" id="product_id">
99
+ </div>
100
+ </th>
101
+ <th class=" ">&nbsp;</th>
102
+ <th class="no-link last"></th>
103
+ </tr>
104
+ </thead>
105
+
106
+ <tbody id="tbody_update">
107
+ <?php include('_table.php'); ?>
108
+
109
+
110
+ </tbody>
111
+ </table>
112
+ </div>
113
+ </div>
app/code/local/Abcv/ManageCustomer/controllers/Adminhtml/html/_table.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $is_exsits_template = false;
3
+ foreach ($save_template as $key=>$template):
4
+ $is_exsits_template = true;
5
+ $template = (object) $template;
6
+ $product_id = str_replace('product_','',$template->product_id)
7
+ ?>
8
+ <tr title="" class="even pointer">
9
+ <td class=" "><?php echo $template->save_id?></td>
10
+
11
+ <td class=" ">
12
+ <?php
13
+ $d = new DateTime($template->date_at);
14
+ echo $d->format('M d, Y h:i:s A');
15
+ ?>
16
+ </td>
17
+ <td class=" "><?=$product_id?></td>
18
+ <td class=" ">
19
+ <?php
20
+ $url = Mage::getBaseUrl()."editor/index/template/template/".$template->template_id."/product/".$product_id."/productstyle/".$template->productstyle_id."/save/".$template->save_id."/is_admin/".strtotime("now");
21
+ ?>
22
+ <a target="_blank" href="<?php echo $url ?>">View &amp; Change</a>
23
+ </td>
24
+ <td class="last">
25
+ <?php
26
+ $image = $template->image;
27
+ $image = json_decode($image);
28
+ foreach($image as $ikey => $img):
29
+ ?>
30
+ <div style="float:left;padding-left: 5px;" class="photo">
31
+ <a href="#<?=$template->save_id?>_<?=$ikey?>">
32
+ <img src="<?='/image.php?ID='. $template->productstyle_id."_".$template->save_id. '&savetemplates'//$img->imageData?>" width="100" height="100" />
33
+ </div>
34
+ <div id="<?=$template->save_id?>_<?=$ikey?>" style="display: none;">
35
+ <img src="<?='/image.php?ID='. $template->productstyle_id."_".$template->save_id. '&savetemplates'//$img->imageData?>">
36
+ </div>
37
+ <?php endforeach;
38
+ ?>
39
+ </td>
40
+ </tr>
41
+ <?php endforeach; ?>
42
+ <?php if (!$is_exsits_template) : ?>
43
+ <tr>
44
+ <td colspan="5" class="a-center"> No template </td>
45
+ </tr>
46
+ <?php endif; ?>
app/code/local/Abcv/ManageCustomer/etc/adminhtml.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--<config>
3
+ <menu>
4
+ <abcv_managecustomer>
5
+ <title>May</title>
6
+ <sort_order>100</sort_order>
7
+ <children>
8
+ <test>
9
+ <title>Test</title>
10
+ <action>adminhtml/ajaxsavedtemplate/index</action>
11
+ <sort_order>0</sort_order>
12
+ </test>
13
+ </children>
14
+ </abcv_managecustomer>
15
+ </menu>
16
+ </config>-->
app/code/local/Abcv/ManageCustomer/etc/config.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Abcv_ManageCustomer>
4
+ <version>0.1.0</version>
5
+ </Abcv_ManageCustomer>
6
+ </modules>
7
+ <admin>
8
+ <routers>
9
+ <adminhtml>
10
+ <args>
11
+ <modules>
12
+ <abcv_managecustomer before="Mage_Adminhtml">Abcv_ManageCustomer_Adminhtml</abcv_managecustomer>
13
+ </modules>
14
+ </args>
15
+ </adminhtml>
16
+ </routers>
17
+ </admin>
18
+ <adminhtml>
19
+ <layout>
20
+ <updates>
21
+ <managecustomer>
22
+ <file>abcv/managecustomer.xml</file>
23
+ </managecustomer>
24
+ </updates>
25
+ </layout>
26
+ </adminhtml>
27
+ <global>
28
+ <blocks>
29
+ <managecustomer>
30
+ <class>Abcv_ManageCustomer_Block</class>
31
+ </managecustomer>
32
+ </blocks>
33
+ </global>
34
+ </config>
app/code/local/Abcv/Managecustom/Block/Adminhtml/Custom.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Block_Adminhtml_Custom extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_blockGroup = 'abcv_managecustom';
7
+ $this->_controller = 'adminhtml_custom';
8
+ $this->_headerText = $this->__('Manage Custom Field');
9
+ parent::__construct();
10
+ $this->_removeButton('add');
11
+ }
12
+ }
app/code/local/Abcv/Managecustom/Block/Adminhtml/Custom/Grid.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Block_Adminhtml_Custom_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ // Set some defaults for our grid
9
+ $this->setDefaultSort('id');
10
+ $this->setId('abcv_managecustom_custom_grid');
11
+ $this->setDefaultDir('asc');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _getCollectionClass()
16
+ {
17
+ // This is the model we are using for the grid
18
+ return 'abcv_managecustom/custom_collection';
19
+ }
20
+
21
+ protected function _prepareCollection()
22
+ {
23
+ // Get and set our collection for the grid
24
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
25
+ $this->setCollection($collection);
26
+
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ protected function _prepareColumns()
31
+ {
32
+ // Add the columns that should appear in the grid
33
+ $this->addColumn('id',
34
+ array(
35
+ 'header'=> $this->__('ID'),
36
+ 'align' =>'center',
37
+ 'width' => '50px',
38
+ 'index' => 'id'
39
+ )
40
+ );
41
+
42
+ $this->addColumn('order_id',
43
+ array(
44
+ 'header'=> $this->__('Order Id'),
45
+ 'align' => 'right',
46
+ 'width' => '80px',
47
+ 'index' => 'order_id'
48
+ )
49
+ );
50
+
51
+ $this->addColumn('employer',
52
+ array(
53
+ 'header'=> $this->__('Employer Name'),
54
+ 'width' => '35%',
55
+ 'index' => 'employer'
56
+ )
57
+ );
58
+ $this->addColumn('occupation',
59
+ array(
60
+ 'header'=> $this->__('Occupation'),
61
+ 'index' => 'occupation'
62
+ )
63
+ );
64
+
65
+ return parent::_prepareColumns();
66
+ }
67
+
68
+ public function getRowUrl($row)
69
+ {
70
+ return '';
71
+ }
72
+ }
app/code/local/Abcv/Managecustom/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Abcv/Managecustom/Model/Custom.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Model_Custom extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_managecustom/custom');
7
+ }
8
+ }
app/code/local/Abcv/Managecustom/Model/Mysql4/Custom.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Model_Mysql4_Custom extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_managecustom/custom', 'id');
7
+ }
8
+ }
app/code/local/Abcv/Managecustom/Model/Mysql4/Custom/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Model_Mysql4_Custom_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('abcv_managecustom/custom');
7
+ }
8
+ }
app/code/local/Abcv/Managecustom/controllers/Adminhtml/CustomController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Abcv_Managecustom_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ // Let's call our initAction method which will set some basic params for each action
7
+ $this->_initAction()
8
+ ->renderLayout();
9
+ }
10
+
11
+ public function newAction()
12
+ {
13
+ // We just forward the new action to a blank edit form
14
+ $this->_forward('edit');
15
+ }
16
+
17
+
18
+ protected function _initAction()
19
+ {
20
+ $this->loadLayout()
21
+ // Make the active menu match the menu config nodes (without 'children' inbetween)
22
+ ->_setActiveMenu('editor/abcv_managecustom_custom')
23
+ ->_title($this->__('Editor'))->_title($this->__('Managecustom'))
24
+ ->_addBreadcrumb($this->__('Editor'), $this->__('Editor'))
25
+ ->_addBreadcrumb($this->__('Managecustom'), $this->__('Managecustom'));
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Check currently called action by permissions for current user
31
+ *
32
+ * @return bool
33
+ */
34
+ protected function _isAllowed()
35
+ {
36
+ return Mage::getSingleton('admin/session')->isAllowed('editor/abcv_managecustom_custom');
37
+ }
38
+ }
app/code/local/Abcv/Managecustom/etc/adminhtml.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <editor>
5
+ <children>
6
+ <!-- Here, I like to use the namespacename_modulename_controllername naming convention -->
7
+ <abcv_managecustom_custom translate="title" module="abcv_managecustom">
8
+ <!-- This is how the menu text will be displayed -->
9
+ <title>Manage Custom Field</title>
10
+ <sort_order>11</sort_order>
11
+ <action>adminhtml/custom</action>
12
+ </abcv_managecustom_custom>
13
+ </children>
14
+ </editor>
15
+ </menu>
16
+
17
+ <acl>
18
+ <resources>
19
+ <admin>
20
+ <children>
21
+ <!-- Same as above, but instead of referencing the config/menu node, you reference the acl/resources node of adminhtml.xml -->
22
+ <sales>
23
+ <children>
24
+ <!-- Keep the same naming convention as above -->
25
+ <abcv_managecustom_custom>
26
+ <!-- This is how the ACL text will be displayed on System > Permissions > Roles > Role > Role Resources -->
27
+ <title>Manage Custom Field</title>
28
+ </abcv_managecustom_custom>
29
+ </children>
30
+ </sales>
31
+ </children>
32
+ </admin>
33
+ </resources>
34
+ </acl>
35
+ </config>
app/code/local/Abcv/Managecustom/etc/config.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <abcv_managecustom>
5
+ <version>1.0.0</version>
6
+ </abcv_managecustom>
7
+ </modules>
8
+
9
+ <global>
10
+ <helpers>
11
+ <abcv_managecustom>
12
+ <!-- This is where we define our helper directory -->
13
+ <class>Abcv_Managecustom_Helper</class>
14
+ </abcv_managecustom>
15
+ </helpers>
16
+
17
+ <blocks>
18
+ <abcv_managecustom>
19
+ <!-- Set a block definition and lookup directory -->
20
+ <class>Abcv_Managecustom_Block</class>
21
+ </abcv_managecustom>
22
+ </blocks>
23
+
24
+ <models>
25
+ <abcv_managecustom>
26
+ <!-- This is where we define our model directory -->
27
+ <class>Abcv_Managecustom_Model</class>
28
+ <!-- Define a resource to create a custom table -->
29
+ <resourceModel>abcv_managecustom_mysql4</resourceModel>
30
+ </abcv_managecustom>
31
+
32
+ <!-- Here's our resource model we'll use to create a database table -->
33
+ <abcv_managecustom_mysql4>
34
+ <class>Abcv_Managecustom_Model_Mysql4</class>
35
+ <entities>
36
+ <!-- Let's define our table, we'll call it with the baz name, but the real table is abcv_managecustom_baz -->
37
+ <!-- After we define our entity, we can call it with our model by calling abcv_managecustom/baz -->
38
+ <custom>
39
+ <table>sales_order_custom</table>
40
+ </custom>
41
+ </entities>
42
+ </abcv_managecustom_mysql4>
43
+ </models>
44
+
45
+ <!-- And finally we define our resource setup script -->
46
+ <resources>
47
+ <abcv_managecustom_setup>
48
+ <setup>
49
+ <module>abcv_managecustom</module>
50
+ </setup>
51
+ </abcv_managecustom_setup>
52
+ </resources>
53
+ </global>
54
+
55
+ <admin>
56
+ <routers>
57
+ <adminhtml>
58
+ <args>
59
+ <!-- This is how we load our Adminhtml controllers -->
60
+ <modules>
61
+ <abcv_managecustom before="Mage_Adminhtml">Abcv_Managecustom_Adminhtml</abcv_managecustom>
62
+ </modules>
63
+ </args>
64
+ </adminhtml>
65
+ </routers>
66
+ </admin>
67
+
68
+ <adminhtml>
69
+ <layout>
70
+ <updates>
71
+ <abcv_managecustom>
72
+ <!--
73
+ We again keep a nice naming convention and make our module upgrade proof by placing it in a separate folder
74
+ - Since we are in the adminhtml node, this will look for the XML file in the app/design/adminhtml/default/default root folder
75
+ -->
76
+ <file>abcv/managecustom.xml</file>
77
+ </abcv_managecustom>
78
+ </updates>
79
+ </layout>
80
+ </adminhtml>
81
+ </config>
app/code/local/Abcv/Tabcustom/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Abcv_Tabcustom_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Abcv/Tabcustom/etc/config.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Abcv_Tabcustom><version>0.1.0</version></Abcv_Tabcustom>
5
+ </modules>
6
+
7
+ <global>
8
+ <helpers>
9
+ <tabcustom>
10
+ <class>Abcv_Tabcustom_Helper</class>
11
+ </tabcustom>
12
+ </helpers>
13
+ </global>
14
+
15
+ <frontend>
16
+ <routers>
17
+ <tabcustom>
18
+ <use>standard</use>
19
+ <args>
20
+ <module>Abcv_Tabcustom</module>
21
+ <frontName>tabcustom</frontName>
22
+ </args>
23
+ </tabcustom>
24
+ </routers>
25
+ </frontend>
26
+
27
+ <adminhtml>
28
+ <acl>
29
+ <resources>
30
+ <admin>
31
+ <children>
32
+ <system>
33
+ <children>
34
+ <config>
35
+ <children>
36
+ <tabcustom_options>
37
+ <title>Store Hello World Module Section</title>
38
+ </tabcustom_options>
39
+ </children>
40
+ </config>
41
+ </children>
42
+ </system>
43
+ </children>
44
+ </admin>
45
+ </resources>
46
+ </acl>
47
+ </adminhtml>
48
+
49
+ </config>
app/code/local/Abcv/Tabcustom/etc/system.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <tabconfig translate="label" module="tabcustom">
5
+ <label>ABCV Custom Field</label>
6
+ <sort_order>99999</sort_order>
7
+ </tabconfig>
8
+ </tabs>
9
+ <sections>
10
+ <general>
11
+ <groups>
12
+ <example>
13
+ <label>Adding a Group</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ </example>
20
+ </groups>
21
+ </general>
22
+ <tabcustom_options translate="label" module="tabcustom">
23
+ <label>Manage Custom Field Message</label>
24
+ <tab>tabconfig</tab>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>1000</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <groups>
31
+ <messages translate="label">
32
+ <label>Manage Custom Field In Public Site</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <fields>
39
+ <header_text translate="label tooltip comment">
40
+ <label>Header custom field</label>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>1</sort_order>
46
+ </header_text>
47
+ <top_text translate="label tooltip comment">
48
+ <label>Top message in public site</label>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <frontend_type>Textarea</frontend_type>
53
+ <sort_order>2</sort_order>
54
+ </top_text>
55
+ <label_text translate="label tooltip comment">
56
+ <label>Label of checkbox</label>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <frontend_type>text</frontend_type>
61
+ <sort_order>3</sort_order>
62
+ </label_text>
63
+ <bottom_text translate="label tooltip comment">
64
+ <label>Bottom message in public site</label>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ <frontend_type>Textarea</frontend_type>
69
+ <sort_order>4</sort_order>
70
+ </bottom_text>
71
+ <enable_text translate="label tooltip comment">
72
+ <label>Enable Custom Field</label>
73
+ <frontend_type>select</frontend_type>
74
+ <sort_order>5</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ </enable_text>
80
+ </fields>
81
+ </messages>
82
+ </groups>
83
+ </tabcustom_options>
84
+ </sections>
85
+ </config>
app/etc/modules/Abcv_AbcPay.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <!-- declare Abcv_AbcPay module -->
5
+ <Abcv_AbcPay>
6
+ <!-- this is an active module -->
7
+ <active>true</active>
8
+ <!-- this module will be located in app/code/local code pool -->
9
+ <codePool>local</codePool>
10
+ <!-- specify dependencies for correct module loading order -->
11
+ <depends>
12
+ <Mage_Payment />
13
+ </depends>
14
+ </Abcv_AbcPay>
15
+ </modules>
16
+ </config>
package.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>abcv_pay</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Official Magento Plugin to connect to Payment Service Provider ABCV Pay</summary>
10
+ <description>The ABCV Pay Magento extension fully configurable, with a simple integration, you can get access to ABCV Merchant Service Gateway so the ABCV Pay makes it easy to do payments on your stores. We are a level 1 PCI compliant company, which ensures our customers&#x2019; data security.&#xD;
11
+ &#xD;
12
+ About ABC Virtual &#xD;
13
+ One of ABC Virtual&#x2019;s core areas is that of online payment acceptance and distribution of funds. We are our own payment gateway, which means our customers don&#x2019;t have to go through other gateways that may cost more or have higher service fees. We are a level 1 PCI compliant company, which ensures our customers&#x2019; data security. Merchants that choose to do business with us can either establish their own merchant account or use one of ours. We are capable of taking Visa, MasterCard, Discover and American Express, as well as Debit cards and echecks (ACH transfer).&#xD;
14
+ &#xD;
15
+ Several of our clients that currently use our payment service have commissioned us to build their web application and then incorporate the payment acceptance as a part of the application/web site. The Iowa League of Cities (iCash) is one such client that has been using the system for several years now. Other clients include the Iowa YPO &amp;amp; WPO, YPO Golf Network, DMACC Continuing Education, Missouri Valley Line Constructors, and others.&#xD;
16
+ &#xD;
17
+ In addition to customized web sites that utilize our payment system, we also offer a complete online payment system that allows for maximum flexibility and ease of use. Configurable in almost every aspect you can think of, this payment system is capable of integrating with existing web sites, or can be used as a company&#x2019;s main presence on the web. It is unique from other online payment applications in that it is also capable of taking in office, or point of sale, payments using a pin pad device. It is entirely Internet based, so no lengthy installations are required other than java and a driver for the device.</description>
18
+ <notes>Prepare for publish</notes>
19
+ <authors><author><name>ABCV Company</name><user>dang_nguyen</user><email>dang.nguyen@abcv.com</email></author></authors>
20
+ <date>2015-04-21</date>
21
+ <time>10:44:55</time>
22
+ <contents><target name="magelocal"><dir name="Abcv"><dir name="AbcPay"><dir name="Model"><dir name="AbcPay"><dir name="Source"><file name="PaymentAction.php" hash="aabcd6b164d811a607e33f10fe264f02"/></dir></dir><file name="PaymentMethod.php" hash="cc3f1ba3d01112f18282093fdf0715c3"/></dir><dir name="etc"><file name="config.xml" hash="989a7d9215f169eca9b65cf88c188584"/><file name="system.xml" hash="d97575f464af0f1b77c8520786afe1b7"/></dir><dir name="keys"><file name="childKeyQA1" hash="2bffdc8d7d332213d6f15237107f4e14"/><file name="parentKeyQA1" hash="9e0e03ffe52f394aa5eae6bd3d2a4875"/></dir></dir><dir name="Bigfunny"><dir name="Block"><dir name="Adminhtml"><dir name="Bigfunny"><dir name="Edit"><file name="Form.php" hash="ae71906f3ed013a671923fd2c07fea18"/><dir name="Tab"><file name="Form.php" hash="9798113e188c3f04793d35a807a5d872"/></dir><file name="Tabs.php" hash="7b0e08582aa05c65722e40ef83f223ef"/></dir><file name="Edit.php" hash="fe6cf29605597f5a1f951a2716208333"/><file name="Grid.php" hash="64218586002c7df13d94092e184a2503"/></dir><file name="Bigfunny.php" hash="3c0b0c300170bf942eaaf235d39a87e2"/></dir></dir><dir name="Helper"><file name="Data.php" hash="9f1b6f798fb12ac9cfda0354c179db44"/></dir><dir name="Model"><file name="Bigfunny.php" hash="021b5e83b727c7687048e3b31642764c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="BigfunnyController.php" hash="755d8e941fab3cc5adedf92bf4ed6567"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c8be7975fb2845fb9172bbe0933a5ea3"/><file name="config.xml" hash="341e44ebe4e5342bc0ca0fec192da2c6"/></dir></dir><dir name="Catalog"><dir name="Model"><dir name="Price"><file name="Observer.php" hash="72c2ea298b70a831c1f1bdf54388e8fb"/></dir></dir><dir name="etc"><file name="config.xml" hash="2184c93b8b545b187c0386ca03802b79"/></dir></dir><dir name="Custom"><dir name="Block"><dir name="Adminhtml"><dir name="Custom"><file name="Order.php" hash="002a5ec9ac1cec2f35bf30da3f90b034"/></dir></dir><dir name="Custom"><file name="Order.php" hash="8d2c50008380d63722259c9d8ad9032d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="3c56ac9e7f2fddc2116bb62a668881ac"/></dir><dir name="Model"><dir name="Custom"><file name="Order.php" hash="d6968549a6c9a5d742dd987740e8bdae"/><file name="Quote.php" hash="eefb8eb93c807546ade44333565a73cc"/></dir><dir name="Mysql4"><dir name="Custom"><dir name="Order"><file name="Collection.php" hash="3b646dd0752edd3209a7b1e934e8a584"/></dir><file name="Order.php" hash="ae11a48d91ddcc44f2d2201afb06efd8"/><dir name="Quote"><file name="Collection.php" hash="5b5f58016f372427e65afd01e43984d9"/></dir><file name="Quote.php" hash="42d98a90149bad10083eb2e3b0084dcb"/></dir></dir><file name="Observer.php" hash="115097949081e09adc5b9a43d212048d"/><dir name="Sales"><file name="Order.php" hash="89fa9cc2e49323180f1f093c3e65d2dc"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="542b3044ca3aae10ead90afb81d494f3"/></dir><dir name="etc"><file name="config.xml" hash="d8277a93f4d8687e32a8f7e9a8aa8397"/></dir></dir><dir name="Dimensions"><dir name="Block"><dir name="Adminhtml"><dir name="Dimensions"><dir name="Edit"><file name="Form.php" hash="288df2d9b8c52cdf4ff8e0d160bc1f54"/><dir name="Tab"><file name="Form.php" hash="c410c5ead80b1e762f6b86f03b235911"/></dir><file name="Tabs.php" hash="b090ddc930fde54c619cc9a21c5b263f"/></dir><file name="Edit.php" hash="15b5e0a6a5f882d26e1c2417b1bdd7f6"/><file name="Grid.php" hash="64218586002c7df13d94092e184a2503"/></dir><file name="Dimensions.php" hash="9b999efdef5a30a9fd3801ab04ece69e"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4986e5d5bec52f4c8366f5137a98093e"/></dir><dir name="Model"><file name="Dimensions.php" hash="098fee4ad55c793ab6d1b5972496ab39"/><dir name="Mysql4"><dir name="Dimensions"><file name="Collection.php" hash="dbca0420b387c25e61045463affad823"/></dir><file name="Dimensions.php" hash="9815db98613204784dac3889d6ee73d8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DimensionsController.php" hash="aa9e679bab312388df3c0ba09ee1d8bb"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="143eef5b069000646380e236f7d1acf7"/><file name="config.xml" hash="f47e936532a652e1cad6857889fabfe3"/></dir></dir><dir name="Editor"><dir name="Block"><dir name="Adminhtml"><file name="Customdyotab.php" hash="7cf60020e20ad309814810968afab36f"/><file name="Dyotab.php" hash="e6f563c0d61edfaaae191c132d4e5e6a"/><dir name="Editor"><dir name="Edit"><file name="Form.php" hash="de6f6412a857ca63f37d1eb4c92789dc"/><dir name="Tab"><file name="Form.php" hash="c20dcb0929375bb3122d1d2e38d377c7"/></dir><file name="Tabs.php" hash="43b78695bec52d1775917eb9da5ec2c9"/></dir><file name="Edit.php" hash="af8bf14cfc4a3366239963a5ac99bca2"/><file name="Grid.php" hash="5a17586d8dc8f325196785aeeff1338c"/></dir><file name="Editor.php" hash="1838badcffbf23ff299b0a88b5de5486"/></dir><dir name="Cart"><dir name="Item"><file name="Renderer.php" hash="b12aea9c9c081693542bd2b0612e7f9b"/></dir></dir><file name="Choosetemplate.php" hash="7bf52c8edd36b18f5b3bb74b1cba8c80"/><file name="Editor.php" hash="8d662283423ebedceac3827b15a36c39"/><file name="Product.php" hash="c553ea0e10c5b6952e4a499c3b98d949"/></dir><dir name="Helper"><file name="Data.php" hash="f3ffaa1635a3a650f64d560b226129b8"/></dir><dir name="Model"><file name="Editor.php" hash="c4ffdb2a8b83debecbb3b699cb9ff897"/><dir name="Mysql4"><dir name="Editor"><file name="Collection.php" hash="c0db4a5611264f2ecaaaa873902b7b05"/></dir><file name="Editor.php" hash="9a17788351b0425e1c8c8934648c7a2f"/><dir name="Product"><file name="Collection.php" hash="90716484d27177210e9bc1be305b7ebe"/></dir><file name="Product.php" hash="2cb3cdec22617af623fec518ad26c3a2"/></dir><file name="Observer.php" hash="17f88967b6b279969550b0f38e873889"/><file name="Product.php" hash="1226e377445cae4c51f1f11cdd7406df"/><dir name="Quote"><file name="Item.php" hash="0e8e379a2f34ee3e79721039720557d6"/></dir><file name="Status.php" hash="0a13ea3932c42fc03b0e171e2a026216"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxController.php" hash="cf0b4741ba48ffa395a5a1ce31f663e5"/><file name="AjaxController_2014.06.04.php" hash="cf0b4741ba48ffa395a5a1ce31f663e5"/><file name="CategoryController.php" hash="fb42953d982c67b1c1677f1d56dcc9cf"/><file name="CategoryController_2014.06.04.php" hash="056ede92c17a10cbfc5c9f6584692876"/><file name="EditorController.php" hash="6fd18887cecc90728acb3602c63eedfe"/><file name="EditorController_2014.06.04.php" hash="6fd18887cecc90728acb3602c63eedfe"/></dir><file name="AjaxLoginController.php" hash="817cae877ce4b5e09681388edcae29ab"/><file name="IndexController.php" hash="43d2c30557d288849072753b8d20b65e"/><file name="ProductController.php" hash="25babfd6d91e0604ae5e76ae8942bf57"/><file name="ProductDialogController.php" hash="d06c617a2027805a439cf7fe51f214b2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="632004de5dbdf8a0ddf66b78bc4e5fd8"/><file name="config.xml" hash="0274e6019da4bdcf3e87cbb1893bfbf7"/><file name="config.xml.bak" hash="50e227fca7ecf165f2480159654627bc"/><file name="config.xml_03.06.2015" hash="48a4c9b002464c7186e492808ba1f849"/><file name="config_12.15.2014.xml" hash="48a4c9b002464c7186e492808ba1f849"/><file name="system.xml" hash="11b9dcc5c6bb434493d9756ad6f38968"/></dir><dir name="sql"><dir name="editor_setup"><file name="mysql4-install-0.1.0.php" hash="738cc655f42ae73b05af032777532f71"/></dir></dir></dir><dir name="ManageCustomer"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><file name="Savedtemplatetab.php" hash="ec02f1af30bb3610b32c726030e781ba"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxsavedtemplateController.php" hash="d10afab8dda5f077df9dddece10611c6"/><dir name="html"><file name="_paging.php" hash="87ff24a6211dce6f13bf3a34f578d2ce"/><file name="_pattern.php" hash="e45a4305f6e6650447983477b4ce32f5"/><file name="_table.php" hash="4c18e57b8a672bf2ca930d02019b9ee2"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7f4f381ef2b7c3653d2cc597c521cc12"/><file name="config.xml" hash="f82bd5af7661c0898480d37179f2ebc5"/></dir></dir><dir name="Managecustom"><dir name="Block"><dir name="Adminhtml"><dir name="Custom"><file name="Grid.php" hash="d01d7ef08162132f142188d8cb7c58f7"/></dir><file name="Custom.php" hash="839c6e238e96adbab3837dcfd59002dc"/></dir></dir><dir name="Helper"><file name="Data.php" hash="d3a267b6b74bf47bc0ec650f6de0ab3c"/></dir><dir name="Model"><file name="Custom.php" hash="0501208507bdb556b83b54eb749760b8"/><dir name="Mysql4"><dir name="Custom"><file name="Collection.php" hash="cc48076f79691b2b5ca01151345741a5"/></dir><file name="Custom.php" hash="f7b9eb18d7c26cd1475fa01448c392b3"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomController.php" hash="20ca7bd3ee539cf225067226138e690e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="9f79444bb4f20f088822242117be2681"/><file name="config.xml" hash="faf7de8194c1d03d1c303d507c183956"/></dir></dir><dir name="Tabcustom"><dir name="Helper"><file name="Data.php" hash="70df4bc5e880913a38fe2309f5aeec11"/></dir><dir name="etc"><file name="config.xml" hash="f079feb5a1662c8a703baa1888696fbe"/><file name="system.xml" hash="cf4db6ee1864d054ca413de71b20c782"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Abcv_AbcPay.xml" hash="62ef6631585936a6e698f14c77dfbb9e"/></dir></target></contents>
23
+ <compatible/>
24
+ <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
25
+ </package>