simicart_0116 - Version 4.0.0

Version Notes

4.0 Stable Version

Download this release

Release Info

Developer Hải Tạ Hoàng
Extension simicart_0116
Version 4.0.0
Comparing to
See all releases


Version 4.0.0

Files changed (245) hide show
  1. app/code/local/Simi/Simiconnector/.DS_Store +0 -0
  2. app/code/local/Simi/Simiconnector/Block/.DS_Store +0 -0
  3. app/code/local/Simi/Simiconnector/Block/Adminhtml/.DS_Store +0 -0
  4. app/code/local/Simi/Simiconnector/Block/Adminhtml/Appreport.php +30 -0
  5. app/code/local/Simi/Simiconnector/Block/Adminhtml/Appreport/Grid.php +159 -0
  6. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner.php +38 -0
  7. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit.php +100 -0
  8. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Form.php +45 -0
  9. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Categories.php +106 -0
  10. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Form.php +271 -0
  11. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Products.php +166 -0
  12. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Renderer/Sku.php +53 -0
  13. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tabs.php +44 -0
  14. app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Grid.php +173 -0
  15. app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms.php +15 -0
  16. app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit.php +74 -0
  17. app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit/Form.php +45 -0
  18. app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit/Tab/Form.php +172 -0
  19. app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit/Tabs.php +44 -0
  20. app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Grid.php +101 -0
  21. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device.php +15 -0
  22. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit.php +42 -0
  23. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/.DS_Store +0 -0
  24. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Form.php +24 -0
  25. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Renderer/Datetime.php +28 -0
  26. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Renderer/Selectname.php +31 -0
  27. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Tab/.DS_Store +0 -0
  28. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Tab/Form.php +92 -0
  29. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Tabs.php +27 -0
  30. app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Grid.php +181 -0
  31. app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Date.php +12 -0
  32. app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Device.php +9 -0
  33. app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Edit.php +11 -0
  34. app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Osystem.php +18 -0
  35. app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Website.php +9 -0
  36. app/code/local/Simi/Simiconnector/Block/Adminhtml/History.php +16 -0
  37. app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit.php +78 -0
  38. app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit/Form.php +24 -0
  39. app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit/Tab/Form.php +124 -0
  40. app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit/Tabs.php +24 -0
  41. app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Grid.php +161 -0
  42. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist.php +19 -0
  43. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit.php +76 -0
  44. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Form.php +28 -0
  45. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tab/Form.php +302 -0
  46. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tab/Products.php +138 -0
  47. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tab/Renderer/Sku.php +53 -0
  48. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tabs.php +44 -0
  49. app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Grid.php +101 -0
  50. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode.php +13 -0
  51. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit.php +59 -0
  52. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/.DS_Store +0 -0
  53. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Form.php +20 -0
  54. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/.DS_Store +0 -0
  55. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Barcodecustom.php +43 -0
  56. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Datetime.php +31 -0
  57. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Qrcodecustom.php +43 -0
  58. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Select.php +46 -0
  59. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Tab/Form.php +75 -0
  60. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Tab/Products.php +245 -0
  61. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Tabs.php +32 -0
  62. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Grid.php +128 -0
  63. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory.php +19 -0
  64. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit.php +42 -0
  65. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit/Form.php +19 -0
  66. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit/Tab/Form.php +198 -0
  67. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit/Tabs.php +21 -0
  68. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Grid.php +108 -0
  69. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification.php +14 -0
  70. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/.DS_Store +0 -0
  71. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit.php +102 -0
  72. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Form.php +24 -0
  73. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/.DS_Store +0 -0
  74. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Categories.php +75 -0
  75. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Devices.php +187 -0
  76. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Form.php +388 -0
  77. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Products.php +134 -0
  78. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Renderer/Devices.php +23 -0
  79. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Renderer/Sku.php +21 -0
  80. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tabs.php +21 -0
  81. app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Grid.php +135 -0
  82. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel.php +12 -0
  83. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit.php +45 -0
  84. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Form.php +20 -0
  85. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tab/Form.php +191 -0
  86. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tab/Products.php +132 -0
  87. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tab/Render.php +18 -0
  88. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tabs.php +26 -0
  89. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Grid.php +107 -0
  90. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo.php +12 -0
  91. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit.php +45 -0
  92. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Form.php +20 -0
  93. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tab/Form.php +140 -0
  94. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tab/Products.php +132 -0
  95. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tab/Render.php +18 -0
  96. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tabs.php +26 -0
  97. app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Grid.php +115 -0
  98. app/code/local/Simi/Simiconnector/Block/Adminhtml/System/Config/Category/Categories.php +61 -0
  99. app/code/local/Simi/Simiconnector/Block/Adminhtml/System/Config/Category/Categorytree.php +10 -0
  100. app/code/local/Simi/Simiconnector/Block/Adminhtml/System/Config/Form/Field/Separator.php +28 -0
  101. app/code/local/Simi/Simiconnector/Block/Adminhtml/Web/Switcher.php +258 -0
  102. app/code/local/Simi/Simiconnector/Block/Catalog/Bundle.php +148 -0
  103. app/code/local/Simi/Simiconnector/Block/Simicategory.php +8 -0
  104. app/code/local/Simi/Simiconnector/Controller/Action.php +99 -0
  105. app/code/local/Simi/Simiconnector/Helper/.DS_Store +0 -0
  106. app/code/local/Simi/Simiconnector/Helper/Address.php +284 -0
  107. app/code/local/Simi/Simiconnector/Helper/Bundle/Price.php +423 -0
  108. app/code/local/Simi/Simiconnector/Helper/Bundle/Tierprice.php +24 -0
  109. app/code/local/Simi/Simiconnector/Helper/Checkout.php +204 -0
  110. app/code/local/Simi/Simiconnector/Helper/Checkout/Payment.php +216 -0
  111. app/code/local/Simi/Simiconnector/Helper/Checkout/Shipping.php +70 -0
  112. app/code/local/Simi/Simiconnector/Helper/Cloud.php +53 -0
  113. app/code/local/Simi/Simiconnector/Helper/Coupon.php +32 -0
  114. app/code/local/Simi/Simiconnector/Helper/Customer.php +72 -0
  115. app/code/local/Simi/Simiconnector/Helper/Data.php +83 -0
  116. app/code/local/Simi/Simiconnector/Helper/Options.php +40 -0
  117. app/code/local/Simi/Simiconnector/Helper/Options/Bundle.php +20 -0
  118. app/code/local/Simi/Simiconnector/Helper/Options/Configurable.php +23 -0
  119. app/code/local/Simi/Simiconnector/Helper/Options/Download.php +93 -0
  120. app/code/local/Simi/Simiconnector/Helper/Options/Grouped.php +73 -0
  121. app/code/local/Simi/Simiconnector/Helper/Options/Simple.php +84 -0
  122. app/code/local/Simi/Simiconnector/Helper/Orders.php +131 -0
  123. app/code/local/Simi/Simiconnector/Helper/Plugins/Instantcontact.php +52 -0
  124. app/code/local/Simi/Simiconnector/Helper/Price.php +399 -0
  125. app/code/local/Simi/Simiconnector/Helper/Productlabel.php +61 -0
  126. app/code/local/Simi/Simiconnector/Helper/Productlist.php +286 -0
  127. app/code/local/Simi/Simiconnector/Helper/Products.php +338 -0
  128. app/code/local/Simi/Simiconnector/Helper/Review.php +190 -0
  129. app/code/local/Simi/Simiconnector/Helper/Simibarcode.php +216 -0
  130. app/code/local/Simi/Simiconnector/Helper/Siminotification.php +312 -0
  131. app/code/local/Simi/Simiconnector/Helper/Simivideo.php +26 -0
  132. app/code/local/Simi/Simiconnector/Helper/Tierprice.php +303 -0
  133. app/code/local/Simi/Simiconnector/Helper/Total.php +189 -0
  134. app/code/local/Simi/Simiconnector/Helper/Wishlist.php +218 -0
  135. app/code/local/Simi/Simiconnector/Model/.DS_Store +0 -0
  136. app/code/local/Simi/Simiconnector/Model/Address.php +79 -0
  137. app/code/local/Simi/Simiconnector/Model/Api/Abstract.php +306 -0
  138. app/code/local/Simi/Simiconnector/Model/Api/Addresses.php +146 -0
  139. app/code/local/Simi/Simiconnector/Model/Api/Categories.php +81 -0
  140. app/code/local/Simi/Simiconnector/Model/Api/Cmspages.php +21 -0
  141. app/code/local/Simi/Simiconnector/Model/Api/Customers.php +92 -0
  142. app/code/local/Simi/Simiconnector/Model/Api/Devices.php +30 -0
  143. app/code/local/Simi/Simiconnector/Model/Api/Downloadableproducts.php +92 -0
  144. app/code/local/Simi/Simiconnector/Model/Api/Homebanners.php +62 -0
  145. app/code/local/Simi/Simiconnector/Model/Api/Homecategories.php +98 -0
  146. app/code/local/Simi/Simiconnector/Model/Api/Homeproductlists.php +80 -0
  147. app/code/local/Simi/Simiconnector/Model/Api/Homes.php +61 -0
  148. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Abstract.php +81 -0
  149. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Categories.php +41 -0
  150. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Categorytrees.php +33 -0
  151. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Customers.php +13 -0
  152. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Orders.php +13 -0
  153. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Packages.php +48 -0
  154. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Products.php +14 -0
  155. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Stores.php +13 -0
  156. app/code/local/Simi/Simiconnector/Model/Api/Migrate/Storeviews.php +13 -0
  157. app/code/local/Simi/Simiconnector/Model/Api/Notifications.php +73 -0
  158. app/code/local/Simi/Simiconnector/Model/Api/Orders.php +309 -0
  159. app/code/local/Simi/Simiconnector/Model/Api/Products.php +285 -0
  160. app/code/local/Simi/Simiconnector/Model/Api/Quoteitems.php +275 -0
  161. app/code/local/Simi/Simiconnector/Model/Api/Reviews.php +196 -0
  162. app/code/local/Simi/Simiconnector/Model/Api/Simibarcodes.php +20 -0
  163. app/code/local/Simi/Simiconnector/Model/Api/Simivideos.php +23 -0
  164. app/code/local/Simi/Simiconnector/Model/Api/Stores.php +34 -0
  165. app/code/local/Simi/Simiconnector/Model/Api/Storeviews.php +296 -0
  166. app/code/local/Simi/Simiconnector/Model/Api/Wishlistitems.php +175 -0
  167. app/code/local/Simi/Simiconnector/Model/Appreport.php +10 -0
  168. app/code/local/Simi/Simiconnector/Model/Banner.php +84 -0
  169. app/code/local/Simi/Simiconnector/Model/Cms.php +74 -0
  170. app/code/local/Simi/Simiconnector/Model/Config/Source/Addressrequiretype.php +21 -0
  171. app/code/local/Simi/Simiconnector/Model/Config/Source/Productsviewtype.php +17 -0
  172. app/code/local/Simi/Simiconnector/Model/Config/Source/Qrcodetypes.php +40 -0
  173. app/code/local/Simi/Simiconnector/Model/Config/Source/Showandhideoption.php +59 -0
  174. app/code/local/Simi/Simiconnector/Model/Customer.php +240 -0
  175. app/code/local/Simi/Simiconnector/Model/Device.php +69 -0
  176. app/code/local/Simi/Simiconnector/Model/History.php +18 -0
  177. app/code/local/Simi/Simiconnector/Model/Mysql4/Appreport.php +26 -0
  178. app/code/local/Simi/Simiconnector/Model/Mysql4/Appreport/Collection.php +10 -0
  179. app/code/local/Simi/Simiconnector/Model/Mysql4/Banner.php +27 -0
  180. app/code/local/Simi/Simiconnector/Model/Mysql4/Banner/Collection.php +30 -0
  181. app/code/local/Simi/Simiconnector/Model/Mysql4/Cms.php +12 -0
  182. app/code/local/Simi/Simiconnector/Model/Mysql4/Cms/Collection.php +13 -0
  183. app/code/local/Simi/Simiconnector/Model/Mysql4/Device.php +12 -0
  184. app/code/local/Simi/Simiconnector/Model/Mysql4/Device/Collection.php +13 -0
  185. app/code/local/Simi/Simiconnector/Model/Mysql4/History.php +11 -0
  186. app/code/local/Simi/Simiconnector/Model/Mysql4/History/Collection.php +14 -0
  187. app/code/local/Simi/Simiconnector/Model/Mysql4/Productlist.php +12 -0
  188. app/code/local/Simi/Simiconnector/Model/Mysql4/Productlist/Collection.php +13 -0
  189. app/code/local/Simi/Simiconnector/Model/Mysql4/Simibarcode.php +9 -0
  190. app/code/local/Simi/Simiconnector/Model/Mysql4/Simibarcode/Collection.php +10 -0
  191. app/code/local/Simi/Simiconnector/Model/Mysql4/Simicategory.php +8 -0
  192. app/code/local/Simi/Simiconnector/Model/Mysql4/Simicategory/Collection.php +10 -0
  193. app/code/local/Simi/Simiconnector/Model/Mysql4/Siminotification.php +13 -0
  194. app/code/local/Simi/Simiconnector/Model/Mysql4/Siminotification/Collection.php +13 -0
  195. app/code/local/Simi/Simiconnector/Model/Mysql4/Simiproductlabel.php +9 -0
  196. app/code/local/Simi/Simiconnector/Model/Mysql4/Simiproductlabel/Collection.php +10 -0
  197. app/code/local/Simi/Simiconnector/Model/Mysql4/Simivideo.php +9 -0
  198. app/code/local/Simi/Simiconnector/Model/Mysql4/Simivideo/Collection.php +10 -0
  199. app/code/local/Simi/Simiconnector/Model/Mysql4/Visibility.php +27 -0
  200. app/code/local/Simi/Simiconnector/Model/Mysql4/Visibility/Collection.php +30 -0
  201. app/code/local/Simi/Simiconnector/Model/Observer.php +188 -0
  202. app/code/local/Simi/Simiconnector/Model/Platform.php +39 -0
  203. app/code/local/Simi/Simiconnector/Model/Productlist.php +24 -0
  204. app/code/local/Simi/Simiconnector/Model/Server.php +125 -0
  205. app/code/local/Simi/Simiconnector/Model/Simibarcode.php +46 -0
  206. app/code/local/Simi/Simiconnector/Model/Simicategory.php +48 -0
  207. app/code/local/Simi/Simiconnector/Model/Simiconnector.php +10 -0
  208. app/code/local/Simi/Simiconnector/Model/Siminotification.php +23 -0
  209. app/code/local/Simi/Simiconnector/Model/Simiproductlabel.php +10 -0
  210. app/code/local/Simi/Simiconnector/Model/Simivideo.php +10 -0
  211. app/code/local/Simi/Simiconnector/Model/Status.php +41 -0
  212. app/code/local/Simi/Simiconnector/Model/Visibility.php +28 -0
  213. app/code/local/Simi/Simiconnector/controllers/.DS_Store +0 -0
  214. app/code/local/Simi/Simiconnector/controllers/Adminhtml/.DS_Store +0 -0
  215. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/AppreportController.php +61 -0
  216. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/BannerController.php +354 -0
  217. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/CmsController.php +213 -0
  218. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/ConfigController.php +35 -0
  219. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/DeviceController.php +96 -0
  220. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/HistoryController.php +96 -0
  221. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/ProductlistController.php +255 -0
  222. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimibarcodeController.php +465 -0
  223. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimicategoryController.php +244 -0
  224. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SiminotificationController.php +288 -0
  225. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimiproductlabelController.php +213 -0
  226. app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimivideoController.php +199 -0
  227. app/code/local/Simi/Simiconnector/controllers/IndexController.php +65 -0
  228. app/code/local/Simi/Simiconnector/controllers/RestController.php +42 -0
  229. app/code/local/Simi/Simiconnector/etc/adminhtml.xml +238 -0
  230. app/code/local/Simi/Simiconnector/etc/config.xml +254 -0
  231. app/code/local/Simi/Simiconnector/etc/system.xml +1114 -0
  232. app/code/local/Simi/Simiconnector/sql/.DS_Store +0 -0
  233. app/code/local/Simi/Simiconnector/sql/simiconnector_setup/mysql4-install-0.1.0.php +256 -0
  234. app/design/adminhtml/default/default/layout/simiconnector.xml +157 -0
  235. app/design/adminhtml/default/default/template/simiconnector/banner/categories.phtml +198 -0
  236. app/design/adminhtml/default/default/template/simiconnector/banner/grid.phtml +226 -0
  237. app/design/adminhtml/default/default/template/simiconnector/categories.phtml +174 -0
  238. app/design/adminhtml/default/default/template/simiconnector/productlist/grid.phtml +215 -0
  239. app/design/adminhtml/default/default/template/simiconnector/render/category.phtml +25 -0
  240. app/design/adminhtml/default/default/template/simiconnector/siminotification/categories.phtml +198 -0
  241. app/design/adminhtml/default/default/template/simiconnector/siminotification/devicegrid.phtml +231 -0
  242. app/design/adminhtml/default/default/template/simiconnector/siminotification/grid.phtml +226 -0
  243. app/design/adminhtml/default/default/template/simiconnector/siminotification/guide.phtml +23 -0
  244. app/design/adminhtml/default/default/template/simiconnector/simiproductlabel/grid.phtml +215 -0
  245. app/design/adminhtml/default/default/template/simiconnector/simivideo/grid.phtml +163 -0
app/code/local/Simi/Simiconnector/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Appreport.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
5
+ * version in the future.
6
+ *
7
+ * @category
8
+ * @package Appreport
9
+ * @copyright Copyright (c) 2012
10
+ * @license
11
+ */
12
+
13
+ /**
14
+ * Appreport Adminhtml Block
15
+ *
16
+ * @category
17
+ * @package Appreport
18
+ * @author Developer
19
+ */
20
+ class Simi_Simiconnector_Block_Adminhtml_Appreport extends Mage_Adminhtml_Block_Widget_Grid_Container
21
+ {
22
+ public function __construct()
23
+ {
24
+ $this->_controller = 'adminhtml_appreport';
25
+ $this->_blockGroup = 'simiconnector';
26
+ $this->_headerText = Mage::helper('simiconnector')->__('App Transactions');
27
+ parent::__construct();
28
+ $this->removeButton("add");
29
+ }
30
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Appreport/Grid.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Appreport_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('sales_order_grid');
8
+ $this->setUseAjax(true);
9
+ $this->setDefaultSort('created_at');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ /**
15
+ * Retrieve collection class
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _getCollectionClass() {
20
+ return 'sales/order_grid_collection';
21
+ }
22
+
23
+ protected function _prepareCollection() {
24
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
25
+ $appreport_table = Mage::getSingleton('core/resource')->getTableName('simiconnector/appreport');
26
+ $collection->getSelect()->join(array('transaction' => $appreport_table), 'transaction.order_id = main_table.entity_id');
27
+
28
+ $this->setCollection($collection);
29
+ return parent::_prepareCollection();
30
+ }
31
+
32
+ protected function _prepareColumns() {
33
+
34
+ $this->addColumn('real_order_id', array(
35
+ 'header' => Mage::helper('sales')->__('Order #'),
36
+ 'width' => '80px',
37
+ 'type' => 'text',
38
+ 'index' => 'increment_id',
39
+ ));
40
+
41
+ if (!Mage::app()->isSingleStoreMode()) {
42
+ $this->addColumn('store_id', array(
43
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
44
+ 'index' => 'store_id',
45
+ 'type' => 'store',
46
+ 'store_view' => true,
47
+ 'display_deleted' => true,
48
+ ));
49
+ }
50
+
51
+ $this->addColumn('created_at', array(
52
+ 'header' => Mage::helper('sales')->__('Purchased On'),
53
+ 'index' => 'created_at',
54
+ 'type' => 'datetime',
55
+ 'width' => '100px',
56
+ ));
57
+
58
+ $this->addColumn('billing_name', array(
59
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
60
+ 'index' => 'billing_name',
61
+ ));
62
+
63
+ $this->addColumn('shipping_name', array(
64
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
65
+ 'index' => 'shipping_name',
66
+ ));
67
+
68
+ $this->addColumn('base_grand_total', array(
69
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
70
+ 'index' => 'base_grand_total',
71
+ 'type' => 'currency',
72
+ 'currency' => 'base_currency_code',
73
+ ));
74
+
75
+ $this->addColumn('grand_total', array(
76
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
77
+ 'index' => 'grand_total',
78
+ 'type' => 'currency',
79
+ 'currency' => 'order_currency_code',
80
+ ));
81
+
82
+ $this->addColumn('status', array(
83
+ 'header' => Mage::helper('sales')->__('Status'),
84
+ 'index' => 'status',
85
+ 'type' => 'options',
86
+ 'width' => '70px',
87
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
88
+ ));
89
+
90
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
91
+ $this->addColumn('action', array(
92
+ 'header' => Mage::helper('sales')->__('Action'),
93
+ 'width' => '50px',
94
+ 'type' => 'action',
95
+ 'getter' => 'getId',
96
+ 'actions' => array(
97
+ array(
98
+ 'caption' => Mage::helper('sales')->__('View'),
99
+ 'url' => array('base' => 'adminhtml/sales_order/view'),
100
+ 'field' => 'order_id'
101
+ )
102
+ ),
103
+ 'filter' => false,
104
+ 'sortable' => false,
105
+ 'index' => 'stores',
106
+ 'is_system' => true,
107
+ ));
108
+ }
109
+ $this->addExportType('*/*/exportCsv', Mage::helper('simiconnector')->__('CSV'));
110
+ $this->addExportType('*/*/exportXml', Mage::helper('simiconnector')->__('XML'));
111
+
112
+ return parent::_prepareColumns();
113
+ }
114
+
115
+ protected function _prepareMassaction() {
116
+ $this->setMassactionIdField('entity_id');
117
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
118
+ $this->getMassactionBlock()->setUseSelectAll(false);
119
+
120
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
121
+ $this->getMassactionBlock()->addItem('cancel_order', array(
122
+ 'label' => Mage::helper('sales')->__('Cancel'),
123
+ 'url' => $this->getUrl('adminhtml/sales_order/massCancel'),
124
+ ));
125
+ }
126
+
127
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
128
+ $this->getMassactionBlock()->addItem('hold_order', array(
129
+ 'label' => Mage::helper('sales')->__('Hold'),
130
+ 'url' => $this->getUrl('adminhtml/sales_order/massHold'),
131
+ ));
132
+ }
133
+
134
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
135
+ $this->getMassactionBlock()->addItem('unhold_order', array(
136
+ 'label' => Mage::helper('sales')->__('Unhold'),
137
+ 'url' => $this->getUrl('adminhtml/sales_order/massUnhold'),
138
+ ));
139
+ }
140
+ return $this;
141
+ }
142
+
143
+ public function getRowUrl($row) {
144
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
145
+ return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
146
+ }
147
+ return false;
148
+ }
149
+
150
+ /**
151
+ * get url for using ajax reloading
152
+ *
153
+ * @return string
154
+ */
155
+ public function getGridUrl() {
156
+ return $this->getUrl('*/*/grid', array('_current' => true));
157
+ }
158
+
159
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Adminhtml Block
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Block_Adminhtml_Banner extends Mage_Adminhtml_Block_Widget_Grid_Container {
23
+
24
+ protected $_theme;
25
+
26
+ public function __construct() {
27
+ $this->_theme = Mage::helper('simiconnector/cloud')->getThemeLayout();
28
+ $this->_controller = 'adminhtml_banner';
29
+ $this->_blockGroup = 'simiconnector';
30
+ $this->_headerText = Mage::helper('simiconnector')->__('Banner Manager on ' .$this->_theme.' theme');
31
+ $this->_addButtonLabel = Mage::helper('simiconnector')->__('Add Banner');
32
+ parent::__construct();
33
+ }
34
+
35
+ public function getTheme(){
36
+ return $this->_theme;
37
+ }
38
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Edit Block
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
23
+
24
+ public function __construct() {
25
+ parent::__construct();
26
+
27
+ $this->_objectId = 'id';
28
+ $this->_blockGroup = 'simiconnector';
29
+ $this->_controller = 'adminhtml_banner';
30
+
31
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Save Banner'));
32
+ $this->_updateButton('delete', 'label', Mage::helper('simiconnector')->__('Delete Banner'));
33
+
34
+ $this->_addButton('saveandcontinue', array(
35
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
36
+ 'onclick' => 'saveAndContinueEdit()',
37
+ 'class' => 'save',
38
+ ), -100);
39
+
40
+ $this->_formScripts[] = "
41
+ function toggleEditor() {
42
+ if (tinyMCE.getInstanceById('madapter_content') == null)
43
+ tinyMCE.execCommand('mceAddControl', false, 'madapter_content');
44
+ else
45
+ tinyMCE.execCommand('mceRemoveControl', false, 'madapter_content');
46
+ }
47
+
48
+ function saveAndContinueEdit(){
49
+ editForm.submit($('edit_form').action+'back/edit/');
50
+ }
51
+
52
+ function onchangeNoticeType(type){
53
+ switch (type) {
54
+ case '1':
55
+ $('product_id').up('tr').show();
56
+ $('product_id').className = 'required-entry input-text';
57
+ $('category_id').up('tr').hide();
58
+ $('category_id').className = 'input-text';
59
+ $('banner_url').up('tr').hide();
60
+ $('banner_url').className = 'input-text';
61
+ break;
62
+ case '2':
63
+ $('category_id').up('tr').show();
64
+ $('category_id').className = 'required-entry input-text';
65
+ $('product_id').up('tr').hide();
66
+ $('product_id').className = 'input-text';
67
+ $('banner_url').up('tr').hide();
68
+ $('banner_url').className = 'input-text';
69
+ break;
70
+ case '3':
71
+ $('banner_url').up('tr').show();
72
+ $('product_id').up('tr').hide();
73
+ $('product_id').className = 'input-text';
74
+ $('category_id').up('tr').hide();
75
+ $('category_id').className = 'input-text';
76
+ break;
77
+ default:
78
+ $('product_id').up('tr').show();
79
+ $('product_id').className = 'required-entry input-text';
80
+ $('category_id').up('tr').hide();
81
+ $('category_id').className = 'input-text';
82
+ $('banner_url').up('tr').hide();
83
+ $('banner_url').className = 'input-text';
84
+ }
85
+ }
86
+ ";
87
+ }
88
+
89
+ /**
90
+ * get text to show in header when edit an item
91
+ *
92
+ * @return string
93
+ */
94
+ public function getHeaderText() {
95
+ if (Mage::registry('banner_data') && Mage::registry('banner_data')->getId())
96
+ return Mage::helper('simiconnector')->__("Edit Banner '%s'", $this->htmlEscape(Mage::registry('banner_data')->getBannerTitle()));
97
+ return Mage::helper('simiconnector')->__('Add Banner');
98
+ }
99
+
100
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Form.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Edit Form Block
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
24
+
25
+ /**
26
+ * prepare form's information for block
27
+ *
28
+ * @return Simi_Connector_Block_Adminhtml_Banner_Edit_Form
29
+ */
30
+ protected function _prepareForm() {
31
+ $form = new Varien_Data_Form(array(
32
+ 'id' => 'edit_form',
33
+ 'action' => $this->getUrl('*/*/save', array(
34
+ 'id' => $this->getRequest()->getParam('id'),
35
+ )),
36
+ 'method' => 'post',
37
+ 'enctype' => 'multipart/form-data'
38
+ ));
39
+
40
+ $form->setUseContainer(true);
41
+ $this->setForm($form);
42
+ return parent::_prepareForm();
43
+ }
44
+
45
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Categories.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category chooser for Wysiwyg CMS widget
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit_Tab_Categories extends Mage_Adminhtml_Block_Catalog_Category_Tree
35
+ {
36
+ protected $_selectedIds = array();
37
+
38
+ protected function _prepareLayout()
39
+ {
40
+ $this->setTemplate('simiconnector/banner/categories.phtml');
41
+ }
42
+ public function getCategoryIds()
43
+ {
44
+ return $this->_selectedIds;
45
+ }
46
+
47
+ public function setCategoryIds($id)
48
+ {
49
+ if (!$id) {
50
+ $ids = array();
51
+ }
52
+ elseif ($id) {
53
+ $ids[] = $id;
54
+ }
55
+ $this->_selectedIds = $ids;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Get JSON of a tree node or an associative array
61
+ *
62
+ * @param Varien_Data_Tree_Node|array $node
63
+ * @param int $level
64
+ * @return string
65
+ */
66
+ protected function _getNodeJson($node, $level = 1)
67
+ {
68
+ $item = array();
69
+ $item['text']= $this->htmlEscape($node->getName());
70
+
71
+ if ($this->_withProductCount) {
72
+ $item['text'].= ' ('.$node->getProductCount().')';
73
+ }
74
+ $item['id'] = $node->getId();
75
+ $item['path'] = $node->getData('path');
76
+ $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
77
+ $item['allowDrop'] = false;
78
+ $item['allowDrag'] = false;
79
+
80
+ if ($node->hasChildren()) {
81
+ $item['children'] = array();
82
+ foreach ($node->getChildren() as $child) {
83
+ $item['children'][] = $this->_getNodeJson($child, $level + 1);
84
+ }
85
+ }
86
+
87
+ if (empty($item['children']) && (int)$node->getChildrenCount() > 0) {
88
+ $item['children'] = array();
89
+ }
90
+
91
+ if (!empty($item['children'])) {
92
+ $item['expanded'] = true;
93
+ }
94
+
95
+ if (in_array($node->getId(), $this->getCategoryIds())) {
96
+ $item['checked'] = true;
97
+ }
98
+
99
+ return $item;
100
+ }
101
+
102
+ public function getRoot($parentNodeCategory=null, $recursionLevel=3)
103
+ {
104
+ return $this->getRootByIds($this->getCategoryIds());
105
+ }
106
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Form.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Simi Edit Form Content Tab Block
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
24
+
25
+ /**
26
+ * prepare tab form's information
27
+ *
28
+ * @return Simi_Connector_Block_Adminhtml_Banner_Edit_Tab_Form
29
+ */
30
+ protected function _prepareForm() {
31
+ $form = new Varien_Data_Form();
32
+ $this->setForm($form);
33
+
34
+ if (Mage::getSingleton('adminhtml/session')->getConnectorData()) {
35
+ $data = Mage::getSingleton('adminhtml/session')->getConnectorData();
36
+ Mage::getSingleton('adminhtml/session')->setConnectorData(null);
37
+ } elseif (Mage::registry('banner_data'))
38
+ $data = Mage::registry('banner_data')->getData();
39
+ if ($data['banner_id']) {
40
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('banner');
41
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
42
+ ->addFieldToFilter('content_type', $typeID)
43
+ ->addFieldToFilter('item_id', $data['banner_id']);
44
+ $storeIdArray = array();
45
+ foreach ($visibleStoreViews as $visibilityItem) {
46
+ $storeIdArray[] = $visibilityItem->getData('store_view_id');
47
+ }
48
+ $data['storeview_id'] = implode(',', $storeIdArray);
49
+ }
50
+ else {
51
+ $storeIdArray = array();
52
+ foreach (Mage::getModel('core/store')->getCollection() as $storeModel)
53
+ $storeIdArray[] = $storeModel->getId();
54
+ $data['storeview_id'] = implode(',', $storeIdArray);
55
+ }
56
+
57
+ $fieldset = $form->addFieldset('simiconnector_form', array('legend' => Mage::helper('simiconnector')->__('Banner information')));
58
+ /*
59
+ $fieldset->addField('website_id', 'select', array(
60
+ 'label' => Mage::helper('simiconnector')->__('Choose website'),
61
+ 'name' => 'website_id',
62
+ 'values' => Mage::getSingleton('simiconnector/status')->getWebsite(),
63
+ ));
64
+ */
65
+
66
+ $field = $fieldset->addField('storeview_id', 'multiselect', array(
67
+ 'name' => 'storeview_id[]',
68
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
69
+ 'title' => Mage::helper('simiconnector')->__('Store View'),
70
+ 'required' => true,
71
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, false),
72
+ ));
73
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
74
+ $field->setRenderer($renderer);
75
+
76
+
77
+ $fieldset->addField('banner_title', 'text', array(
78
+ 'label' => Mage::helper('simiconnector')->__('Title'),
79
+ 'class' => 'required-entry',
80
+ 'required' => true,
81
+ 'name' => 'banner_title',
82
+ ));
83
+
84
+ $fieldset->addField('banner_name', 'image', array(
85
+ 'label' => Mage::helper('simiconnector')->__('Image (width:640px, height:340px)'),
86
+ 'required' => FALSE,
87
+ 'name' => 'banner_name_co',
88
+ ));
89
+
90
+ $fieldset->addField('banner_name_tablet', 'image', array(
91
+ 'label' => Mage::helper('simiconnector')->__('Tablet Image (width:640px, height:340px)'),
92
+ 'required' => FALSE,
93
+ 'name' => 'banner_name_tablet_co',
94
+ ));
95
+
96
+ $fieldset->addField('type', 'select', array(
97
+ 'label' => Mage::helper('simiconnector')->__('Direct viewers to'),
98
+ 'class' => 'required-entry',
99
+ 'required' => true,
100
+ 'name' => 'type',
101
+ 'values' => Mage::getModel('simiconnector/banner')->toOptionArray(),
102
+ 'onchange' => 'onchangeNoticeType(this.value)',
103
+ 'after_element_html' => '<script> Event.observe(window, "load", function(){onchangeNoticeType(\'' . $data['type'] . '\');});</script>',
104
+ ));
105
+
106
+ $productIds = implode(", ", Mage::getResourceModel('catalog/product_collection')->getAllIds());
107
+ $fieldset->addField('product_id', 'text', array(
108
+ 'name' => 'product_id',
109
+ 'class' => 'required-entry',
110
+ 'required' => true,
111
+ 'label' => Mage::helper('simiconnector')->__('Product ID'),
112
+ 'note' => Mage::helper('simiconnector')->__('Choose a product'),
113
+ 'after_element_html' => '<a id="product_link" href="javascript:void(0)" onclick="toggleMainProducts()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Products"></a><input type="hidden" value="' . $productIds . '" id="product_all_ids"/><div id="main_products_select" style="display:none;width:640px"></div>
114
+ <script type="text/javascript">
115
+ function toggleMainProducts(){
116
+ if($("main_products_select").style.display == "none"){
117
+ var url = "' . $this->getUrl('adminhtml/simiconnector_banner/chooserMainProducts') . '";
118
+ var params = $("product_id").value.split(", ");
119
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
120
+ var request = new Ajax.Request(url,
121
+ {
122
+ evalScripts: true,
123
+ parameters: parameters,
124
+ onComplete:function(transport){
125
+ $("main_products_select").update(transport.responseText);
126
+ $("main_products_select").style.display = "block";
127
+ }
128
+ });
129
+ }else{
130
+ $("main_products_select").style.display = "none";
131
+ }
132
+ };
133
+ var grid;
134
+
135
+ function constructData(div){
136
+ grid = window[div.id+"JsObject"];
137
+ if(!grid.reloadParams){
138
+ grid.reloadParams = {};
139
+ grid.reloadParams["selected[]"] = $("product_id").value.split(", ");
140
+ }
141
+ }
142
+ function toogleCheckAllProduct(el){
143
+ if(el.checked == true){
144
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
145
+ if(e.name != "check_all"){
146
+ if(!e.checked){
147
+ if($("product_id").value == "")
148
+ $("product_id").value = e.value;
149
+ else
150
+ $("product_id").value = $("product_id").value + ", "+e.value;
151
+ e.checked = true;
152
+ grid.reloadParams["selected[]"] = $("product_id").value.split(", ");
153
+ }
154
+ }
155
+ });
156
+ }else{
157
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
158
+ if(e.name != "check_all"){
159
+ if(e.checked){
160
+ var vl = e.value;
161
+ if($("product_id").value.search(vl) == 0){
162
+ if($("product_id").value == vl) $("product_id").value = "";
163
+ $("product_id").value = $("product_id").value.replace(vl+", ","");
164
+ }else{
165
+ $("product_id").value = $("product_id").value.replace(", "+ vl,"");
166
+ }
167
+ e.checked = false;
168
+ grid.reloadParams["selected[]"] = $("product_id").value.split(", ");
169
+ }
170
+ }
171
+ });
172
+
173
+ }
174
+ }
175
+ function selectProduct(e) {
176
+ if(e.checked == true){
177
+ if(e.id == "main_on"){
178
+ $("product_id").value = $("product_all_ids").value;
179
+ }else{
180
+ if($("product_id").value == "")
181
+ $("product_id").value = e.value;
182
+ else
183
+ $("product_id").value = e.value;
184
+ grid.reloadParams["selected[]"] = $("product_id").value;
185
+ }
186
+ }else{
187
+ if(e.id == "main_on"){
188
+ $("product_id").value = "";
189
+ }else{
190
+ var vl = e.value;
191
+ if($("product_id").value.search(vl) == 0){
192
+ $("product_id").value = $("product_id").value.replace(vl+", ","");
193
+ }else{
194
+ $("product_id").value = $("product_id").value.replace(", "+ vl,"");
195
+ }
196
+ }
197
+ }
198
+
199
+ }
200
+ </script>'
201
+ ));
202
+
203
+ $fieldset->addField('category_id', 'text', array(
204
+ 'name' => 'category_id',
205
+ 'class' => 'required-entry',
206
+ 'required' => true,
207
+ 'label' => Mage::helper('simiconnector')->__('Category ID'),
208
+ 'note' => Mage::helper('simiconnector')->__('Choose a category'),
209
+ 'after_element_html' => '<a id="category_link" href="javascript:void(0)" onclick="toggleMainCategories()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Category"></a>
210
+ <div id="main_categories_select" style="display:none"></div>
211
+ <script type="text/javascript">
212
+ function toggleMainCategories(check){
213
+ var cate = $("main_categories_select");
214
+ if($("main_categories_select").style.display == "none" || (check ==1) || (check == 2)){
215
+ var url = "' . $this->getUrl('adminhtml/simiconnector_banner/chooserMainCategories') . '";
216
+ if(check == 1){
217
+ $("category_id").value = $("category_all_ids").value;
218
+ }else if(check == 2){
219
+ $("category_id").value = "";
220
+ }
221
+ var params = $("category_id").value.split(", ");
222
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
223
+ var request = new Ajax.Request(url,
224
+ {
225
+ evalScripts: true,
226
+ parameters: parameters,
227
+ onComplete:function(transport){
228
+ $("main_categories_select").update(transport.responseText);
229
+ $("main_categories_select").style.display = "block";
230
+ }
231
+ });
232
+ if(cate.style.display == "none"){
233
+ cate.style.display = "";
234
+ }else{
235
+ cate.style.display = "none";
236
+ }
237
+ }else{
238
+ cate.style.display = "none";
239
+ }
240
+ };
241
+ </script>
242
+ '
243
+ ));
244
+
245
+ $fieldset->addField('banner_url', 'editor', array(
246
+ 'name' => 'banner_url',
247
+ 'label' => Mage::helper('simiconnector')->__('Url'),
248
+ 'title' => Mage::helper('simiconnector')->__('Url'),
249
+ 'required' => false,
250
+ ));
251
+
252
+ if (!isset($data['sort_order']))
253
+ $data['sort_order'] = 1;
254
+ $fieldset->addField('sort_order', 'text', array(
255
+ 'label' => Mage::helper('simiconnector')->__('Sort Order'),
256
+ 'required' => false,
257
+ 'class' => 'validate-not-negative-number',
258
+ 'name' => 'sort_order',
259
+ ));
260
+
261
+ $fieldset->addField('status', 'select', array(
262
+ 'label' => Mage::helper('simiconnector')->__('Status'),
263
+ 'name' => 'status',
264
+ 'values' => Mage::getSingleton('simiconnector/status')->getOptionHash(),
265
+ ));
266
+
267
+ $form->setValues($data);
268
+ return parent::_prepareForm();
269
+ }
270
+
271
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Products.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * 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_Adminhtml
24
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Adminhtml sales order create search products block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
36
+
37
+
38
+ public function __construct($arguments = array()) {
39
+ parent::__construct($arguments);
40
+ if ($this->getRequest()->getParam('current_grid_id')) {
41
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
42
+ } else {
43
+ $this->setId('skuChooserGrid_' . $this->getId());
44
+ }
45
+
46
+ $form = $this->getJsFormObject();
47
+ $gridId = $this->getId();
48
+ $this->setCheckboxCheckCallback("constructData($gridId)");
49
+ $this->setDefaultSort('sku');
50
+ $this->setUseAjax(true);
51
+ if ($this->getRequest()->getParam('collapse')) {
52
+ $this->setIsCollapsed(true);
53
+ }
54
+ $this->setTemplate('simiconnector/banner/grid.phtml');
55
+ }
56
+
57
+ /**
58
+ * Retrieve quote store object
59
+ * @return Mage_Core_Model_Store
60
+ */
61
+ public function getStore() {
62
+ return Mage::app()->getStore();
63
+ }
64
+
65
+ protected function _addColumnFilterToCollection($column) {
66
+ // Set custom filter for in product flag
67
+ if ($column->getId() == 'in_products') {
68
+ $selected = $this->_getSelectedProducts();
69
+ if (empty($selected)) {
70
+ $selected = '';
71
+ }
72
+ if ($column->getFilter()->getValue()) {
73
+ $this->getCollection()->addFieldToFilter('sku', array('in' => $selected));
74
+ } else {
75
+ $this->getCollection()->addFieldToFilter('sku', array('nin' => $selected));
76
+ }
77
+ } else {
78
+ parent::_addColumnFilterToCollection($column);
79
+ }
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
85
+ *
86
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
87
+ */
88
+ protected function _prepareCollection() {
89
+ $collection = Mage::getResourceModel('catalog/product_collection')
90
+ ->setStoreId(0)
91
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id')
92
+ ->addFieldToFilter('visibility', array('neq' => '1'))
93
+ ->addFieldToFilter('status', '1')
94
+ ;
95
+ $this->setCollection($collection);
96
+
97
+ return parent::_prepareCollection();
98
+ }
99
+
100
+ /**
101
+ * Define Cooser Grid Columns and filters
102
+ *
103
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
104
+ */
105
+ protected function _prepareColumns() {
106
+ $this->addColumn('in_products', array(
107
+ 'header_css_class' => 'a-center',
108
+ 'type' => 'checkbox',
109
+ 'name' => 'in_products',
110
+ 'values' => $this->_getSelectedProducts(),
111
+ 'align' => 'center',
112
+ 'index' => 'sku',
113
+ 'use_index' => true,
114
+ 'width' => '50px',
115
+ 'renderer' => 'simiconnector/adminhtml_banner_edit_tab_renderer_sku'
116
+ ));
117
+
118
+ $this->addColumn('entity_id', array(
119
+ 'header' => Mage::helper('sales')->__('ID'),
120
+ 'sortable' => true,
121
+ 'width' => '60px',
122
+ 'index' => 'entity_id'
123
+ ));
124
+
125
+ $this->addColumn('chooser_name', array(
126
+ 'header' => Mage::helper('sales')->__('Product Name'),
127
+ 'name' => 'chooser_name',
128
+ 'index' => 'name',
129
+ 'width' => '400px'
130
+ ));
131
+
132
+ $this->addColumn('type', array(
133
+ 'header' => Mage::helper('catalog')->__('Type'),
134
+ 'width' => '60px',
135
+ 'index' => 'type_id',
136
+ 'type' => 'options',
137
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
138
+ ));
139
+
140
+ $this->addColumn('chooser_sku', array(
141
+ 'header' => Mage::helper('sales')->__('SKU'),
142
+ 'name' => 'chooser_sku',
143
+ 'width' => '80px',
144
+ 'index' => 'sku',
145
+ ));
146
+
147
+
148
+ return parent::_prepareColumns();
149
+ }
150
+
151
+ public function getGridUrl() {
152
+ return $this->getUrl('*/*/chooserMainProducts', array(
153
+ '_current' => true,
154
+ 'current_grid_id' => $this->getId(),
155
+ 'collapse' => null
156
+ ));
157
+ }
158
+
159
+ protected function _getSelectedProducts() {
160
+ $products = $this->getRequest()->getPost('selected', array());
161
+ return $products;
162
+ }
163
+
164
+
165
+ }
166
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tab/Renderer/Sku.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml sales order create search products block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit_Tab_Renderer_Sku extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $checked = '';
40
+ if(in_array($row->getId(), $this->_getSelectedProducts()))
41
+ $checked = 'checked';
42
+ $html = '<input type="radio" '.$checked.' name="selected" value="'.$row->getId().'" class="checkbox" onclick="selectProduct(this)">';
43
+ return sprintf('%s', $html);
44
+ }
45
+
46
+ protected function _getSelectedProducts()
47
+ {
48
+ $products = $this->getRequest()->getPost('selected', array());
49
+ return $products;
50
+ }
51
+
52
+ }
53
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Edit/Tabs.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Edit Tabs Block
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
23
+ {
24
+ public function __construct(){
25
+ parent::__construct();
26
+ $this->setId('banner_tabs');
27
+ $this->setDestElementId('edit_form');
28
+ $this->setTitle(Mage::helper('simiconnector')->__('Banner Information'));
29
+ }
30
+
31
+ /**
32
+ * prepare before render block to html
33
+ *
34
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Edit_Tabs
35
+ */
36
+ protected function _beforeToHtml(){
37
+ $this->addTab('form_section', array(
38
+ 'label' => Mage::helper('simiconnector')->__('Banner Information'),
39
+ 'title' => Mage::helper('simiconnector')->__('Banner Information'),
40
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_banner_edit_tab_form')->toHtml(),
41
+ ));
42
+ return parent::_beforeToHtml();
43
+ }
44
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Banner/Grid.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Grid Block
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Banner_Grid extends Mage_Adminhtml_Block_Widget_Grid {
24
+
25
+ public function __construct() {
26
+ parent::__construct();
27
+ $this->setId('bannerGrid');
28
+ $this->setDefaultSort('banner_id');
29
+ $this->setDefaultDir('ASC');
30
+ $this->setSaveParametersInSession(true);
31
+ }
32
+
33
+ /**
34
+ * prepare collection for block to display
35
+ *
36
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
37
+ */
38
+ protected function _prepareCollection() {
39
+ $webId = 0;
40
+ $collection = Mage::getModel('simiconnector/banner')->getCollection();
41
+ if ($this->getRequest()->getParam('website')) {
42
+ $webId = $this->getRequest()->getParam('website');
43
+ $collection->addFieldToFilter('website_id', array('eq' => $webId));
44
+ }
45
+ $this->setCollection($collection);
46
+ return parent::_prepareCollection();
47
+ }
48
+
49
+ /**
50
+ * prepare columns for this grid
51
+ *
52
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
53
+ */
54
+ protected function _prepareColumns() {
55
+ $this->addColumn('banner_id', array(
56
+ 'header' => Mage::helper('simiconnector')->__('ID'),
57
+ 'align' => 'right',
58
+ 'width' => '50px',
59
+ 'index' => 'banner_id',
60
+ ));
61
+
62
+ $this->addColumn('banner_title', array(
63
+ 'header' => Mage::helper('simiconnector')->__('Title'),
64
+ 'align' => 'left',
65
+ 'index' => 'banner_title',
66
+ ));
67
+
68
+ // $this->addColumn('banner_url', array(
69
+ // 'header' => Mage::helper('simiconnector')->__('URL'),
70
+ // 'width' => '550px',
71
+ // 'index' => 'banner_url',
72
+ // ));
73
+
74
+ $this->addColumn('type', array(
75
+ 'header' => Mage::helper('simiconnector')->__('Direct viewers to'),
76
+ 'width' => '150px',
77
+ 'index' => 'type',
78
+ 'type' => 'options',
79
+ 'options' => array(
80
+ 1 => Mage::helper('simiconnector')->__('Product In-app'),
81
+ 2 => Mage::helper('simiconnector')->__('Category In-app'),
82
+ 3 => Mage::helper('simiconnector')->__('Website Page'),
83
+ ),
84
+ ));
85
+
86
+ $this->addColumn('sort_order', array(
87
+ 'header' => Mage::helper('simiconnector')->__('Sort Order'),
88
+ 'align' => 'left',
89
+ 'width' => '50px',
90
+ 'index' => 'sort_order',
91
+ 'filter' => false
92
+ ));
93
+
94
+
95
+ $this->addColumn('status', array(
96
+ 'header' => Mage::helper('simiconnector')->__('Status'),
97
+ 'align' => 'left',
98
+ 'width' => '80px',
99
+ 'index' => 'status',
100
+ 'type' => 'options',
101
+ 'options' => array(
102
+ 1 => 'Enabled',
103
+ 2 => 'Disabled',
104
+ ),
105
+ ));
106
+
107
+ $this->addColumn('action', array(
108
+ 'header' => Mage::helper('simiconnector')->__('Action'),
109
+ 'width' => '100',
110
+ 'type' => 'action',
111
+ 'getter' => 'getId',
112
+ 'actions' => array(
113
+ array(
114
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
115
+ 'url' => array('base' => '*/*/edit'),
116
+ 'field' => 'id'
117
+ )),
118
+ 'filter' => false,
119
+ 'sortable' => false,
120
+ 'index' => 'stores',
121
+ 'is_system' => true,
122
+ ));
123
+
124
+ $this->addExportType('*/*/exportCsv', Mage::helper('simiconnector')->__('CSV'));
125
+ $this->addExportType('*/*/exportXml', Mage::helper('simiconnector')->__('XML'));
126
+
127
+ return parent::_prepareColumns();
128
+ }
129
+
130
+ /**
131
+ * prepare mass action for this grid
132
+ *
133
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Grid
134
+ */
135
+ protected function _prepareMassaction() {
136
+ $this->setMassactionIdField('banner_id');
137
+ $this->getMassactionBlock()->setFormFieldName('simiconnector');
138
+
139
+ $this->getMassactionBlock()->addItem('delete', array(
140
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
141
+ 'url' => $this->getUrl('*/*/massDelete'),
142
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
143
+ ));
144
+
145
+ $statuses = Mage::getSingleton('simiconnector/status')->getOptionArray();
146
+
147
+ array_unshift($statuses, array('label' => '', 'value' => ''));
148
+ $this->getMassactionBlock()->addItem('status', array(
149
+ 'label' => Mage::helper('simiconnector')->__('Change status'),
150
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
151
+ 'additional' => array(
152
+ 'visibility' => array(
153
+ 'name' => 'status',
154
+ 'type' => 'select',
155
+ 'class' => 'required-entry',
156
+ 'label' => Mage::helper('simiconnector')->__('Status'),
157
+ 'values' => $statuses
158
+ ))
159
+ ));
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ * get url for each row in grid
165
+ *
166
+ * @return string
167
+ */
168
+ public function getRowUrl($row) {
169
+ $webId = Mage::getBlockSingleton('simiconnector/adminhtml_web_switcher')->getWebsiteId();
170
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
171
+ }
172
+
173
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ class Simi_Simiconnector_Block_Adminhtml_Cms extends Mage_Adminhtml_Block_Widget_Grid_Container {
6
+
7
+ public function __construct() {
8
+ $this->_controller = 'adminhtml_cms';
9
+ $this->_blockGroup = 'simiconnector';
10
+ $this->_headerText = Mage::helper('simiconnector')->__('CMS');
11
+ $this->_addButtonLabel = Mage::helper('simiconnector')->__('Add Static Block');
12
+ parent::__construct();
13
+ }
14
+
15
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Edit Block
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Block_Adminhtml_Cms_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
23
+
24
+ public function __construct() {
25
+ parent::__construct();
26
+
27
+ $this->_objectId = 'id';
28
+ $this->_blockGroup = 'simiconnector';
29
+ $this->_controller = 'adminhtml_cms';
30
+ $this->_updateButton('delete', 'label', Mage::helper('simiconnector')->__('Delete'));
31
+ $this->_addButton('saveandcontinue', array(
32
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
33
+ 'onclick' => 'saveAndContinueEdit()',
34
+ 'class' => 'save',
35
+ ), -100);
36
+ $this->_formScripts[] = "
37
+ function toggleEditor() {
38
+ if (tinyMCE.getInstanceById('notice_content') == null)
39
+ tinyMCE.execCommand('mceAddControl', false, 'notice_content');
40
+ else
41
+ tinyMCE.execCommand('mceRemoveControl', false, 'notice_content');
42
+ }
43
+
44
+ function saveAndContinueEdit(){
45
+ editForm.submit($('edit_form').action+'back/edit/');
46
+ }
47
+ function onchangeCmsType(type){
48
+ switch (type) {
49
+ case '1':
50
+ $('category_id').up('tr').hide();
51
+ $('category_id').className = 'input-text';
52
+ $('cms_image').up('tr').show();
53
+ break;
54
+ case '2':
55
+ $('category_id').up('tr').show();
56
+ $('category_id').className = 'required-entry input-text';
57
+ $('cms_image').up('tr').hide();
58
+ }
59
+ }
60
+ ";
61
+ }
62
+
63
+ /**
64
+ * get text to show in header when edit an item
65
+ *
66
+ * @return string
67
+ */
68
+ public function getHeaderText() {
69
+ if (Mage::registry('cms_data') && Mage::registry('cms_data')->getId())
70
+ return Mage::helper('simiconnector')->__("Edit Block '%s'", $this->htmlEscape(Mage::registry('cms_data')->getCmsTitle()));
71
+ return Mage::helper('simiconnector')->__('Add Block');
72
+ }
73
+
74
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit/Form.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Edit Form Block
18
+ *
19
+ * @category
20
+ * @package Madapter
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Cms_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
24
+
25
+ /**
26
+ * prepare form's information for block
27
+ *
28
+ * @return Simi_Connector_Block_Adminhtml_Banner_Edit_Form
29
+ */
30
+ protected function _prepareForm() {
31
+ $form = new Varien_Data_Form(array(
32
+ 'id' => 'edit_form',
33
+ 'action' => $this->getUrl('*/*/save', array(
34
+ 'id' => $this->getRequest()->getParam('id'),
35
+ )),
36
+ 'method' => 'post',
37
+ 'enctype' => 'multipart/form-data'
38
+ ));
39
+
40
+ $form->setUseContainer(true);
41
+ $this->setForm($form);
42
+ return parent::_prepareForm();
43
+ }
44
+
45
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit/Tab/Form.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Simi Edit Form Content Tab Block
18
+ *
19
+ * @category
20
+ * @package Madapter
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Cms_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
24
+
25
+ /**
26
+ * prepare tab form's information
27
+ *
28
+ * @return Simi_Connector_Block_Adminhtml_Banner_Edit_Tab_Form
29
+ */
30
+ protected function _prepareForm() {
31
+ $form = new Varien_Data_Form();
32
+ $this->setForm($form);
33
+
34
+ if (Mage::getSingleton('adminhtml/session')->getConnectorData()) {
35
+ $data = Mage::getSingleton('adminhtml/session')->getConnectorData();
36
+ Mage::getSingleton('adminhtml/session')->setConnectorData(null);
37
+ } elseif (Mage::registry('cms_data'))
38
+ $data = Mage::registry('cms_data')->getData();
39
+
40
+ if ($data['cms_id']) {
41
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('cms');
42
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
43
+ ->addFieldToFilter('content_type', $typeID)
44
+ ->addFieldToFilter('item_id', $data['cms_id']);
45
+ $storeIdArray = array();
46
+ foreach ($visibleStoreViews as $visibilityItem) {
47
+ $storeIdArray[] = $visibilityItem->getData('store_view_id');
48
+ }
49
+ $data['storeview_id'] = implode(',', $storeIdArray);
50
+ }
51
+ if (!$data['type'])
52
+ $data['type'] = '1';
53
+
54
+ $fieldset = $form->addFieldset('simiconnector_form', array('legend' => Mage::helper('simiconnector')->__('CMS information')));
55
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig();
56
+ $wysiwygConfig->addData(array(
57
+ 'add_variables' => false,
58
+ 'plugins' => array(),
59
+ 'widget_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/widget/index'),
60
+ 'directives_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive'),
61
+ 'directives_url_quoted' => preg_quote(Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive')),
62
+ 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index'),
63
+ ));
64
+
65
+
66
+ $field = $fieldset->addField('storeview_id', 'multiselect', array(
67
+ 'name' => 'storeview_id[]',
68
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
69
+ 'title' => Mage::helper('simiconnector')->__('Store View'),
70
+ 'required' => true,
71
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, false),
72
+ ));
73
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
74
+ $field->setRenderer($renderer);
75
+
76
+ $fieldset->addField('cms_title', 'text', array(
77
+ 'label' => Mage::helper('simiconnector')->__('Title'),
78
+ 'class' => 'required-entry',
79
+ 'required' => true,
80
+ 'name' => 'cms_title',
81
+ ));
82
+
83
+
84
+ $fieldset->addField('cms_content', 'editor', array(
85
+ 'name' => 'cms_content',
86
+ 'class' => 'required-entry',
87
+ 'required' => true,
88
+ 'config' => $wysiwygConfig,
89
+ 'label' => Mage::helper('simiconnector')->__('Content'),
90
+ 'title' => Mage::helper('simiconnector')->__('Content'),
91
+ 'style' => 'width: 600px;',
92
+ ));
93
+
94
+ if (!isset($data['sort_order']))
95
+ $data['sort_order'] = 1;
96
+ $fieldset->addField('sort_order', 'text', array(
97
+ 'label' => Mage::helper('simiconnector')->__('Sort Order'),
98
+ 'required' => false,
99
+ 'class' => 'validate-not-negative-number',
100
+ 'name' => 'sort_order',
101
+ ));
102
+
103
+ $fieldset->addField('cms_status', 'select', array(
104
+ 'label' => Mage::helper('simiconnector')->__('Enable'),
105
+ 'name' => 'cms_status',
106
+ 'values' => array(
107
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('Yes')),
108
+ array('value' => 0, 'label' => Mage::helper('simiconnector')->__('No')),
109
+ )
110
+ ));
111
+
112
+ $fieldset->addField('type', 'select', array(
113
+ 'label' => Mage::helper('simiconnector')->__('Show Block On'),
114
+ 'class' => 'required-entry',
115
+ 'required' => true,
116
+ 'name' => 'type',
117
+ 'values' => Mage::getModel('simiconnector/cms')->toOptionArray(),
118
+ 'onchange' => 'onchangeCmsType(this.value)',
119
+ 'after_element_html' => '<script> Event.observe(window, "load", function(){onchangeCmsType(\'' . $data['type'] . '\');});</script>',
120
+ ));
121
+
122
+ $fieldset->addField('cms_image', 'image', array(
123
+ 'label' => Mage::helper('simiconnector')->__('Icon (width:64px, height:64px)'),
124
+ 'name' => 'cms_image_o',
125
+ ));
126
+
127
+ $fieldset->addField('category_id', 'text', array(
128
+ 'name' => 'category_id',
129
+ 'class' => 'required-entry',
130
+ 'required' => true,
131
+ 'label' => Mage::helper('simiconnector')->__('Category ID'),
132
+ 'note' => Mage::helper('simiconnector')->__('Choose a category'),
133
+ 'after_element_html' => '<a id="category_link" href="javascript:void(0)" onclick="toggleMainCategories()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Category"></a>
134
+ <div id="main_categories_select" style="display:none"></div>
135
+ <script type="text/javascript">
136
+ function toggleMainCategories(check){
137
+ var cate = $("main_categories_select");
138
+ if($("main_categories_select").style.display == "none" || (check ==1) || (check == 2)){
139
+ var url = "' . $this->getUrl('adminhtml/simiconnector_banner/chooserMainCategories') . '";
140
+ if(check == 1){
141
+ $("category_id").value = $("category_all_ids").value;
142
+ }else if(check == 2){
143
+ $("category_id").value = "";
144
+ }
145
+ var params = $("category_id").value.split(", ");
146
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
147
+ var request = new Ajax.Request(url,
148
+ {
149
+ evalScripts: true,
150
+ parameters: parameters,
151
+ onComplete:function(transport){
152
+ $("main_categories_select").update(transport.responseText);
153
+ $("main_categories_select").style.display = "block";
154
+ }
155
+ });
156
+ if(cate.style.display == "none"){
157
+ cate.style.display = "";
158
+ }else{
159
+ cate.style.display = "none";
160
+ }
161
+ }else{
162
+ cate.style.display = "none";
163
+ }
164
+ };
165
+ </script>'
166
+ ));
167
+
168
+ $form->setValues($data);
169
+ return parent::_prepareForm();
170
+ }
171
+
172
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Edit/Tabs.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Edit Tabs Block
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Block_Adminhtml_Cms_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
23
+ {
24
+ public function __construct(){
25
+ parent::__construct();
26
+ $this->setId('notice_tabs');
27
+ $this->setDestElementId('edit_form');
28
+ $this->setTitle(Mage::helper('simiconnector')->__('CMS Information'));
29
+ }
30
+
31
+ /**
32
+ * prepare before render block to html
33
+ *
34
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Edit_Tabs
35
+ */
36
+ protected function _beforeToHtml(){
37
+ $this->addTab('form_section', array(
38
+ 'label' => Mage::helper('simiconnector')->__('CMS Information'),
39
+ 'title' => Mage::helper('simiconnector')->__('CMS Information'),
40
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_cms_edit_tab_form')->toHtml(),
41
+ ));
42
+ return parent::_beforeToHtml();
43
+ }
44
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Cms/Grid.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Cms_Grid extends Mage_Adminhtml_Block_Widget_Grid {
7
+
8
+ public function __construct() {
9
+ parent::__construct();
10
+ $this->setId('noticeGrid');
11
+ $this->setDefaultSort('cms_id');
12
+ $this->setDefaultDir('ASC');
13
+ $this->setSaveParametersInSession(true);
14
+ }
15
+
16
+ protected function _prepareCollection() {
17
+ $webId = 0;
18
+ $collection = Mage::getModel('simiconnector/cms')->getCollection();
19
+ if ($this->getRequest()->getParam('website')) {
20
+ $webId = $this->getRequest()->getParam('website');
21
+ $collection->addFieldToFilter('website_id', array('eq' => $webId));
22
+ }
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ protected function _prepareColumns() {
28
+ $this->addColumn('cms_id', array(
29
+ 'header' => Mage::helper('simiconnector')->__('ID'),
30
+ 'align' => 'right',
31
+ 'width' => '50px',
32
+ 'index' => 'cms_id',
33
+ ));
34
+
35
+ $this->addColumn('cms_title', array(
36
+ 'header' => Mage::helper('simiconnector')->__('Title'),
37
+ 'align' => 'left',
38
+ 'index' => 'cms_title',
39
+ ));
40
+
41
+
42
+ $this->addColumn('sort_order', array(
43
+ 'header' => Mage::helper('simiconnector')->__('Sort Order'),
44
+ 'align' => 'left',
45
+ 'width' => '50px',
46
+ 'index' => 'sort_order',
47
+ 'filter' => false
48
+ ));
49
+
50
+
51
+ $this->addColumn('cms_status', array(
52
+ 'header' => Mage::helper('simiconnector')->__('Status'),
53
+ 'align' => 'left',
54
+ 'width' => '80px',
55
+ 'index' => 'cms_status',
56
+ 'type' => 'options',
57
+ 'options' => array(
58
+ 1 => 'Yes',
59
+ 0 => 'No',
60
+ ),
61
+ ));
62
+
63
+ $this->addColumn('action', array(
64
+ 'header' => Mage::helper('simiconnector')->__('Action'),
65
+ 'width' => '100',
66
+ 'type' => 'action',
67
+ 'getter' => 'getId',
68
+ 'actions' => array(
69
+ array(
70
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
71
+ 'url' => array('base' => '*/*/edit'),
72
+ 'field' => 'id'
73
+ )),
74
+ 'filter' => false,
75
+ 'sortable' => false,
76
+ 'index' => 'stores',
77
+ 'is_system' => true,
78
+ ));
79
+
80
+
81
+ return parent::_prepareColumns();
82
+ }
83
+
84
+ protected function _prepareMassaction() {
85
+ $this->setMassactionIdField('cms_id');
86
+ $this->getMassactionBlock()->setFormFieldName('simiconnector');
87
+
88
+ $this->getMassactionBlock()->addItem('delete', array(
89
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
90
+ 'url' => $this->getUrl('*/*/massDelete'),
91
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
92
+ ));
93
+
94
+ return $this;
95
+ }
96
+
97
+ public function getRowUrl($row) {
98
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
99
+ }
100
+
101
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Device extends Mage_Adminhtml_Block_Widget_Grid_Container
7
+ {
8
+ public function __construct(){
9
+ $this->_controller = 'adminhtml_device';
10
+ $this->_blockGroup = 'simiconnector';
11
+ $this->_headerText = Mage::helper('simiconnector')->__('Device Manager');
12
+ parent::__construct();
13
+ $this->removeButton('add');
14
+ }
15
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Device_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
7
+
8
+ public function __construct() {
9
+ parent::__construct();
10
+
11
+ $this->_objectId = 'id';
12
+ $this->_blockGroup = 'simiconnector';
13
+ $this->_controller = 'adminhtml_device';
14
+
15
+ $this->removeButton('reset');
16
+ $this->removeButton('save');
17
+ $this->_formScripts[] = "
18
+ function toggleEditor() {
19
+ if (tinyMCE.getInstanceById('device_content') == null)
20
+ tinyMCE.execCommand('mceAddControl', false, 'device_content');
21
+ else
22
+ tinyMCE.execCommand('mceRemoveControl', false, 'device_content');
23
+ }
24
+
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+ }
30
+
31
+ /**
32
+ * get text to show in header when edit an device
33
+ *
34
+ * @return string
35
+ */
36
+ public function getHeaderText() {
37
+ if (Mage::registry('device_data') && Mage::registry('device_data')->getId())
38
+ return Mage::helper('simiconnector')->__("View Device '%s'", $this->htmlEscape(Mage::registry('device_data')->getId()));
39
+ return Mage::helper('simiconnector')->__('Add Device');
40
+ }
41
+
42
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Form.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_Device_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
8
+
9
+ protected function _prepareForm() {
10
+ $form = new Varien_Data_Form(array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/*/save', array(
13
+ 'id' => $this->getRequest()->getParam('id'),
14
+ )),
15
+ 'method' => 'post',
16
+ 'enctype' => 'multipart/form-data'
17
+ ));
18
+
19
+ $form->setUseContainer(true);
20
+ $this->setForm($form);
21
+ return parent::_prepareForm();
22
+ }
23
+
24
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Renderer/Datetime.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Device_Edit_Renderer_Datetime extends Varien_Data_Form_Element_Abstract {
4
+
5
+ /**
6
+ * Retrieve Element HTML
7
+ *
8
+ * @return string
9
+ */
10
+ public function getElementHtml()
11
+ {
12
+ $values = explode(',', $this->getEscapedValue());
13
+ $html = $this->getBold() ? '<strong>' : '';
14
+ foreach($values as $id => $value){
15
+ $dateFormatIso = Mage::app()->getLocale()
16
+ ->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
17
+ $time = Mage::app()->getLocale()->date($value, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($dateFormatIso);
18
+ $html .= $time . '<br/>';
19
+ }
20
+
21
+ $html.= $this->getBold() ? '</strong>' : '';
22
+ $html.= $this->getAfterElementHtml();
23
+ return $html;
24
+ }
25
+
26
+ }
27
+
28
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Renderer/Selectname.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Device_Edit_Renderer_Selectname extends Varien_Data_Form_Element_Abstract {
4
+
5
+ /**
6
+ * Retrieve Element HTML
7
+ *
8
+ * @return string
9
+ */
10
+ public function getElementHtml()
11
+ {
12
+
13
+ $html = $this->getBold() ? '<strong>' : '';
14
+ $values = explode(',', $this->getEscapedValue());
15
+ foreach($values as $id => $value){
16
+ $countryId = $value;
17
+ $country = Mage::getResourceModel('directory/country_collection')
18
+ ->loadByStore()
19
+ ->addFieldToFilter('country_id',$countryId)
20
+ ->getFirstItem();
21
+ $html .= $country->getName().'<br/>';
22
+ }
23
+
24
+ $html .= $this->getBold() ? '</strong>' : '';
25
+ $html .= $this->getAfterElementHtml();
26
+ return $html;
27
+ }
28
+
29
+ }
30
+
31
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Tab/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Tab/Form.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Device_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
7
+
8
+ protected function _prepareForm() {
9
+ $form = new Varien_Data_Form();
10
+ $this->setForm($form);
11
+
12
+
13
+ if (Mage::getSingleton('adminhtml/session')->getDeviceData()) {
14
+ $data = Mage::getSingleton('adminhtml/session')->getDeviceData();
15
+ Mage::getSingleton('adminhtml/session')->setDeviceData(null);
16
+ } elseif (Mage::registry('device_data'))
17
+ $data = Mage::registry('device_data')->getData();
18
+
19
+ $fieldset = $form->addFieldset('device_form', array('legend' => Mage::helper('simiconnector')->__('Device information')));
20
+ $fieldset->addType('datetime', 'Simi_Simiconnector_Block_Adminhtml_Device_Edit_Renderer_Datetime');
21
+ $fieldset->addType('selectname', 'Simi_Simiconnector_Block_Adminhtml_Device_Edit_Renderer_Selectname');
22
+
23
+ $stores = Mage::getModel('core/store')->getCollection();
24
+
25
+ $list_store = array();
26
+ foreach ($stores as $store) {
27
+ $list_store[] = array(
28
+ 'value' => $store->getId(),
29
+ 'label' => $store->getName(),
30
+ );
31
+ }
32
+ $fieldset->addField('storeview_id', 'select', array(
33
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
34
+ 'name' => 'storeview_id',
35
+ 'values' => $list_store,
36
+ 'disabled' => true,
37
+ 'onchange' => 'clearDevices()'
38
+ ));
39
+
40
+ $fieldset->addField('plaform_id', 'select', array(
41
+ 'label' => Mage::helper('simiconnector')->__('Device Type'),
42
+ 'name' => 'plaform_id',
43
+ 'values' => array(
44
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('iPhone')),
45
+ array('value' => 2, 'label' => Mage::helper('simiconnector')->__('iPad')),
46
+ array('value' => 3, 'label' => Mage::helper('simiconnector')->__('Android')),
47
+ ),
48
+ 'disabled' => true,
49
+ ));
50
+
51
+ $fieldset->addField('country', 'selectname', array(
52
+ 'label' => Mage::helper('simiconnector')->__('Country'),
53
+ 'bold' => true,
54
+ 'name' => 'country',
55
+ ));
56
+
57
+ $fieldset->addField('state', 'label', array(
58
+ 'label' => Mage::helper('simiconnector')->__('State/Province'),
59
+ // 'bold' => true,
60
+ ));
61
+
62
+ $fieldset->addField('city', 'label', array(
63
+ 'label' => Mage::helper('simiconnector')->__('City'),
64
+ // 'bold' => true,
65
+ ));
66
+
67
+ $fieldset->addField('device_token', 'label', array(
68
+ 'label' => Mage::helper('simiconnector')->__('Device Token'),
69
+ ));
70
+
71
+ $fieldset->addField('created_time', 'datetime', array(
72
+ 'label' => Mage::helper('simiconnector')->__('Create Date'),
73
+ 'bold' => true,
74
+ 'name' => 'created_date',
75
+ ));
76
+
77
+ $fieldset->addField('is_demo', 'select', array(
78
+ 'label' => Mage::helper('simiconnector')->__('Is Demo'),
79
+ 'bold' => true,
80
+ 'values' => array(
81
+ array('value' => 3, 'label' => Mage::helper('simiconnector')->__('N/A')),
82
+ array('value' => 0, 'label' => Mage::helper('simiconnector')->__('NO')),
83
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('YES')),
84
+ ),
85
+ 'name' => 'is_demo',
86
+ 'disabled' => true,
87
+ ));
88
+ $form->setValues($data);
89
+ return parent::_prepareForm();
90
+ }
91
+
92
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Edit/Tabs.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_Device_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
8
+
9
+ public function __construct() {
10
+ parent::__construct();
11
+ $this->setId('siminotification_tabs');
12
+ $this->setDestElementId('edit_form');
13
+ $this->setTitle(Mage::helper('simiconnector')->__('Device Information'));
14
+ }
15
+
16
+ /**
17
+ */
18
+ protected function _beforeToHtml() {
19
+ $this->addTab('form_section', array(
20
+ 'label' => Mage::helper('simiconnector')->__('Device Information'),
21
+ 'title' => Mage::helper('simiconnector')->__('Device Information'),
22
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_device_edit_tab_form')->toHtml(),
23
+ ));
24
+ return parent::_beforeToHtml();
25
+ }
26
+
27
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Device/Grid.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Device_Grid extends Mage_Adminhtml_Block_Widget_Grid {
7
+
8
+ public function __construct() {
9
+ parent::__construct();
10
+ $this->setId('deviceGrid');
11
+ $this->setDefaultSort('device_id');
12
+ $this->setDefaultDir('DESC');
13
+ $this->setSaveParametersInSession(true);
14
+ }
15
+
16
+ /**
17
+ * prepare collection for block to display
18
+ *
19
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
20
+ */
21
+ protected function _prepareCollection() {
22
+ $collection = Mage::getModel('simiconnector/device')->getCollection();
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ /**
28
+ * prepare columns for this grid
29
+ *
30
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
31
+ */
32
+ protected function _prepareColumns() {
33
+ $this->addColumn('device_id', array(
34
+ 'header' => Mage::helper('simiconnector')->__('ID'),
35
+ 'align' => 'right',
36
+ 'width' => '50px',
37
+ 'index' => 'device_id',
38
+ ));
39
+
40
+ $this->addColumn('user_email', array(
41
+ 'header' => Mage::helper('simiconnector')->__('Customer Email'),
42
+ 'width' => '150px',
43
+ 'index' => 'user_email'
44
+ ));
45
+
46
+ $this->addColumn('plaform_id', array(
47
+ 'header' => Mage::helper('simiconnector')->__('Device Type'),
48
+ 'align' => 'left',
49
+ 'width' => '100px',
50
+ 'index' => 'plaform_id',
51
+ 'type' => 'options',
52
+ 'options' => array(
53
+ 3 => Mage::helper('simiconnector')->__('Android'),
54
+ 1 => Mage::helper('simiconnector')->__('iPhone'),
55
+ 2 => Mage::helper('simiconnector')->__('iPad'),
56
+ ),
57
+ ));
58
+
59
+ $this->addColumn('city', array(
60
+ 'header' => Mage::helper('simiconnector')->__('City'),
61
+ 'width' => '150px',
62
+ 'index' => 'city',
63
+ ));
64
+
65
+ $this->addColumn('state', array(
66
+ 'header' => Mage::helper('simiconnector')->__('State/Province'),
67
+ 'width' => '150px',
68
+ 'index' => 'state',
69
+ ));
70
+
71
+ $this->addColumn('country', array(
72
+ 'header' => Mage::helper('simiconnector')->__('Country'),
73
+ 'width' => '150px',
74
+ 'index' => 'country',
75
+ 'type' => 'options',
76
+ 'options' => Mage::helper('simiconnector/siminotification')->getListCountry(),
77
+ ));
78
+
79
+
80
+ $this->addColumn('is_demo', array(
81
+ 'header' => Mage::helper('simiconnector')->__('Is Demo'),
82
+ 'width' => '50px',
83
+ 'align' => 'right',
84
+ 'index' => 'is_demo',
85
+ 'type' => 'options',
86
+ 'options' => array(
87
+ 3 => Mage::helper('simiconnector')->__('N/A'),
88
+ 0 => Mage::helper('simiconnector')->__('NO'),
89
+ 1 => Mage::helper('simiconnector')->__('YES'),
90
+ ),
91
+ ));
92
+
93
+ $this->addColumn('created_time', array(
94
+ 'header' => Mage::helper('simiconnector')->__('Created Date'),
95
+ 'width' => '150px',
96
+ 'align' => 'right',
97
+ 'index' => 'created_time',
98
+ 'type' => 'datetime'
99
+ ));
100
+
101
+ $this->addColumn('app_id', array(
102
+ 'header' => Mage::helper('simiconnector')->__('App Id'),
103
+ 'width' => '100px',
104
+ 'align' => 'right',
105
+ 'index' => 'app_id'
106
+ ));
107
+
108
+ $this->addColumn('build_version', array(
109
+ 'header' => Mage::helper('simiconnector')->__('Build Version'),
110
+ 'width' => '50px',
111
+ 'align' => 'right',
112
+ 'index' => 'build_version'
113
+ ));
114
+ /*
115
+ $this->addColumn('device_token', array(
116
+ 'header' => Mage::helper('simiconnector')->__('Device Token'),
117
+ 'width' => '150px',
118
+ 'align' => 'right',
119
+ 'index' => 'device_token'
120
+ ));
121
+ */
122
+ $storeOptions = array();
123
+ foreach (Mage::getModel('core/store')->getCollection() as $store) {
124
+ $storeOptions [$store->getId()] = $store->getName();
125
+ }
126
+ $this->addColumn('storeview_id', array(
127
+ 'header' => Mage::helper('simiconnector')->__('Store View'),
128
+ 'align' => 'left',
129
+ 'width' => '80px',
130
+ 'index' => 'storeview_id',
131
+ 'type' => 'options',
132
+ 'options' => $storeOptions,
133
+ ));
134
+
135
+ $this->addColumn('action', array(
136
+ 'header' => Mage::helper('simiconnector')->__('Action'),
137
+ 'width' => '80px',
138
+ 'type' => 'action',
139
+ 'getter' => 'getId',
140
+ 'actions' => array(
141
+ array(
142
+ 'caption' => Mage::helper('simiconnector')->__('View'),
143
+ 'url' => array('base' => '*/*/edit'),
144
+ 'field' => 'id'
145
+ )),
146
+ 'filter' => false,
147
+ 'sortable' => false,
148
+ 'index' => 'stores',
149
+ 'is_system' => true,
150
+ ));
151
+ return parent::_prepareColumns();
152
+ }
153
+
154
+ /**
155
+ * prepare mass action for this grid
156
+ *
157
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Grid
158
+ */
159
+ protected function _prepareMassaction() {
160
+ $this->setMassactionIdField('notice_id');
161
+ $this->getMassactionBlock()->setFormFieldName('siminotification');
162
+
163
+ $this->getMassactionBlock()->addItem('delete', array(
164
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
165
+ 'url' => $this->getUrl('*/*/massDelete'),
166
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
167
+ ));
168
+
169
+ return $this;
170
+ }
171
+
172
+ /**
173
+ * get url for each row in grid
174
+ *
175
+ * @return string
176
+ */
177
+ public function getRowUrl($row) {
178
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
179
+ }
180
+
181
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Date.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Grid_Renderer_Date extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ if ($row->getExpiredTime()){
7
+ return $row->getExpiredTime();
8
+ }
9
+ return '0000-00-00';
10
+ }
11
+
12
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Device.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Grid_Renderer_Device extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ return Mage::helper('simiconnector')->getNameDeviceById($row->getData('device_id'));
7
+ }
8
+
9
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Edit.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Grid_Renderer_Edit extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $webId = Mage::getBlockSingleton('simiconnector/adminhtml_web_switcher')->getWebsiteId();
7
+ $url = Mage::helper("adminhtml")->getUrl('*/*/edit', array('id' => $row->getId(), 'website' => $webId, 'device_id' => $row->getDeviceId()));
8
+ return "<a href=" . "'" . $url . "'" . ">" . Mage::helper('core')->__("Edit") . "</a>";
9
+ }
10
+
11
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Osystem.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Grid_Renderer_Osystem extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $os = (int) $row->getDeviceId();
7
+ $name = '';
8
+ if ($os == 0) {
9
+ $name = Mage::helper('simiconnector')->__('ALL');
10
+ } elseif ($os == 1) {
11
+ $name = Mage::helper('simiconnector')->__('IOS');
12
+ } else {
13
+ $name = Mage::helper('simiconnector')->__('Android');
14
+ }
15
+ return $name;
16
+ }
17
+
18
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Grid/Renderer/Website.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Grid_Renderer_Website extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ return Mage::getModel('core/website')->load($row->getWebsiteId())->getName();
7
+ }
8
+
9
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/History.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_History extends Mage_Adminhtml_Block_Widget_Grid_Container {
7
+
8
+ public function __construct() {
9
+ $this->_controller = 'adminhtml_history';
10
+ $this->_blockGroup = 'simiconnector';
11
+ $this->_headerText = Mage::helper('simiconnector')->__('Notification History');
12
+ parent::__construct();
13
+ $this->removeButton('add');
14
+ }
15
+
16
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_History_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
7
+ {
8
+ public function __construct(){
9
+ parent::__construct();
10
+
11
+ $this->_objectId = 'id';
12
+ $this->_blockGroup = 'simiconnector';
13
+ $this->_controller = 'adminhtml_history';
14
+
15
+ $this->removeButton('reset');
16
+ $this->removeButton('save');
17
+
18
+ $this->_formScripts[] = "
19
+ function toggleEditor() {
20
+ if (tinyMCE.getInstanceById('siminotification_content') == null)
21
+ tinyMCE.execCommand('mceAddControl', false, 'siminotification_content');
22
+ else
23
+ tinyMCE.execCommand('mceRemoveControl', false, 'siminotification_content');
24
+ }
25
+
26
+ function saveAndContinueEdit(){
27
+ editForm.submit($('edit_form').action+'back/edit/');
28
+ }
29
+
30
+ function onchangeNoticeType(type){
31
+ switch (type) {
32
+ case '1':
33
+ $('product_id').up('tr').show();
34
+ $('product_id').className = 'required-entry input-text';
35
+ $('category_id').up('tr').hide();
36
+ $('category_id').className = 'input-text';
37
+ $('notice_url').up('tr').hide();
38
+ $('notice_url').className = 'input-text';
39
+ break;
40
+ case '2':
41
+ $('category_id').up('tr').show();
42
+ $('category_id').className = 'required-entry input-text';
43
+ $('product_id').up('tr').hide();
44
+ $('product_id').className = 'input-text';
45
+ $('notice_url').up('tr').hide();
46
+ $('notice_url').className = 'input-text';
47
+ break;
48
+ case '3':
49
+ $('notice_url').up('tr').show();
50
+ $('notice_url').className = 'required-entry input-text';
51
+ $('product_id').up('tr').hide();
52
+ $('product_id').className = 'input-text';
53
+ $('category_id').up('tr').hide();
54
+ $('category_id').className = 'input-text';
55
+ break;
56
+ default:
57
+ $('product_id').up('tr').show();
58
+ $('product_id').className = 'required-entry input-text';
59
+ $('category_id').up('tr').hide();
60
+ $('category_id').className = 'input-text';
61
+ $('notice_url').up('tr').hide();
62
+ $('notice_url').className = 'input-text';
63
+ }
64
+ }
65
+ ";
66
+ }
67
+
68
+ /**
69
+ * get text to show in header when edit an notification
70
+ *
71
+ * @return string
72
+ */
73
+ public function getHeaderText(){
74
+ if(Mage::registry('history_data') && Mage::registry('history_data')->getId())
75
+ return Mage::helper('simiconnector')->__("View Message '%s'", $this->htmlEscape(Mage::registry('history_data')->getNoticeTitle()));
76
+ return Mage::helper('simiconnector')->__('Add Message');
77
+ }
78
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit/Form.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_History_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
8
+
9
+ protected function _prepareForm() {
10
+ $form = new Varien_Data_Form(array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/*/save', array(
13
+ 'id' => $this->getRequest()->getParam('id'),
14
+ )),
15
+ 'method' => 'post',
16
+ 'enctype' => 'multipart/form-data'
17
+ ));
18
+
19
+ $form->setUseContainer(true);
20
+ $this->setForm($form);
21
+ return parent::_prepareForm();
22
+ }
23
+
24
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit/Tab/Form.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_History_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
7
+
8
+ protected function _prepareForm() {
9
+ $form = new Varien_Data_Form();
10
+ $this->setForm($form);
11
+
12
+ if (Mage::getSingleton('adminhtml/session')->getHistoryData()) {
13
+ $data = Mage::getSingleton('adminhtml/session')->getHistoryData();
14
+ Mage::getSingleton('adminhtml/session')->setHistoryData(null);
15
+ } elseif (Mage::registry('history_data'))
16
+ $data = Mage::registry('history_data')->getData();
17
+
18
+ $fieldset = $form->addFieldset('history_data', array('legend' => Mage::helper('simiconnector')->__('Notification Information')));
19
+ $fieldset->addType('datetime', 'Simi_Simiconnector_Block_Adminhtml_Device_Edit_Renderer_Datetime');
20
+
21
+ $stores = Mage::getModel('core/store')->getCollection();
22
+
23
+ $list_store = array();
24
+ foreach ($stores as $store) {
25
+ $list_store[] = array(
26
+ 'value' => $store->getId(),
27
+ 'label' => $store->getName(),
28
+ );
29
+ }
30
+ $fieldset->addField('storeview_id', 'select', array(
31
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
32
+ 'name' => 'storeview_id',
33
+ 'values' => $list_store,
34
+ 'disabled' => true,
35
+ 'onchange' => 'clearDevices()'
36
+ ));
37
+
38
+
39
+ $fieldset->addField('show_popup', 'select', array(
40
+ 'label' => Mage::helper('simiconnector')->__('Show Popup'),
41
+ 'name' => 'show_popup',
42
+ 'values' => array(
43
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('Yes')),
44
+ array('value' => 0, 'label' => Mage::helper('simiconnector')->__('No')),
45
+ ),
46
+ 'disabled' => true,
47
+ ));
48
+
49
+ $fieldset->addField('notice_title', 'label', array(
50
+ 'label' => Mage::helper('simiconnector')->__('Title'),
51
+ 'class' => 'required-entry',
52
+ 'required' => true,
53
+ 'name' => 'notice_title',
54
+ 'bold' => true,
55
+ ));
56
+
57
+ $fieldset->addField('image_url', 'image', array(
58
+ 'label' => Mage::helper('simiconnector')->__('Image'),
59
+ 'name' => 'image_url',
60
+ 'disabled' => true,
61
+ ));
62
+
63
+ $fieldset->addField('notice_content', 'editor', array(
64
+ 'name' => 'notice_content',
65
+ // 'class' => 'required-entry',
66
+ // 'required' => true,
67
+ 'label' => Mage::helper('simiconnector')->__('Message'),
68
+ 'title' => Mage::helper('simiconnector')->__('Message'),
69
+ 'note' => Mage::helper('simiconnector')->__('characters max: 250'),
70
+ 'readonly' => true,
71
+ ));
72
+
73
+ $fieldset->addField('type', 'select', array(
74
+ 'label' => Mage::helper('simiconnector')->__('Direct viewers to'),
75
+ 'class' => 'required-entry',
76
+ 'required' => true,
77
+ 'name' => 'type',
78
+ 'values' => Mage::getModel('simiconnector/siminotification')->toOptionArray(),
79
+ 'onchange' => 'onchangeNoticeType(this.value)',
80
+ 'after_element_html' => '<script> Event.observe(window, "load", function(){onchangeNoticeType(\'' . $data['type'] . '\');});</script>',
81
+ 'disabled' => true,
82
+ ));
83
+
84
+ $fieldset->addField('product_id', 'text', array(
85
+ 'name' => 'product_id',
86
+ 'class' => 'required-entry',
87
+ 'required' => true,
88
+ 'label' => Mage::helper('simiconnector')->__('Product ID'),
89
+ 'readonly' => true,
90
+ ));
91
+
92
+ $fieldset->addField('category_id', 'text', array(
93
+ 'name' => 'category_id',
94
+ 'class' => 'required-entry',
95
+ 'required' => true,
96
+ 'label' => Mage::helper('simiconnector')->__('Category ID'),
97
+ 'readonly' => true,
98
+ ));
99
+
100
+ $fieldset->addField('notice_url', 'text', array(
101
+ 'name' => 'notice_url',
102
+ 'class' => 'required-entry',
103
+ 'required' => true,
104
+ 'label' => Mage::helper('simiconnector')->__('URL'),
105
+ 'readonly' => true,
106
+ ));
107
+
108
+ $fieldset->addField('created_time', 'datetime', array(
109
+ 'label' => Mage::helper('simiconnector')->__('Sent Date'),
110
+ 'bold' => true,
111
+ 'name' => 'created_date',
112
+ ));
113
+
114
+ $fieldset->addField('devices_pushed', 'text', array(
115
+ 'label' => Mage::helper('simiconnector')->__('Devices pushed'),
116
+ 'name' => 'devices_pushed',
117
+ 'readonly' => true,
118
+ ));
119
+
120
+ $form->setValues($data);
121
+ return parent::_prepareForm();
122
+ }
123
+
124
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ class Simi_Simiconnector_Block_Adminhtml_History_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
6
+ {
7
+ public function __construct(){
8
+ parent::__construct();
9
+ $this->setId('history_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('simiconnector')->__('History Information'));
12
+ }
13
+
14
+ /**
15
+ */
16
+ protected function _beforeToHtml(){
17
+ $this->addTab('form_section', array(
18
+ 'label' => Mage::helper('simiconnector')->__('History Information'),
19
+ 'title' => Mage::helper('simiconnector')->__('History Information'),
20
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_history_edit_tab_form')->toHtml(),
21
+ ));
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/History/Grid.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_History_Grid extends Mage_Adminhtml_Block_Widget_Grid
7
+ {
8
+ public function __construct() {
9
+ parent::__construct();
10
+ $this->setId('noticeGrid');
11
+ $this->setDefaultSort('history_id');
12
+ $this->setDefaultDir('DESC');
13
+ $this->setSaveParametersInSession(true);
14
+ }
15
+
16
+ /**
17
+ * prepare collection for block to display
18
+ *
19
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
20
+ */
21
+ protected function _prepareCollection() {
22
+ $collection = Mage::getModel('simiconnector/history')->getCollection();
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ /**
28
+ * prepare columns for this grid
29
+ *
30
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
31
+ */
32
+ protected function _prepareColumns() {
33
+ $this->addColumn('history_id', array(
34
+ 'header' => Mage::helper('simiconnector')->__('ID'),
35
+ 'align' => 'right',
36
+ 'width' => '50px',
37
+ 'index' => 'history_id',
38
+ ));
39
+
40
+ $this->addColumn('notice_title', array(
41
+ 'header' => Mage::helper('simiconnector')->__('Title'),
42
+ 'align' => 'left',
43
+ 'width' => '150px',
44
+ 'index' => 'notice_title',
45
+ ));
46
+
47
+ $this->addColumn('notice_content', array(
48
+ 'header' => Mage::helper('simiconnector')->__('Message'),
49
+ 'align' => 'left',
50
+ 'index' => 'notice_content',
51
+ ));
52
+
53
+ $storeOptions = array();
54
+ foreach (Mage::getModel('core/store')->getCollection() as $store) {
55
+ $storeOptions [$store->getId()] = $store->getName();
56
+ }
57
+ $this->addColumn('storeview_id', array(
58
+ 'header' => Mage::helper('simiconnector')->__('Store View'),
59
+ 'align' => 'left',
60
+ 'width' => '80px',
61
+ 'index' => 'storeview_id',
62
+ 'type' => 'options',
63
+ 'options' => $storeOptions,
64
+ ));
65
+
66
+ $this->addColumn('device_id', array(
67
+ 'header' => Mage::helper('simiconnector')->__('Device'),
68
+ 'align' => 'left',
69
+ 'width' => '80px',
70
+ 'index' => 'device_id',
71
+ 'type' => 'options',
72
+ 'options' => array(
73
+ 0 => Mage::helper('simiconnector')->__('All'),
74
+ 1 => Mage::helper('simiconnector')->__('IOS'),
75
+ 2 => Mage::helper('simiconnector')->__('Android'),
76
+ ),
77
+ ));
78
+
79
+
80
+ $this->addColumn('notice_type', array(
81
+ 'header' => Mage::helper('simiconnector')->__('Type'),
82
+ 'align' => 'left',
83
+ 'width' => '120px',
84
+ 'index' => 'notice_type',
85
+ 'type' => 'options',
86
+ 'options' => array(
87
+ 0 => Mage::helper('simiconnector')->__('Custom'),
88
+ 1 => Mage::helper('simiconnector')->__('Price Updates'),
89
+ 2 => Mage::helper('simiconnector')->__('New Product'),
90
+ 3 => Mage::helper('simiconnector')->__('Order Purchase'),
91
+ ),
92
+ ));
93
+
94
+ $this->addColumn('created_time', array(
95
+ 'header' => Mage::helper('simiconnector')->__('Sent Date'),
96
+ 'width' => '150px',
97
+ 'index' => 'created_time',
98
+ 'type' => 'datetime',
99
+ ));
100
+
101
+ $this->addColumn('status', array(
102
+ 'header' => Mage::helper('simiconnector')->__('Status'),
103
+ 'align' => 'left',
104
+ 'width' => '80px',
105
+ 'index' => 'status',
106
+ 'type' => 'options',
107
+ 'options' => array(
108
+ 1 => Mage::helper('simiconnector')->__('Successfully'),
109
+ 0 => Mage::helper('simiconnector')->__('Unsuccessfully'),
110
+ ),
111
+ ));
112
+
113
+ $this->addColumn('action', array(
114
+ 'header' => Mage::helper('simiconnector')->__('Action'),
115
+ 'width' => '60px',
116
+ 'type' => 'action',
117
+ 'getter' => 'getId',
118
+ 'align' => 'left',
119
+ 'actions' => array(
120
+ array(
121
+ 'caption' => Mage::helper('simiconnector')->__('View'),
122
+ 'url' => array('base' => '*/*/edit'),
123
+ 'field' => 'id'
124
+ )),
125
+ 'filter' => false,
126
+ 'sortable' => false,
127
+ 'index' => 'stores',
128
+ 'is_system' => true,
129
+ ));
130
+
131
+
132
+ return parent::_prepareColumns();
133
+ }
134
+
135
+ /**
136
+ * prepare mass action for this grid
137
+ *
138
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Grid
139
+ */
140
+ protected function _prepareMassaction() {
141
+ $this->setMassactionIdField('history_id');
142
+ $this->getMassactionBlock()->setFormFieldName('history');
143
+
144
+ $this->getMassactionBlock()->addItem('delete', array(
145
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
146
+ 'url' => $this->getUrl('*/*/massDelete'),
147
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
148
+ ));
149
+
150
+ return $this;
151
+ }
152
+
153
+ /**
154
+ * get url for each row in grid
155
+ *
156
+ * @return string
157
+ */
158
+ public function getRowUrl($row) {
159
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
160
+ }
161
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ class Simi_Simiconnector_Block_Adminhtml_Productlist extends Mage_Adminhtml_Block_Widget_Grid_Container {
6
+ protected $_theme;
7
+ public function __construct() {
8
+ $this->_theme = Mage::helper('simiconnector/cloud')->getThemeLayout();
9
+ $this->_controller = 'adminhtml_productlist';
10
+ $this->_blockGroup = 'simiconnector';
11
+ $this->_headerText = Mage::helper('simiconnector')->__('Product List on ' .$this->_theme.' theme');
12
+ $this->_addButtonLabel = Mage::helper('simiconnector')->__('Add Product List');
13
+ parent::__construct();
14
+ }
15
+
16
+ public function getTheme(){
17
+ return $this->_theme;
18
+ }
19
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Edit Block
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
24
+
25
+ public function __construct() {
26
+ parent::__construct();
27
+
28
+ $this->_objectId = 'id';
29
+ $this->_blockGroup = 'simiconnector';
30
+ $this->_controller = 'adminhtml_productlist';
31
+
32
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Save List'));
33
+ $this->_updateButton('delete', 'label', Mage::helper('simiconnector')->__('Delete List'));
34
+
35
+ $this->_addButton('saveandcontinue', array(
36
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
37
+ 'onclick' => 'saveAndContinueEdit()',
38
+ 'class' => 'save',
39
+ ), -100);
40
+
41
+ $this->_formScripts[] = "
42
+ function toggleEditor() {
43
+ if (tinyMCE.getInstanceById('madapter_content') == null)
44
+ tinyMCE.execCommand('mceAddControl', false, 'madapter_content');
45
+ else
46
+ tinyMCE.execCommand('mceRemoveControl', false, 'madapter_content');
47
+ }
48
+
49
+ function saveAndContinueEdit(){
50
+ editForm.submit($('edit_form').action+'back/edit/');
51
+ }
52
+
53
+ function onchangeNoticeType(type){
54
+ switch (type) {
55
+ case '1':
56
+ $('list_products').up('tr').show();
57
+ break;
58
+ default:
59
+ $('list_products').up('tr').hide();
60
+ }
61
+ }
62
+ ";
63
+ }
64
+
65
+ /**
66
+ * get text to show in header when edit an item
67
+ *
68
+ * @return string
69
+ */
70
+ public function getHeaderText() {
71
+ if (Mage::registry('productlist_data') && Mage::registry('productlist_data')->getId())
72
+ return Mage::helper('simiconnector')->__("Edit List '%s'", $this->htmlEscape(Mage::registry('productlist_data')->getListTitle()));
73
+ return Mage::helper('simiconnector')->__('Add List');
74
+ }
75
+
76
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Form.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
7
+
8
+ /**
9
+ * prepare form's information for block
10
+ *
11
+ * @return Simi_Connector_Block_Adminhtml_Banner_Edit_Form
12
+ */
13
+ protected function _prepareForm() {
14
+ $form = new Varien_Data_Form(array(
15
+ 'id' => 'edit_form',
16
+ 'action' => $this->getUrl('*/*/save', array(
17
+ 'id' => $this->getRequest()->getParam('id'),
18
+ )),
19
+ 'method' => 'post',
20
+ 'enctype' => 'multipart/form-data'
21
+ ));
22
+
23
+ $form->setUseContainer(true);
24
+ $this->setForm($form);
25
+ return parent::_prepareForm();
26
+ }
27
+
28
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tab/Form.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Simi Edit Form Content Tab Block
18
+ *
19
+ * @category
20
+ * @package Madapter
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
24
+
25
+ /**
26
+ * prepare tab form's information
27
+ *
28
+ */
29
+ protected function _prepareForm() {
30
+ $form = new Varien_Data_Form();
31
+ $this->setForm($form);
32
+
33
+ if (Mage::getSingleton('adminhtml/session')->getConnectorData()) {
34
+ $data = Mage::getSingleton('adminhtml/session')->getConnectorData();
35
+ Mage::getSingleton('adminhtml/session')->setConnectorData(null);
36
+ } elseif (Mage::registry('productlist_data'))
37
+ $data = Mage::registry('productlist_data')->getData();
38
+
39
+ if ($data['productlist_id']) {
40
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('productlist');
41
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
42
+ ->addFieldToFilter('content_type', $typeID)
43
+ ->addFieldToFilter('item_id', $data['productlist_id']);
44
+ $storeIdArray = array();
45
+ foreach ($visibleStoreViews as $visibilityItem) {
46
+ $storeIdArray[] = $visibilityItem->getData('store_view_id');
47
+ }
48
+ $data['storeview_id'] = implode(',', $storeIdArray);
49
+ } else {
50
+ $storeIdArray = array();
51
+ foreach (Mage::getModel('core/store')->getCollection() as $storeModel)
52
+ $storeIdArray[] = $storeModel->getId();
53
+ $data['storeview_id'] = implode(',', $storeIdArray);
54
+ }
55
+ $fieldset = $form->addFieldset('simiconnector_form', array('legend' => Mage::helper('simiconnector')->__('Product List information')));
56
+
57
+
58
+ $field = $fieldset->addField('storeview_id', 'multiselect', array(
59
+ 'name' => 'storeview_id[]',
60
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
61
+ 'title' => Mage::helper('simiconnector')->__('Store View'),
62
+ 'required' => true,
63
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, false),
64
+ ));
65
+
66
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
67
+ $field->setRenderer($renderer);
68
+
69
+ $fieldset->addField('list_title', 'text', array(
70
+ 'label' => Mage::helper('simiconnector')->__('Title'),
71
+ 'class' => 'required-entry',
72
+ 'required' => true,
73
+ 'name' => 'list_title',
74
+ ));
75
+ if(Mage::helper('simiconnector/cloud')->getThemeLayout() == 'matrix'
76
+ || Mage::helper('simiconnector/cloud')->getThemeLayout() == 'zara'){
77
+ $fieldset->addField('list_image', 'image', array(
78
+ 'label' => Mage::helper('simiconnector')->__('Product List Image'),
79
+ 'name' => 'productlist_image_o',
80
+ ));
81
+
82
+ $fieldset->addField('list_image_tablet', 'image', array(
83
+ 'label' => Mage::helper('simiconnector')->__('Product List Tablet Image'),
84
+ 'name' => 'productlist_image_tablet_o',
85
+ ));
86
+ }
87
+
88
+ if (!isset($data['sort_order']))
89
+ $data['sort_order'] = 1;
90
+ $fieldset->addField('sort_order', 'text', array(
91
+ 'label' => Mage::helper('simiconnector')->__('Sort Order'),
92
+ 'required' => false,
93
+ 'class' => 'validate-not-negative-number',
94
+ 'name' => 'sort_order',
95
+ ));
96
+
97
+ if (!$data['list_type'])
98
+ $data['list_type'] = 1;
99
+ $fieldset->addField('list_type', 'select', array(
100
+ 'label' => Mage::helper('simiconnector')->__('Product List Type'),
101
+ 'name' => 'list_type',
102
+ 'values' => Mage::helper('simiconnector/productlist')->getTypeOption(),
103
+ 'onchange' => 'onchangeNoticeType(this.value)',
104
+ 'after_element_html' => '<script> Event.observe(window, "load", function(){onchangeNoticeType(\'' . $data['list_type'] . '\');});</script>',
105
+ ));
106
+
107
+ $productIds = implode(", ", Mage::getResourceModel('catalog/product_collection')->getAllIds());
108
+ $fieldset->addField('list_products', 'text', array(
109
+ 'name' => 'list_products',
110
+ 'label' => Mage::helper('simiconnector')->__('Product ID'),
111
+ 'note' => Mage::helper('simiconnector')->__('Choose a product'),
112
+ 'after_element_html' => '<a id="product_link" href="javascript:void(0)" onclick="toggleMainProducts()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Products"></a><input type="hidden" value="' . $productIds . '" id="product_all_ids"/><div id="main_products_select" style="display:none;width:640px"></div>
113
+ <script type="text/javascript">
114
+ function toggleMainProducts(){
115
+ if($("main_products_select").style.display == "none"){
116
+ var url = "' . $this->getUrl('adminhtml/simiconnector_productlist/chooserMainProducts') . '";
117
+ var params = $("list_products").value.split(", ");
118
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
119
+ var request = new Ajax.Request(url,
120
+ {
121
+ evalScripts: true,
122
+ parameters: parameters,
123
+ onComplete:function(transport){
124
+ $("main_products_select").update(transport.responseText);
125
+ $("main_products_select").style.display = "block";
126
+ }
127
+ });
128
+ }else{
129
+ $("main_products_select").style.display = "none";
130
+ }
131
+ };
132
+ var grid;
133
+
134
+ function constructData(div){
135
+ grid = window[div.id+"JsObject"];
136
+ if(!grid.reloadParams){
137
+ grid.reloadParams = {};
138
+ grid.reloadParams["selected[]"] = $("list_products").value.split(", ");
139
+ }
140
+ }
141
+ function toogleCheckAllProduct(el){
142
+ if(el == true){
143
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
144
+ if(e.name != "check_all"){
145
+ if(!e.checked){
146
+ if($("list_products").value == "")
147
+ $("list_products").value = e.value;
148
+ else
149
+ $("list_products").value = $("list_products").value + ", "+e.value;
150
+ e.checked = true;
151
+ grid.reloadParams["selected[]"] = $("list_products").value.split(", ");
152
+ }
153
+ }
154
+ });
155
+ }else{
156
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
157
+ if(e.name != "check_all"){
158
+ if(e.checked){
159
+ var vl = e.value;
160
+ if($("list_products").value.search(vl) == 0){
161
+ if($("list_products").value == vl) $("list_products").value = "";
162
+ $("list_products").value = $("list_products").value.replace(vl+", ","");
163
+ }else{
164
+ $("list_products").value = $("list_products").value.replace(", "+ vl,"");
165
+ }
166
+ e.checked = false;
167
+ grid.reloadParams["selected[]"] = $("list_products").value.split(", ");
168
+ }
169
+ }
170
+ });
171
+
172
+ }
173
+ }
174
+
175
+ function selectProduct(e) {
176
+ if(e.checked == true){
177
+ if(e.id == "main_on"){
178
+ $("list_products").value = $("product_all_ids").value;
179
+ }else{
180
+ if($("list_products").value == "")
181
+ $("list_products").value = e.value;
182
+ else
183
+ $("list_products").value = $("list_products").value + ", "+e.value;
184
+
185
+ grid.reloadParams["selected[]"] = $("list_products").value;
186
+ }
187
+ }else{
188
+ if(e.id == "main_on"){
189
+ $("list_products").value = "";
190
+ }else{
191
+ var vl = e.value;
192
+ if($("list_products").value.search(vl) == 0){
193
+ $("list_products").value = $("list_products").value.replace(vl+", ","");
194
+ }else{
195
+ $("list_products").value = $("list_products").value.replace(", "+ vl,"");
196
+ }
197
+ }
198
+ }
199
+
200
+ }
201
+ </script>'
202
+ ));
203
+
204
+
205
+ $fieldset->addField('list_status', 'select', array(
206
+ 'label' => Mage::helper('simiconnector')->__('Enable'),
207
+ 'name' => 'list_status',
208
+ 'values' => array(
209
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('Yes')),
210
+ array('value' => 0, 'label' => Mage::helper('simiconnector')->__('No')),
211
+ )
212
+ ));
213
+ if(Mage::helper('simiconnector/cloud')->getThemeLayout() == 'matrix'){
214
+ $matrixfieldset = $form->addFieldset('productlist_matrix', array('legend' => Mage::helper('simiconnector')->__('Matrix Layout Config')));
215
+
216
+ if (!$data['matrix_width_percent'])
217
+ $data['matrix_width_percent'] = 100;
218
+ if (!$data['matrix_height_percent'])
219
+ $data['matrix_height_percent'] = 30;
220
+ if (!$data['matrix_width_percent_tablet'])
221
+ $data['matrix_width_percent_tablet'] = 100;
222
+ if (!$data['matrix_height_percent_tablet'])
223
+ $data['matrix_height_percent_tablet'] = 30;
224
+ if (!$data['matrix_row'])
225
+ $data['matrix_row'] = 1;
226
+
227
+ $matrixfieldset->addField('matrix_width_percent', 'text', array(
228
+ 'label' => Mage::helper('simiconnector')->__('Image Width/ Screen Width Ratio'),
229
+ 'required' => false,
230
+ 'name' => 'matrix_width_percent',
231
+ 'class' => 'required-entry validate-number',
232
+ 'note' => Mage::helper('simiconnector')->__('With Screen Width is 100%'),
233
+ ));
234
+
235
+ $matrixfieldset->addField('matrix_height_percent', 'text', array(
236
+ 'label' => Mage::helper('simiconnector')->__('Image Height/ Screen Width Ratio'),
237
+ 'required' => false,
238
+ 'name' => 'matrix_height_percent',
239
+ 'class' => 'required-entry validate-number',
240
+ 'note' => Mage::helper('simiconnector')->__('With Screen Height is 100%'),
241
+ ));
242
+
243
+
244
+
245
+ $matrixfieldset->addField('matrix_width_percent_tablet', 'text', array(
246
+ 'label' => Mage::helper('simiconnector')->__('Tablet Image Width/Screen Width Ratio'),
247
+ 'required' => false,
248
+ 'name' => 'matrix_width_percent_tablet',
249
+ 'class' => 'required-entry validate-number',
250
+ 'note' => Mage::helper('simiconnector')->__('Leave it empty if you want to use Phone Value'),
251
+ ));
252
+
253
+ $matrixfieldset->addField('matrix_height_percent_tablet', 'text', array(
254
+ 'label' => Mage::helper('simiconnector')->__('Tablet Image Height/Screen Width Ratio'),
255
+ 'required' => false,
256
+ 'name' => 'matrix_height_percent_tablet',
257
+ 'class' => 'required-entry validate-number',
258
+ 'note' => Mage::helper('simiconnector')->__('Leave it empty if you want to use Phone Value'),
259
+ ));
260
+
261
+
262
+ $matrixfieldset->addField('matrix_row', 'select', array(
263
+ 'label' => Mage::helper('simiconnector')->__('Row Number'),
264
+ 'values' => Mage::helper('simiconnector/productlist')->getMatrixRowOptions(),
265
+ 'onchange' => 'autoFillHeight(this.value)',
266
+ 'name' => 'matrix_row',
267
+ ));
268
+
269
+
270
+ foreach (Mage::getModel('core/store')->getCollection() as $storeView) {
271
+ if (!$data['storeview_scope'])
272
+ $data['storeview_scope'] = $storeView->getId();
273
+ $storeviewArray[$storeView->getId()] = $storeView->getName();
274
+ }
275
+
276
+ $matrixfieldset->addField('storeview_scope', 'select', array(
277
+ 'label' => Mage::helper('simiconnector')->__('Storeview for Mockup Preview'),
278
+ 'name' => 'storeview_scope',
279
+ 'values' => $storeviewArray,
280
+ 'onchange' => 'updateMockupPreview(this.value)',
281
+ 'after_element_html' => '<div id="mockuppreview"></div> <script>
282
+ ' . Mage::helper('simiconnector/productlist')->autoFillMatrixRowHeight() . '
283
+ function updateMockupPreview(storeview){
284
+ var urlsend = "' . Mage::helper("adminhtml")->getUrl("*/*/getMockup") . '?storeview_id=" + storeview;
285
+ xhttp = new XMLHttpRequest();
286
+ xhttp.onreadystatechange = function() {
287
+ if (xhttp.readyState == 4 && xhttp.status == 200) {
288
+ document.getElementById("mockuppreview").innerHTML = xhttp.responseText;
289
+ }
290
+ };
291
+ xhttp.open("GET", urlsend, true);
292
+ xhttp.send();
293
+ }
294
+ Event.observe(window, "load", function(){updateMockupPreview(\'' . $data['storeview_scope'] . '\');});</script>',
295
+ ));
296
+ }
297
+
298
+ $form->setValues($data);
299
+ return parent::_prepareForm();
300
+ }
301
+
302
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tab/Products.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
8
+
9
+
10
+ public function __construct($arguments = array()) {
11
+ parent::__construct($arguments);
12
+ if ($this->getRequest()->getParam('current_grid_id')) {
13
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
14
+ } else {
15
+ $this->setId('skuChooserGrid_' . $this->getId());
16
+ }
17
+
18
+ $form = $this->getJsFormObject();
19
+ $gridId = $this->getId();
20
+ $this->setCheckboxCheckCallback("constructData($gridId)");
21
+ $this->setDefaultSort('sku');
22
+ $this->setUseAjax(true);
23
+ if ($this->getRequest()->getParam('collapse')) {
24
+ $this->setIsCollapsed(true);
25
+ }
26
+ $this->setTemplate('simiconnector/productlist/grid.phtml');
27
+ }
28
+
29
+ /**
30
+ * Retrieve quote store object
31
+ * @return Mage_Core_Model_Store
32
+ */
33
+ public function getStore() {
34
+ return Mage::app()->getStore();
35
+ }
36
+
37
+ protected function _addColumnFilterToCollection($column) {
38
+ // Set custom filter for in product flag
39
+ if ($column->getId() == 'in_products') {
40
+ $selected = $this->_getSelectedProducts();
41
+ if (empty($selected)) {
42
+ $selected = '';
43
+ }
44
+ if ($column->getFilter()->getValue()) {
45
+ $this->getCollection()->addFieldToFilter('sku', array('in' => $selected));
46
+ } else {
47
+ $this->getCollection()->addFieldToFilter('sku', array('nin' => $selected));
48
+ }
49
+ } else {
50
+ parent::_addColumnFilterToCollection($column);
51
+ }
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
57
+ *
58
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
59
+ */
60
+ protected function _prepareCollection() {
61
+ $collection = Mage::getResourceModel('catalog/product_collection')
62
+ ->setStoreId(0)
63
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id')
64
+ ->addFieldToFilter('visibility', array('neq' => '1'))
65
+ ->addFieldToFilter('status', '1')
66
+ ;
67
+ $this->setCollection($collection);
68
+
69
+ return parent::_prepareCollection();
70
+ }
71
+
72
+ /**
73
+ * Define Cooser Grid Columns and filters
74
+ *
75
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
76
+ */
77
+ protected function _prepareColumns() {
78
+ $this->addColumn('in_products', array(
79
+ 'header_css_class' => 'a-center',
80
+ 'type' => 'checkbox',
81
+ 'name' => 'in_products',
82
+ 'values' => $this->_getSelectedProducts(),
83
+ 'align' => 'center',
84
+ 'index' => 'sku',
85
+ 'use_index' => true,
86
+ 'width' => '50px',
87
+ 'renderer' => 'simiconnector/adminhtml_productlist_edit_tab_renderer_sku'
88
+ ));
89
+
90
+ $this->addColumn('entity_id', array(
91
+ 'header' => Mage::helper('sales')->__('ID'),
92
+ 'sortable' => true,
93
+ 'width' => '60px',
94
+ 'index' => 'entity_id'
95
+ ));
96
+
97
+ $this->addColumn('chooser_name', array(
98
+ 'header' => Mage::helper('sales')->__('Product Name'),
99
+ 'name' => 'chooser_name',
100
+ 'index' => 'name',
101
+ 'width' => '400px'
102
+ ));
103
+
104
+ $this->addColumn('type', array(
105
+ 'header' => Mage::helper('catalog')->__('Type'),
106
+ 'width' => '60px',
107
+ 'index' => 'type_id',
108
+ 'type' => 'options',
109
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
110
+ ));
111
+
112
+ $this->addColumn('chooser_sku', array(
113
+ 'header' => Mage::helper('sales')->__('SKU'),
114
+ 'name' => 'chooser_sku',
115
+ 'width' => '80px',
116
+ 'index' => 'sku',
117
+ ));
118
+
119
+
120
+ return parent::_prepareColumns();
121
+ }
122
+
123
+ public function getGridUrl() {
124
+ return $this->getUrl('*/*/chooserMainProducts', array(
125
+ '_current' => true,
126
+ 'current_grid_id' => $this->getId(),
127
+ 'collapse' => null
128
+ ));
129
+ }
130
+
131
+ protected function _getSelectedProducts() {
132
+ $products = $this->getRequest()->getPost('selected', array());
133
+ return $products;
134
+ }
135
+
136
+
137
+ }
138
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tab/Renderer/Sku.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml sales order create search products block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Edit_Tab_Renderer_Sku extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $checked = '';
40
+ if(in_array($row->getId(), $this->_getSelectedProducts()))
41
+ $checked = 'checked';
42
+ $html = '<input type="checkbox" '.$checked.' name="selected" value="'.$row->getId().'" class="checkbox" onclick="selectProduct(this)">';
43
+ return sprintf('%s', $html);
44
+ }
45
+
46
+ protected function _getSelectedProducts()
47
+ {
48
+ $products = $this->getRequest()->getPost('selected', array());
49
+ return $products;
50
+ }
51
+
52
+ }
53
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Edit/Tabs.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Edit Tabs Block
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
23
+ {
24
+ public function __construct(){
25
+ parent::__construct();
26
+ $this->setId('notice_tabs');
27
+ $this->setDestElementId('edit_form');
28
+ $this->setTitle(Mage::helper('simiconnector')->__('Product List Information'));
29
+ }
30
+
31
+ /**
32
+ * prepare before render block to html
33
+ *
34
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Edit_Tabs
35
+ */
36
+ protected function _beforeToHtml(){
37
+ $this->addTab('form_section', array(
38
+ 'label' => Mage::helper('simiconnector')->__('Product List Information'),
39
+ 'title' => Mage::helper('simiconnector')->__('Product List Information'),
40
+ 'content'=> $this->getLayout()->createBlock('simiconnector/adminhtml_productlist_edit_tab_form')->toHtml(),
41
+ ));
42
+ return parent::_beforeToHtml();
43
+ }
44
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Productlist/Grid.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Productlist_Grid extends Mage_Adminhtml_Block_Widget_Grid {
7
+
8
+ public function __construct() {
9
+ parent::__construct();
10
+ $this->setId('noticeGrid');
11
+ $this->setDefaultSort('productlist_id');
12
+ $this->setDefaultDir('ASC');
13
+ $this->setSaveParametersInSession(true);
14
+ }
15
+
16
+ protected function _prepareCollection() {
17
+ $webId = 0;
18
+ $collection = Mage::getModel('simiconnector/productlist')->getCollection();
19
+ if ($this->getRequest()->getParam('website')) {
20
+ $webId = $this->getRequest()->getParam('website');
21
+ $collection->addFieldToFilter('website_id', array('eq' => $webId));
22
+ }
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ protected function _prepareColumns() {
28
+ $this->addColumn('productlist_id', array(
29
+ 'header' => Mage::helper('simiconnector')->__('ID'),
30
+ 'align' => 'right',
31
+ 'width' => '50px',
32
+ 'index' => 'productlist_id',
33
+ ));
34
+
35
+ $this->addColumn('list_title', array(
36
+ 'header' => Mage::helper('simiconnector')->__('Title'),
37
+ 'align' => 'left',
38
+ 'index' => 'list_title',
39
+ ));
40
+
41
+
42
+ $this->addColumn('sort_order', array(
43
+ 'header' => Mage::helper('simiconnector')->__('Sort Order'),
44
+ 'align' => 'left',
45
+ 'width' => '50px',
46
+ 'index' => 'sort_order',
47
+ 'filter' => false
48
+ ));
49
+
50
+
51
+ $this->addColumn('list_status', array(
52
+ 'header' => Mage::helper('simiconnector')->__('Status'),
53
+ 'align' => 'left',
54
+ 'width' => '80px',
55
+ 'index' => 'list_status',
56
+ 'type' => 'options',
57
+ 'options' => array(
58
+ 1 => 'Yes',
59
+ 0 => 'No',
60
+ ),
61
+ ));
62
+
63
+ $this->addColumn('action', array(
64
+ 'header' => Mage::helper('simiconnector')->__('Action'),
65
+ 'width' => '100',
66
+ 'type' => 'action',
67
+ 'getter' => 'getId',
68
+ 'actions' => array(
69
+ array(
70
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
71
+ 'url' => array('base' => '*/*/edit'),
72
+ 'field' => 'id'
73
+ )),
74
+ 'filter' => false,
75
+ 'sortable' => false,
76
+ 'index' => 'stores',
77
+ 'is_system' => true,
78
+ ));
79
+
80
+
81
+ return parent::_prepareColumns();
82
+ }
83
+
84
+ protected function _prepareMassaction() {
85
+ $this->setMassactionIdField('productlist_id');
86
+ $this->getMassactionBlock()->setFormFieldName('simiconnector');
87
+
88
+ $this->getMassactionBlock()->addItem('delete', array(
89
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
90
+ 'url' => $this->getUrl('*/*/massDelete'),
91
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
92
+ ));
93
+
94
+ return $this;
95
+ }
96
+
97
+ public function getRowUrl($row) {
98
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
99
+ }
100
+
101
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+ $this->_controller = 'adminhtml_simibarcode';
7
+ $this->_blockGroup = 'simiconnector';
8
+ $this->_headerText = Mage::helper('simiconnector')->__('Manage QR & Barcodes');
9
+ $this->_addButtonLabel = Mage::helper('simiconnector')->__('Add New Custom QR & Barcode');
10
+ parent::__construct();
11
+ }
12
+
13
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Simibarcode
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Simibarcode Edit Block
18
+ *
19
+ * @category
20
+ * @package Simibarcode
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
24
+
25
+ public function __construct() {
26
+ parent::__construct();
27
+
28
+ $this->_objectId = 'id';
29
+ $this->_blockGroup = 'simiconnector';
30
+ $this->_controller = 'adminhtml_simibarcode';
31
+
32
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Save Item'));
33
+
34
+ if ($this->getRequest()->getParam('id')) {
35
+ $this->_removeButton('reset');
36
+
37
+ $this->_addButton('saveandcontinue', array(
38
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
39
+ 'onclick' => 'saveAndContinueEdit()',
40
+ 'class' => 'save',
41
+ ), -100);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * get text to show in header when edit an item
47
+ *
48
+ * @return string
49
+ */
50
+ public function getHeaderText() {
51
+ if (Mage::registry('simibarcode_data') && Mage::registry('simibarcode_data')->getId()
52
+ ) {
53
+ return Mage::helper('simiconnector')->__("Edit Code '%s'", $this->htmlEscape(Mage::registry('simibarcode_data')->getBarcode())
54
+ );
55
+ }
56
+ return Mage::helper('simiconnector')->__('Add QR & Barcode ');
57
+ }
58
+
59
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array(
9
+ 'id' => $this->getRequest()->getParam('id'),
10
+ )),
11
+ 'method' => 'post',
12
+ 'enctype' => 'multipart/form-data'
13
+ ));
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+
20
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Barcodecustom.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Renderer_Barcodecustom extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ protected $_values;
6
+
7
+ /**
8
+ * Renders grid column
9
+ *
10
+ * @param Varien_Object $row
11
+ * @return string
12
+ */
13
+ public function render(Varien_Object $row)
14
+ {
15
+ $value = $row->getData($this->getColumn()->getIndex());
16
+
17
+ if ($barcodeProducts = Mage::getModel('admin/session')->getData('barcode_product_import')) {
18
+ foreach($barcodeProducts as $barcodeProduct){
19
+ if($barcodeProduct['PRODUCT_ID']==$row->getId()){
20
+ if(isset($barcodeProduct['BARCODE']) && $barcodeProduct['BARCODE']){
21
+ $value = $barcodeProduct['BARCODE'];
22
+ }
23
+ }
24
+ }
25
+
26
+ }
27
+ $checked = 'checked="checked"';
28
+ if($value)
29
+ $checked = '';
30
+ $html = Mage::helper('simiconnector')->__('Auto').': <input onclick="setBarcodeAuto(this,\'barcode-' . $row->getId() . '\')" type="checkbox" name="barcode_auto" '.$checked.' value="">';
31
+ $html .= '<input type="text" ';
32
+ $html .= 'id="barcode-' . $row->getId() . '" ';
33
+ $html .= 'style="width: 130px !important;"';
34
+ $html .= 'name="' . $this->getColumn()->getId() . '" ';
35
+ $html .= 'value="' . $value . '"';
36
+ $html .= 'class="input-text' . $this->getColumn()->getInlineCss() . '" readonly />';
37
+ // $html .= '<p class="note" id="note_barcode"><span>'.Mage::helper('inventory')->__('Just [A-Z][a-z][0-9] are allowed').'</span></p>';
38
+ return $html;
39
+ }
40
+
41
+ }
42
+
43
+ ?>
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Datetime.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Renderer_Datetime extends Varien_Data_Form_Element_Abstract {
4
+
5
+ /**
6
+ * Retrieve Element HTML
7
+ *
8
+ * @return string
9
+ */
10
+ public function getElementHtml()
11
+ {
12
+ $values = explode(',', $this->getEscapedValue());
13
+
14
+ $html = $this->getBold() ? '<strong>' : '';
15
+
16
+
17
+ foreach($values as $id => $value){
18
+ $dateFormatIso = Mage::app()->getLocale()
19
+ ->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
20
+ $time = Mage::app()->getLocale()->date($value, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($dateFormatIso);
21
+ $html .= $time . '<br/>';
22
+ }
23
+
24
+ $html.= $this->getBold() ? '</strong>' : '';
25
+ $html.= $this->getAfterElementHtml();
26
+ return $html;
27
+ }
28
+
29
+ }
30
+
31
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Qrcodecustom.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Renderer_Qrcodecustom extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ protected $_values;
6
+
7
+ /**
8
+ * Renders grid column
9
+ *
10
+ * @param Varien_Object $row
11
+ * @return string
12
+ */
13
+ public function render(Varien_Object $row)
14
+ {
15
+ $value = $row->getData($this->getColumn()->getIndex());
16
+
17
+ if ($barcodeProducts = Mage::getModel('admin/session')->getData('barcode_product_import')) {
18
+ foreach($barcodeProducts as $barcodeProduct){
19
+ if($barcodeProduct['PRODUCT_ID']==$row->getId()){
20
+ if(isset($barcodeProduct['BARCODE']) && $barcodeProduct['BARCODE']){
21
+ $value = $barcodeProduct['BARCODE'];
22
+ }
23
+ }
24
+ }
25
+
26
+ }
27
+ $checked = 'checked="checked"';
28
+ if($value)
29
+ $checked = '';
30
+ $html = Mage::helper('simiconnector')->__('Auto').': <input onclick="setBarcodeAuto(this,\'qrcode-' . $row->getId() . '\')" type="checkbox" name="barcode_auto" '.$checked.' value="">';
31
+ $html .= '<input type="text" ';
32
+ $html .= 'id="qrcode-' . $row->getId() . '" ';
33
+ $html .= 'style="width: 130px !important;"';
34
+ $html .= 'name="' . $this->getColumn()->getId() . '" ';
35
+ $html .= 'value="' . $value . '"';
36
+ $html .= 'class="input-text' . $this->getColumn()->getInlineCss() . '" readonly />';
37
+ // $html .= '<p class="note" id="note_barcode"><span>'.Mage::helper('inventory')->__('Just [A-Z][a-z][0-9] are allowed').'</span></p>';
38
+ return $html;
39
+ }
40
+
41
+ }
42
+
43
+ ?>
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Renderer/Select.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Renderer_Select extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ /**
6
+ * Renders grid column
7
+ *
8
+ * @param Varien_Object $row
9
+ * @return string
10
+ */
11
+ public function render(Varien_Object $row)
12
+ {
13
+
14
+ $name = $this->getColumn()->getName() ? $this->getColumn()->getName() : $this->getColumn()->getId();
15
+ $html = '<select name="' . $this->escapeHtml($name) . '" ' . $this->getColumn()->getValidateClass() . '>';
16
+ $value = $row->getData($this->getColumn()->getIndex());
17
+ if ($barcodeProducts = Mage::getModel('admin/session')->getData('barcode_product_import')) {
18
+ $fieldIds = explode('_', $this->getColumn()->getId());
19
+ foreach($fieldIds as $id => $value){
20
+ if($id == 1)
21
+ $_field = $value;
22
+ if($id > 1)
23
+ $_field .= '_'. $value;
24
+ }
25
+ foreach($barcodeProducts as $barcodeProduct){
26
+ if($barcodeProduct['PRODUCT_ID']==$row->getId()){
27
+ if(isset($barcodeProduct[strtoupper($_field)]) && $barcodeProduct[strtoupper($_field)]){
28
+ $value = $barcodeProduct[strtoupper($_field)];
29
+ }
30
+ }
31
+ }
32
+
33
+ }
34
+
35
+ foreach ($this->getColumn()->getOptions() as $val => $label){
36
+ $selected = ( ($val == $value && (!is_null($value))) ? ' selected="selected"' : '' );
37
+ $html .= '<option value="' . $this->escapeHtml($val) . '"' . $selected . '>';
38
+ $html .= $this->escapeHtml($label) . '</option>';
39
+ }
40
+ $html.='</select>';
41
+ return $html;
42
+ }
43
+
44
+ }
45
+
46
+ ?>
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Tab/Form.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ /**
6
+ * prepare tab form's information
7
+ *
8
+ * @return Simi_Simibarcode_Block_Adminhtml_Simibarcode_Edit_Tab_Form
9
+ */
10
+ protected function _prepareForm() {
11
+ $form = new Varien_Data_Form();
12
+ $this->setForm($form);
13
+
14
+ if (Mage::getSingleton('adminhtml/session')->getSimibarcodeData()) {
15
+ $data = Mage::getSingleton('adminhtml/session')->getSimibarcodeData();
16
+ Mage::getSingleton('adminhtml/session')->setSimibarcodeData(null);
17
+ } elseif (Mage::registry('simibarcode_data'))
18
+ $data = Mage::registry('simibarcode_data')->getData();
19
+
20
+ //zend_debug::dump($data);die;
21
+ $width = $height = 200;
22
+ $sampleQR = '<img src="http://chart.googleapis.com/chart?chs='.$width.'x'.$height.'&cht=qr&chl='.$data['qrcode'].'" />';
23
+ $sampleBar = '</br></br><img src="'.Mage::helper("adminhtml")->getUrl('*/*/barcode').'?code='.$data['barcode'].'" />';
24
+ $fieldset = $form->addFieldset('simibarcode_form', array('legend' => Mage::helper('simiconnector')->__('Barcode Information')));
25
+ $fieldset->addType('datetime', 'Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Renderer_Datetime');
26
+
27
+ $fieldset->addField('barcode', 'text', array(
28
+ 'label' => Mage::helper('simiconnector')->__('Barcode'),
29
+ 'required' => false,
30
+ 'bold' => true,
31
+ 'name' => 'barcode',
32
+ 'after_element_html' => $sampleBar
33
+ ));
34
+
35
+ $fieldset->addField('qrcode', 'text', array(
36
+ 'label' => Mage::helper('simiconnector')->__('QR code'),
37
+ 'required' => false,
38
+ 'bold' => true,
39
+ 'name' => 'qrcode',
40
+ 'after_element_html' => $sampleQR
41
+ ));
42
+
43
+ $fieldset->addField('barcode_status', 'select', array(
44
+ 'label' => Mage::helper('simiconnector')->__('Status'),
45
+ 'name' => 'barcode_status',
46
+ 'required' => false,
47
+ 'values' => Mage::getSingleton('simiconnector/status')->getOptionHash(),
48
+ ));
49
+
50
+ $fieldset->addField('product_name', 'label', array(
51
+ 'label' => Mage::helper('simiconnector')->__('Product Name'),
52
+ 'required' => false,
53
+ 'bold' => true,
54
+ 'name' => 'product_name',
55
+ ));
56
+
57
+ $fieldset->addField('product_sku', 'label', array(
58
+ 'label' => Mage::helper('simiconnector')->__('Product Sku'),
59
+ 'required' => false,
60
+ 'bold' => true,
61
+ 'name' => 'product_sku',
62
+ ));
63
+
64
+ $fieldset->addField('created_date', 'datetime', array(
65
+ 'label' => Mage::helper('simiconnector')->__('Created Date'),
66
+ 'required' => false,
67
+ 'bold' => true,
68
+ 'name' => 'created_date',
69
+ ));
70
+
71
+ $form->setValues($data);
72
+ return parent::_prepareForm();
73
+ }
74
+
75
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Tab/Products.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('productGrid');
8
+ $this->setDefaultSort('entity_id');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setUseAjax(true);
11
+ if (Mage::getModel('admin/session')->getData('barcode_product_import')) {
12
+ $this->setDefaultFilter(array('in_products' => 1));
13
+ }
14
+ }
15
+
16
+ protected function _getStore() {
17
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
18
+ return Mage::app()->getStore($storeId);
19
+ }
20
+
21
+ protected function _addColumnFilterToCollection($column) {
22
+ if ($column->getId() == 'in_products') {
23
+ $productIds = $this->_getSelectedProducts();
24
+ if (empty($productIds))
25
+ $productIds = 0;
26
+ if ($column->getFilter()->getValue())
27
+ $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
28
+ elseif ($productIds)
29
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
30
+ return $this;
31
+ }
32
+ return parent::_addColumnFilterToCollection($column);
33
+ }
34
+
35
+ protected function _prepareCollection() {
36
+
37
+ // $collection = Mage::getModel('catalog/product')->getCollection()
38
+ // ->addAttributeToSelect('sku')
39
+ // ->addAttributeToSelect('name')
40
+ // ->addAttributeToSelect('status')
41
+ // ->addAttributeToSelect('price')
42
+ // ->addAttributeToSelect('attribute_set_id')
43
+ // ->addAttributeToSelect('type_id')
44
+ // ->addAttributeToFilter('type_id', array('nin' => array('configurable', 'bundle', 'grouped')));
45
+ // $this->setCollection($collection);
46
+ // return parent::_prepareCollection();
47
+
48
+ $store = $this->_getStore();
49
+ $collection = Mage::getModel('catalog/product')->getCollection()
50
+ ->addAttributeToSelect('sku')
51
+ ->addAttributeToSelect('name')
52
+ ->addAttributeToSelect('attribute_set_id')
53
+ ->addAttributeToSelect('type_id');
54
+
55
+ if ($store->getId()) {
56
+ //$collection->setStoreId($store->getId());
57
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
58
+ $collection->addStoreFilter($store);
59
+ $collection->joinAttribute(
60
+ 'name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore
61
+ );
62
+ $collection->joinAttribute(
63
+ 'visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId()
64
+ );
65
+ } else {
66
+ $collection->addAttributeToSelect('price');
67
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
68
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
69
+ }
70
+
71
+ $collection->addAttributeToFilter('visibility', array('nin' => array('1')));
72
+ $this->setCollection($collection);
73
+
74
+ parent::_prepareCollection();
75
+ $this->getCollection()->addWebsiteNamesToResult();
76
+ return $this;
77
+ }
78
+
79
+ protected function _prepareColumns() {
80
+ $this->addColumn('in_products', array(
81
+ 'header_css_class' => 'a-center',
82
+ 'type' => 'checkbox',
83
+ 'name' => 'in_products',
84
+ 'values' => $this->_getSelectedProducts(),
85
+ 'align' => 'center',
86
+ 'index' => 'entity_id'
87
+ ));
88
+
89
+ $this->addColumn('entity_id', array(
90
+ 'header' => Mage::helper('simiconnector')->__('ID'),
91
+ 'sortable' => true,
92
+ 'width' => '50px',
93
+ 'type' => 'number',
94
+ 'index' => 'entity_id',
95
+ ));
96
+
97
+ $this->addColumn('product_name', array(
98
+ 'header' => Mage::helper('simiconnector')->__('Name'),
99
+ 'align' => 'left',
100
+ 'index' => 'name'
101
+ ));
102
+
103
+ $this->addColumn('type', array(
104
+ 'header' => Mage::helper('catalog')->__('Type'),
105
+ 'width' => '60px',
106
+ 'index' => 'type_id',
107
+ 'type' => 'options',
108
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
109
+ ));
110
+
111
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
112
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
113
+ ->load()
114
+ ->toOptionHash();
115
+
116
+ $this->addColumn('set_name', array(
117
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
118
+ 'width' => '100px',
119
+ 'index' => 'attribute_set_id',
120
+ 'type' => 'options',
121
+ 'options' => $sets,
122
+ ));
123
+
124
+ $this->addColumn('product_sku', array(
125
+ 'header' => Mage::helper('simiconnector')->__('SKU'),
126
+ 'width' => '80px',
127
+ 'index' => 'sku'
128
+ ));
129
+
130
+ $this->addColumn('barcode', array(
131
+ 'header' => Mage::helper('simiconnector')->__('Barcode'),
132
+ 'align' => 'left',
133
+ 'width' => '130px',
134
+ 'index' => 'barcode',
135
+ 'type' => 'input',
136
+ 'editable' => true,
137
+ 'edit_only' => true,
138
+ 'renderer' => 'simiconnector/adminhtml_simibarcode_edit_renderer_barcodecustom',
139
+ ));
140
+
141
+ $this->addColumn('qrcode', array(
142
+ 'header' => Mage::helper('simiconnector')->__('QR code'),
143
+ 'align' => 'left',
144
+ 'width' => '130px',
145
+ 'index' => 'qrcode',
146
+ 'type' => 'input',
147
+ 'editable' => true,
148
+ 'edit_only' => true,
149
+ 'renderer' => 'simiconnector/adminhtml_simibarcode_edit_renderer_qrcodecustom',
150
+ ));
151
+
152
+ $store = $this->_getStore();
153
+ // $this->addColumn('price',
154
+ // array(
155
+ // 'header'=> Mage::helper('catalog')->__('Price'),
156
+ // 'type' => 'price',
157
+ // 'currency_code' => $store->getBaseCurrency()->getCode(),
158
+ // 'index' => 'price',
159
+ // ));
160
+ // $this->addColumn('visibility',
161
+ // array(
162
+ // 'header'=> Mage::helper('catalog')->__('Visibility'),
163
+ // 'width' => '70px',
164
+ // 'index' => 'visibility',
165
+ // 'type' => 'options',
166
+ // 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
167
+ // ));
168
+
169
+ $this->addColumn('status', array(
170
+ 'header' => Mage::helper('simiconnector')->__('Status'),
171
+ 'width' => '90px',
172
+ 'index' => 'status',
173
+ 'type' => 'options',
174
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
175
+ ));
176
+
177
+ $this->addColumn('action', array(
178
+ 'header' => Mage::helper('simiconnector')->__('Action'),
179
+ 'width' => '70px',
180
+ 'align' => 'center',
181
+ 'type' => 'action',
182
+ 'getter' => 'getId',
183
+ 'actions' => array(
184
+ array(
185
+ 'caption' => Mage::helper('simiconnector')->__('View'),
186
+ 'url' => array('base' => 'adminhtml/catalog_product/edit'),
187
+ 'field' => 'id'
188
+ )),
189
+ 'filter' => false,
190
+ 'sortable' => false,
191
+ 'index' => 'stores',
192
+ 'is_system' => true,
193
+ ));
194
+
195
+
196
+ return parent::_prepareColumns();
197
+ }
198
+
199
+ public function _getSelectedProducts() {
200
+ $productArrays = $this->getProducts();
201
+ $products = '';
202
+ $warehouseProducts = array();
203
+ if ($productArrays) {
204
+ $products = array();
205
+ foreach ($productArrays as $productArray) {
206
+ parse_str(urldecode($productArray), $warehouseProducts);
207
+ if (count($warehouseProducts)) {
208
+ foreach ($warehouseProducts as $pId => $enCoded) {
209
+ $products[] = $pId;
210
+ }
211
+ }
212
+ }
213
+ }
214
+ if (!is_array($products) || Mage::getModel('admin/session')->getData('barcode_product_import')) {
215
+ $products = array_keys($this->getSelectedProducts());
216
+ }
217
+
218
+ return $products;
219
+ }
220
+
221
+ public function getSelectedProducts() {
222
+
223
+ $products = array();
224
+ if ($barcodeProducts = Mage::getModel('admin/session')->getData('barcode_product_import')) {
225
+ foreach ($barcodeProducts as $barcodeProduct) {
226
+ $products[$barcodeProduct['PRODUCT_ID']] = array('barcode' => $barcodeProduct['BARCODE']);
227
+ $products[$barcodeProduct['PRODUCT_ID']] = array('qrcode' => $barcodeProduct['QRCODE']);
228
+ $products[$barcodeProduct['PRODUCT_ID']] = array('barcode_status' => $barcodeProduct['BARCODE_STATUS']);
229
+ }
230
+ }
231
+
232
+ return $products;
233
+ }
234
+
235
+ public function getGridUrl() {
236
+ return $this->getUrl('*/*/productsGrid', array(
237
+ '_current' => true
238
+ ));
239
+ }
240
+
241
+ public function getRowUrl($row) {
242
+ return false;
243
+ }
244
+
245
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Edit/Tabs.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('simibarcode_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('simiconnector')->__('Barcode'));
10
+ }
11
+
12
+ protected function _beforeToHtml() {
13
+ if (!$this->getRequest()->getParam('id')) {
14
+ $this->addTab('products_section', array(
15
+ 'label' => Mage::helper('simiconnector')->__('Barcode'),
16
+ 'title' => Mage::helper('simiconnector')->__('Barcode'),
17
+ 'url' => $this->getUrl('*/*/products', array('_current' => true)),
18
+ 'class' => 'ajax',
19
+ ));
20
+ } else {
21
+ $this->addTab('form_section', array(
22
+ 'label' => Mage::helper('simiconnector')->__('Barcode Information'),
23
+ 'title' => Mage::helper('simiconnector')->__('Barcode Information'),
24
+ 'content' => $this->getLayout()
25
+ ->createBlock('simiconnector/adminhtml_simibarcode_edit_tab_form')
26
+ ->toHtml(),
27
+ ));
28
+ }
29
+ return parent::_beforeToHtml();
30
+ }
31
+
32
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simibarcode/Grid.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simibarcode_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('simibarcodeGrid');
8
+ $this->setDefaultSort('barcode_id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+
14
+ protected function _prepareCollection() {
15
+ $collection = Mage::getModel('simiconnector/simibarcode')->getCollection();
16
+ $this->setCollection($collection);
17
+ return parent::_prepareCollection();
18
+ }
19
+
20
+
21
+ protected function _prepareColumns() {
22
+ $this->addColumn('barcode_id', array(
23
+ 'header' => Mage::helper('simiconnector')->__('ID'),
24
+ 'align' => 'right',
25
+ 'width' => '50px',
26
+ 'index' => 'barcode_id',
27
+ ));
28
+
29
+ $this->addColumn('barcode', array(
30
+ 'header' => Mage::helper('simiconnector')->__('Barcode'),
31
+ 'align' => 'left',
32
+ 'index' => 'barcode',
33
+ ));
34
+
35
+ $this->addColumn('qrcode', array(
36
+ 'header' => Mage::helper('simiconnector')->__('QRcode'),
37
+ 'align' => 'left',
38
+ 'index' => 'qrcode',
39
+ ));
40
+
41
+ $this->addColumn('product_name', array(
42
+ 'header' => Mage::helper('simiconnector')->__('Product Name'),
43
+ 'align' => 'left',
44
+ 'index' => 'product_name',
45
+ ));
46
+
47
+ $this->addColumn('product_sku', array(
48
+ 'header' => Mage::helper('simiconnector')->__('Product Sku'),
49
+ 'align' => 'left',
50
+ 'index' => 'product_sku',
51
+ ));
52
+
53
+ $this->addColumn('created_date', array(
54
+ 'header' => Mage::helper('simiconnector')->__('Created Date'),
55
+ 'align' => 'left',
56
+ 'index' => 'created_date',
57
+ 'type' => 'datetime'
58
+ ));
59
+
60
+ $this->addColumn('barcode_status', array(
61
+ 'header' => Mage::helper('simiconnector')->__('Status'),
62
+ 'align' => 'left',
63
+ 'width' => '80px',
64
+ 'index' => 'barcode_status',
65
+ 'type' => 'options',
66
+ 'options' => array(
67
+ 1 => 'Enabled',
68
+ 2 => 'Disabled',
69
+ ),
70
+ ));
71
+
72
+ $this->addColumn('action', array(
73
+ 'header' => Mage::helper('simiconnector')->__('Action'),
74
+ 'width' => '100',
75
+ 'type' => 'action',
76
+ 'getter' => 'getId',
77
+ 'actions' => array(
78
+ array(
79
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
80
+ 'url' => array('base' => '*/*/edit'),
81
+ 'field' => 'id'
82
+ )),
83
+ 'filter' => false,
84
+ 'sortable' => false,
85
+ 'index' => 'stores',
86
+ 'is_system' => true,
87
+ ));
88
+
89
+ $this->addExportType('*/*/exportCsv', Mage::helper('simiconnector')->__('CSV'));
90
+ $this->addExportType('*/*/exportXml', Mage::helper('simiconnector')->__('XML'));
91
+
92
+ return parent::_prepareColumns();
93
+ }
94
+
95
+
96
+ protected function _prepareMassaction() {
97
+ $this->setMassactionIdField('barcode_id');
98
+ $this->getMassactionBlock()->setFormFieldName('simibarcode');
99
+
100
+ $this->getMassactionBlock()->addItem('delete', array(
101
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
102
+ 'url' => $this->getUrl('*/*/massDelete'),
103
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
104
+ ));
105
+
106
+ $statuses = Mage::getSingleton('simiconnector/status')->getOptionArray();
107
+
108
+ array_unshift($statuses, array('label' => '', 'value' => ''));
109
+ $this->getMassactionBlock()->addItem('status', array(
110
+ 'label' => Mage::helper('simiconnector')->__('Change status'),
111
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
112
+ 'additional' => array(
113
+ 'visibility' => array(
114
+ 'name' => 'status',
115
+ 'type' => 'select',
116
+ 'class' => 'required-entry',
117
+ 'label' => Mage::helper('simiconnector')->__('Status'),
118
+ 'values' => $statuses
119
+ ))
120
+ ));
121
+ return $this;
122
+ }
123
+
124
+ public function getRowUrl($row) {
125
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
126
+ }
127
+
128
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simicategory extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ protected $_theme;
6
+ public function __construct() {
7
+ $this->_theme = Mage::helper('simiconnector/cloud')->getThemeLayout();
8
+ $this->_controller = 'adminhtml_simicategory';
9
+ $this->_blockGroup = 'simiconnector';
10
+ $this->_headerText = Mage::helper('simiconnector')->__('Category Manager on ' .$this->_theme.' theme');
11
+ $this->_addButtonLabel = Mage::helper('simiconnector')->__('Add Category');
12
+ parent::__construct();
13
+ }
14
+
15
+ public function getTheme(){
16
+ return $this->_theme;
17
+ }
18
+
19
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simicategory_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+
8
+ $this->_objectId = 'id';
9
+ $this->_blockGroup = 'simiconnector';
10
+ $this->_controller = 'adminhtml_simicategory';
11
+
12
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Save Category'));
13
+ $this->_updateButton('delete', 'label', Mage::helper('simiconnector')->__('Delete Category'));
14
+
15
+ $this->_addButton('saveandcontinue', array(
16
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
17
+ 'onclick' => 'saveAndContinueEdit()',
18
+ 'class' => 'save',
19
+ ), -100);
20
+
21
+ $this->_formScripts[] = "
22
+ function toggleEditor() {
23
+ if (tinyMCE.getInstanceById('simicategory_content') == null)
24
+ tinyMCE.execCommand('mceAddControl', false, 'simicategory_content');
25
+ else
26
+ tinyMCE.execCommand('mceRemoveControl', false, 'simicategory_content');
27
+ }
28
+
29
+ function saveAndContinueEdit(){
30
+ editForm.submit($('edit_form').action+'back/edit/');
31
+ }
32
+ ";
33
+
34
+ }
35
+
36
+ public function getHeaderText() {
37
+ if (Mage::registry('simicategory_data') && Mage::registry('simicategory_data')->getId())
38
+ return Mage::helper('simiconnector')->__("Edit Category '%s'", $this->htmlEscape(Mage::registry('simicategory_data')->getSimicategoryName()));
39
+ return Mage::helper('simiconnector')->__('Add Category');
40
+ }
41
+
42
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simicategory_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array(
9
+ 'id' => $this->getRequest()->getParam('id'),
10
+ )),
11
+ 'method' => 'post',
12
+ 'enctype' => 'multipart/form-data'
13
+ ));
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+
19
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit/Tab/Form.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simicategory_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+
9
+ if (Mage::getSingleton('adminhtml/session')->getSimicategoryData()) {
10
+ $data = Mage::getSingleton('adminhtml/session')->getSimicategoryData();
11
+ Mage::getSingleton('adminhtml/session')->setSimicategoryData(null);
12
+ } elseif (Mage::registry('simicategory_data'))
13
+ $data = Mage::registry('simicategory_data')->getData();
14
+ if ($data['simicategory_id']) {
15
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('homecategory');
16
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
17
+ ->addFieldToFilter('content_type', $typeID)
18
+ ->addFieldToFilter('item_id', $data['simicategory_id']);
19
+ $storeIdArray = array();
20
+ foreach ($visibleStoreViews as $visibilityItem) {
21
+ $storeIdArray[] = $visibilityItem->getData('store_view_id');
22
+ }
23
+ $data['storeview_id'] = implode(',', $storeIdArray);
24
+ } else {
25
+ $storeIdArray = array();
26
+ foreach (Mage::getModel('core/store')->getCollection() as $storeModel)
27
+ $storeIdArray[] = $storeModel->getId();
28
+ $data['storeview_id'] = implode(',', $storeIdArray);
29
+ }
30
+
31
+ $fieldset = $form->addFieldset('simicategory_form', array('legend' => Mage::helper('simiconnector')->__('Item information')));
32
+
33
+ $field = $fieldset->addField('storeview_id', 'multiselect', array(
34
+ 'name' => 'storeview_id[]',
35
+ 'label' => Mage::helper('cms')->__('Store View'),
36
+ 'title' => Mage::helper('cms')->__('Store View'),
37
+ 'required' => true,
38
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, false),
39
+ ));
40
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
41
+ $field->setRenderer($renderer);
42
+
43
+ $fieldset->addField('simicategory_filename', 'image', array(
44
+ 'label' => Mage::helper('simiconnector')->__('Image'),
45
+ 'required' => true,
46
+ 'name' => 'simicategory_filename',
47
+ ));
48
+
49
+ $fieldset->addField('simicategory_filename_tablet', 'image', array(
50
+ 'label' => Mage::helper('simiconnector')->__('Tablet Image'),
51
+ 'required' => true,
52
+ 'name' => 'simicategory_filename_tablet',
53
+ ));
54
+
55
+ $fieldset->addField('category_id', 'text', array(
56
+ 'name' => 'category_id',
57
+ 'class' => 'required-entry',
58
+ 'required' => true,
59
+ 'label' => Mage::helper('simiconnector')->__('Category ID'),
60
+ 'note' => Mage::helper('simiconnector')->__('Choose a category'),
61
+ 'after_element_html' => '<a id="category_link" href="javascript:void(0)" onclick="toggleMainCategories()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Category"></a>
62
+ <div id="main_categories_select" style="display:none"></div>
63
+ <script type="text/javascript">
64
+ function toggleMainCategories(check){
65
+ var cate = $("main_categories_select");
66
+ if($("main_categories_select").style.display == "none" || (check ==1) || (check == 2)){
67
+ var url = "' . $this->getUrl('adminhtml/simiconnector_banner/chooserMainCategories') . '";
68
+ if(check == 1){
69
+ $("category_id").value = $("category_all_ids").value;
70
+ }else if(check == 2){
71
+ $("category_id").value = "";
72
+ }
73
+ var params = $("category_id").value.split(", ");
74
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
75
+ var request = new Ajax.Request(url,
76
+ {
77
+ evalScripts: true,
78
+ parameters: parameters,
79
+ onComplete:function(transport){
80
+ $("main_categories_select").update(transport.responseText);
81
+ $("main_categories_select").style.display = "block";
82
+ }
83
+ });
84
+ if(cate.style.display == "none"){
85
+ cate.style.display = "";
86
+ }else{
87
+ cate.style.display = "none";
88
+ }
89
+ }else{
90
+ cate.style.display = "none";
91
+ }
92
+ };
93
+ </script>
94
+ '
95
+ ));
96
+
97
+ if (!isset($data['sort_order']))
98
+ $data['sort_order'] = 1;
99
+ $fieldset->addField('sort_order', 'text', array(
100
+ 'label' => Mage::helper('simiconnector')->__('Sort Order'),
101
+ 'required' => false,
102
+ 'class' => 'validate-not-negative-number',
103
+ 'name' => 'sort_order',
104
+ ));
105
+
106
+ $fieldset->addField('status', 'select', array(
107
+ 'label' => Mage::helper('simiconnector')->__('Status'),
108
+ 'name' => 'status',
109
+ 'values' => Mage::getSingleton('simiconnector/status')->getOptionHash(),
110
+ ));
111
+
112
+ if(Mage::helper('simiconnector/cloud')->getThemeLayout() == 'matrix'){
113
+ $matrixfieldset = $form->addFieldset('simicategory_matrix', array('legend' => Mage::helper('simiconnector')->__('Matrix Layout Config')));
114
+
115
+ if (!$data['matrix_width_percent'])
116
+ $data['matrix_width_percent'] = 100;
117
+ if (!$data['matrix_height_percent'])
118
+ $data['matrix_height_percent'] = 30;
119
+ if (!$data['matrix_width_percent_tablet'])
120
+ $data['matrix_width_percent_tablet'] = 100;
121
+ if (!$data['matrix_height_percent_tablet'])
122
+ $data['matrix_height_percent_tablet'] = 30;
123
+ if (!$data['matrix_row'])
124
+ $data['matrix_row'] = 1;
125
+
126
+ $matrixfieldset->addField('matrix_width_percent', 'text', array(
127
+ 'label' => Mage::helper('simiconnector')->__('Image Width/Screen Width Ratio'),
128
+ 'required' => false,
129
+ 'class' => 'required-entry validate-number',
130
+ 'name' => 'matrix_width_percent',
131
+ 'note' => Mage::helper('simiconnector')->__('With Screen Width is 100%'),
132
+ ));
133
+
134
+ $matrixfieldset->addField('matrix_height_percent', 'text', array(
135
+ 'label' => Mage::helper('simiconnector')->__('Image Height/Screen Width Ratio'),
136
+ 'required' => false,
137
+ 'name' => 'matrix_height_percent',
138
+ 'class' => 'required-entry validate-number',
139
+ 'note' => Mage::helper('simiconnector')->__('With Screen Width is 100%'),
140
+ ));
141
+
142
+ $matrixfieldset->addField('matrix_width_percent_tablet', 'text', array(
143
+ 'label' => Mage::helper('simiconnector')->__('Tablet Image Width/Screen Width Ratio'),
144
+ 'required' => false,
145
+ 'name' => 'matrix_width_percent_tablet',
146
+ 'class' => 'required-entry validate-number',
147
+ 'note' => Mage::helper('simiconnector')->__('Leave it empty if you want to use Phone Value'),
148
+ ));
149
+
150
+ $matrixfieldset->addField('matrix_height_percent_tablet', 'text', array(
151
+ 'label' => Mage::helper('simiconnector')->__('Tablet Image Height/Screen Width Ratio'),
152
+ 'required' => false,
153
+ 'name' => 'matrix_height_percent_tablet',
154
+ 'class' => 'required-entry validate-number',
155
+ 'note' => Mage::helper('simiconnector')->__('Leave it empty if you want to use Phone Value'),
156
+ ));
157
+
158
+ $matrixfieldset->addField('matrix_row', 'select', array(
159
+ 'label' => Mage::helper('simiconnector')->__('Row Number'),
160
+ 'values' => Mage::helper('simiconnector/productlist')->getMatrixRowOptions(),
161
+ 'onchange' => 'autoFillHeight(this.value)',
162
+ 'name' => 'matrix_row',
163
+ ));
164
+
165
+
166
+ foreach (Mage::getModel('core/store')->getCollection() as $storeView) {
167
+ if (!$data['storeview_scope'])
168
+ $data['storeview_scope'] = $storeView->getId();
169
+ $storeviewArray[$storeView->getId()] = $storeView->getName();
170
+ }
171
+
172
+ $matrixfieldset->addField('storeview_scope', 'select', array(
173
+ 'label' => Mage::helper('simiconnector')->__('Storeview for Mockup Preview'),
174
+ 'name' => 'storeview_scope',
175
+ 'values' => $storeviewArray,
176
+ 'onchange' => 'updateMockupPreview(this.value)',
177
+ 'after_element_html' => '<div id="mockuppreview"></div> <script>
178
+ ' . Mage::helper('simiconnector/productlist')->autoFillMatrixRowHeight() . '
179
+ function updateMockupPreview(storeview){
180
+ var urlsend = "' . Mage::helper("adminhtml")->getUrl("*/simiconnector_productlist/getMockup") . '?storeview_id=" + storeview;
181
+ xhttp = new XMLHttpRequest();
182
+ xhttp.onreadystatechange = function() {
183
+ if (xhttp.readyState == 4 && xhttp.status == 200) {
184
+ document.getElementById("mockuppreview").innerHTML = xhttp.responseText;
185
+ }
186
+ };
187
+ xhttp.open("GET", urlsend, true);
188
+ xhttp.send();
189
+ }
190
+ Event.observe(window, "load", function(){updateMockupPreview(\'' . $data['storeview_scope'] . '\');});</script>',
191
+ ));
192
+
193
+ }
194
+ $form->setValues($data);
195
+ return parent::_prepareForm();
196
+ }
197
+
198
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simicategory_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('simicategory_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('simiconnector')->__('Category Information'));
10
+ }
11
+
12
+ protected function _beforeToHtml() {
13
+ $this->addTab('form_section', array(
14
+ 'label' => Mage::helper('simiconnector')->__('Category Information'),
15
+ 'title' => Mage::helper('simiconnector')->__('Category Information'),
16
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_simicategory_edit_tab_form')->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simicategory/Grid.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simicategory_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('simicategoryGrid');
8
+ $this->setDefaultSort('simicategory_id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection() {
14
+ $collection = Mage::getModel('simiconnector/simicategory')->getCollection();
15
+ $this->setCollection($collection);
16
+ return parent::_prepareCollection();
17
+ }
18
+
19
+ protected function _prepareColumns() {
20
+ $this->addColumn('simicategory_id', array(
21
+ 'header' => Mage::helper('simiconnector')->__('ID'),
22
+ 'align' => 'right',
23
+ 'width' => '50px',
24
+ 'index' => 'simicategory_id',
25
+ ));
26
+
27
+ $this->addColumn('simicategory_name', array(
28
+ 'header' => Mage::helper('simiconnector')->__('Category Name'),
29
+ 'align' => 'left',
30
+ 'index' => 'simicategory_name',
31
+ ));
32
+
33
+ $this->addColumn('sort_order', array(
34
+ 'header' => Mage::helper('simiconnector')->__('Sort Order'),
35
+ 'align' => 'left',
36
+ 'width' => '50px',
37
+ 'index' => 'sort_order',
38
+ 'filter' => false
39
+ ));
40
+
41
+ $this->addColumn('status', array(
42
+ 'header' => Mage::helper('simiconnector')->__('Status'),
43
+ 'align' => 'left',
44
+ 'width' => '80px',
45
+ 'index' => 'status',
46
+ 'type' => 'options',
47
+ 'options' => array(
48
+ 1 => 'Enabled',
49
+ 2 => 'Disabled',
50
+ ),
51
+ ));
52
+
53
+ $this->addColumn('action', array(
54
+ 'header' => Mage::helper('simiconnector')->__('Action'),
55
+ 'width' => '100',
56
+ 'type' => 'action',
57
+ 'getter' => 'getId',
58
+ 'actions' => array(
59
+ array(
60
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
61
+ 'url' => array('base' => '*/*/edit'),
62
+ 'field' => 'id'
63
+ )),
64
+ 'filter' => false,
65
+ 'sortable' => false,
66
+ 'index' => 'stores',
67
+ 'is_system' => true,
68
+ ));
69
+
70
+ $this->addExportType('*/*/exportCsv', Mage::helper('simiconnector')->__('CSV'));
71
+ $this->addExportType('*/*/exportXml', Mage::helper('simiconnector')->__('XML'));
72
+
73
+ return parent::_prepareColumns();
74
+ }
75
+
76
+ protected function _prepareMassaction() {
77
+ $this->setMassactionIdField('simicategory_id');
78
+ $this->getMassactionBlock()->setFormFieldName('simicategory');
79
+
80
+ $this->getMassactionBlock()->addItem('delete', array(
81
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
82
+ 'url' => $this->getUrl('*/*/massDelete'),
83
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
84
+ ));
85
+
86
+ $statuses = Mage::getSingleton('simiconnector/status')->getOptionArray();
87
+
88
+ array_unshift($statuses, array('label' => '', 'value' => ''));
89
+ $this->getMassactionBlock()->addItem('status', array(
90
+ 'label' => Mage::helper('simiconnector')->__('Change status'),
91
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
92
+ 'additional' => array(
93
+ 'visibility' => array(
94
+ 'name' => 'status',
95
+ 'type' => 'select',
96
+ 'class' => 'required-entry',
97
+ 'label' => Mage::helper('simiconnector')->__('Status'),
98
+ 'values' => $statuses
99
+ ))
100
+ ));
101
+ return $this;
102
+ }
103
+
104
+ public function getRowUrl($row) {
105
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
106
+ }
107
+
108
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification extends Mage_Adminhtml_Block_Widget_Grid_Container
6
+ {
7
+ public function __construct(){
8
+ $this->_controller = 'adminhtml_siminotification';
9
+ $this->_blockGroup = 'simiconnector';
10
+ $this->_headerText = Mage::helper('simiconnector')->__('Notification Manager');
11
+ $this->_addButtonLabel = Mage::helper('simiconnector')->__('Add Notification');
12
+ parent::__construct();
13
+ }
14
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
8
+
9
+ public function __construct() {
10
+ parent::__construct();
11
+
12
+ $this->_objectId = 'id';
13
+ $this->_blockGroup = 'simiconnector';
14
+ $this->_controller = 'adminhtml_siminotification';
15
+
16
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Send'));
17
+ $this->_addButton('saveandcontinue', array(
18
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
19
+ 'onclick' => 'saveAndContinueEdit()',
20
+ 'class' => 'save',
21
+ ), -100);
22
+
23
+ $this->_formScripts[] = "
24
+ function toggleEditor() {
25
+ if (tinyMCE.getInstanceById('siminotification_content') == null)
26
+ tinyMCE.execCommand('mceAddControl', false, 'siminotification_content');
27
+ else
28
+ tinyMCE.execCommand('mceRemoveControl', false, 'siminotification_content');
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+
35
+ function onchangeNoticeType(type){
36
+ switch (type) {
37
+ case '1':
38
+ $('product_id').up('tr').show();
39
+ $('product_id').className = 'required-entry input-text';
40
+ $('category_id').up('tr').hide();
41
+ $('category_id').className = 'input-text';
42
+ $('notice_url').up('tr').hide();
43
+ $('notice_url').className = 'input-text';
44
+ break;
45
+ case '2':
46
+ $('category_id').up('tr').show();
47
+ $('category_id').className = 'required-entry input-text';
48
+ $('product_id').up('tr').hide();
49
+ $('product_id').className = 'input-text';
50
+ $('notice_url').up('tr').hide();
51
+ $('notice_url').className = 'input-text';
52
+ break;
53
+ case '3':
54
+ $('notice_url').up('tr').show();
55
+ $('notice_url').className = 'required-entry input-text';
56
+ $('product_id').up('tr').hide();
57
+ $('product_id').className = 'input-text';
58
+ $('category_id').up('tr').hide();
59
+ $('category_id').className = 'input-text';
60
+ break;
61
+ default:
62
+ $('product_id').up('tr').show();
63
+ $('product_id').className = 'required-entry input-text';
64
+ $('category_id').up('tr').hide();
65
+ $('category_id').className = 'input-text';
66
+ $('notice_url').up('tr').hide();
67
+ $('notice_url').className = 'input-text';
68
+ }
69
+ }
70
+
71
+ // function previewNoti(){
72
+ // alert('Developing...');
73
+ // }
74
+
75
+ // var autocompleteBilling = new google.maps.places.Autocomplete(document.getElementById('location'), {});
76
+ // if (document.getElementById('country')) {
77
+ // google.maps.event.addListener(autocompleteBilling, 'place_changed', function () {
78
+ // var place = autocompleteBilling.getPlace();
79
+ // for (var i = 0; i < place.address_components.length; i++) {
80
+ // if (place.address_components[i].types[0] == 'country') {
81
+ // document.getElementById('country').value = place.address_components[i]['short_name'];
82
+ // break;
83
+ // }
84
+ // }
85
+
86
+ // });
87
+ // }
88
+ ";
89
+ }
90
+
91
+ /**
92
+ * get text to show in header when edit an notification
93
+ *
94
+ * @return string
95
+ */
96
+ public function getHeaderText() {
97
+ if (Mage::registry('siminotification_data') && Mage::registry('siminotification_data')->getId())
98
+ return Mage::helper('simiconnector')->__("Edit Message '%s'", $this->htmlEscape(Mage::registry('siminotification_data')->getNoticeTitle()));
99
+ return Mage::helper('simiconnector')->__('Add Message');
100
+ }
101
+
102
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Form.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
8
+
9
+ protected function _prepareForm() {
10
+ $form = new Varien_Data_Form(array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/*/save', array(
13
+ 'id' => $this->getRequest()->getParam('id'),
14
+ )),
15
+ 'method' => 'post',
16
+ 'enctype' => 'multipart/form-data'
17
+ ));
18
+
19
+ $form->setUseContainer(true);
20
+ $this->setForm($form);
21
+ return parent::_prepareForm();
22
+ }
23
+
24
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Categories.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tab_Categories extends Mage_Adminhtml_Block_Catalog_Category_Tree {
8
+
9
+ protected $_selectedIds = array();
10
+
11
+ protected function _prepareLayout() {
12
+ $this->setTemplate('simiconnector/siminotification/categories.phtml');
13
+ }
14
+
15
+ public function getCategoryIds() {
16
+ return $this->_selectedIds;
17
+ }
18
+
19
+ public function setCategoryIds($id) {
20
+ if (!$id) {
21
+ $ids = array();
22
+ } elseif ($id) {
23
+ $ids[] = $id;
24
+ }
25
+ $this->_selectedIds = $ids;
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Get JSON of a tree node or an associative array
31
+ *
32
+ * @param Varien_Data_Tree_Node|array $node
33
+ * @param int $level
34
+ * @return string
35
+ */
36
+ protected function _getNodeJson($node, $level = 1) {
37
+ $item = array();
38
+ $item['text'] = $this->htmlEscape($node->getName());
39
+
40
+ if ($this->_withProductCount) {
41
+ $item['text'].= ' (' . $node->getProductCount() . ')';
42
+ }
43
+ $item['id'] = $node->getId();
44
+ $item['path'] = $node->getData('path');
45
+ $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
46
+ $item['allowDrop'] = false;
47
+ $item['allowDrag'] = false;
48
+
49
+ if ($node->hasChildren()) {
50
+ $item['children'] = array();
51
+ foreach ($node->getChildren() as $child) {
52
+ $item['children'][] = $this->_getNodeJson($child, $level + 1);
53
+ }
54
+ }
55
+
56
+ if (empty($item['children']) && (int) $node->getChildrenCount() > 0) {
57
+ $item['children'] = array();
58
+ }
59
+
60
+ if (!empty($item['children'])) {
61
+ $item['expanded'] = true;
62
+ }
63
+
64
+ if (in_array($node->getId(), $this->getCategoryIds())) {
65
+ $item['checked'] = true;
66
+ }
67
+
68
+ return $item;
69
+ }
70
+
71
+ public function getRoot($parentNodeCategory = null, $recursionLevel = 3) {
72
+ return $this->getRootByIds($this->getCategoryIds());
73
+ }
74
+
75
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Devices.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tab_Devices extends Mage_Adminhtml_Block_Widget_Grid {
5
+
6
+ public $storeview_id;
7
+
8
+ public function __construct($arguments = array()) {
9
+ parent::__construct($arguments);
10
+ if ($this->getRequest()->getParam('current_grid_id')) {
11
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
12
+ } else {
13
+ $this->setId('skuChooserGrid_' . $this->getId());
14
+ }
15
+ $form = $this->getJsFormObject();
16
+ $gridId = $this->getId();
17
+ $this->setCheckboxCheckCallback("constructDataDevice($gridId)");
18
+ $this->setDefaultSort('device_id');
19
+ $this->setDefaultDir('ASC');
20
+ $this->setUseAjax(true);
21
+ if ($this->getRequest()->getParam('collapse')) {
22
+ $this->setIsCollapsed(true);
23
+ }
24
+ $this->setTemplate('simiconnector/siminotification/devicegrid.phtml');
25
+ }
26
+
27
+ /**
28
+ * Retrieve quote store object
29
+ * @return Mage_Core_Model_Store
30
+ */
31
+ public function getStore() {
32
+ return Mage::app()->getStore();
33
+ }
34
+
35
+ protected function _addColumnFilterToCollection($column) {
36
+ if ($column->getId() == 'in_devices') {
37
+ $selected = $this->_getSelectedDevices();
38
+ if (empty($selected)) {
39
+ $selected = '';
40
+ }
41
+ if ($column->getFilter()->getValue()) {
42
+ $this->getCollection()->addFieldToFilter('device_id', array('in' => $selected));
43
+ } else {
44
+ $this->getCollection()->addFieldToFilter('device_id', array('nin' => $selected));
45
+ }
46
+ } else {
47
+ parent::_addColumnFilterToCollection($column);
48
+ }
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
54
+ *
55
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
56
+ */
57
+ protected function _prepareCollection() {
58
+ $collection = Mage::getModel('simiconnector/device')->getCollection()->addFieldToFilter('storeview_id',$this->storeview_id);
59
+ $this->setCollection($collection);
60
+
61
+ return parent::_prepareCollection();
62
+ }
63
+
64
+ /**
65
+ * Define Cooser Grid Columns and filters
66
+ *
67
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
68
+ */
69
+ protected function _prepareColumns() {
70
+
71
+ $this->addColumn('in_devices', array(
72
+ 'header_css_class' => 'a-center',
73
+ 'type' => 'checkbox',
74
+ 'name' => 'in_devices',
75
+ 'values' => $this->_getSelectedDevices(),
76
+ 'align' => 'center',
77
+ 'index' => 'in_devices',
78
+ 'use_index' => true,
79
+ 'width' => '50px',
80
+ 'renderer' => 'simiconnector/adminhtml_siminotification_edit_tab_renderer_devices'
81
+ ));
82
+
83
+ $this->addColumn('device_id', array(
84
+ 'header' => Mage::helper('simiconnector')->__('ID'),
85
+ 'align' => 'right',
86
+ 'width' => '50px',
87
+ 'index' => 'device_id',
88
+ ));
89
+
90
+ $this->addColumn('user_email', array(
91
+ 'header' => Mage::helper('simiconnector')->__('Customer Email'),
92
+ 'width' => '150px',
93
+ 'index' => 'user_email'
94
+ ));
95
+ $this->addColumn('plaform_id', array(
96
+ 'header' => Mage::helper('simiconnector')->__('Device Type'),
97
+ 'align' => 'left',
98
+ 'width' => '100px',
99
+ 'index' => 'plaform_id',
100
+ 'type' => 'options',
101
+ 'options' => array(
102
+ 3 => Mage::helper('simiconnector')->__('Android'),
103
+ 1 => Mage::helper('simiconnector')->__('iPhone'),
104
+ 2 => Mage::helper('simiconnector')->__('iPad'),
105
+ ),
106
+ ));
107
+
108
+ $this->addColumn('city', array(
109
+ 'header' => Mage::helper('simiconnector')->__('City'),
110
+ 'width' => '150px',
111
+ 'index' => 'city',
112
+ ));
113
+
114
+ $this->addColumn('state', array(
115
+ 'header' => Mage::helper('simiconnector')->__('State/Province'),
116
+ 'width' => '150px',
117
+ 'index' => 'state',
118
+ ));
119
+
120
+ $this->addColumn('country', array(
121
+ 'header' => Mage::helper('simiconnector')->__('Country'),
122
+ 'width' => '150px',
123
+ 'index' => 'country',
124
+ 'type' => 'options',
125
+ 'options' => Mage::helper('simiconnector/siminotification')->getListCountry(),
126
+ ));
127
+
128
+
129
+ $this->addColumn('is_demo', array(
130
+ 'header' => Mage::helper('simiconnector')->__('Is Demo'),
131
+ 'width' => '50px',
132
+ 'align' => 'right',
133
+ 'index' => 'is_demo',
134
+ 'type' => 'options',
135
+ 'options' => array(
136
+ 3 => Mage::helper('simiconnector')->__('N/A'),
137
+ 0 => Mage::helper('simiconnector')->__('NO'),
138
+ 1 => Mage::helper('simiconnector')->__('YES'),
139
+ ),
140
+ ));
141
+
142
+ $this->addColumn('created_time', array(
143
+ 'header' => Mage::helper('simiconnector')->__('Created Date'),
144
+ 'width' => '150px',
145
+ 'align' => 'right',
146
+ 'index' => 'created_time',
147
+ 'type' => 'datetime'
148
+ ));
149
+
150
+ $this->addColumn('app_id', array(
151
+ 'header' => Mage::helper('simiconnector')->__('App Id'),
152
+ 'width' => '100px',
153
+ 'align' => 'right',
154
+ 'index' => 'app_id'
155
+ ));
156
+
157
+ $this->addColumn('build_version', array(
158
+ 'header' => Mage::helper('simiconnector')->__('Build Version'),
159
+ 'width' => '50px',
160
+ 'align' => 'right',
161
+ 'index' => 'build_version'
162
+ ));
163
+
164
+ return parent::_prepareColumns();
165
+ }
166
+
167
+ public function getGridUrl() {
168
+ return $this->getUrl('*/*/chooseDevices', array(
169
+ '_current' => true,
170
+ 'current_grid_id' => $this->getId(),
171
+ 'selected_ids' => implode(',', $this->_getSelectedDevices()),
172
+ 'storeview_id' => $this->storeview_id,
173
+ 'collapse' => null
174
+ ));
175
+ }
176
+
177
+ protected function _getSelectedDevices() {
178
+ $devices = $this->getRequest()->getPost('selected', array());
179
+ if (!$devices) {
180
+ if ($this->getRequest()->getParam('selected_ids')) {
181
+ $devices = explode(',', $this->getRequest()->getParam('selected_ids'));
182
+ }
183
+ }
184
+ return $devices;
185
+ }
186
+
187
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Form.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
7
+
8
+ protected function _prepareForm() {
9
+ $form = new Varien_Data_Form();
10
+ $this->setForm($form);
11
+
12
+ if (Mage::getSingleton('adminhtml/session')->getSiminotificationData()) {
13
+ $data = Mage::getSingleton('adminhtml/session')->getSiminotificationData();
14
+ Mage::getSingleton('adminhtml/session')->setSiminotificationData(null);
15
+ } elseif (Mage::registry('siminotification_data'))
16
+ $data = Mage::registry('siminotification_data')->getData();
17
+
18
+ $fieldset = $form->addFieldset('siminotification_form', array('legend' => Mage::helper('simiconnector')->__('Notification Content')));
19
+ $fieldset->addType('datetime', 'Simi_Simiconnector_Block_Adminhtml_Device_Edit_Renderer_Datetime');
20
+
21
+ $stores = Mage::getModel('core/store')->getCollection();
22
+
23
+ $list_store = array();
24
+ foreach ($stores as $store) {
25
+ $list_store[] = array(
26
+ 'value' => $store->getId(),
27
+ 'label' => Mage::getModel('core/store_group')->load($store->getData('group_id'))->getName() . ' - ' . $store->getName(),
28
+ );
29
+ }
30
+ $fieldset->addField('storeview_id', 'select', array(
31
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
32
+ 'name' => 'storeview_id',
33
+ 'note' => Mage::helper('simiconnector')->__('After changed this setting, you would need to re-select the devices to be sent'),
34
+ 'values' => $list_store,
35
+ 'onchange' => 'clearDevices()'
36
+ ));
37
+
38
+ $fieldset->addField('notice_sanbox', 'select', array(
39
+ 'label' => Mage::helper('simiconnector')->__('Send To'),
40
+ 'name' => 'notice_sanbox',
41
+ 'values' => array(
42
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('Test App')),
43
+ array('value' => 2, 'label' => Mage::helper('simiconnector')->__('Live App')),
44
+ ),
45
+ 'note' => '',
46
+ ));
47
+
48
+ $data['device_type'] = $data['device_id'];
49
+ $fieldset->addField('device_type', 'select', array(
50
+ 'label' => Mage::helper('simiconnector')->__('Device Type'),
51
+ 'name' => 'device_type',
52
+ 'values' => array(
53
+ array('value' => 0, 'label' => Mage::helper('simiconnector')->__('All')),
54
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('IOS')),
55
+ array('value' => 2, 'label' => Mage::helper('simiconnector')->__('Android')),
56
+ ),
57
+ ));
58
+
59
+ $fieldset->addField('show_popup', 'select', array(
60
+ 'label' => Mage::helper('simiconnector')->__('Show Popup'),
61
+ 'name' => 'show_popup',
62
+ 'values' => array(
63
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('Yes')),
64
+ array('value' => 0, 'label' => Mage::helper('simiconnector')->__('No')),
65
+ ),
66
+ 'note' => 'If you choose Yes, there will be a popup shown on mobile screen when notification comes',
67
+ ));
68
+
69
+ $fieldset->addField('notice_title', 'text', array(
70
+ 'label' => Mage::helper('simiconnector')->__('Title'),
71
+ 'class' => 'required-entry',
72
+ 'required' => true,
73
+ 'name' => 'notice_title',
74
+ ));
75
+
76
+ $fieldset->addField('image_url', 'image', array(
77
+ 'label' => Mage::helper('simiconnector')->__('Image'),
78
+ 'name' => 'image_url',
79
+ 'note' => Mage::helper('simiconnector')->__('Size max: 1000 x 1000 (PX)'),
80
+ ));
81
+
82
+ $fieldset->addField('notice_content', 'editor', array(
83
+ 'name' => 'notice_content',
84
+ // 'class' => 'required-entry',
85
+ // 'required' => true,
86
+ 'label' => Mage::helper('simiconnector')->__('Message'),
87
+ 'title' => Mage::helper('simiconnector')->__('Message'),
88
+ 'note' => Mage::helper('simiconnector')->__('Characters recommended: < 250'),
89
+ ));
90
+
91
+ $fieldset->addField('type', 'select', array(
92
+ 'label' => Mage::helper('simiconnector')->__('Direct viewers to'),
93
+ 'class' => 'required-entry',
94
+ 'required' => true,
95
+ 'name' => 'type',
96
+ 'values' => Mage::getModel('simiconnector/siminotification')->toOptionArray(),
97
+ 'onchange' => 'onchangeNoticeType(this.value)',
98
+ 'after_element_html' => '<script> Event.observe(window, "load", function(){onchangeNoticeType(\'' . $data['type'] . '\');});</script>',
99
+ ));
100
+
101
+ $productIds = implode(", ", Mage::getResourceModel('catalog/product_collection')->getAllIds());
102
+ $fieldset->addField('product_id', 'text', array(
103
+ 'name' => 'product_id',
104
+ 'class' => 'required-entry',
105
+ 'required' => true,
106
+ 'label' => Mage::helper('simiconnector')->__('Product ID'),
107
+ 'note' => Mage::helper('simiconnector')->__('Choose a product'),
108
+ 'after_element_html' => '<a id="product_link" href="javascript:void(0)" onclick="toggleMainProducts()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Products"></a><input type="hidden" value="' . $productIds . '" id="product_all_ids"/><div id="main_products_select" style="display:none;width:640px"></div>
109
+ <script type="text/javascript">
110
+ function toggleMainProducts(){
111
+ if($("main_products_select").style.display == "none"){
112
+ var url = "' . $this->getUrl('adminhtml/simiconnector_siminotification/chooserMainProducts') . '";
113
+ var params = $("product_id").value.split(", ");
114
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
115
+ var request = new Ajax.Request(url,
116
+ {
117
+ evalScripts: true,
118
+ parameters: parameters,
119
+ onComplete:function(transport){
120
+ $("main_products_select").update(transport.responseText);
121
+ $("main_products_select").style.display = "block";
122
+ }
123
+ });
124
+ }else{
125
+ $("main_products_select").style.display = "none";
126
+ }
127
+ };
128
+ var grid;
129
+
130
+ function constructData(div){
131
+ grid = window[div.id+"JsObject"];
132
+ if(!grid.reloadParams){
133
+ grid.reloadParams = {};
134
+ grid.reloadParams["selected[]"] = $("product_id").value.split(", ");
135
+ }
136
+ }
137
+ function toogleCheckAllProduct(el){
138
+ if(el.checked == true){
139
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
140
+ if(e.name != "check_all"){
141
+ if(!e.checked){
142
+ if($("product_id").value == "")
143
+ $("product_id").value = e.value;
144
+ else
145
+ $("product_id").value = $("product_id").value + ", "+e.value;
146
+ e.checked = true;
147
+ grid.reloadParams["selected[]"] = $("product_id").value.split(", ");
148
+ }
149
+ }
150
+ });
151
+ }else{
152
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
153
+ if(e.name != "check_all"){
154
+ if(e.checked){
155
+ var vl = e.value;
156
+ if($("product_id").value.search(vl) == 0){
157
+ if($("product_id").value == vl) $("product_id").value = "";
158
+ $("product_id").value = $("product_id").value.replace(vl+", ","");
159
+ }else{
160
+ $("product_id").value = $("product_id").value.replace(", "+ vl,"");
161
+ }
162
+ e.checked = false;
163
+ grid.reloadParams["selected[]"] = $("product_id").value.split(", ");
164
+ }
165
+ }
166
+ });
167
+
168
+ }
169
+ }
170
+ function selectProduct(e) {
171
+ if(e.checked == true){
172
+ if(e.id == "main_on"){
173
+ $("product_id").value = $("product_all_ids").value;
174
+ }else{
175
+ if($("product_id").value == "")
176
+ $("product_id").value = e.value;
177
+ else
178
+ $("product_id").value = e.value;
179
+ grid.reloadParams["selected[]"] = $("product_id").value;
180
+ }
181
+ }else{
182
+ if(e.id == "main_on"){
183
+ $("product_id").value = "";
184
+ }else{
185
+ var vl = e.value;
186
+ if($("product_id").value.search(vl) == 0){
187
+ $("product_id").value = $("product_id").value.replace(vl+", ","");
188
+ }else{
189
+ $("product_id").value = $("product_id").value.replace(", "+ vl,"");
190
+ }
191
+ }
192
+ }
193
+
194
+ }
195
+ </script>'
196
+ ));
197
+
198
+ $fieldset->addField('category_id', 'text', array(
199
+ 'name' => 'category_id',
200
+ 'class' => 'required-entry',
201
+ 'required' => true,
202
+ 'label' => Mage::helper('simiconnector')->__('Category ID'),
203
+ 'note' => Mage::helper('simiconnector')->__('Choose a category'),
204
+ 'after_element_html' => '<a id="category_link" href="javascript:void(0)" onclick="toggleMainCategories()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Category"></a>
205
+ <div id="main_categories_select" style="display:none"></div>
206
+ <script type="text/javascript">
207
+ function toggleMainCategories(check){
208
+ var cate = $("main_categories_select");
209
+ if($("main_categories_select").style.display == "none" || (check ==1) || (check == 2)){
210
+ var url = "' . $this->getUrl('adminhtml/simiconnector_siminotification/chooserMainCategories') . '";
211
+ if(check == 1){
212
+ $("category_id").value = $("category_all_ids").value;
213
+ }else if(check == 2){
214
+ $("category_id").value = "";
215
+ }
216
+ var params = $("category_id").value.split(", ");
217
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
218
+ var request = new Ajax.Request(url,
219
+ {
220
+ evalScripts: true,
221
+ parameters: parameters,
222
+ onComplete:function(transport){
223
+ $("main_categories_select").update(transport.responseText);
224
+ $("main_categories_select").style.display = "block";
225
+ }
226
+ });
227
+ if(cate.style.display == "none"){
228
+ cate.style.display = "";
229
+ }else{
230
+ cate.style.display = "none";
231
+ }
232
+ }else{
233
+ cate.style.display = "none";
234
+ }
235
+ };
236
+ </script>
237
+ '
238
+ ));
239
+
240
+ $fieldset->addField('notice_url', 'text', array(
241
+ 'name' => 'notice_url',
242
+ 'class' => 'required-entry',
243
+ 'required' => true,
244
+ 'label' => Mage::helper('simiconnector')->__('URL'),
245
+ ));
246
+
247
+ $fieldset->addField('created_time', 'datetime', array(
248
+ 'label' => Mage::helper('simiconnector')->__('Created Date'),
249
+ 'bold' => true,
250
+ 'name' => 'created_date',
251
+ ));
252
+
253
+ $fieldsetFilter = $form->addFieldset('filter_form', array(
254
+ 'legend' => Mage::helper('simiconnector')->__('Notification Devices Select')
255
+ ));
256
+ $deviceIds = Mage::getModel('simiconnector/device')->getCollection()->getAllIds();
257
+
258
+ $fieldsetFilter->addField('devices_pushed', 'textarea', array(
259
+ 'name' => 'devices_pushed',
260
+ 'class' => 'required-entry',
261
+ 'required' => true,
262
+ 'label' => Mage::helper('simiconnector')->__('Device IDs'),
263
+ 'note' => Mage::helper('simiconnector')->__('Select your Devices'),
264
+ 'after_element_html' => '
265
+ <a id="product_link" href="javascript:void(0)" onclick="toggleMainDevices()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Device"></a>
266
+ <input type="hidden" value="' . $deviceIds . '" id="device_all_ids"/>
267
+ <div id="main_devices_select" style="display:none"></div>
268
+ <script type="text/javascript">
269
+ function clearDevices(){
270
+ $("main_devices_select").style.display == "none";
271
+ toggleMainDevices(2);
272
+ }
273
+ function updateNumberSeleced(){
274
+ $("note_devices_pushed_number").update($("devices_pushed").value.split(", ").size());
275
+ }
276
+ function toggleMainDevices(check){
277
+ var cate = $("main_devices_select");
278
+ if($("main_devices_select").style.display == "none" || (check ==1) || (check == 2)){
279
+ var url = "' . $this->getUrl('adminhtml/simiconnector_siminotification/chooseDevices') . '?storeview_id="+$("storeview_id").value;
280
+ if(check == 1){
281
+ $("devices_pushed").value = $("devices_all_ids").value;
282
+ }else if(check == 2){
283
+ $("devices_pushed").value = "";
284
+ }
285
+ var params = $("devices_pushed").value.split(", ");
286
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
287
+ var request = new Ajax.Request(url,
288
+ {
289
+ evalScripts: true,
290
+ parameters: parameters,
291
+ onComplete:function(transport){
292
+ $("main_devices_select").update(transport.responseText);
293
+ $("main_devices_select").style.display = "block";
294
+ }
295
+ });
296
+ if(cate.style.display == "none"){
297
+ cate.style.display = "";
298
+ }else{
299
+ cate.style.display = "none";
300
+ }
301
+ }else{
302
+ cate.style.display = "none";
303
+ }
304
+ updateNumberSeleced();
305
+ };
306
+
307
+ var griddevice;
308
+
309
+ function constructDataDevice(div){
310
+ griddevice = window[div.id+"JsObject"];
311
+ if(!griddevice.reloadParams){
312
+ griddevice.reloadParams = {};
313
+ griddevice.reloadParams["selected[]"] = $("devices_pushed").value.split(", ");
314
+ }
315
+ }
316
+ function toogleCheckAllDevices(el){
317
+ if(el == true){
318
+ $$("#main_devices_select input[type=checkbox][class=checkbox]").each(function(e){
319
+ if(e.name != "check_all"){
320
+ if(!e.checked){
321
+ if($("devices_pushed").value == "")
322
+ $("devices_pushed").value = e.value;
323
+ else
324
+ $("devices_pushed").value = $("devices_pushed").value + ", "+e.value;
325
+ e.checked = true;
326
+ griddevice.reloadParams["selected[]"] = $("devices_pushed").value.split(", ");
327
+ }
328
+ }
329
+ });
330
+ }else{
331
+ $$("#main_devices_select input[type=checkbox][class=checkbox]").each(function(e){
332
+ if(e.name != "check_all"){
333
+ if(e.checked){
334
+ var vl = e.value;
335
+ if($("devices_pushed").value.search(vl) == 0){
336
+ if($("devices_pushed").value == vl) $("devices_pushed").value = "";
337
+ $("devices_pushed").value = $("devices_pushed").value.replace(vl+", ","");
338
+ }else{
339
+ $("devices_pushed").value = $("devices_pushed").value.replace(", "+ vl,"");
340
+ }
341
+ e.checked = false;
342
+ griddevice.reloadParams["selected[]"] = $("devices_pushed").value.split(", ");
343
+ }
344
+ }
345
+ });
346
+ }
347
+ updateNumberSeleced();
348
+ }
349
+ function selectDevice(e) {
350
+ if(e.checked == true){
351
+ if(e.id == "main_on"){
352
+ $("devices_pushed").value = $("device_all_ids").value;
353
+ }else{
354
+ if($("devices_pushed").value == "")
355
+ $("devices_pushed").value = e.value;
356
+ else
357
+ $("devices_pushed").value = $("devices_pushed").value + ", "+e.value;
358
+ e.checked == false;
359
+ griddevice.reloadParams["selected[]"] = $("devices_pushed").value.split(", ");
360
+ }
361
+ }else{
362
+ if(e.id == "main_on"){
363
+ $("devices_pushed").value = "";
364
+ }else{
365
+ var vl = e.value;
366
+ if($("devices_pushed").value.search(vl) == 0){
367
+ if ($("devices_pushed").value.search(",") == -1)
368
+ $("devices_pushed").value = "";
369
+ else
370
+ $("devices_pushed").value = $("devices_pushed").value.replace(vl+", ","");
371
+ }else{
372
+ $("devices_pushed").value = $("devices_pushed").value.replace(", "+ vl,"");
373
+ }
374
+ e.checked == false;
375
+ griddevice.reloadParams["selected[]"] = $("devices_pushed").value.split(", ");
376
+ }
377
+ }
378
+ updateNumberSeleced();
379
+ }
380
+ </script>
381
+ '
382
+ ));
383
+
384
+ $form->setValues($data);
385
+ return parent::_prepareForm();
386
+ }
387
+
388
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Products.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
5
+
6
+ public function __construct($arguments = array()) {
7
+ parent::__construct($arguments);
8
+ if ($this->getRequest()->getParam('current_grid_id')) {
9
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
10
+ } else {
11
+ $this->setId('skuChooserGrid_' . $this->getId());
12
+ }
13
+
14
+ $form = $this->getJsFormObject();
15
+ $gridId = $this->getId();
16
+ $this->setCheckboxCheckCallback("constructData($gridId)");
17
+ $this->setDefaultSort('sku');
18
+ $this->setUseAjax(true);
19
+ if ($this->getRequest()->getParam('collapse')) {
20
+ $this->setIsCollapsed(true);
21
+ }
22
+ $this->setTemplate('simiconnector/siminotification/grid.phtml');
23
+ }
24
+
25
+ /**
26
+ * Retrieve quote store object
27
+ * @return Mage_Core_Model_Store
28
+ */
29
+ public function getStore() {
30
+ return Mage::app()->getStore();
31
+ }
32
+
33
+ protected function _addColumnFilterToCollection($column) {
34
+ if ($column->getId() == 'in_products') {
35
+ $selected = $this->_getSelectedProducts();
36
+ if (empty($selected)) {
37
+ $selected = '';
38
+ }
39
+ if ($column->getFilter()->getValue()) {
40
+ $this->getCollection()->addFieldToFilter('sku', array('in' => $selected));
41
+ } else {
42
+ $this->getCollection()->addFieldToFilter('sku', array('nin' => $selected));
43
+ }
44
+ } else {
45
+ parent::_addColumnFilterToCollection($column);
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
52
+ *
53
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
54
+ */
55
+ protected function _prepareCollection() {
56
+ $collection = Mage::getResourceModel('catalog/product_collection')
57
+ ->setStoreId(0)
58
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id')
59
+ ->addFieldToFilter('visibility', array('neq' => '1'))
60
+ ->addFieldToFilter('status', '1')
61
+ ;
62
+
63
+ $this->setCollection($collection);
64
+
65
+ return parent::_prepareCollection();
66
+ }
67
+
68
+ /**
69
+ * Define Cooser Grid Columns and filters
70
+ *
71
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
72
+ */
73
+ protected function _prepareColumns() {
74
+ $this->addColumn('in_products', array(
75
+ 'header_css_class' => 'a-center',
76
+ 'type' => 'checkbox',
77
+ 'name' => 'in_products',
78
+ 'values' => $this->_getSelectedProducts(),
79
+ 'align' => 'center',
80
+ 'index' => 'sku',
81
+ 'use_index' => true,
82
+ 'width' => '50px',
83
+ 'renderer' => 'simiconnector/adminhtml_siminotification_edit_tab_renderer_sku'
84
+ ));
85
+
86
+ $this->addColumn('entity_id', array(
87
+ 'header' => Mage::helper('sales')->__('ID'),
88
+ 'sortable' => true,
89
+ 'width' => '60px',
90
+ 'index' => 'entity_id'
91
+ ));
92
+
93
+ $this->addColumn('chooser_name', array(
94
+ 'header' => Mage::helper('sales')->__('Product Name'),
95
+ 'name' => 'chooser_name',
96
+ 'index' => 'name',
97
+ 'width' => '400px'
98
+ ));
99
+
100
+ $this->addColumn('type', array(
101
+ 'header' => Mage::helper('catalog')->__('Type'),
102
+ 'width' => '60px',
103
+ 'index' => 'type_id',
104
+ 'type' => 'options',
105
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
106
+ ));
107
+
108
+ $this->addColumn('chooser_sku', array(
109
+ 'header' => Mage::helper('sales')->__('SKU'),
110
+ 'name' => 'chooser_sku',
111
+ 'width' => '80px',
112
+ 'index' => 'sku',
113
+ ));
114
+
115
+
116
+ return parent::_prepareColumns();
117
+ }
118
+
119
+ public function getGridUrl() {
120
+ return $this->getUrl('*/*/chooserMainProducts', array(
121
+ '_current' => true,
122
+ 'current_grid_id' => $this->getId(),
123
+ 'collapse' => null
124
+ ));
125
+ }
126
+
127
+ protected function _getSelectedProducts() {
128
+ $products = $this->getRequest()->getPost('selected', array());
129
+ return $products;
130
+ }
131
+
132
+
133
+ }
134
+
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Renderer/Devices.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tab_Renderer_Devices extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $checked = '';
7
+ if (in_array($row->getId(), $this->_getSelectedDevices()))
8
+ $checked = 'checked';
9
+ $html = '<input type="checkbox" ' . $checked . ' name="selected" value="' . $row->getId() . '" class="checkbox" onclick="selectDevice(this)">';
10
+ return sprintf('%s', $html);
11
+ }
12
+
13
+ protected function _getSelectedDevices() {
14
+ $devices = $this->getRequest()->getPost('selected', array());
15
+ if (!$devices) {
16
+ if ($this->getRequest()->getParam('selected_ids')) {
17
+ $devices = explode(',', $this->getRequest()->getParam('selected_ids'));
18
+ }
19
+ }
20
+ return $devices;
21
+ }
22
+
23
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tab/Renderer/Sku.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tab_Renderer_Sku extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
7
+
8
+ public function render(Varien_Object $row) {
9
+ $checked = '';
10
+ if (in_array($row->getId(), $this->_getSelectedProducts()))
11
+ $checked = 'checked';
12
+ $html = '<input type="radio" ' . $checked . ' name="selected" value="' . $row->getId() . '" class="checkbox" onclick="selectProduct(this)">';
13
+ return sprintf('%s', $html);
14
+ }
15
+
16
+ protected function _getSelectedProducts() {
17
+ $products = $this->getRequest()->getPost('selected', array());
18
+ return $products;
19
+ }
20
+
21
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('siminotification_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('simiconnector')->__('Notification Information'));
10
+ }
11
+
12
+ protected function _beforeToHtml() {
13
+ $this->addTab('form_section', array(
14
+ 'label' => Mage::helper('simiconnector')->__('Notification Information'),
15
+ 'title' => Mage::helper('simiconnector')->__('Notification Information'),
16
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_siminotification_edit_tab_form')->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Siminotification/Grid.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ class Simi_Simiconnector_Block_Adminhtml_Siminotification_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+ public function __construct() {
8
+ parent::__construct();
9
+ $this->setId('noticeGrid');
10
+ $this->setDefaultSort('notice_id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ /**
16
+ * prepare collection for block to display
17
+ *
18
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
19
+ */
20
+ protected function _prepareCollection() {
21
+ $collection = Mage::getModel('simiconnector/siminotification')->getCollection();
22
+ $this->setCollection($collection);
23
+ return parent::_prepareCollection();
24
+ }
25
+
26
+ /**
27
+ * prepare columns for this grid
28
+ *
29
+ * @return Simi_Connector_Block_Adminhtml_Banner_Grid
30
+ */
31
+ protected function _prepareColumns() {
32
+ $this->addColumn('notice_id', array(
33
+ 'header' => Mage::helper('simiconnector')->__('ID'),
34
+ 'align' => 'right',
35
+ 'width' => '50px',
36
+ 'index' => 'notice_id',
37
+ ));
38
+
39
+ $this->addColumn('notice_title', array(
40
+ 'header' => Mage::helper('simiconnector')->__('Title'),
41
+ 'align' => 'left',
42
+ 'width' => '150px',
43
+ 'index' => 'notice_title',
44
+ ));
45
+
46
+ $this->addColumn('notice_content', array(
47
+ 'header' => Mage::helper('simiconnector')->__('Message'),
48
+ 'align' => 'left',
49
+ 'index' => 'notice_content',
50
+ ));
51
+
52
+ $storeOptions = array();
53
+ foreach (Mage::getModel('core/store')->getCollection() as $store) {
54
+ $storeOptions [$store->getId()] = $store->getName();
55
+ }
56
+ $this->addColumn('storeview_id', array(
57
+ 'header' => Mage::helper('simiconnector')->__('Store View'),
58
+ 'align' => 'left',
59
+ 'width' => '80px',
60
+ 'index' => 'storeview_id',
61
+ 'type' => 'options',
62
+ 'options' => $storeOptions,
63
+ ));
64
+
65
+
66
+ $this->addColumn('device_id', array(
67
+ 'header' => Mage::helper('simiconnector')->__('Device'),
68
+ 'align' => 'left',
69
+ 'width' => '80px',
70
+ 'index' => 'device_id',
71
+ 'type' => 'options',
72
+ 'options' => array(
73
+ 0 => Mage::helper('simiconnector')->__('All'),
74
+ 1 => Mage::helper('simiconnector')->__('IOS'),
75
+ 2 => Mage::helper('simiconnector')->__('Android'),
76
+ ),
77
+ ));
78
+
79
+ $this->addColumn('created_time', array(
80
+ 'header' => Mage::helper('simiconnector')->__('Created Date'),
81
+ 'width' => '150px',
82
+ 'index' => 'created_time',
83
+ 'type' => 'datetime',
84
+ ));
85
+
86
+
87
+ $this->addColumn('action', array(
88
+ 'header' => Mage::helper('simiconnector')->__('Action'),
89
+ 'width' => '60px',
90
+ 'type' => 'action',
91
+ 'getter' => 'getId',
92
+ 'align' => 'left',
93
+ 'actions' => array(
94
+ array(
95
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
96
+ 'url' => array('base' => '*/*/edit'),
97
+ 'field' => 'id'
98
+ )),
99
+ 'filter' => false,
100
+ 'sortable' => false,
101
+ 'index' => 'stores',
102
+ 'is_system' => true,
103
+ ));
104
+
105
+
106
+ return parent::_prepareColumns();
107
+ }
108
+
109
+ /**
110
+ * prepare mass action for this grid
111
+ *
112
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Grid
113
+ */
114
+ protected function _prepareMassaction() {
115
+ $this->setMassactionIdField('notice_id');
116
+ $this->getMassactionBlock()->setFormFieldName('simiconnector');
117
+
118
+ $this->getMassactionBlock()->addItem('delete', array(
119
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
120
+ 'url' => $this->getUrl('*/*/massDelete'),
121
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
122
+ ));
123
+
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * get url for each row in grid
129
+ *
130
+ * @return string
131
+ */
132
+ public function getRowUrl($row) {
133
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
134
+ }
135
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_controller = 'adminhtml_simiproductlabel';
8
+ $this->_blockGroup = 'simiconnector';
9
+ $this->_headerText = Mage::helper('simiconnector')->__('Product Label');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->_objectId = 'id';
8
+ $this->_blockGroup = 'simiconnector';
9
+ $this->_controller = 'adminhtml_simiproductlabel';
10
+
11
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Save Label'));
12
+ $this->_updateButton('delete', 'label', Mage::helper('simiconnector')->__('Delete Label'));
13
+
14
+ $this->_addButton('saveandcontinue', array(
15
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
16
+ 'onclick' => 'saveAndContinueEdit()',
17
+ 'class' => 'save',
18
+ ), -100);
19
+
20
+ $this->_formScripts[] = "
21
+ function toggleEditor() {
22
+ if (tinyMCE.getInstanceById('madapter_content') == null)
23
+ tinyMCE.execCommand('mceAddControl', false, 'madapter_content');
24
+ else
25
+ tinyMCE.execCommand('mceRemoveControl', false, 'madapter_content');
26
+ }
27
+
28
+ function saveAndContinueEdit(){
29
+ editForm.submit($('edit_form').action+'back/edit/');
30
+ }
31
+ ";
32
+ }
33
+
34
+ /**
35
+ * get text to show in header when edit an item
36
+ *
37
+ * @return string
38
+ */
39
+ public function getHeaderText() {
40
+ if (Mage::registry('simiproductlabel_data') && Mage::registry('simiproductlabel_data')->getId())
41
+ return Mage::helper('simiconnector')->__("Edit Label '%s'", $this->htmlEscape(Mage::registry('simiproductlabel_data')->getData('name')));
42
+ return Mage::helper('simiconnector')->__('Add Label');
43
+ }
44
+
45
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array(
9
+ 'label_id' => $this->getRequest()->getParam('label_id'),
10
+ )),
11
+ 'method' => 'post',
12
+ 'enctype' => 'multipart/form-data'
13
+ ));
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+
20
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tab/Form.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ if (Mage::getSingleton('adminhtml/session')->getConnectorData()) {
9
+ $data = Mage::getSingleton('adminhtml/session')->getConnectorData();
10
+ Mage::getSingleton('adminhtml/session')->setConnectorData(null);
11
+ } elseif (Mage::registry('simiproductlabel_data'))
12
+ $data = Mage::registry('simiproductlabel_data')->getData();
13
+
14
+ $fieldset = $form->addFieldset('simiproductlabel_form', array('legend' => Mage::helper('simiconnector')->__('Label information')));
15
+
16
+ $fieldset->addField('status', 'select', array(
17
+ 'label' => Mage::helper('simiconnector')->__('Status'),
18
+ 'name' => 'status',
19
+ 'values' => Mage::getSingleton('simiconnector/status')->getOptionHash(),
20
+ ));
21
+
22
+ if ($data['status'] == null) {
23
+ $data['status'] = 1;
24
+ }
25
+
26
+ $stores = Mage::getModel('core/store')->getCollection();
27
+ $list_store = array();
28
+ foreach ($stores as $store) {
29
+ $list_store[] = array(
30
+ 'value' => $store->getId(),
31
+ 'label' => $store->getName(),
32
+ );
33
+ }
34
+ $fieldset->addField('storeview_id', 'select', array(
35
+ 'label' => Mage::helper('simiconnector')->__('Store View'),
36
+ 'name' => 'storeview_id',
37
+ 'values' => $list_store
38
+ ));
39
+
40
+ $fieldset->addField('name', 'text', array(
41
+ 'label' => Mage::helper('simiconnector')->__('Label Name'),
42
+ 'class' => 'required-entry',
43
+ 'required' => true,
44
+ 'name' => 'name',
45
+ ));
46
+
47
+ $fieldset->addField('description', 'textarea', array(
48
+ 'name' => 'description',
49
+ 'label' => Mage::helper('simiconnector')->__('Description'),
50
+ 'title' => Mage::helper('simiconnector')->__('Description'),
51
+ 'style' => 'height: 100px;',
52
+ 'wysiwyg' => false,
53
+ 'required' => false,
54
+ ));
55
+
56
+ $fieldset->addField('image', 'image', array(
57
+ 'label' => Mage::helper('simiconnector')->__('Image (width:340px, height:340px)'),
58
+ 'required' => FALSE,
59
+ 'name' => 'image_name_co',
60
+ ));
61
+
62
+
63
+ $fieldset->addField('position', 'select', array(
64
+ 'label' => Mage::helper('simiconnector')->__('Position'),
65
+ 'name' => 'position',
66
+ 'required' => false,
67
+ 'values' => Mage::helper('simiconnector/productlabel')->getOptionHash()
68
+ ));
69
+
70
+ $fieldset->addField('priority', 'text', array(
71
+ 'name' => 'priority',
72
+ 'class' => 'validate-number',
73
+ 'label' => Mage::helper('simiconnector')->__('Priority'),
74
+ 'note' => Mage::helper('simiconnector')->__('The higher the value, the higher the priority.'),
75
+ ));
76
+
77
+
78
+ $fieldset->addField('text', 'textarea', array(
79
+ 'label' => Mage::helper('simiconnector')->__('Text'),
80
+ 'required' => false,
81
+ 'name' => 'text',
82
+ ));
83
+
84
+ if ($data['is_auto_fill'] == null) {
85
+ $data['is_auto_fill'] = 1;
86
+ }
87
+
88
+
89
+ $productIds = implode(", ", Mage::getResourceModel('catalog/product_collection')->getAllIds());
90
+ $fieldset->addField('product_ids', 'text', array(
91
+ 'name' => 'product_ids',
92
+ 'class' => 'required-entry',
93
+ 'required' => true,
94
+ 'label' => Mage::helper('simiconnector')->__('Product ID'),
95
+ 'note' => Mage::helper('simiconnector')->__('Choose a product'),
96
+ 'after_element_html' => '<a id="product_link" href="javascript:void(0)" onclick="toggleMainProducts()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Products"></a><input type="hidden" value="' . $productIds . '" id="product_all_ids"/><div id="main_products_select" style="display:none;width:640px"></div>
97
+ <script type="text/javascript">
98
+ function toggleMainProducts(){
99
+ if($("main_products_select").style.display == "none"){
100
+ var url = "' . $this->getUrl('adminhtml/simiconnector_simiproductlabel/chooserMainProducts', array('_secure' => true)) . '";
101
+ var params = $("product_ids").value.split(", ");
102
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
103
+ var request = new Ajax.Request(url,
104
+ {
105
+ evalScripts: true,
106
+ parameters: parameters,
107
+ onComplete:function(transport){
108
+ $("main_products_select").update(transport.responseText);
109
+ $("main_products_select").style.display = "block";
110
+ }
111
+ });
112
+ }else{
113
+ $("main_products_select").style.display = "none";
114
+ }
115
+ };
116
+ var grid;
117
+
118
+ function constructData(div){
119
+ grid = window[div.id+"JsObject"];
120
+ if(!grid.reloadParams){
121
+ grid.reloadParams = {};
122
+ grid.reloadParams["selected[]"] = $("product_ids").value.split(", ");
123
+ }
124
+ }
125
+ function toogleCheckAllProduct(el){
126
+ if(el.checked == true){
127
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
128
+ if(e.name != "check_all"){
129
+ if(!e.checked){
130
+ if($("product_ids").value == "")
131
+ $("product_ids").value = e.value;
132
+ else
133
+ $("product_ids").value = $("product_ids").value + ", "+e.value;
134
+ e.checked = true;
135
+ grid.reloadParams["selected[]"] = $("product_ids").value.split(", ");
136
+ }
137
+ }
138
+ });
139
+ }else{
140
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
141
+ if(e.name != "check_all"){
142
+ if(e.checked){
143
+ var vl = e.value;
144
+ if($("product_ids").value.search(vl) == 0){
145
+ if($("product_ids").value == vl) $("product_ids").value = "";
146
+ $("product_ids").value = $("product_ids").value.replace(vl+", ","");
147
+ }else{
148
+ $("product_ids").value = $("product_ids").value.replace(", "+ vl,"");
149
+ }
150
+ e.checked = false;
151
+ grid.reloadParams["selected[]"] = $("product_ids").value.split(", ");
152
+ }
153
+ }
154
+ });
155
+
156
+ }
157
+ }
158
+ function selectProduct(e) {
159
+ if(e.checked == true){
160
+ if(e.id == "main_on"){
161
+ $("product_ids").value = $("product_all_ids").value;
162
+ }else{
163
+ if($("product_ids").value == "")
164
+ $("product_ids").value = e.value;
165
+ else
166
+ $("product_ids").value = $("product_ids").value + ", "+e.value;
167
+
168
+ grid.reloadParams["selected[]"] = $("product_ids").value;
169
+ }
170
+ }else{
171
+ if(e.id == "main_on"){
172
+ $("product_ids").value = "";
173
+ }else{
174
+ var vl = e.value;
175
+ if($("product_ids").value.search(vl) == 0){
176
+ $("product_ids").value = $("product_ids").value.replace(vl+", ","");
177
+ }else{
178
+ $("product_ids").value = $("product_ids").value.replace(", "+ vl,"");
179
+ }
180
+ }
181
+ }
182
+
183
+ }
184
+ </script>'
185
+ ));
186
+
187
+ $form->setValues($data);
188
+ return parent::_prepareForm();
189
+ }
190
+
191
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tab/Products.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct($arguments = array()) {
6
+ parent::__construct($arguments);
7
+ if ($this->getRequest()->getParam('current_grid_id')) {
8
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
9
+ } else {
10
+ $this->setId('skuChooserGrid_' . $this->getId());
11
+ }
12
+
13
+ $form = $this->getJsFormObject();
14
+ $gridId = $this->getId();
15
+ $this->setCheckboxCheckCallback("constructData($gridId)");
16
+ $this->setDefaultSort('sku');
17
+ $this->setUseAjax(true);
18
+ if ($this->getRequest()->getParam('collapse')) {
19
+ $this->setIsCollapsed(true);
20
+ }
21
+ $this->setTemplate('simiconnector/simiproductlabel/grid.phtml');
22
+ }
23
+
24
+ /**
25
+ * Retrieve quote store object
26
+ * @return Mage_Core_Model_Store
27
+ */
28
+ public function getStore() {
29
+ return Mage::app()->getStore();
30
+ }
31
+
32
+ protected function _addColumnFilterToCollection($column) {
33
+ // Set custom filter for in product flag
34
+ if ($column->getId() == 'in_products') {
35
+ $selected = $this->_getSelectedProducts();
36
+ if (empty($selected)) {
37
+ $selected = '';
38
+ }
39
+ if ($column->getFilter()->getValue()) {
40
+ $this->getCollection()->addFieldToFilter('sku', array('in' => $selected));
41
+ } else {
42
+ $this->getCollection()->addFieldToFilter('sku', array('nin' => $selected));
43
+ }
44
+ } else {
45
+ parent::_addColumnFilterToCollection($column);
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
52
+ *
53
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
54
+ */
55
+ protected function _prepareCollection() {
56
+ $collection = Mage::getResourceModel('catalog/product_collection')
57
+ ->setStoreId(0)
58
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id')
59
+ ->addFieldToFilter('visibility', array('neq' => '1'))
60
+ ->addFieldToFilter('status', '1')
61
+ ;
62
+
63
+ $this->setCollection($collection);
64
+
65
+ return parent::_prepareCollection();
66
+ }
67
+
68
+ /**
69
+ * Define Cooser Grid Columns and filters
70
+ *
71
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
72
+ */
73
+ protected function _prepareColumns() {
74
+ $this->addColumn('in_products', array(
75
+ 'header_css_class' => 'a-center',
76
+ 'type' => 'checkbox',
77
+ 'name' => 'in_products',
78
+ 'values' => $this->_getSelectedProducts(),
79
+ 'align' => 'center',
80
+ 'index' => 'sku',
81
+ 'use_index' => true,
82
+ 'width' => '50px',
83
+ 'renderer' => 'simiconnector/adminhtml_simiproductlabel_edit_tab_render'
84
+ ));
85
+
86
+ $this->addColumn('entity_id', array(
87
+ 'header' => Mage::helper('sales')->__('ID'),
88
+ 'sortable' => true,
89
+ 'width' => '60px',
90
+ 'index' => 'entity_id'
91
+ ));
92
+
93
+ $this->addColumn('chooser_name', array(
94
+ 'header' => Mage::helper('sales')->__('Product Name'),
95
+ 'name' => 'chooser_name',
96
+ 'index' => 'name',
97
+ 'width' => '400px'
98
+ ));
99
+
100
+ $this->addColumn('type', array(
101
+ 'header' => Mage::helper('catalog')->__('Type'),
102
+ 'width' => '60px',
103
+ 'index' => 'type_id',
104
+ 'type' => 'options',
105
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
106
+ ));
107
+
108
+ $this->addColumn('chooser_sku', array(
109
+ 'header' => Mage::helper('sales')->__('SKU'),
110
+ 'name' => 'chooser_sku',
111
+ 'width' => '80px',
112
+ 'index' => 'sku',
113
+ ));
114
+
115
+
116
+ return parent::_prepareColumns();
117
+ }
118
+
119
+ public function getGridUrl() {
120
+ return $this->getUrl('*/*/chooserMainProducts', array(
121
+ '_current' => true,
122
+ 'current_grid_id' => $this->getId(),
123
+ 'collapse' => null
124
+ ));
125
+ }
126
+
127
+ protected function _getSelectedProducts() {
128
+ $products = $this->getRequest()->getPost('selected', array());
129
+ return $products;
130
+ }
131
+
132
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tab/Render.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Edit_Tab_Render extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $checked = '';
7
+ if (in_array($row->getId(), $this->_getSelectedProducts()))
8
+ $checked = 'checked';
9
+ $html = '<input type="checkbox" ' . $checked . ' name="selected" value="' . $row->getId() . '" class="checkbox" onclick="selectProduct(this)">';
10
+ return sprintf('%s', $html);
11
+ }
12
+
13
+ protected function _getSelectedProducts() {
14
+ $products = $this->getRequest()->getPost('selected', array());
15
+ return $products;
16
+ }
17
+
18
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Edit/Tabs.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('simiproductlabel_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('simiconnector')->__('Label Information'));
10
+ }
11
+
12
+ /**
13
+ * prepare before render block to html
14
+ *
15
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Edit_Tabs
16
+ */
17
+ protected function _beforeToHtml() {
18
+ $this->addTab('form_section', array(
19
+ 'label' => Mage::helper('simiconnector')->__('Label Information'),
20
+ 'title' => Mage::helper('simiconnector')->__('Label Information'),
21
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_simiproductlabel_edit_tab_form')->toHtml(),
22
+ ));
23
+ return parent::_beforeToHtml();
24
+ }
25
+
26
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simiproductlabel/Grid.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simiproductlabel_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('labelGrid');
8
+ $this->setDefaultSort('label_id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection() {
14
+ $webId = 0;
15
+ $collection = Mage::getModel('simiconnector/simiproductlabel')->getCollection();
16
+ $this->setCollection($collection);
17
+ return parent::_prepareCollection();
18
+ }
19
+
20
+ protected function _prepareColumns() {
21
+ $this->addColumn('label_id', array(
22
+ 'header' => Mage::helper('simiconnector')->__('ID'),
23
+ 'align' => 'right',
24
+ 'width' => '50px',
25
+ 'index' => 'label_id',
26
+ ));
27
+ $this->addColumn('name', array(
28
+ 'header' => Mage::helper('simiconnector')->__('Label Name'),
29
+ 'align' => 'left',
30
+ 'index' => 'name',
31
+ ));
32
+
33
+ $this->addColumn('status', array(
34
+ 'header' => Mage::helper('simiconnector')->__('Status'),
35
+ 'align' => 'left',
36
+ 'width' => '80px',
37
+ 'index' => 'status',
38
+ 'type' => 'options',
39
+ 'options' => array(
40
+ 1 => Mage::helper('simiconnector')->__('Active'),
41
+ 2 => Mage::helper('simiconnector')->__('Inactive'),
42
+ ),
43
+ ));
44
+ $this->addColumn('action', array(
45
+ 'header' => Mage::helper('simiconnector')->__('Action'),
46
+ 'width' => '100',
47
+ 'type' => 'action',
48
+ 'getter' => 'getId',
49
+ 'actions' => array(
50
+ array(
51
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
52
+ 'url' => array('base' => '*/*/edit'),
53
+ 'field' => 'label_id'
54
+ )),
55
+ 'filter' => false,
56
+ 'sortable' => false,
57
+ 'index' => 'stores',
58
+ 'is_system' => true,
59
+ ));
60
+
61
+ return parent::_prepareColumns();
62
+ }
63
+
64
+ /**
65
+ * prepare mass action for this grid
66
+ *
67
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Grid
68
+ */
69
+ protected function _prepareMassaction() {
70
+ $this->setMassactionIdField('label_id');
71
+ $this->getMassactionBlock()->setFormFieldName('label_id');
72
+
73
+ $this->getMassactionBlock()->addItem('delete', array(
74
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
75
+ 'url' => $this->getUrl('*/*/massDelete'),
76
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
77
+ ));
78
+
79
+ $statuses = Mage::getSingleton('simiconnector/status')->getOptionArray();
80
+
81
+ array_unshift($statuses, array('label' => '', 'value' => ''));
82
+ $this->getMassactionBlock()->addItem('status', array(
83
+ 'label' => Mage::helper('simiconnector')->__('Change status'),
84
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
85
+ 'additional' => array(
86
+ 'visibility' => array(
87
+ 'name' => 'status',
88
+ 'type' => 'select',
89
+ 'class' => 'required-entry',
90
+ 'label' => Mage::helper('simiconnector')->__('Status'),
91
+ 'values' => $statuses
92
+ ))
93
+ ));
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * get url for each row in grid
99
+ *
100
+ * @return string
101
+ */
102
+ public function getRowUrl($row) {
103
+ $webId = Mage::getBlockSingleton('simiconnector/adminhtml_web_switcher')->getWebsiteId();
104
+ return $this->getUrl('*/*/edit', array('label_id' => $row->getId()));
105
+ }
106
+
107
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_controller = 'adminhtml_simivideo';
8
+ $this->_blockGroup = 'simiconnector';
9
+ $this->_headerText = Mage::helper('simiconnector')->__('Videos');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_SimiVideo_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->_objectId = 'id';
8
+ $this->_blockGroup = 'simiconnector';
9
+ $this->_controller = 'adminhtml_simivideo';
10
+
11
+ $this->_updateButton('save', 'label', Mage::helper('simiconnector')->__('Save Video'));
12
+ $this->_updateButton('delete', 'label', Mage::helper('simiconnector')->__('Delete Video'));
13
+
14
+ $this->_addButton('saveandcontinue', array(
15
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
16
+ 'onclick' => 'saveAndContinueEdit()',
17
+ 'class' => 'save',
18
+ ), -100);
19
+
20
+ $this->_formScripts[] = "
21
+ function toggleEditor() {
22
+ if (tinyMCE.getInstanceById('madapter_content') == null)
23
+ tinyMCE.execCommand('mceAddControl', false, 'madapter_content');
24
+ else
25
+ tinyMCE.execCommand('mceRemoveControl', false, 'madapter_content');
26
+ }
27
+
28
+ function saveAndContinueEdit(){
29
+ editForm.submit($('edit_form').action+'back/edit/');
30
+ }
31
+ ";
32
+ }
33
+
34
+ /**
35
+ * get text to show in header when edit an item
36
+ *
37
+ * @return string
38
+ */
39
+ public function getHeaderText() {
40
+ if (Mage::registry('simivideo_data') && Mage::registry('simivideo_data')->getId())
41
+ return Mage::helper('simiconnector')->__("Edit Video '%s'", $this->htmlEscape(Mage::registry('simivideo_data')->getData('video_title')));
42
+ return Mage::helper('simiconnector')->__('Add Video');
43
+ }
44
+
45
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array(
9
+ 'video_id' => $this->getRequest()->getParam('video_id'),
10
+ )),
11
+ 'method' => 'post',
12
+ 'enctype' => 'multipart/form-data'
13
+ ));
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+
20
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tab/Form.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ if (Mage::getSingleton('adminhtml/session')->getConnectorData()) {
9
+ $data = Mage::getSingleton('adminhtml/session')->getConnectorData();
10
+ Mage::getSingleton('adminhtml/session')->setConnectorData(null);
11
+ } elseif (Mage::registry('simivideo_data'))
12
+ $data = Mage::registry('simivideo_data')->getData();
13
+
14
+ $fieldset = $form->addFieldset('simivideo_form', array('legend' => Mage::helper('simiconnector')->__('Video information')));
15
+
16
+ $fieldset->addField('status', 'select', array(
17
+ 'label' => Mage::helper('simiconnector')->__('Status'),
18
+ 'name' => 'status',
19
+ 'values' => Mage::getSingleton('simiconnector/status')->getOptionHash(),
20
+ ));
21
+
22
+ $fieldset->addField('video_title', 'text', array(
23
+ 'label' => Mage::helper('simiconnector')->__('Title'),
24
+ 'class' => 'required-entry',
25
+ 'required' => true,
26
+ 'name' => 'video_title',
27
+ ));
28
+
29
+
30
+ $fieldset->addField('video_url', 'text', array(
31
+ 'name' => 'video_url',
32
+ 'required' => true,
33
+ 'label' => Mage::helper('simiconnector')->__('Youtube Video URL'),
34
+ 'note' => Mage::helper('simiconnector')->__('Example: https://www.youtube.com/watch?v=AfgX7GB_Rkc'),
35
+ ));
36
+
37
+ $productIds = implode(", ", Mage::getResourceModel('catalog/product_collection')->getAllIds());
38
+ $fieldset->addField('product_ids', 'text', array(
39
+ 'name' => 'product_ids',
40
+ 'class' => 'required-entry',
41
+ 'required' => true,
42
+ 'label' => Mage::helper('simiconnector')->__('Product ID'),
43
+ 'note' => Mage::helper('simiconnector')->__('Choose a product'),
44
+ 'after_element_html' => '<a id="product_link" href="javascript:void(0)" onclick="toggleMainProducts()"><img src="' . $this->getSkinUrl('images/rule_chooser_trigger.gif') . '" alt="" class="v-middle rule-chooser-trigger" title="Select Products"></a><input type="hidden" value="' . $productIds . '" id="product_all_ids"/><div id="main_products_select" style="display:none;width:640px"></div>
45
+ <script type="text/javascript">
46
+ function toggleMainProducts(){
47
+ if($("main_products_select").style.display == "none"){
48
+ var url = "' . $this->getUrl('adminhtml/simiconnector_simivideo/chooserMainProducts', array('_secure' => true)) . '";
49
+ var params = $("product_ids").value.split(", ");
50
+ var parameters = {"form_key": FORM_KEY,"selected[]":params };
51
+ var request = new Ajax.Request(url,
52
+ {
53
+ evalScripts: true,
54
+ parameters: parameters,
55
+ onComplete:function(transport){
56
+ $("main_products_select").update(transport.responseText);
57
+ $("main_products_select").style.display = "block";
58
+ }
59
+ });
60
+ }else{
61
+ $("main_products_select").style.display = "none";
62
+ }
63
+ };
64
+ var grid;
65
+
66
+ function constructData(div){
67
+ grid = window[div.id+"JsObject"];
68
+ if(!grid.reloadParams){
69
+ grid.reloadParams = {};
70
+ grid.reloadParams["selected[]"] = $("product_ids").value.split(", ");
71
+ }
72
+ }
73
+ function toogleCheckAllProduct(el){
74
+ if(el.checked == true){
75
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
76
+ if(e.name != "check_all"){
77
+ if(!e.checked){
78
+ if($("product_ids").value == "")
79
+ $("product_ids").value = e.value;
80
+ else
81
+ $("product_ids").value = $("product_ids").value + ", "+e.value;
82
+ e.checked = true;
83
+ grid.reloadParams["selected[]"] = $("product_ids").value.split(", ");
84
+ }
85
+ }
86
+ });
87
+ }else{
88
+ $$("#main_products_select input[type=checkbox][class=checkbox]").each(function(e){
89
+ if(e.name != "check_all"){
90
+ if(e.checked){
91
+ var vl = e.value;
92
+ if($("product_ids").value.search(vl) == 0){
93
+ if($("product_ids").value == vl) $("product_ids").value = "";
94
+ $("product_ids").value = $("product_ids").value.replace(vl+", ","");
95
+ }else{
96
+ $("product_ids").value = $("product_ids").value.replace(", "+ vl,"");
97
+ }
98
+ e.checked = false;
99
+ grid.reloadParams["selected[]"] = $("product_ids").value.split(", ");
100
+ }
101
+ }
102
+ });
103
+
104
+ }
105
+ }
106
+ function selectProduct(e) {
107
+ if(e.checked == true){
108
+ if(e.id == "main_on"){
109
+ $("product_ids").value = $("product_all_ids").value;
110
+ }else{
111
+ if($("product_ids").value == "")
112
+ $("product_ids").value = e.value;
113
+ else
114
+ $("product_ids").value = $("product_ids").value + ", "+e.value;
115
+
116
+ grid.reloadParams["selected[]"] = $("product_ids").value;
117
+ }
118
+ }else{
119
+ if(e.id == "main_on"){
120
+ $("product_ids").value = "";
121
+ }else{
122
+ var vl = e.value;
123
+ if($("product_ids").value.search(vl) == 0){
124
+ $("product_ids").value = $("product_ids").value.replace(vl+", ","");
125
+ }else{
126
+ $("product_ids").value = $("product_ids").value.replace(", "+ vl,"");
127
+ }
128
+ }
129
+ }
130
+
131
+ }
132
+ </script>'
133
+ ));
134
+
135
+
136
+ $form->setValues($data);
137
+ return parent::_prepareForm();
138
+ }
139
+
140
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tab/Products.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct($arguments = array()) {
6
+ parent::__construct($arguments);
7
+ if ($this->getRequest()->getParam('current_grid_id')) {
8
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
9
+ } else {
10
+ $this->setId('skuChooserGrid_' . $this->getId());
11
+ }
12
+
13
+ $form = $this->getJsFormObject();
14
+ $gridId = $this->getId();
15
+ $this->setCheckboxCheckCallback("constructData($gridId)");
16
+ $this->setDefaultSort('sku');
17
+ $this->setUseAjax(true);
18
+ if ($this->getRequest()->getParam('collapse')) {
19
+ $this->setIsCollapsed(true);
20
+ }
21
+ $this->setTemplate('simiconnector/simivideo/grid.phtml');
22
+ }
23
+
24
+ /**
25
+ * Retrieve quote store object
26
+ * @return Mage_Core_Model_Store
27
+ */
28
+ public function getStore() {
29
+ return Mage::app()->getStore();
30
+ }
31
+
32
+ protected function _addColumnFilterToCollection($column) {
33
+ // Set custom filter for in product flag
34
+ if ($column->getId() == 'in_products') {
35
+ $selected = $this->_getSelectedProducts();
36
+ if (empty($selected)) {
37
+ $selected = '';
38
+ }
39
+ if ($column->getFilter()->getValue()) {
40
+ $this->getCollection()->addFieldToFilter('sku', array('in' => $selected));
41
+ } else {
42
+ $this->getCollection()->addFieldToFilter('sku', array('nin' => $selected));
43
+ }
44
+ } else {
45
+ parent::_addColumnFilterToCollection($column);
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
52
+ *
53
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
54
+ */
55
+ protected function _prepareCollection() {
56
+ $collection = Mage::getResourceModel('catalog/product_collection')
57
+ ->setStoreId(0)
58
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id')
59
+ ->addFieldToFilter('visibility', array('neq' => '1'))
60
+ ->addFieldToFilter('status', '1')
61
+ ;
62
+
63
+ $this->setCollection($collection);
64
+
65
+ return parent::_prepareCollection();
66
+ }
67
+
68
+ /**
69
+ * Define Cooser Grid Columns and filters
70
+ *
71
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
72
+ */
73
+ protected function _prepareColumns() {
74
+ $this->addColumn('in_products', array(
75
+ 'header_css_class' => 'a-center',
76
+ 'type' => 'checkbox',
77
+ 'name' => 'in_products',
78
+ 'values' => $this->_getSelectedProducts(),
79
+ 'align' => 'center',
80
+ 'index' => 'sku',
81
+ 'use_index' => true,
82
+ 'width' => '50px',
83
+ 'renderer' => 'simiconnector/adminhtml_simivideo_edit_tab_render'
84
+ ));
85
+
86
+ $this->addColumn('entity_id', array(
87
+ 'header' => Mage::helper('sales')->__('ID'),
88
+ 'sortable' => true,
89
+ 'width' => '60px',
90
+ 'index' => 'entity_id'
91
+ ));
92
+
93
+ $this->addColumn('chooser_name', array(
94
+ 'header' => Mage::helper('sales')->__('Product Name'),
95
+ 'name' => 'chooser_name',
96
+ 'index' => 'name',
97
+ 'width' => '400px'
98
+ ));
99
+
100
+ $this->addColumn('type', array(
101
+ 'header' => Mage::helper('catalog')->__('Type'),
102
+ 'width' => '60px',
103
+ 'index' => 'type_id',
104
+ 'type' => 'options',
105
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
106
+ ));
107
+
108
+ $this->addColumn('chooser_sku', array(
109
+ 'header' => Mage::helper('sales')->__('SKU'),
110
+ 'name' => 'chooser_sku',
111
+ 'width' => '80px',
112
+ 'index' => 'sku',
113
+ ));
114
+
115
+
116
+ return parent::_prepareColumns();
117
+ }
118
+
119
+ public function getGridUrl() {
120
+ return $this->getUrl('*/*/chooserMainProducts', array(
121
+ '_current' => true,
122
+ 'current_grid_id' => $this->getId(),
123
+ 'collapse' => null
124
+ ));
125
+ }
126
+
127
+ protected function _getSelectedProducts() {
128
+ $products = $this->getRequest()->getPost('selected', array());
129
+ return $products;
130
+ }
131
+
132
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tab/Render.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo_Edit_Tab_Render extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $checked = '';
7
+ if (in_array($row->getId(), $this->_getSelectedProducts()))
8
+ $checked = 'checked';
9
+ $html = '<input type="checkbox" ' . $checked . ' name="selected" value="' . $row->getId() . '" class="checkbox" onclick="selectProduct(this)">';
10
+ return sprintf('%s', $html);
11
+ }
12
+
13
+ protected function _getSelectedProducts() {
14
+ $products = $this->getRequest()->getPost('selected', array());
15
+ return $products;
16
+ }
17
+
18
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Edit/Tabs.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('simivideo_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('simiconnector')->__('Video Information'));
10
+ }
11
+
12
+ /**
13
+ * prepare before render block to html
14
+ *
15
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Edit_Tabs
16
+ */
17
+ protected function _beforeToHtml() {
18
+ $this->addTab('form_section', array(
19
+ 'label' => Mage::helper('simiconnector')->__('Video Information'),
20
+ 'title' => Mage::helper('simiconnector')->__('Video Information'),
21
+ 'content' => $this->getLayout()->createBlock('simiconnector/adminhtml_simivideo_edit_tab_form')->toHtml(),
22
+ ));
23
+ return parent::_beforeToHtml();
24
+ }
25
+
26
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Simivideo/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_Simivideo_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('videoGrid');
8
+ $this->setDefaultSort('video_id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection() {
14
+ $webId = 0;
15
+ $collection = Mage::getModel('simiconnector/simivideo')->getCollection();
16
+ $this->setCollection($collection);
17
+ return parent::_prepareCollection();
18
+ }
19
+
20
+ protected function _prepareColumns() {
21
+ $this->addColumn('video_id', array(
22
+ 'header' => Mage::helper('simiconnector')->__('ID'),
23
+ 'align' => 'right',
24
+ 'width' => '50px',
25
+ 'index' => 'video_id',
26
+ ));
27
+
28
+ $this->addColumn('video_title', array(
29
+ 'header' => Mage::helper('simiconnector')->__('Title'),
30
+ 'align' => 'left',
31
+ 'index' => 'video_title',
32
+ ));
33
+
34
+ $this->addColumn('video_url', array(
35
+ 'header' => Mage::helper('simiconnector')->__('Video Key'),
36
+ 'width' => '550px',
37
+ 'index' => 'video_url',
38
+ ));
39
+
40
+ $this->addColumn('status', array(
41
+ 'header' => Mage::helper('simiconnector')->__('Status'),
42
+ 'align' => 'left',
43
+ 'width' => '80px',
44
+ 'index' => 'status',
45
+ 'type' => 'options',
46
+ 'options' => array(
47
+ 1 => 'Enabled',
48
+ 2 => 'Disabled',
49
+ ),
50
+ ));
51
+
52
+ $this->addColumn('action', array(
53
+ 'header' => Mage::helper('simiconnector')->__('Action'),
54
+ 'width' => '100',
55
+ 'type' => 'action',
56
+ 'getter' => 'getId',
57
+ 'actions' => array(
58
+ array(
59
+ 'caption' => Mage::helper('simiconnector')->__('Edit'),
60
+ 'url' => array('base' => '*/*/edit'),
61
+ 'field' => 'video_id'
62
+ )),
63
+ 'filter' => false,
64
+ 'sortable' => false,
65
+ 'index' => 'stores',
66
+ 'is_system' => true,
67
+ ));
68
+
69
+ return parent::_prepareColumns();
70
+ }
71
+
72
+ /**
73
+ * prepare mass action for this grid
74
+ *
75
+ * @return Magestore_Madapter_Block_Adminhtml_Madapter_Grid
76
+ */
77
+ protected function _prepareMassaction() {
78
+ $this->setMassactionIdField('video_id');
79
+ $this->getMassactionBlock()->setFormFieldName('video_id');
80
+
81
+ $this->getMassactionBlock()->addItem('delete', array(
82
+ 'label' => Mage::helper('simiconnector')->__('Delete'),
83
+ 'url' => $this->getUrl('*/*/massDelete'),
84
+ 'confirm' => Mage::helper('simiconnector')->__('Are you sure?')
85
+ ));
86
+
87
+ $statuses = Mage::getSingleton('simiconnector/status')->getOptionArray();
88
+
89
+ array_unshift($statuses, array('label' => '', 'value' => ''));
90
+ $this->getMassactionBlock()->addItem('status', array(
91
+ 'label' => Mage::helper('simiconnector')->__('Change status'),
92
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
93
+ 'additional' => array(
94
+ 'visibility' => array(
95
+ 'name' => 'status',
96
+ 'type' => 'select',
97
+ 'class' => 'required-entry',
98
+ 'label' => Mage::helper('simiconnector')->__('Status'),
99
+ 'values' => $statuses
100
+ ))
101
+ ));
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * get url for each row in grid
107
+ *
108
+ * @return string
109
+ */
110
+ public function getRowUrl($row) {
111
+ $webId = Mage::getBlockSingleton('simiconnector/adminhtml_web_switcher')->getWebsiteId();
112
+ return $this->getUrl('*/*/edit', array('video_id' => $row->getId()));
113
+ }
114
+
115
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/System/Config/Category/Categories.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_System_Config_Category_Categories extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories {
4
+
5
+ protected $_categoryIds;
6
+ protected $_selectedNodes = null;
7
+
8
+ public function __construct() {
9
+ parent::__construct();
10
+ $this->_withProductCount = false;
11
+ $this->setTemplate('simiconnector/categories.phtml');
12
+ }
13
+
14
+ public function getCategoryCollection() {
15
+ $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
16
+ $collection = $this->getData('category_collection');
17
+ if (is_null($collection)) {
18
+ $collection = Mage::getModel('catalog/category')->getCollection();
19
+
20
+ /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
21
+ $collection->addAttributeToSelect('name')
22
+ ->addAttributeToSelect('is_active')
23
+ ->setProductStoreId($storeId)
24
+ ->setLoadProductCount($this->_withProductCount)
25
+ ->setStoreId($storeId);
26
+
27
+ $this->setData('category_collection', $collection);
28
+ }
29
+ return $collection;
30
+ }
31
+
32
+ /**
33
+ * Checks when this block is readonly
34
+ *
35
+ * @return boolean
36
+ */
37
+ public function isReadonly() {
38
+ return false; //$this->getProduct()->getCategoriesReadonly();
39
+ }
40
+
41
+ protected function getCategoryIds() {
42
+ return explode(',', $this->getIdsString()); //$this->getProduct()->getCategoryIds();
43
+ }
44
+
45
+ public function getIdsString() {
46
+ if ($storecode = Mage::app()->getRequest()->getParam('store')) {
47
+ $storeviewModel = Mage::getModel('core/store')->getCollection()->addFieldToFilter('code', $storecode)->getFirstItem();
48
+ return Mage::getStoreConfig("simiconnector/general/categories_in_app", $storeviewModel->getId());
49
+ }
50
+ return Mage::getStoreConfig("simiconnector/general/categories_in_app"); //Mage::registry('simiconnector_categories');//Mage::registry('bannerslider_data')->getCategories();//implode(',', $this->getCategoryIds());
51
+ }
52
+
53
+ public function getLoadTreeUrl($expanded = null) {
54
+ $params = array('_current' => true, 'id' => null, 'store' => null);
55
+ if ((is_null($expanded) && Mage::getSingleton('admin/session')->getIsTreeWasExpanded()) || $expanded == true) {
56
+ $params['expand_all'] = true;
57
+ }
58
+ return $this->getUrl('adminhtml/simiconnector_config/categoriesJson', $params);
59
+ }
60
+
61
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/System/Config/Category/Categorytree.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_System_Config_Category_Categorytree extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ return $this->getLayout()->createBlock('simiconnector/adminhtml_system_config_category_categories')->toHtml();
8
+ }
9
+
10
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/System/Config/Form/Field/Separator.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Adminhtml_System_Config_Form_Field_Separator extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
+
5
+ /**
6
+ * render separator config row
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ * @return string
10
+ */
11
+ public function render(Varien_Data_Form_Element_Abstract $element) {
12
+ $fieldConfig = $element->getFieldConfig();
13
+ $htmlId = $element->getHtmlId();
14
+ $html = '<tr id="row_' . $htmlId . '">'
15
+ . '<td class="label" colspan="3">';
16
+
17
+ $marginTop = $fieldConfig->margin_top ? (string) $fieldConfig->margin_top : '0px';
18
+ $customStyle = $fieldConfig->style ? (string) $fieldConfig->style : '';
19
+
20
+ $html .= '<div style="margin-top: ' . $marginTop
21
+ . '; font-weight: bold; border-bottom: 1px solid #dfdfdf;'
22
+ . $customStyle . '">';
23
+ $html .= $element->getLabel();
24
+ $html .= '</div></td></tr>';
25
+ return $html;
26
+ }
27
+
28
+ }
app/code/local/Simi/Simiconnector/Block/Adminhtml/Web/Switcher.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * 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_Adminhtml
24
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Store switcher block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Simi_Simiconnector_Block_Adminhtml_Web_Switcher extends Mage_Adminhtml_Block_Template {
36
+ /**
37
+ * Key in config for store switcher hint
38
+ */
39
+
40
+ const XPATH_HINT_KEY = 'simiconnector_web_switcher';
41
+
42
+ /**
43
+ * @var array
44
+ */
45
+ protected $_storeIds;
46
+
47
+ /**
48
+ * Name of store variable
49
+ *
50
+ * @var string
51
+ */
52
+ protected $_storeVarName = 'website';
53
+
54
+ /**
55
+ * Url for store switcher hint
56
+ *
57
+ * @var string
58
+ */
59
+ protected $_hintUrl;
60
+
61
+ /**
62
+ * @var bool
63
+ */
64
+ protected $_hasDefaultOption = true;
65
+
66
+ public function __construct() {
67
+ parent::__construct();
68
+ $this->setTemplate('simiconnector/web/switcher.phtml');
69
+ $this->setUseConfirm(true);
70
+ $this->setUseAjax(true);
71
+ $this->setDefaultStoreName($this->__('All Store Views'));
72
+ }
73
+
74
+ /**
75
+ * Deprecated
76
+ */
77
+ public function getWebsiteCollection() {
78
+ $collection = Mage::getModel('core/website')->getResourceCollection();
79
+
80
+ $websiteIds = $this->getWebsiteIds();
81
+ if (!is_null($websiteIds)) {
82
+ $collection->addIdFilter($this->getWebsiteIds());
83
+ }
84
+
85
+ return $collection->load();
86
+ }
87
+
88
+ /**
89
+ * Get websites
90
+ *
91
+ * @return array
92
+ */
93
+ public function getWebsites() {
94
+ $websites = Mage::app()->getWebsites();
95
+ if ($websiteIds = $this->getWebsiteIds()) {
96
+ foreach ($websites as $websiteId => $website) {
97
+ if (!in_array($websiteId, $websiteIds)) {
98
+ unset($websites[$websiteId]);
99
+ }
100
+ }
101
+ }
102
+ return $websites;
103
+ }
104
+
105
+ /**
106
+ * Deprecated
107
+ */
108
+ public function getGroupCollection($website) {
109
+ if (!$website instanceof Mage_Core_Model_Website) {
110
+ $website = Mage::getModel('core/website')->load($website);
111
+ }
112
+ return $website->getGroupCollection();
113
+ }
114
+
115
+ /**
116
+ * Get store groups for specified website
117
+ *
118
+ * @param Mage_Core_Model_Website $website
119
+ * @return array
120
+ */
121
+ public function getStoreGroups($website) {
122
+ if (!$website instanceof Mage_Core_Model_Website) {
123
+ $website = Mage::app()->getWebsite($website);
124
+ }
125
+ return $website->getGroups();
126
+ }
127
+
128
+ /**
129
+ * Deprecated
130
+ */
131
+ public function getStoreCollection($group) {
132
+ if (!$group instanceof Mage_Core_Model_Store_Group) {
133
+ $group = Mage::getModel('core/store_group')->load($group);
134
+ }
135
+ $stores = $group->getStoreCollection();
136
+ $_storeIds = $this->getStoreIds();
137
+ if (!empty($_storeIds)) {
138
+ $stores->addIdFilter($_storeIds);
139
+ }
140
+ return $stores;
141
+ }
142
+
143
+ /**
144
+ * Get store views for specified store group
145
+ *
146
+ * @param Mage_Core_Model_Store_Group $group
147
+ * @return array
148
+ */
149
+ public function getStores($group) {
150
+ if (!$group instanceof Mage_Core_Model_Store_Group) {
151
+ $group = Mage::app()->getGroup($group);
152
+ }
153
+ $stores = $group->getStores();
154
+ if ($storeIds = $this->getStoreIds()) {
155
+ foreach ($stores as $storeId => $store) {
156
+ if (!in_array($storeId, $storeIds)) {
157
+ unset($stores[$storeId]);
158
+ }
159
+ }
160
+ }
161
+ return $stores;
162
+ }
163
+
164
+ public function getSwitchUrl() {
165
+ if ($url = $this->getData('switch_url')) {
166
+ return $url;
167
+ }
168
+ return $this->getUrl('*/*/*', array('_current' => true, $this->_storeVarName => null));
169
+ }
170
+
171
+ public function setStoreVarName($varName) {
172
+ $this->_storeVarName = $varName;
173
+ return $this;
174
+ }
175
+
176
+ public function getStoreId() {
177
+ return $this->getRequest()->getParam($this->_storeVarName);
178
+ }
179
+
180
+ public function setStoreIds($storeIds) {
181
+ $this->_storeIds = $storeIds;
182
+ return $this;
183
+ }
184
+
185
+ public function getStoreIds() {
186
+ return $this->_storeIds;
187
+ }
188
+
189
+ public function isShow() {
190
+ return !Mage::app()->isSingleStoreMode();
191
+ }
192
+
193
+ protected function _toHtml() {
194
+ if (!Mage::app()->isSingleStoreMode()) {
195
+ return parent::_toHtml();
196
+ }
197
+ return '';
198
+ }
199
+
200
+ /**
201
+ * Set/Get whether the switcher should show default option
202
+ *
203
+ * @param bool $hasDefaultOption
204
+ * @return bool
205
+ */
206
+ public function hasDefaultOption($hasDefaultOption = null) {
207
+ if (null !== $hasDefaultOption) {
208
+ $this->_hasDefaultOption = $hasDefaultOption;
209
+ }
210
+ return $this->_hasDefaultOption;
211
+ }
212
+
213
+ /**
214
+ * Return url for store switcher hint
215
+ *
216
+ * @return string
217
+ */
218
+ public function getHintUrl() {
219
+ if (null === $this->_hintUrl) {
220
+ $this->_hintUrl = Mage::helper('core/hint')->getHintByCode(self::XPATH_HINT_KEY);
221
+ }
222
+ return $this->_hintUrl;
223
+ }
224
+
225
+ /**
226
+ * Return store switcher hint html
227
+ *
228
+ * @return string
229
+ */
230
+ public function getHintHtml() {
231
+ $html = '';
232
+ $url = $this->getHintUrl();
233
+ if ($url) {
234
+ $html = '<a'
235
+ . ' href="' . $this->escapeUrl($url) . '"'
236
+ . ' onclick="this.target=\'_blank\'"'
237
+ . ' title="' . $this->__('What is this?') . '"'
238
+ . ' class="link-store-scope">'
239
+ . $this->__('What is this?')
240
+ . '</a>';
241
+ }
242
+ return $html;
243
+ }
244
+
245
+ public function isSiteDefault() {
246
+ $web = $this->getRequest()->getParam('website', 0);
247
+ return $web;
248
+ }
249
+
250
+ public function getWebsiteId() {
251
+ if(!$this->isSiteDefault()){
252
+ $websites = $this->getWebsites();
253
+ return current($websites)->getId();
254
+ }
255
+ return $this->getRequest()->getParam('website');
256
+ }
257
+
258
+ }
app/code/local/Simi/Simiconnector/Block/Catalog/Bundle.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Catalog_Bundle extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle
4
+ {
5
+ /**
6
+ * Returns JSON encoded config to be used in JS scripts
7
+ *
8
+ * @return string
9
+ */
10
+ public function getJsonConfig()
11
+ {
12
+ /** @var $taxHelper Mage_Tax_Helper_Data */
13
+ $taxHelper = Mage::helper('tax');
14
+ Mage::app()->getLocale()->getJsPriceFormat();
15
+ $optionsArray = $this->getOptions();
16
+ $options = array();
17
+ $selected = array();
18
+ $currentProduct = $this->getProduct();
19
+ /* @var $coreHelper Mage_Core_Helper_Data */
20
+ $coreHelper = Mage::helper('core');
21
+ /* @var $bundlePriceModel Mage_Bundle_Model_Product_Price */
22
+ $bundlePriceModel = Mage::getModel('bundle/product_price');
23
+
24
+ $preConfiguredFlag = $currentProduct->hasPreconfiguredValues();
25
+ if ($preConfiguredFlag) {
26
+ $preConfiguredValues = $currentProduct->getPreconfiguredValues();
27
+ $defaultValues = array();
28
+ }
29
+
30
+ $position = 0;
31
+ foreach ($optionsArray as $_option) {
32
+ /* @var $_option Mage_Bundle_Model_Option */
33
+ if (!$_option->getSelections()) {
34
+ continue;
35
+ }
36
+
37
+ $optionId = $_option->getId();
38
+ $option = array (
39
+ 'selections' => array(),
40
+ 'title' => $_option->getTitle(),
41
+ 'isMulti' => in_array($_option->getType(), array('multi', 'checkbox')),
42
+ 'position' => $position++,
43
+ 'isRequired' => $_option->getRequired(),
44
+ );
45
+
46
+ $selectionCount = count($_option->getSelections());
47
+
48
+ foreach ($_option->getSelections() as $_selection) {
49
+ /* @var $_selection Mage_Catalog_Model_Product */
50
+ $selectionId = $_selection->getSelectionId();
51
+ $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1;
52
+ // recalculate currency
53
+ $tierPrices = $_selection->getTierPrice();
54
+ foreach ($tierPrices as &$tierPriceInfo) {
55
+ $tierPriceInfo['price'] =
56
+ $bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['price']);
57
+ $tierPriceInfo['website_price'] =
58
+ $bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['website_price']);
59
+ $tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false);
60
+ $tierPriceInfo['priceInclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], true,
61
+ null, null, null, null, null, false);
62
+ $tierPriceInfo['priceExclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], false,
63
+ null, null, null, null, null, false);
64
+ }
65
+ unset($tierPriceInfo); // break the reference with the last element
66
+
67
+ $itemPrice = $bundlePriceModel->getSelectionFinalTotalPrice($currentProduct, $_selection,
68
+ $currentProduct->getQty(), $_selection->getQty(), false, false
69
+ );
70
+
71
+ $canApplyMAP = false;
72
+ $_priceInclTax = $taxHelper->getPrice($_selection, $itemPrice, true,
73
+ null, null, null, null, null, false);
74
+ $_priceExclTax = $taxHelper->getPrice($_selection, $itemPrice, false,
75
+ null, null, null, null, null, false);
76
+
77
+ if ($currentProduct->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) {
78
+ $_priceInclTax = $taxHelper->getPrice($currentProduct, $itemPrice, true,
79
+ null, null, null, null, null, false);
80
+ $_priceExclTax = $taxHelper->getPrice($currentProduct, $itemPrice, false,
81
+ null, null, null, null, null, false);
82
+ }
83
+
84
+ $selection = array (
85
+ 'qty' => $_qty,
86
+ 'customQty' => $_selection->getSelectionCanChangeQty(),
87
+ 'price' => $coreHelper->currency($_selection->getFinalPrice(), false, false),
88
+ 'priceInclTax' => $coreHelper->currency($_priceInclTax, false, false),
89
+ 'priceExclTax' => $coreHelper->currency($_priceExclTax, false, false),
90
+ 'priceValue' => $coreHelper->currency($_selection->getSelectionPriceValue(), false, false),
91
+ 'priceType' => $_selection->getSelectionPriceType(),
92
+ 'tierPrice' => $tierPrices,
93
+ 'name' => $_selection->getName(),
94
+ 'plusDisposition' => 0,
95
+ 'minusDisposition' => 0,
96
+ 'canApplyMAP' => $canApplyMAP,
97
+ 'tierPriceHtml' => $this->getTierPriceHtml($_selection, $currentProduct),
98
+ );
99
+
100
+ $responseObject = new Varien_Object();
101
+ $args = array('response_object' => $responseObject, 'selection' => $_selection);
102
+ Mage::dispatchEvent('bundle_product_view_config', $args);
103
+ if (is_array($responseObject->getAdditionalOptions())) {
104
+ foreach ($responseObject->getAdditionalOptions() as $o => $v) {
105
+ $selection[$o] = $v;
106
+ }
107
+ }
108
+ $option['selections'][$selectionId] = $selection;
109
+
110
+ if (($_selection->getIsDefault() || ($selectionCount == 1 && $_option->getRequired()))
111
+ && $_selection->isSalable()
112
+ ) {
113
+ $selected[$optionId][] = $selectionId;
114
+ }
115
+ }
116
+ $options[$optionId] = $option;
117
+
118
+ // Add attribute default value (if set)
119
+ if ($preConfiguredFlag) {
120
+ $configValue = $preConfiguredValues->getData('bundle_option/' . $optionId);
121
+ if ($configValue) {
122
+ $defaultValues[$optionId] = $configValue;
123
+ }
124
+ }
125
+ }
126
+
127
+ $config = array(
128
+ 'options' => $options,
129
+ 'selected' => $selected,
130
+ 'bundleId' => $currentProduct->getId(),
131
+ 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(),
132
+ 'basePrice' => $coreHelper->currency($currentProduct->getPrice(), false, false),
133
+ 'priceType' => $currentProduct->getPriceType(),
134
+ 'specialPrice' => $currentProduct->getSpecialPrice(),
135
+ 'includeTax' => Mage::helper('tax')->priceIncludesTax(),
136
+ 'showIncludeTax' => $taxHelper->displayPriceIncludingTax(),
137
+ 'showBothPrices' => Mage::helper('tax')->displayBothPrices(),
138
+ 'isFixedPrice' => $this->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED,
139
+ 'isMAPAppliedDirectly' => Mage::helper('catalog')->canApplyMsrp($this->getProduct(), null, false)
140
+ );
141
+
142
+ if ($preConfiguredFlag && !empty($defaultValues)) {
143
+ $config['defaultValues'] = $defaultValues;
144
+ }
145
+
146
+ return $coreHelper->jsonEncode($config);
147
+ }
148
+ }
app/code/local/Simi/Simiconnector/Block/Simicategory.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Block_Simicategory extends Mage_Core_Block_Template
4
+ {
5
+ public function _prepareLayout(){
6
+ return parent::_prepareLayout();
7
+ }
8
+ }
app/code/local/Simi/Simiconnector/Controller/Action.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/2/16
7
+ * Time: 4:14 PM
8
+ */
9
+ class Simi_Simiconnector_Controller_Action extends Mage_Core_Controller_Front_Action
10
+ {
11
+
12
+ protected $_data;
13
+
14
+ public function preDispatch()
15
+ {
16
+ parent::preDispatch();
17
+ $enable = (int) Mage::getStoreConfig("simiconnector/general/enable");
18
+
19
+ if (!$enable) {
20
+ echo 'Connector was disabled!';
21
+ header("HTTP/1.0 503");
22
+ exit();
23
+ }
24
+ /*
25
+ if (!$this->isHeader()) {
26
+ echo 'Connect error!';
27
+ header("HTTP/1.0 401 Unauthorized");
28
+ exit();
29
+ }
30
+ */
31
+ }
32
+
33
+ protected function _getServer()
34
+ {
35
+ return Mage::getSingleton('simiconnector/server');
36
+ }
37
+
38
+ protected function _printData($result)
39
+ {
40
+ header("Content-Type: application/json");
41
+ $this->setData($result);
42
+ Mage::dispatchEvent($this->getFullActionName(), array('object' => $this, 'data' => $result));
43
+ $this->_data = $this->getData();
44
+ ob_clean();
45
+ echo Mage::helper('core')->jsonEncode($this->_data);
46
+ }
47
+
48
+ protected function isHeader()
49
+ {
50
+ if (strpos(Mage::helper('core/url')->getCurrentUrl(), 'migrate_') !== false)
51
+ return true;
52
+ if (!function_exists('getallheaders')) {
53
+
54
+ function getallheaders()
55
+ {
56
+ $head = array();
57
+ foreach ($_SERVER as $name => $value) {
58
+ if (substr($name, 0, 5) == 'HTTP_') {
59
+ $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
60
+ $head[$name] = $value;
61
+ } else if ($name == "CONTENT_TYPE") {
62
+ $head["Content-Type"] = $value;
63
+ } else if ($name == "CONTENT_LENGTH") {
64
+ $head["Content-Length"] = $value;
65
+ } else {
66
+ $head[$name] = $value;
67
+ }
68
+ }
69
+ return $head;
70
+ }
71
+
72
+ }
73
+
74
+ $head = getallheaders();
75
+ // token is key
76
+ $keySecret = md5(Mage::getStoreConfig('simiconnector/general/secret_key'));
77
+ $token = "";
78
+ foreach ($head as $k => $h) {
79
+ if ($k == "Authorization" || $k == "TOKEN" || $k == "Token") {
80
+ $token = $h;
81
+ }
82
+ }
83
+ if (strcmp($token, 'Bearer ' . $keySecret) == 0)
84
+ return true;
85
+ else
86
+ return false;
87
+ }
88
+
89
+ public function getData()
90
+ {
91
+ return $this->_data;
92
+ }
93
+
94
+ public function setData($data)
95
+ {
96
+ $this->_data = $data;
97
+ }
98
+
99
+ }
app/code/local/Simi/Simiconnector/Helper/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Helper/Address.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Helper_Address extends Mage_Core_Helper_Abstract {
7
+
8
+ public function _getOnepage() {
9
+ return Mage::getSingleton('checkout/type_onepage');
10
+ }
11
+
12
+ /*
13
+ * Convert Address before Saving
14
+ */
15
+
16
+ public function convertDataAddress($data) {
17
+ $listState = array();
18
+ $check_state = false;
19
+ if (isset($data->country_id)) {
20
+ $country = $data->country_id;
21
+ $listState = Mage::helper('simiconnector/address')->getStates($country);
22
+ }
23
+ $state_id = Mage::getStoreConfig('simiconnector/hideaddress/region_id_default');
24
+ if (count($listState) == 0) {
25
+ $check_state = true;
26
+ }
27
+
28
+ foreach ($listState as $state) {
29
+ if (in_array($data->region_code, $state) || in_array($data->region, $state) || in_array($data->region_id, $state)) {
30
+ $state_id = $state['state_id'];
31
+ $check_state = true;
32
+ break;
33
+ }
34
+ }
35
+ if (!$check_state) {
36
+ if (!$state_id)
37
+ throw new Exception($this->__('State invalid'), 4);
38
+ }
39
+ if (!isset($data->country_id) && !isset($data->country_name))
40
+ $data->country_id = Mage::getStoreConfig('simiconnector/hideaddress/country_id_default');
41
+
42
+ if (!isset($data->street))
43
+ $data->street = Mage::getStoreConfig('simiconnector/hideaddress/street_default');
44
+
45
+ if (!isset($data->city))
46
+ $data->city = Mage::getStoreConfig('simiconnector/hideaddress/city_default');
47
+
48
+ if (!isset($data->postcode))
49
+ $data->postcode = Mage::getStoreConfig('simiconnector/hideaddress/zipcode_default');
50
+
51
+ if (!isset($data->telephone))
52
+ $data->telephone = Mage::getStoreConfig('simiconnector/hideaddress/telephone_default');
53
+
54
+ $latlng = isset($data->latlng) == true ? $data->latlng : '';
55
+ $address = array();
56
+ foreach ((array) $data as $index => $info) {
57
+ $address[$index] = $info;
58
+ }
59
+ $address['street'] = array($data->street, '', $latlng, '');
60
+ $address['region_id'] = $state_id;
61
+ return $address;
62
+ }
63
+
64
+ public function getStates($code) {
65
+ $list = array();
66
+ if ($code) {
67
+ $states = Mage::getModel('directory/country')->loadByCode($code)->getRegions();
68
+ foreach ($states as $state) {
69
+ $list[] = array(
70
+ 'state_id' => $state->getRegionId(),
71
+ 'state_name' => $state->getName(),
72
+ 'state_code' => $state->getCode(),
73
+ );
74
+ }
75
+ }
76
+ return $list;
77
+ }
78
+
79
+ /*
80
+ * Get Address to be Shown
81
+ */
82
+
83
+ public function getAddressDetail($data, $customer = null) {
84
+ if(!$data) return array();
85
+ $street = $data->getStreet();
86
+ if (!($email = $data->getData('email')) && $customer && $customer->getEmail())
87
+ $email = $customer->getEmail();
88
+ return array(
89
+ 'firstname' => $data->getFirstname(),
90
+ 'lastname' => $data->getLastname(),
91
+ 'prefix' => $data->getPrefix(),
92
+ 'suffix' => $data->getSuffix(),
93
+ 'vat_id' => $data->getVatId(),
94
+ 'street' => $street[0],
95
+ 'city' => $data->getCity(),
96
+ 'region' => $data->getRegion(),
97
+ 'region_id' => $data->getRegionId(),
98
+ 'region_code' => $data->getRegionCode(),
99
+ 'postcode' => $data->getPostcode(),
100
+ 'country_name' => $data->getCountry() ? $data->getCountryModel()->loadByCode($data->getCountry())->getName() : NULL,
101
+ 'country_id' => $data->getCountry(),
102
+ 'telephone' => $data->getTelephone(),
103
+ 'email' => $email,
104
+ 'company' => $data->getCompany(),
105
+ 'fax' => $data->getFax(),
106
+ 'latlng' => isset($street[2]) ? $street[2] : "",
107
+ );
108
+ }
109
+
110
+ /*
111
+ * Save Billing Address To Quote
112
+ */
113
+
114
+ public function saveBillingAddress($billingAddress) {
115
+ $is_register_mode = false;
116
+ if (isset($billingAddress->customer_password) && $billingAddress->customer_password) {
117
+ $is_register_mode = true;
118
+ $this->_getOnepage()->saveCheckoutMethod('register');
119
+ } elseif (Mage::getSingleton('customer/session')->isLoggedIn()) {
120
+ $this->_getOnepage()->saveCheckoutMethod('customer');
121
+ } else {
122
+ $this->_getOnepage()->saveCheckoutMethod('guest');
123
+ }
124
+
125
+ if ($is_register_mode) {
126
+ $customer_email = $billingAddress->email;
127
+ $customer = Mage::getModel('customer/customer');
128
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
129
+ $customer->loadByEmail($customer_email);
130
+ if ($customer->getId()) {
131
+ throw new Exception($this->__('There is already a customer registered using this email address. Please login using this email address or enter a different email address to register your account.'), 7);
132
+ }
133
+ }
134
+ $address = $this->convertDataAddress($billingAddress);
135
+ $address['save_in_address_book'] = '1';
136
+ $saveBilling = $this->_getOnepage()->saveBilling($address, $billingAddress->entity_id);
137
+
138
+ if (isset($saveBilling['error'])){
139
+ $error_message = '';
140
+ if (is_array($saveBilling['message'])) {
141
+ foreach ($saveBilling['message'] as $error) {
142
+ $error_message .=$error . "\n";
143
+ }
144
+ } else {
145
+ $error_message = $saveBilling['message'];
146
+ }
147
+
148
+ throw new Exception(Mage::helper('core')->__($error_message));
149
+ }
150
+ }
151
+
152
+ /*
153
+ * Save Shipping Address To quote
154
+ */
155
+
156
+ public function saveShippingAddress($shippingAddress) {
157
+ $address = $this->convertDataAddress($shippingAddress);
158
+ $address['save_in_address_book'] = '1';
159
+ $saveShipping = $this->_getOnepage()->saveShipping($address, $shippingAddress->entity_id);
160
+
161
+ if (isset($saveShipping['error'])){
162
+ $error_message = '';
163
+ if (is_array($saveShipping['message'])) {
164
+ foreach ($saveShipping['message'] as $error) {
165
+ $error_message .=$error . "\n";
166
+ }
167
+ } else {
168
+ $error_message = $saveShipping['message'];
169
+ }
170
+
171
+ throw new Exception(Mage::helper('core')->__($error_message));
172
+ }
173
+ }
174
+
175
+ /*
176
+ * Add Hidden Address Fields on Storeview Config Result
177
+ */
178
+
179
+ public function getCheckoutAddressSetting() {
180
+ if (!Mage::getStoreConfig('simiconnector/hideaddress/hideaddress_enable'))
181
+ return NULL;
182
+ $addresss = array('company', 'street', 'country_id', 'region_id', 'city', 'zipcode',
183
+ 'telephone', 'fax', 'prefix', 'suffix', 'dob', 'gender', 'taxvat');
184
+ foreach ($addresss as $address) {
185
+ $path = "simiconnector/hideaddress/" . $address;
186
+ $value = Mage::getStoreConfig($path);
187
+ if (!$value || $value == null || !isset($value))
188
+ $value = 3;
189
+ $address.='_show';
190
+ if ($value == 1)
191
+ $data[$address] = "req";
192
+ else if ($value == 2)
193
+ $data[$address] = "opt";
194
+ else if ($value == 3)
195
+ $data[$address] = "";
196
+ }
197
+ /*
198
+ //sample add custom address fields
199
+ $data['custom_fields'] = array();
200
+ //text field
201
+ $data['custom_fields'][] = array('code' => 'text_field_sample',
202
+ 'title' => 'Text Field',
203
+ 'type' => 'text',
204
+ 'required' => 'opt',
205
+ 'position' => '7',
206
+ );
207
+ //number field
208
+ $data['custom_fields'][] = array('code' => 'number_field_sample',
209
+ 'title' => 'Number Field',
210
+ 'type' => 'number',
211
+ 'required' => 'req',
212
+ 'position' => '8',
213
+ );
214
+ //single choice Option
215
+ $data['custom_fields'][] = array('code' => 'single_option_sample',
216
+ 'title' => 'Sample Field Single Option',
217
+ 'type' => 'single_option',
218
+ 'required' => '',
219
+ 'option_array' => array('Option Single 1', 'Option Single 2', 'Option Single 3'),
220
+ 'position' => '9',
221
+ );
222
+ //multi choice Option
223
+ $data['custom_fields'][] = array('code' => 'multi_option_sample',
224
+ 'title' => 'Sample Field Multi Option',
225
+ 'type' => 'multi_option',
226
+ 'required' => 'opt',
227
+ 'option_array' => array('Option Multi 1', 'Option Multi 2', 'Option Multi 3', 'Option Multi 4', 'Option Multi 5'),
228
+ 'separated_by' => '%',
229
+ 'position' => '10',
230
+ );
231
+ */
232
+ return $data;
233
+ }
234
+
235
+ /*
236
+ * Get Geocode result from Lat and Long
237
+ */
238
+
239
+ public function getLocationInfo($lat, $lng) {
240
+ $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) . '&sensor=false';
241
+ $json = @file_get_contents($url);
242
+ $data = json_decode($json);
243
+ $status = $data->status;
244
+ if ($status == "OK") {
245
+ $addresses = array();
246
+ $address = '';
247
+ for ($j = 0; $j < count($data->results[0]->address_components); $j++) {
248
+ $addressComponents = $data->results[0]->address_components[$j];
249
+ $types = $addressComponents->types;
250
+ if (in_array('street_number', $types)) {
251
+ $address .= $addressComponents->long_name;
252
+ }
253
+ if (in_array('route', $types)) {
254
+ $address .= ' ' . $addressComponents->long_name;
255
+ }
256
+ if (in_array('locality', $types)) {
257
+ $address .= ', ' . $addressComponents->long_name;
258
+ }
259
+ if (in_array('postal_town', $types) || in_array('administrative_area_level_1', $types)) {
260
+ $city .= $addressComponents->long_name;
261
+ }
262
+ if (in_array('administrative_area_level_2', $types)) {
263
+ $state .= $addressComponents->long_name;
264
+ }
265
+ if (in_array('country', $types)) {
266
+ $country .= $addressComponents->short_name;
267
+ }
268
+ if (in_array('postal_code', $types)) {
269
+ $zipcode .= $addressComponents->long_name;
270
+ }
271
+ }
272
+ $addresses['address'] = $address;
273
+ $addresses['city'] = $city;
274
+ $addresses['state'] = $state;
275
+ $addresses['country'] = $country;
276
+ $addresses['zipcode'] = $zipcode;
277
+ $addresses['geocoding'] = $data;
278
+ return $addresses;
279
+ } else {
280
+ return false;
281
+ }
282
+ }
283
+
284
+ }
app/code/local/Simi/Simiconnector/Helper/Bundle/Price.php ADDED
@@ -0,0 +1,423 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/20/16
7
+ * Time: 8:52 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Bundle_Price extends Mage_Core_Helper_Abstract
10
+ {
11
+ protected $_product = null;
12
+ protected $_minimalPriceTax = null;
13
+ protected $_minimalPriceInclTax = null;
14
+
15
+ public function helper($helper)
16
+ {
17
+ return Mage::helper($helper);
18
+ }
19
+
20
+ public function getProductAttribute($attribute) {
21
+ return $this->_product->getResource()->getAttribute($attribute);
22
+ }
23
+
24
+ public function displayBothPrices()
25
+ {
26
+ $product = $this->_product;
27
+ if ($product->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC &&
28
+ $product->getPriceModel()->getIsPricesCalculatedByIndex() !== false) {
29
+ return false;
30
+ }
31
+ return $this->helper('tax')->displayBothPrices();
32
+ }
33
+
34
+ public function formatPriceFromProduct($_product, $is_detail = false)
35
+ {
36
+ $priceV2 = array();
37
+ $this->_product = $_product;
38
+ /**
39
+ * @var $_coreHelper Mage_Core_Helper_Data
40
+ * @var $_weeeHelper Mage_Weee_Helper_Data
41
+ * @var $_taxHelper Mage_Tax_Helper_Data
42
+ */
43
+ $_coreHelper = $this->helper('core');
44
+ $_weeeHelper = $this->helper('weee');
45
+ $_taxHelper = $this->helper('tax');
46
+
47
+ /**
48
+ * @var $_product Mage_Catalog_Model_Product
49
+ * @var $_priceModel Mage_Bundle_Model_Product_Price
50
+ */
51
+ $_priceModel = $_product->getPriceModel();
52
+
53
+ list($_minimalPriceTax, $_maximalPriceTax) = $_priceModel->getTotalPrices($_product, null, null, false);
54
+ list($_minimalPriceInclTax, $_maximalPriceInclTax) = $_priceModel->getTotalPrices($_product, null, true, false);
55
+
56
+ $_weeeTaxAmount = 0;
57
+
58
+ if ($_product->getPriceType() == 1) {
59
+ $_weeeTaxAmount = $_weeeHelper->getAmountForDisplay($_product);
60
+ $_weeeTaxAmountInclTaxes = $_weeeTaxAmount;
61
+ if ($_weeeHelper->isTaxable()) {
62
+ $_attributes = $_weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true);
63
+ $_weeeTaxAmountInclTaxes = $_weeeHelper->getAmountInclTaxes($_attributes);
64
+ }
65
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, array(0, 1, 4))) {
66
+ $_minimalPriceTax += $_weeeTaxAmount;
67
+ $_minimalPriceInclTax += $_weeeTaxAmountInclTaxes;
68
+ $_maximalPriceTax += $_weeeTaxAmount;
69
+ $_maximalPriceInclTax += $_weeeTaxAmountInclTaxes;
70
+ }
71
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)) {
72
+ $_minimalPriceInclTax += $_weeeTaxAmountInclTaxes;
73
+ $_maximalPriceInclTax += $_weeeTaxAmountInclTaxes;
74
+ }
75
+
76
+ if ($_weeeHelper->typeOfDisplay($_product, array(1, 2, 4))) {
77
+ $_weeeTaxAttributes = $_weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true);
78
+ }
79
+ }
80
+ if ($_product->getPriceView()){
81
+ $priceV2['price_label'] = Mage::helper('catalog')->__('As low as');
82
+ $priceV2['minimal_price'] = 1;
83
+ if ($this->displayBothPrices()){
84
+ $priceV2['show_ex_in_price'] = 1;
85
+ $this->setBothTaxPrice($priceV2, $_minimalPriceTax, $_minimalPriceInclTax);
86
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
87
+ $wee = '';
88
+
89
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
90
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
91
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
92
+ }else{
93
+ $amount = $_weeeTaxAttribute->getAmount();
94
+ }
95
+ $wee .= $_weeeTaxAttribute->getName();;
96
+ $wee .= ": ";
97
+ $wee .= $_coreHelper->currency($amount, true, false);
98
+ $wee .= " + ";
99
+ $priceV2["weee"] = $wee;
100
+ }
101
+ $this->setWeePrice($priceV2, $wee);
102
+ $priceV2['show_weee_price'] = 1;
103
+ }
104
+ }else{
105
+ $priceV2['show_ex_in_price'] = 0;
106
+ if ($_taxHelper->displayPriceIncludingTax()){
107
+ $this->setTaxPrice($priceV2, $_minimalPriceInclTax);
108
+ }else{
109
+ $this->setTaxPrice($priceV2, $_minimalPriceTax);
110
+ }
111
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
112
+ $wee = '';
113
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
114
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
115
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
116
+ }else{
117
+ $amount = $_weeeTaxAttribute->getAmount();
118
+ }
119
+ $wee .= $_weeeTaxAttribute->getName();;
120
+ $wee .= ": ";
121
+ $wee .= $_coreHelper->currency($amount, true, false);
122
+ $wee .= " + ";
123
+ $priceV2["weee"] = $wee;
124
+ }
125
+ $this->setWeePrice($priceV2, $wee);
126
+ $priceV2['show_weee_price'] = 1;
127
+ }
128
+ if ($_weeeHelper->typeOfDisplay($_product, 2) && $_weeeTaxAmount){
129
+ $this->setTaxPriceIn($priceV2, $_minimalPriceInclTax);
130
+ }
131
+ }
132
+ }else{
133
+ $priceV2['minimal_price'] = 0;
134
+ if ($_minimalPriceTax <> $_maximalPriceTax){
135
+ $priceV2['product_from_label'] = $this->helper('catalog')->__('From') ;
136
+ $priceV2['product_to_label'] = $this->helper('catalog')->__('To') ;
137
+ $priceV2['show_from_to_tax_price'] = 1;
138
+ if ($this->displayBothPrices()){
139
+ $priceV2['show_ex_in_price'] = 1;
140
+ $this->setBothTaxFromPrice($priceV2, $_minimalPriceTax, $_minimalPriceInclTax);
141
+ $this->setBothTaxToPrice($priceV2, $_maximalPriceTax, $_maximalPriceInclTax);
142
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
143
+ $wee = '';
144
+
145
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
146
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
147
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
148
+ }else{
149
+ $amount = $_weeeTaxAttribute->getAmount();
150
+ }
151
+ $wee .= $_weeeTaxAttribute->getName();;
152
+ $wee .= ": ";
153
+ $wee .= $_coreHelper->currency($amount, true, false);
154
+ $wee .= " + ";
155
+ $priceV2["weee_from"] = $wee;
156
+ $priceV2["weee_to"] = $wee;
157
+ }
158
+ $this->setWeePrice($priceV2, $wee);
159
+ $priceV2['show_weee_price'] = 1;
160
+ }
161
+ }else{
162
+ $priceV2['show_ex_in_price'] = 0;
163
+ if ($_taxHelper->displayPriceIncludingTax()){
164
+ $this->setTaxFromPrice($priceV2, $_minimalPriceInclTax);
165
+ $this->setTaxToPrice($priceV2, $_maximalPriceInclTax);
166
+ }else{
167
+ $this->setTaxFromPrice($priceV2, $_minimalPriceTax);
168
+ $this->setTaxToPrice($priceV2, $_maximalPriceTax);
169
+ }
170
+
171
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
172
+ $wee = '';
173
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
174
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
175
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
176
+ }else{
177
+ $amount = $_weeeTaxAttribute->getAmount();
178
+ }
179
+ $wee .= $_weeeTaxAttribute->getName();;
180
+ $wee .= ": ";
181
+ $wee .= $_coreHelper->currency($amount, true, false);
182
+ $wee .= " + ";
183
+ $priceV2["weee"] = $wee;
184
+ }
185
+ $this->setWeePrice($priceV2, $wee);
186
+ $priceV2['show_weee_price'] = 1;
187
+ }
188
+ if ($_weeeHelper->typeOfDisplay($_product, 2) && $_weeeTaxAmount){
189
+ $this->setTaxFromPrice($priceV2, $_minimalPriceInclTax);
190
+ $this->setTaxToPrice($priceV2, $_maximalPriceInclTax);
191
+ }
192
+ }
193
+ //to price
194
+ }else{
195
+ //not show from and to with tax
196
+ $priceV2['show_from_to_tax_price'] = 0;
197
+ if ($this->displayBothPrices()){
198
+ $priceV2['show_ex_in_price'] = 1;
199
+ $priceV2['product_from_label'] = $this->helper('catalog')->__('From') ;
200
+ $priceV2['product_to_label'] = $this->helper('catalog')->__('To') ;
201
+
202
+ $this->setTaxFromPrice($priceV2, $_minimalPriceTax);
203
+ $this->setTaxToPrice($priceV2, $_minimalPriceInclTax);
204
+
205
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
206
+ $wee = '';
207
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
208
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
209
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
210
+ }else{
211
+ $amount = $_weeeTaxAttribute->getAmount();
212
+ }
213
+ $wee .= $_weeeTaxAttribute->getName();;
214
+ $wee .= ": ";
215
+ $wee .= $_coreHelper->currency($amount, true, false);
216
+ $wee .= " + ";
217
+ $priceV2["weee"] = $wee;
218
+ }
219
+ $this->setWeePrice($priceV2, $wee);
220
+ $priceV2['show_weee_price'] = 1;
221
+ }
222
+ }else{
223
+ $this->setTaxPrice($priceV2, $_minimalPriceTax);
224
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
225
+ $wee = '';
226
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
227
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
228
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
229
+ }else{
230
+ $amount = $_weeeTaxAttribute->getAmount();
231
+ }
232
+ $wee .= $_weeeTaxAttribute->getName();;
233
+ $wee .= ": ";
234
+ $wee .= $_coreHelper->currency($amount, true, false);
235
+ $wee .= " + ";
236
+ $priceV2["weee"] = $wee;
237
+ }
238
+ $this->setWeePrice($priceV2, $wee);
239
+ $priceV2['show_weee_price'] = 1;
240
+ }
241
+ if ($_weeeHelper->typeOfDisplay($_product, 2) && $_weeeTaxAmount){
242
+ if ($_taxHelper->displayPriceIncludingTax()){
243
+ $this->setTaxPrice($priceV2, $_minimalPriceInclTax);
244
+ }else{
245
+ $this->setTaxPrice($priceV2, $_minimalPriceTax + $_weeeTaxAmount);
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }
251
+ if($is_detail){
252
+ $this->_minimalPriceInclTax = $_minimalPriceInclTax;
253
+ $this->_minimalPriceTax = $_minimalPriceTax;
254
+ $priceV2['configure'] = $this->formatPriceFromProductDetail($_product);
255
+ }
256
+ return $priceV2;
257
+ }
258
+
259
+ public function getDisplayMinimalPrice()
260
+ {
261
+ if ($this->_product)
262
+ return $this->_product->getMinimalPrice();
263
+ return 0;
264
+ }
265
+
266
+ /**
267
+ * @param $price
268
+ * @param $_price
269
+ * show type
270
+ * 3 show price only.
271
+ * 4 show price - wee.
272
+ * 5 show wee - price.
273
+ */
274
+ public function setTaxPrice(&$price, $_price)
275
+ {
276
+ $_coreHelper = $this->helper('core');
277
+ // $price['show_type'] = 3;
278
+ $price['price'] = $_coreHelper->currency($_price, false, false);
279
+ }
280
+
281
+ public function setTaxPriceIn(&$price, $_price)
282
+ {
283
+ $_coreHelper = $this->helper('core');
284
+ // $price['show_type'] = 3;
285
+ $price['price_in'] = $_coreHelper->currency($_price, false, false);
286
+ }
287
+
288
+ public function setTaxFromPrice(&$price, $_price)
289
+ {
290
+ $_coreHelper = $this->helper('core');
291
+ // $price['show_type'] = 3;
292
+ $price['from_price'] = $_coreHelper->currency($_price, false, false);
293
+ }
294
+
295
+ public function setTaxToPrice(&$price, $_price)
296
+ {
297
+ $_coreHelper = $this->helper('core');
298
+ // $price['show_type'] = 3;
299
+ $price['to_price'] = $_coreHelper->currency($_price, false, false);
300
+ }
301
+
302
+ /**
303
+ * @param $price
304
+ * @param $_exclTax
305
+ * @param $_inclTax
306
+ * type
307
+ * 0 show price only
308
+ * 1 show ex + wee + in
309
+ * 2 show ex + in + wee
310
+ */
311
+ public function setBothTaxPrice(&$price, $_exclTax, $_inclTax)
312
+ {
313
+ $_coreHelper = $this->helper('core');
314
+ $price['price_excluding_tax'] = array(
315
+ 'label' => $this->helper('tax')->__('Excl. Tax'),
316
+ 'price' => $_coreHelper->currency($_exclTax, false, false),
317
+ );
318
+ $price['price_including_tax'] = array(
319
+ 'label' => $this->helper('tax')->__('Incl. Tax'),
320
+ 'price' => $_coreHelper->currency($_inclTax, false, false),
321
+ );
322
+ }
323
+
324
+ public function setBothTaxFromPrice(&$price, $_exclTax, $_inclTax)
325
+ {
326
+ $_coreHelper = $this->helper('core');
327
+ $price['from_price_excluding_tax'] = array(
328
+ 'label' => $this->helper('tax')->__('Excl. Tax'),
329
+ 'price' => $_coreHelper->currency($_exclTax, false, false),
330
+ );
331
+ $price['from_price_including_tax'] = array(
332
+ 'label' => $this->helper('tax')->__('Incl. Tax'),
333
+ 'price' => $_coreHelper->currency($_inclTax, false, false),
334
+ );
335
+ }
336
+
337
+ public function setBothTaxToPrice(&$price, $_exclTax, $_inclTax)
338
+ {
339
+ $_coreHelper = $this->helper('core');
340
+ $price['to_price_excluding_tax'] = array(
341
+ 'label' => $this->helper('tax')->__('Excl. Tax'),
342
+ 'price' => $_coreHelper->currency($_exclTax, false, false),
343
+ );
344
+ $price['to_price_including_tax'] = array(
345
+ 'label' => $this->helper('tax')->__('Incl. Tax'),
346
+ 'price' => $_coreHelper->currency($_inclTax, false, false),
347
+ );
348
+ }
349
+
350
+ public function setWeePrice(&$price, $wee)
351
+ {
352
+ $price['wee'] = $wee;
353
+ }
354
+
355
+ public function formatPriceFromProductDetail($_product){
356
+ $priceV2 = array();
357
+ $_weeeHelper = $this->helper('weee');
358
+ $_finalPrice = $_product->getFinalPrice() > $this->_minimalPriceTax ? $this->_minimalPriceTax : $_product->getFinalPrice();
359
+ $_finalPriceInclTax = $_product->getFinalPrice()> $this->_minimalPriceInclTax ? $this->_minimalPriceInclTax : $_product->getFinalPrice();
360
+ $_weeeTaxAmount = 0;
361
+
362
+ if ($_product->getPriceType() == 1) {
363
+ $_weeeTaxAmount = Mage::helper('weee')->getAmount($_product);
364
+ if (Mage::helper('weee')->typeOfDisplay($_product, array(1,2,4))) {
365
+ $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForRenderer($_product, null, null, null, true);
366
+ }
367
+ }
368
+ // $isMAPTypeOnGesture = Mage::helper('catalog')->isShowPriceOnGesture($_product);
369
+ $isMAPTypeOnGesture = true;
370
+ $canApplyMAP = Mage::helper('catalog')->canApplyMsrp($_product);
371
+ if ($_product->getCanShowPrice() !== false){
372
+ $priceV2['product_label'] = $this->helper('bundle')->__('Price as configured');
373
+ if ($isMAPTypeOnGesture) {
374
+ if ($this->helper('tax')->displayBothPrices()){
375
+ $priceV2['show_ex_in_price'] = 1;
376
+ if (!$canApplyMAP){
377
+ $this->setBothTaxPrice($priceV2, $_finalPrice, $_finalPriceInclTax);
378
+ }
379
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
380
+ $wee = '';
381
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
382
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
383
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
384
+ }else{
385
+ $amount = $_weeeTaxAttribute->getAmount();
386
+ }
387
+ $wee .= $_weeeTaxAttribute->getName();;
388
+ $wee .= ": ";
389
+ $wee .= $this->helper('core')->currency($amount, true, false);
390
+ $wee .= " + ";
391
+ $priceV2["weee"] = $wee;
392
+ }
393
+ $this->setWeePrice($priceV2, $wee);
394
+ $priceV2['show_weee_price'] = 1;
395
+ }
396
+ }else{
397
+ if (!$canApplyMAP){
398
+ $this->setTaxPrice($priceV2, $_finalPrice);
399
+ }
400
+
401
+ if ($_weeeTaxAmount && $_product->getPriceType() == 1 && $_weeeHelper->typeOfDisplay($_product, array(2, 1, 4))){
402
+ $wee = '';
403
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute){
404
+ if ($_weeeHelper->typeOfDisplay($_product, array(2, 4))){
405
+ $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount();
406
+ }else{
407
+ $amount = $_weeeTaxAttribute->getAmount();
408
+ }
409
+ $wee .= $_weeeTaxAttribute->getName();;
410
+ $wee .= ": ";
411
+ $wee .= $this->helper('core')->currency($amount, true, false);
412
+ $wee .= " + ";
413
+ $priceV2["weee"] = $wee;
414
+ }
415
+ $this->setWeePrice($priceV2, $wee);
416
+ $priceV2['show_weee_price'] = 1;
417
+ }
418
+ }
419
+ }
420
+ }
421
+ return $priceV2;
422
+ }
423
+ }
app/code/local/Simi/Simiconnector/Helper/Bundle/Tierprice.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 11/9/16
7
+ * Time: 1:29 PM
8
+ */
9
+ class Simi_Simiconnector_Helper_Bundle_Tierprice extends Simi_Simiconnector_Helper_Tierprice
10
+ {
11
+ public function formatTierPrice($product) {
12
+ $data = array();
13
+ $_product = $product;
14
+ $_tierPrices = $this->getTierPrices($_product);
15
+ if (count($_tierPrices) > 0) {
16
+ $stringHt = '';
17
+ foreach ($_tierPrices as $_price) {
18
+ $stringHt = Mage::helper('bundle')->__('Buy %1$s with %2$s discount each', $_price['price_qty'], ($_price['price'] * 1) . '%');
19
+ $data[] = $stringHt;
20
+ }
21
+ }
22
+ return $data;
23
+ }
24
+ }
app/code/local/Simi/Simiconnector/Helper/Checkout.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Helper_Checkout extends Mage_Core_Helper_Abstract {
7
+ /*
8
+ * Product Options
9
+ */
10
+
11
+ public function convertOptionsCart($options) {
12
+ $data = array();
13
+ foreach ($options as $option) {
14
+ $data[] = array(
15
+ 'option_title' => $option['label'],
16
+ 'option_value' => $option['value'],
17
+ 'option_price' => isset($option['price']) == true ? $option['price'] : 0,
18
+ );
19
+ }
20
+ return $data;
21
+ }
22
+
23
+ public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item) {
24
+ $options = array();
25
+ $product = $item->getProduct();
26
+ /**
27
+ * @var Mage_Bundle_Model_Product_Type
28
+ */
29
+ $typeInstance = $product->getTypeInstance(true);
30
+
31
+ // get bundle options
32
+ $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
33
+ $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
34
+ if ($bundleOptionsIds) {
35
+ /**
36
+ * @var Mage_Bundle_Model_Mysql4_Option_Collection
37
+ */
38
+ $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
39
+
40
+ // get and add bundle selections collection
41
+ $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
42
+
43
+ $selectionsCollection = $typeInstance->getSelectionsByIds(
44
+ unserialize($selectionsQuoteItemOption->getValue()), $product
45
+ );
46
+
47
+ $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
48
+ foreach ($bundleOptions as $bundleOption) {
49
+ if ($bundleOption->getSelections()) {
50
+
51
+
52
+ $bundleSelections = $bundleOption->getSelections();
53
+
54
+ foreach ($bundleSelections as $bundleSelection) {
55
+ $check = array();
56
+ $qty = Mage::helper('bundle/catalog_product_configuration')->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
57
+ if ($qty) {
58
+ $check[] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName());
59
+ $option = array(
60
+ 'option_title' => $bundleOption->getTitle(),
61
+ 'option_value' => $qty . ' x ' . $this->escapeHtml($bundleSelection->getName()),
62
+ 'option_price' => Mage::helper('core')->currency(Mage::helper('bundle/catalog_product_configuration')->getSelectionFinalPrice($item, $bundleSelection), false),
63
+ );
64
+ }
65
+ }
66
+ if ($check)
67
+ $options[] = $option;
68
+ }
69
+ }
70
+ }
71
+
72
+ return $options;
73
+ }
74
+
75
+ /**
76
+ * Retrieves product options list
77
+ *
78
+ * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
79
+ * @return array
80
+ */
81
+ public function getOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item) {
82
+ return array_merge(
83
+ $this->getBundleOptions($item), $this->convertOptionsCart(Mage::helper('catalog/product_configuration')->getCustomOptions($item))
84
+ );
85
+ }
86
+
87
+ /**
88
+ * for magento < 1.5.0.0
89
+ * @param Mage_Sales_Model_Quote_Item $item
90
+ * @return type
91
+ */
92
+ public function getUsedProductOption(Mage_Sales_Model_Quote_Item $item) {
93
+ $typeId = $item->getProduct()->getTypeId();
94
+ switch ($typeId) {
95
+ case Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE:
96
+ return $this->getConfigurableOptions($item);
97
+ break;
98
+ case Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE:
99
+ return $this->getGroupedOptions($item);
100
+ break;
101
+ }
102
+
103
+ return $this->getCustomOptions($item);
104
+ }
105
+
106
+ public function getConfigurableOptions(Mage_Sales_Model_Quote_Item $item) {
107
+ $product = $item->getProduct();
108
+
109
+ $attributes = $product->getTypeInstance(true)
110
+ ->getSelectedAttributesInfo($product);
111
+ $options = array_merge($attributes, $this->getCustomOptions($item));
112
+ return $this->convertOptionsCart($options);
113
+ }
114
+
115
+ public function getGroupedOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item) {
116
+ return;
117
+ }
118
+
119
+ public function getCustomOptions(Mage_Sales_Model_Quote_Item $item) {
120
+ $options = array();
121
+ $product = $item->getProduct();
122
+ if ($optionIds = $item->getOptionByCode('option_ids')) {
123
+ $options = array();
124
+ foreach (explode(',', $optionIds->getValue()) as $optionId) {
125
+ if ($option = $product->getOptionById($optionId)) {
126
+
127
+ $quoteItemOption = $item->getOptionByCode('option_' . $option->getId());
128
+
129
+ $group = $option->groupFactory($option->getType())
130
+ ->setOption($option)
131
+ ->setQuoteItemOption($quoteItemOption);
132
+
133
+ $options[] = array(
134
+ 'label' => $option->getTitle(),
135
+ 'value' => $group->getFormattedOptionValue($quoteItemOption->getValue()),
136
+ 'print_value' => $group->getPrintableOptionValue($quoteItemOption->getValue()),
137
+ 'option_id' => $option->getId(),
138
+ 'option_type' => $option->getType(),
139
+ 'custom_view' => $group->isCustomizedView()
140
+ );
141
+ }
142
+ }
143
+ }
144
+ if ($addOptions = $item->getOptionByCode('additional_options')) {
145
+ $options = array_merge($options, unserialize($addOptions->getValue()));
146
+ }
147
+ return $this->convertOptionsCart($options);
148
+ }
149
+
150
+ public function getCheckoutTermsAndConditions() {
151
+ if (!Mage::getStoreConfig('simiconnector/terms_conditions/enable_terms'))
152
+ return NULL;
153
+ $data = array();
154
+ $data['title'] = Mage::getStoreConfig('simiconnector/terms_conditions/term_title');
155
+ $data['content'] = Mage::getStoreConfig('simiconnector/terms_conditions/term_html');
156
+ return $data;
157
+ }
158
+
159
+ /*
160
+ * Process order after
161
+ */
162
+ public function processOrderAfter($orderId,&$order){
163
+ /*
164
+ * save To App report
165
+ */
166
+ try {
167
+
168
+ $newTransaction = Mage::getModel('simiconnector/appreport');
169
+ $newTransaction->setOrderId($orderId);
170
+ $newTransaction->save();
171
+ } catch (Exception $exc) {
172
+
173
+ }
174
+
175
+ /*
176
+ * App notification
177
+ */
178
+ if (Mage::getStoreConfig('simiconnector/notification/noti_purchase_enable')) {
179
+ $categoryId = Mage::getStoreConfig('simiconnector/notification/noti_purchase_category_id');
180
+ $category = Mage::getModel('catalog/category')->load($categoryId);
181
+ $categoryName = $category->getName();
182
+ $categoryChildrenCount = $category->getChildrenCount();
183
+ if ($categoryChildrenCount > 0)
184
+ $categoryChildrenCount = 1;
185
+ else
186
+ $categoryChildrenCount = 0;
187
+
188
+ $notification['show_popup'] = '1';
189
+ $notification['title'] = Mage::getStoreConfig('simiconnector/notification/noti_purchase_title');
190
+ $notification['url'] = Mage::getStoreConfig('simiconnector/notification/noti_purchase_url');
191
+ $notification['message'] = Mage::getStoreConfig('simiconnector/notification/noti_purchase_message');
192
+ $notification['notice_sanbox'] = 0;
193
+ $notification['type'] = Mage::getStoreConfig('simiconnector/notification/noti_purchase_type');
194
+ $notification['productID'] = Mage::getStoreConfig('simiconnector/notification/noti_purchase_product_id');
195
+ $notification['categoryID'] = Mage::getStoreConfig('simiconnector/notification/noti_purchase_category_id');
196
+ $notification['categoryName'] = $categoryName;
197
+ $notification['has_children'] = $categoryChildrenCount;
198
+ $notification['created_time'] = now();
199
+ $notification['notice_type'] = 3;
200
+ $order['notification'] = $notification;
201
+ }
202
+ }
203
+
204
+ }
app/code/local/Simi/Simiconnector/Helper/Checkout/Payment.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Checkout_Payment extends Mage_Core_Helper_Abstract {
4
+
5
+ public function _construct() {
6
+ $this->_setListPayment();
7
+ $this->setListCase();
8
+ }
9
+
10
+ public function _getOnepage() {
11
+ return Mage::getSingleton('checkout/type_onepage');
12
+ }
13
+
14
+ protected function _getCart() {
15
+ return Mage::getSingleton('checkout/cart');
16
+ }
17
+
18
+ protected function _getQuote() {
19
+ return $this->_getCart()->getQuote();
20
+ }
21
+
22
+ protected function _getConfig() {
23
+ return Mage::getSingleton('payment/config');
24
+ }
25
+
26
+ public $detail;
27
+ protected $_listPayment = array();
28
+ protected $_listCase;
29
+
30
+ public function savePaymentMethod($data) {
31
+ $method = array('method' => strtolower($data->method));
32
+ if (isset($data->cc_type) && $data->cc_type) {
33
+ $method = array('method' => strtolower($data->method),
34
+ 'cc_type' => $data->cc_type,
35
+ 'cc_number' => $data->cc_number,
36
+ 'cc_exp_month' => $data->cc_exp_month,
37
+ 'cc_exp_year' => $data->cc_exp_year,
38
+ 'cc_cid' => $data->cc_cid,
39
+ );
40
+ }
41
+ $this->_getOnepage()->savePayment($method);
42
+ }
43
+
44
+ /**
45
+ * Add payment method
46
+ * @param $method_code
47
+ * @param $type
48
+ */
49
+ public function addPaymentMethod($method_code, $type) {
50
+ $this->_listPayment[] = $method_code;
51
+ $this->_listPayment = array_unique($this->_listPayment);
52
+ $this->_listCase[$method_code] = $type;
53
+ }
54
+
55
+ public function getMethods() {
56
+ $this->_construct();
57
+ /*
58
+ * Dispatch event simiconnector_add_payment_method
59
+ */
60
+ Mage::dispatchEvent('simiconnector_add_payment_method', array('object' => $this));
61
+
62
+ $quote = $this->_getQuote();
63
+ $store = $quote ? $quote->getStoreId() : null;
64
+ $methods = Mage::helper('payment')->getStoreMethods($store, $quote);
65
+ $total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount();
66
+ foreach ($methods as $key => $method) {
67
+ if ($this->_canUseMethod($method, $quote) && (!in_array($method->getCode(), $this->_getListPaymentNoUse()) &&
68
+ (in_array($method->getCode(), $this->_getListPayment()) || $method->getConfigData('cctypes'))) && ($total != 0 || $method->getCode() == 'free' || ($quote->hasRecurringItems() && $method->canManageRecurringProfiles()))) {
69
+ $this->_assignMethod($method, $quote);
70
+ } else {
71
+ unset($methods[$key]);
72
+ }
73
+ }
74
+ return $methods;
75
+ }
76
+
77
+ protected function _canUseMethod($method, $quote) {
78
+ if (!$method->canUseForCountry($quote->getBillingAddress()->getCountry())) {
79
+ return false;
80
+ }
81
+
82
+ if (!$method->canUseForCurrency($quote->getStore()->getBaseCurrencyCode())) {
83
+ return false;
84
+ }
85
+
86
+ /**
87
+ * Checking for min/max order total for assigned payment method
88
+ */
89
+ $total = $quote->getBaseGrandTotal();
90
+ $minTotal = $method->getConfigData('min_order_total');
91
+ $maxTotal = $method->getConfigData('max_order_total');
92
+
93
+ if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
94
+ return false;
95
+ }
96
+ return true;
97
+ }
98
+
99
+ protected function _getListPaymentNoUse() {
100
+ return array(
101
+ 'authorizenet_directpost'
102
+ );
103
+ }
104
+
105
+ protected function _setListPayment() {
106
+ $this->_listPayment[] = 'transfer_mobile';
107
+ $this->_listPayment[] = 'cashondelivery';
108
+ $this->_listPayment[] = 'banktransfer';
109
+ $this->_listPayment[] = 'checkmo';
110
+ $this->_listPayment[] = 'free';
111
+ $this->_listPayment[] = 'phoenix_cashondelivery';
112
+ }
113
+
114
+ protected function _getListPayment() {
115
+ return $this->_listPayment;
116
+ }
117
+
118
+ protected function _assignMethod($method, $quote) {
119
+ $method->setInfoInstance($quote->getPayment());
120
+ return $this;
121
+ }
122
+
123
+ public function setListCase() {
124
+ $this->_listCase = array(
125
+ 'banktransfer' => 0,
126
+ 'transfer_mobile' => 0,
127
+ 'cashondelivery' => 0,
128
+ 'checkmo' => 0,
129
+ 'free' => 0,
130
+ 'phoenix_cashondelivery' => 0,
131
+ );
132
+ }
133
+
134
+ public function getDetailsPayment($method) {
135
+ $code = $method->getCode();
136
+ $list = $this->getListCase();
137
+
138
+ $type = 1;
139
+ if (in_array($code, $this->_getListPayment())) {
140
+ $type = $list[$code];
141
+ }
142
+
143
+ $detail = array();
144
+ if ($type == 0) {
145
+ if ($code == "checkmo") {
146
+ $detail['payment_method'] = strtoupper($method->getCode());
147
+ $detail['title'] = $method->getConfigData('title');
148
+ $detail['content'] = Mage::helper('simiconnector')->__('Make Check Payable to: ') . $method->getConfigData('payable_to') . Mage::helper('simiconnector')->__('Send Check to: ') . $method->getConfigData('mailing_address');
149
+ $detail['show_type'] = 0;
150
+ } else {
151
+ $detail['content'] = $method->getConfigData('instructions');
152
+ $detail['payment_method'] = strtoupper($method->getCode());
153
+ $detail['title'] = $method->getConfigData('title');
154
+ $detail['show_type'] = 0;
155
+ }
156
+ } elseif ($type == 1) {
157
+ $detail['cc_types'] = $this->getCcAvailableTypes($method);
158
+ $detail['payment_method'] = strtoupper($method->getCode());
159
+ $detail['title'] = $method->getConfigData('title');
160
+ $detail['useccv'] = $method->getConfigData('useccv');
161
+ $detail['is_show_name'] = '0';
162
+ $detail['show_type'] = 1;
163
+ } elseif ($type == 2) {
164
+ $m_code = strtoupper($method->getCode());
165
+ if ($method->getConfigData('business_account'))
166
+ $detail['email'] = $method->getConfigData('business_account');
167
+ if ($method->getConfigData('client_id'))
168
+ $detail['client_id'] = $method->getConfigData('client_id');
169
+ if ($method->getConfigData('is_sandbox'))
170
+ $detail['is_sandbox'] = $method->getConfigData('is_sandbox');
171
+ $detail['payment_method'] = $m_code;
172
+ $detail['title'] = $method->getConfigData('title');
173
+ $detail['show_type'] = 2;
174
+ if (strcasecmp($m_code, 'PAYPAL_MOBILE') == 0) {
175
+ $detail['bncode'] = "Magestore_SI_MagentoCE";
176
+ $detail['use_credit_card'] = Mage::getStoreConfig('payment/paypal_mobile/use_credit_cart');
177
+ }
178
+ } elseif ($type == 3) {
179
+ $detail['payment_method'] = strtoupper($method->getCode());
180
+ $detail['title'] = $method->getConfigData('title');
181
+ $detail['show_type'] = 3;
182
+ }
183
+ $detail['p_method_selected'] = false;
184
+ if ((Mage::getSingleton('checkout/type_onepage')->getQuote()->getPayment()->getMethod()) && (Mage::getSingleton('checkout/type_onepage')->getQuote()->getPayment()->getMethodInstance()->getCode() == $method->getCode())) {
185
+ $detail['p_method_selected'] = true;
186
+ }
187
+ $this->detail = $detail;
188
+ Mage::dispatchEvent('simiconnector_change_payment_detail', array('object' => $this));
189
+ return $this->detail;
190
+ }
191
+
192
+ public function getListCase() {
193
+ return $this->_listCase;
194
+ }
195
+
196
+ public function getCcAvailableTypes($method) {
197
+ $types = $this->_getConfig()->getCcTypes();
198
+ $availableTypes = $method->getConfigData('cctypes');
199
+ $cc_types = array();
200
+ if ($availableTypes) {
201
+ $availableTypes = explode(',', $availableTypes);
202
+ foreach ($types as $code => $name) {
203
+ if (!in_array($code, $availableTypes)) {
204
+ unset($types[$code]);
205
+ } else {
206
+ $cc_types[] = array(
207
+ 'cc_code' => $code,
208
+ 'cc_name' => $name,
209
+ );
210
+ }
211
+ }
212
+ }
213
+ return $cc_types;
214
+ }
215
+
216
+ }
app/code/local/Simi/Simiconnector/Helper/Checkout/Shipping.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Checkout_Shipping extends Mage_Core_Helper_Abstract {
4
+
5
+ public function _getCheckoutSession() {
6
+ return Mage::getSingleton('checkout/session');
7
+ }
8
+
9
+ public function _getOnepage() {
10
+ return Mage::getSingleton('checkout/type_onepage');
11
+ }
12
+
13
+ public function saveShippingMethod($method_code) {
14
+ $this->_getOnepage()->saveShippingMethod($method_code->method);
15
+ }
16
+
17
+ public function getAddress() {
18
+ return $this->_getCheckoutSession()->getShippingAddress();
19
+ }
20
+
21
+ public function getShippingPrice($price, $flag) {
22
+ return $this->_getCheckoutSession()->getQuote()->getStore()->convertPrice(Mage::helper('tax')->getShippingPrice($price, $flag, $this->getAddress()), false);
23
+ }
24
+
25
+ public function getMethods() {
26
+ $shipping = $this->_getCheckoutSession()->getQuote()->getShippingAddress();
27
+ $shipping->collectShippingRates();
28
+ $methods = $shipping->getGroupedAllShippingRates();
29
+
30
+ $list = array();
31
+ foreach ($methods as $_ccode => $_carrier) {
32
+ foreach ($_carrier as $_rate) {
33
+ if ($_rate->getData('error_message') != NULL) {
34
+ continue;
35
+ }
36
+ $select = false;
37
+ if ($shipping->getShippingMethod() != null && $shipping->getShippingMethod() == $_rate->getCode()) {
38
+ $select = true;
39
+ }
40
+
41
+ $s_fee = $this->getShippingPrice($_rate->getPrice(), Mage::helper('tax')->displayShippingPriceIncludingTax());
42
+ $s_fee_incl = $this->getShippingPrice($_rate->getPrice(), true);
43
+
44
+ if (Mage::helper('tax')->displayShippingBothPrices() && $s_fee != $s_fee_incl) {
45
+ $list[] = array(
46
+ 's_method_id' => $_rate->getId(),
47
+ 's_method_code' => $_rate->getCode(),
48
+ 's_method_title' => $_rate->getCarrierTitle(),
49
+ 's_method_fee' => Mage::app()->getStore()->convertPrice(floatval($s_fee), false),
50
+ 's_method_fee_incl_tax' => $s_fee_incl,
51
+ 's_method_name' => $_rate->getMethodTitle(),
52
+ 's_method_selected' => $select,
53
+ );
54
+ } else {
55
+ $list[] = array(
56
+ 's_method_id' => $_rate->getId(),
57
+ 's_method_code' => $_rate->getCode(),
58
+ 's_method_title' => $_rate->getCarrierTitle(),
59
+ 's_method_fee' => $s_fee,
60
+ 's_method_name' => $_rate->getMethodTitle(),
61
+ 's_method_selected' => $select,
62
+ );
63
+ }
64
+ }
65
+ }
66
+ $this->_getCheckoutSession()->getQuote()->collectTotals()->save();
67
+ return $list;
68
+ }
69
+
70
+ }
app/code/local/Simi/Simiconnector/Helper/Cloud.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 11/7/16
7
+ * Time: 1:57 PM
8
+ */
9
+ class Simi_Simiconnector_Helper_Cloud extends Mage_Core_Helper_Abstract
10
+ {
11
+ protected $_json=null;
12
+ public function __construct(){
13
+ if($this->_json == null){
14
+ $this->getConfigfromCloud();
15
+ }
16
+ }
17
+
18
+ public function getConfigfromCloud(){
19
+ ini_set('display_errors', 1);
20
+ $token = (String )Mage::getStoreConfig('simiconnector/general/token_key');
21
+ $ch = curl_init();
22
+ curl_setopt($ch,CURLOPT_URL, "https://api.jajahub.com/rest/app-configs/");
23
+ curl_setopt($ch, CURLOPT_HEADER, false);
24
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
25
+ 'Accept: application/json',
26
+ 'Content-type: application/json',
27
+ 'Authorization: Bearer '.$token,
28
+ ));
29
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
30
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
31
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
32
+ curl_setopt($ch, CURLOPT_AUTOREFERER, true);
33
+ curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
34
+ curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
35
+ $response = curl_exec($ch);
36
+ curl_close($ch);
37
+ $this->_json = json_decode($response, true);
38
+ }
39
+
40
+ //default, matrix, zara
41
+ public function getThemeLayout(){
42
+ $data = $this->_json;
43
+
44
+ if(isset($data['errors']))
45
+ return 'matrix';
46
+
47
+ if(isset($data['app-configs'][0]['layout'])){
48
+ return $data['app-configs'][0]['layout'];
49
+ }
50
+ return 'matrix';
51
+
52
+ }
53
+ }
app/code/local/Simi/Simiconnector/Helper/Coupon.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Coupon extends Mage_Core_Helper_Abstract {
4
+
5
+ protected function _getCart() {
6
+ return Mage::getSingleton('checkout/cart');
7
+ }
8
+
9
+
10
+ public function setCoupon($couponCode) {
11
+ $this->_getCart()->getQuote()->getShippingAddress()->setCollectShippingRates(true);
12
+ $this->_getCart()->getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
13
+ ->collectTotals()
14
+ ->save();
15
+ $total = $this->_getCart()->getQuote()->getTotals();
16
+ $return['discount'] = 0;
17
+ if ($total['discount'] && $total['discount']->getValue()) {
18
+ $return['discount'] = abs($total['discount']->getValue());
19
+ }
20
+ if (strlen($couponCode)) {
21
+ if ($couponCode == $this->_getCart()->getQuote()->getCouponCode() && $return['discount'] != 0) {
22
+ $message = Mage::helper('simiconnector')->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlEscape($couponCode));
23
+ } else {
24
+ $message = Mage::helper('simiconnector')->__('Coupon code "%s" is not valid.', Mage::helper('core')->htmlEscape($couponCode));
25
+ }
26
+ } else {
27
+ $message = Mage::helper('simiconnector')->__('Coupon code was canceled.', Mage::helper('core')->htmlEscape($couponCode));
28
+ }
29
+ return $message;
30
+ }
31
+
32
+ }
app/code/local/Simi/Simiconnector/Helper/Customer.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Helper_Customer extends Mage_Core_Helper_Abstract {
7
+
8
+ protected function _getSession() {
9
+ return Mage::getSingleton('customer/session');
10
+ }
11
+
12
+ public function renewCustomerSesssion($data) {
13
+
14
+ if (isset($data['params']['quote_id']) && $data['params']['quote_id']) {
15
+ $checkoutsession = Mage::getSingleton('checkout/session');
16
+ $checkoutsession->setQuoteId($data['params']['quote_id']);
17
+ }
18
+ if (($data['resource'] == 'customers') && (($data['resourceid'] == 'login') || ($data['resourceid'] == 'sociallogin')))
19
+ return;
20
+
21
+ if (isset($data['contents_array']['email']) && isset($data['contents_array']['password']))
22
+ {
23
+ $data['params']['email'] = $data['contents_array']['email'];
24
+ $data['params']['password'] = $data['contents_array']['password'];
25
+ }
26
+ if ((!isset($data['params']['email'])) || (!isset($data['params']['password'])))
27
+ return;
28
+
29
+ if ((Mage::getSingleton('customer/session')->isLoggedIn()) && (Mage::getSingleton('customer/session')->getCustomer()->getEmail() == $data['params']['email']))
30
+ return;
31
+
32
+ try {
33
+ $this->loginByEmailAndPass($data['params']['email'], $data['params']['password']);
34
+ } catch (Exception $e) {
35
+
36
+ }
37
+ }
38
+
39
+ public function loginByEmailAndPass($username, $password) {
40
+ $websiteId = Mage::app()->getStore()->getWebsiteId();
41
+ $customer = Mage::getModel('customer/customer')
42
+ ->setWebsiteId($websiteId);
43
+ if ($this->validateSimiPass($username, $password)) {
44
+ $customer = $this->getCustomerByEmail($username);
45
+ if ($customer->getId()) {
46
+ $this->loginByCustomer($customer);
47
+ return true;
48
+ }
49
+ } else if ($customer->authenticate($username, $password)) {
50
+ $this->loginByCustomer($customer);
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+
56
+ public function getCustomerByEmail($email) {
57
+ return Mage::getModel('customer/customer')
58
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
59
+ ->loadByEmail($email);
60
+ }
61
+
62
+ public function loginByCustomer($customer) {
63
+ $this->_getSession()->setCustomerAsLoggedIn($customer);
64
+ }
65
+
66
+ public function validateSimiPass($username, $password) {
67
+ if ($password == md5(Mage::getStoreConfig('simiconnector/general/secret_key') . $username)) {
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+ }
app/code/local/Simi/Simiconnector/Helper/Data.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ public $_iphone = 'ios';
6
+ public $_ipad = 'ipad';
7
+ public $_android = 'android';
8
+
9
+
10
+ public function getDevice() {
11
+ return array(
12
+ 1 => 'Iphone',
13
+ 2 => 'Ipad',
14
+ 3 => 'Android',
15
+ );
16
+ }
17
+
18
+
19
+ public function getNameDeviceById($id) {
20
+ $name = '';
21
+ switch ($id) {
22
+ case 1:
23
+ $name = $this->_iphone;
24
+ break;
25
+ case 2:
26
+ $name = $this->_iphone;
27
+ break;
28
+ case 3:
29
+ $name = $this->_android;
30
+ break;
31
+ default :
32
+ $name = $this->_iphone;
33
+ break;
34
+ }
35
+ return $name;
36
+ }
37
+
38
+ public function deleteFile($path) {
39
+ try {
40
+ unlink($path);
41
+ } catch (Exception $e) {
42
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
43
+ }
44
+ }
45
+
46
+ public function getWebsites() {
47
+ $websites = Mage::getModel('core/website')->getCollection();
48
+ return $websites;
49
+ }
50
+
51
+ public function deleteBanner($value) {
52
+ try {
53
+ unlink($value);
54
+ } catch (Exception $e) {
55
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
56
+ }
57
+ }
58
+
59
+ public function getVisibilityTypeId($contentTypeName) {
60
+ switch ($contentTypeName) {
61
+ case 'cms':
62
+ $typeId = 1;
63
+ break;
64
+ case 'banner':
65
+ $typeId = 2;
66
+ break;
67
+ case 'homecategory':
68
+ $typeId = 3;
69
+ break;
70
+ case 'productlist':
71
+ $typeId = 4;
72
+ break;
73
+ case 'storelocator':
74
+ $typeId = 5;
75
+ break;
76
+ default :
77
+ $typeId = 0;
78
+ break;
79
+ }
80
+ return $typeId;
81
+ }
82
+
83
+ }
app/code/local/Simi/Simiconnector/Helper/Options.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/25/16
7
+ * Time: 8:59 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Options extends Mage_Core_Helper_Abstract
10
+ {
11
+ public function helper($helper)
12
+ {
13
+ return Mage::helper('simiconnector/options_' . $helper);
14
+ }
15
+
16
+ public function getOptions($product)
17
+ {
18
+ $type = $product->getTypeId();
19
+ switch ($type) {
20
+ case Mage_Catalog_Model_Product_Type::TYPE_SIMPLE:
21
+ return $this->helper('simple')->getOptions($product);
22
+ break;
23
+ case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE :
24
+ return $this->helper('bundle')->getOptions($product);
25
+ break;
26
+ case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
27
+ return $this->helper('configurable')->getOptions($product);
28
+ break;
29
+ case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
30
+ return $this->helper('grouped')->getOptions($product);
31
+ break;
32
+ case Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL :
33
+ return $this->helper('simple')->getOptions($product);
34
+ break;
35
+ case "downloadable" :
36
+ return $this->helper('download')->getOptions($product);
37
+ break;
38
+ }
39
+ }
40
+ }
app/code/local/Simi/Simiconnector/Helper/Options/Bundle.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/25/16
7
+ * Time: 9:07 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Options_Bundle extends Mage_Core_Helper_Abstract
10
+ {
11
+ function getOptions($product){
12
+ //Mage_Bundle_Block_Catalog_Product_View_Type_Bundle
13
+ $block = Mage::getBlockSingleton('simiconnector/catalog_bundle');
14
+ $block->setProduct($product);
15
+ $options = array();
16
+ $configurable_options = Mage::helper('core')->jsonDecode($block->getJsonConfig());
17
+ $options['bundle_options'] = $configurable_options;
18
+ return $options;
19
+ }
20
+ }
app/code/local/Simi/Simiconnector/Helper/Options/Configurable.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/25/16
7
+ * Time: 9:07 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Options_Configurable extends Mage_Core_Helper_Abstract
10
+ {
11
+ function getOptions($product){
12
+ $block = Mage::getBlockSingleton('catalog/product_view_type_configurable');
13
+ $block->setProduct($product);
14
+ $options = array();
15
+ $configurable_options = Mage::helper('core')->jsonDecode($block->getJsonConfig());
16
+ $options['configurable_options'] = $configurable_options;
17
+ if(!is_null($product->getOptions()) && count($product->getOptions())){
18
+ $custom_options = Mage::helper('simiconnector/options_simple')->getOptions($product);
19
+ $options['custom_options'] = $custom_options['custom_options'];
20
+ }
21
+ return $options;
22
+ }
23
+ }
app/code/local/Simi/Simiconnector/Helper/Options/Download.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/26/16
7
+ * Time: 8:42 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Options_Download extends Mage_Core_Helper_Abstract
10
+ {
11
+ public function getOptions($product)
12
+ {
13
+ $info = array();
14
+ $taxHelper = Mage::helper('tax');
15
+ $block = Mage::getBlockSingleton('downloadable/catalog_product_links');
16
+ $block->setProduct($product);
17
+ //Mage_Catalog_Block_Product_View_Type_Grouped
18
+ $_links = $block->getLinks();
19
+ $_linksPurchasedSeparately = $block->getLinksPurchasedSeparately();
20
+ $_isRequired = $block->getLinkSelectionRequired();
21
+ if ($product->isSaleable() && $block->hasLinks()){
22
+ $item = array(
23
+ 'title' => $block->getLinksTitle(),
24
+ 'type' => 'checkbox',
25
+ 'position' => '0',
26
+ 'links_purchased_separately' => $_linksPurchasedSeparately,
27
+ 'isRequired' => $_isRequired,
28
+ );
29
+
30
+ foreach ($_links as $_link) {
31
+ $value = array(
32
+ 'id' => $_link->getId(),
33
+ 'title' => $block->escapeHtml($_link->getTitle()),
34
+ );
35
+
36
+ $price = $_link->getPrice();
37
+ $_priceInclTax = Mage::helper('core')->currency($this->getPrice($product, $price, true), false, false);
38
+ $_priceExclTax = Mage::helper('core')->currency($this->getPrice($product, $price), false, false);
39
+
40
+ if ($taxHelper->displayPriceIncludingTax()) {
41
+ Mage::helper('simiconnector/price')->setTaxPrice($value, $_priceInclTax);
42
+ } elseif ($taxHelper->displayPriceExcludingTax()) {
43
+ Mage::helper('simiconnector/price')->setTaxPrice($value, $_priceExclTax);
44
+ } elseif ($taxHelper->displayBothPrices()) {
45
+ Mage::helper('simiconnector/price')->setBothTaxPrice($value, $_priceExclTax, $_priceInclTax);
46
+ } else {
47
+ Mage::helper('simiconnector/price')->setTaxPrice($value, $_priceInclTax);
48
+ }
49
+ $item['value'][] = $value;
50
+ }
51
+ $info[] = $item;
52
+ }
53
+ $options = array();
54
+ $options['download_sample'] = $this->getSampleData($product);
55
+ $options['download_options'] = $info;
56
+ if(!is_null($product->getOptions()) && count($product->getOptions())){
57
+ $custom_options = Mage::helper('simiconnector/options_simple')->getOptions($product);
58
+ $options['custom_options'] = $custom_options['custom_options'];
59
+ }
60
+ return $options;
61
+ }
62
+
63
+ public function getPrice($product, $price, $includingTax = null)
64
+ {
65
+ if (!is_null($includingTax)) {
66
+ $price = Mage::helper('tax')->getPrice($product, $price, true);
67
+ } else {
68
+ $price = Mage::helper('tax')->getPrice($product, $price);
69
+ }
70
+ return $price;
71
+ }
72
+
73
+ public function getSampleData($product){
74
+ $info = array();
75
+ $block = Mage::getBlockSingleton('downloadable/catalog_product_samples');
76
+ $block->setProduct($product);
77
+ if ($block->hasSamples()){
78
+ $_samples = $block->getSamples();
79
+ $item = array(
80
+ 'title' => $block->getSamplesTitle(),
81
+ );
82
+ foreach ($_samples as $_sample){
83
+ $value = array(
84
+ 'url' => $block->getSampleUrl($_sample),
85
+ 'title' => $block->escapeHtml($_sample->getTitle()),
86
+ );
87
+ $item['value'][] = $value;
88
+ $info[] = $item;
89
+ }
90
+ }
91
+ return $info;
92
+ }
93
+ }
app/code/local/Simi/Simiconnector/Helper/Options/Grouped.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/25/16
7
+ * Time: 9:07 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Options_Grouped extends Mage_Core_Helper_Abstract
10
+ {
11
+ public function getPrice($product, $price, $includingTax = null)
12
+ {
13
+ if (!is_null($includingTax)) {
14
+ $price = Mage::helper('tax')->getPrice($product, $price, true);
15
+ } else {
16
+ $price = Mage::helper('tax')->getPrice($product, $price);
17
+ }
18
+ return $price;
19
+ }
20
+
21
+ function getOptions($product){
22
+ $info = array();
23
+ $taxHelper = Mage::helper('tax');
24
+ //Mage_Catalog_Block_Product_View_Type_Grouped
25
+ $_associatedProducts = $product->getTypeInstance(true)
26
+ ->getAssociatedProducts($product);
27
+ $_hasAssociatedProducts = count($_associatedProducts) > 0;
28
+ if ($_hasAssociatedProducts){
29
+ foreach ($_associatedProducts as $_item){
30
+ $op = array(
31
+ 'id' => $_item->getId(),
32
+ 'name' => $_item->getName(),
33
+ 'is_salable' => $_item->isSaleable() ? "1":"0",
34
+ 'qty' => is_null($_item->getData('qty')) ? "0" : $_item->getData('qty'),
35
+ 'position' => is_null($_item->getData('position'))? "0": $_item->getData('position'),
36
+ );
37
+
38
+ $final_price = $_item->getFinalPrice();
39
+ $price = $_item->getPrice();
40
+ if($final_price < $price){
41
+ $op['price_label'] = Mage::helper('catalog')->__('Regular Price');
42
+ $op['regular_price'] = $price;
43
+ $op['has_special_price'] = 1;
44
+ $op['special_price_label'] = Mage::helper('catalog')->__('Special Price');
45
+ $_priceInclTax = Mage::helper('core')->currency($this->getPrice($product, $final_price, true), false, false);
46
+ $_priceExclTax = Mage::helper('core')->currency($this->getPrice($product, $final_price), false, false);
47
+ }else{
48
+ $op['has_special_price'] = 0;
49
+ $_priceInclTax = Mage::helper('core')->currency($this->getPrice($product, $price, true), false, false);
50
+ $_priceExclTax = Mage::helper('core')->currency($this->getPrice($product, $price), false, false);
51
+
52
+ }
53
+
54
+ $op['show_ex_in_price'] = 0;
55
+ if ($taxHelper->displayPriceIncludingTax()) {
56
+ Mage::helper('simiconnector/price')->setTaxPrice($op, $_priceInclTax);
57
+ } elseif ($taxHelper->displayPriceExcludingTax()) {
58
+ Mage::helper('simiconnector/price')->setTaxPrice($op, $_priceExclTax);
59
+ } elseif ($taxHelper->displayBothPrices()) {
60
+ $op['show_ex_in_price'] = 1;
61
+ Mage::helper('simiconnector/price')->setBothTaxPrice($op, $_priceExclTax, $_priceInclTax);
62
+ } else {
63
+ Mage::helper('simiconnector/price')->setTaxPrice($op, $_priceInclTax);
64
+ }
65
+ $info[] = $op;
66
+ }
67
+ }
68
+ $options = array();
69
+ $options['grouped_options'] = $info;
70
+ return $options;
71
+ //return $options;
72
+ }
73
+ }
app/code/local/Simi/Simiconnector/Helper/Options/Simple.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/25/16
7
+ * Time: 9:01 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Options_Simple extends Mage_Core_Helper_Abstract
10
+ {
11
+ public function getOptions($product)
12
+ {
13
+ $info = array();
14
+ $taxHelper = Mage::helper('tax');
15
+ $options = Mage::helper('core')->decorateArray($product->getOptions());
16
+ foreach ($options as $option) {
17
+ $item = array();
18
+ $item['id'] = $option->getId();
19
+ $item['title'] = $option->getTitle();
20
+ $item['type'] = $option->getType();
21
+ $item['position'] = $option->getSortOrder();
22
+ $item['isRequired'] = $option->getIsRequire();
23
+ if($option->getType() == "file"){
24
+ $item['file_extension'] = $option->getFileExtension();
25
+ }
26
+ if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
27
+ foreach ($option->getValues() as $value) {
28
+ /* @var $value Mage_Catalog_Model_Product_Option_Value */
29
+ $item_value = array(
30
+ 'id' => $value->getId(),
31
+ 'title' => $value->getTitle(),
32
+ );
33
+ $price = $value->getPrice(true);
34
+ $_priceInclTax = Mage::helper('core')->currency($this->getPrice($product, $price, true), false, false);
35
+ $_priceExclTax = Mage::helper('core')->currency($this->getPrice($product, $price), false, false);
36
+
37
+ if ($taxHelper->displayPriceIncludingTax()) {
38
+ Mage::helper('simiconnector/price')->setTaxPrice($item_value, $_priceInclTax);
39
+ } elseif ($taxHelper->displayPriceExcludingTax()) {
40
+ Mage::helper('simiconnector/price')->setTaxPrice($item_value, $_priceExclTax);
41
+ } elseif ($taxHelper->displayBothPrices()) {
42
+ Mage::helper('simiconnector/price')->setBothTaxPrice($item_value, $_priceExclTax, $_priceInclTax);
43
+ } else {
44
+ Mage::helper('simiconnector/price')->setTaxPrice($item_value, $_priceInclTax);
45
+ }
46
+
47
+ $item['values'][] = $item_value;
48
+ }
49
+ } else {
50
+ $item_value = array();
51
+ $price = $option->getPrice(true);
52
+ $_priceInclTax = Mage::helper('core')->currency($this->getPrice($product, $price, true), false, false);
53
+ $_priceExclTax = Mage::helper('core')->currency($this->getPrice($product, $price), false, false);
54
+
55
+ if ($taxHelper->displayPriceIncludingTax()) {
56
+ Mage::helper('simiconnector/price')->setTaxPrice($item_value, $_priceInclTax);
57
+ } elseif ($taxHelper->displayPriceExcludingTax()) {
58
+ Mage::helper('simiconnector/price')->setTaxPrice($item_value, $_priceExclTax);
59
+ } elseif ($taxHelper->displayBothPrices()) {
60
+ Mage::helper('simiconnector/price')->setBothTaxPrice($item_value, $_priceExclTax, $_priceInclTax);
61
+ } else {
62
+ Mage::helper('simiconnector/price')->setTaxPrice($item_value, $_priceInclTax);
63
+ }
64
+ $item['values'][] = $item_value;
65
+ }
66
+
67
+ $info[] = $item;
68
+ }
69
+ $options = array();
70
+ $options['custom_options'] = $info;
71
+ return $options;
72
+ }
73
+
74
+ public function getPrice($product, $price, $includingTax = null)
75
+ {
76
+ if (!is_null($includingTax)) {
77
+ $price = Mage::helper('tax')->getPrice($product, $price, true);
78
+ } else {
79
+ $price = Mage::helper('tax')->getPrice($product, $price);
80
+ }
81
+ return $price;
82
+ }
83
+
84
+ }
app/code/local/Simi/Simiconnector/Helper/Orders.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 11/4/16
7
+ * Time: 4:05 PM
8
+ */
9
+ class Simi_Simiconnector_Helper_Orders extends Mage_Core_Helper_Abstract
10
+ {
11
+ public function invoiceOrder($order)
12
+ {
13
+ //1 success, 2 fail.
14
+ $result = array(
15
+ 'status_updated' => 1,
16
+ 'message' => "",
17
+ );
18
+ if ($order->canInvoice()) {
19
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
20
+ if ($invoice->getTotalQty()) {
21
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
22
+ $invoice->register();
23
+ $transactionSave = Mage::getModel('core/resource_transaction')
24
+ ->addObject($invoice)
25
+ ->addObject($invoice->getOrder());
26
+ $transactionSave->save();
27
+ $order->setIsInProcess(true);
28
+ $order->addStatusHistoryComment('Invoice was created from Mobile Tracking.', false);
29
+ $order->save();
30
+ $result['message'] = $this->__('Invoice was created from Mobile Tracking.');
31
+ } else {
32
+ $order->addStatusHistoryComment('Cannot create an invoice without products.', false);
33
+ $order->save();
34
+ $result['status_updated'] = 2;
35
+ $result['message'] = $this->__('Cannot create an invoice without products.');
36
+ }
37
+ } else {
38
+ $order->addStatusHistoryComment('Order cannot be invoiced.', false);
39
+ $order->save();
40
+ $result['status_updated'] = 2;
41
+ $result['message'] = $this->__('Order cannot be invoiced.');
42
+ }
43
+ return $result;
44
+ }
45
+
46
+ //$params->is_mail - send email to customer.
47
+ public function shipOrder($order, $params)
48
+ {
49
+ //1 success, 2 fail.
50
+ $result = array(
51
+ 'status_updated' => 1,
52
+ 'message' => "",
53
+ );
54
+ //pending.tracking
55
+ if ($order->canShip()) {
56
+ $shipment = new Mage_Sales_Model_Order_Shipment_Api();
57
+ $shipmentId = $shipment->create($order->getIncrementId());
58
+ // mail customer
59
+ if ($params->is_mail == 1) {
60
+ $shipment->sendInfo($shipmentId);
61
+ }
62
+ $result['message'] = $this->__('The shipment has been created.');
63
+ } else {
64
+ $result['status_updated'] = 2;
65
+ $result['message'] = $this->__('The shipment cannot be created');
66
+ }
67
+ return $result;
68
+ }
69
+
70
+ public function cancelOrder($order)
71
+ {
72
+ //1 success, 2 fail.
73
+ $result = array(
74
+ 'status_updated' => 1,
75
+ 'message' => "",
76
+ );
77
+ if ($order->canCancel()) {
78
+ $order->cancel();
79
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
80
+ $order->addStatusHistoryComment('The order was canceled via Mobile Tracking', false);
81
+ $order->save();
82
+ $result['message'] = $this->__('The order was canceled via Mobile Tracking');
83
+ } else {
84
+ $result['status_updated'] = 2;
85
+ $result['message'] = $this->__('The order cannot be canceled');
86
+ }
87
+ return $result;
88
+ }
89
+
90
+ public function holdOrder($order)
91
+ {
92
+ //1 success, 2 fail.
93
+ $result = array(
94
+ 'status_updated' => 1,
95
+ 'message' => "",
96
+ );
97
+ if ($order->canHold()) {
98
+ $order->hold();
99
+ $order->addStatusHistoryComment('The order was holded via Mobile Tracking', false);
100
+ $order->save();
101
+ $result['message'] = $this->__('The order was holded via Mobile Tracking');
102
+ } else {
103
+ $order->addStatusHistoryComment('The order cannot be holded', false);
104
+ $order->save();
105
+ $result['status_updated'] = 2;
106
+ $result['message'] = $this->__('The order cannot be holded');
107
+ }
108
+ return $result;
109
+ }
110
+
111
+ public function unHoldOrder($order){
112
+ //1 success, 2 fail.
113
+ $result = array(
114
+ 'status_updated' => 1,
115
+ 'message' => "",
116
+ );
117
+ if ($order->canUnhold()) {
118
+ $order->unhold();
119
+ $order->addStatusHistoryComment('The order was unholded via Mobile Tracking', false);
120
+ $order->save();
121
+ $result['message'] = $this->__('The order was unholded via Mobile Tracking');
122
+ } else {
123
+ $order->addStatusHistoryComment('The order cannot be unholded', false);
124
+ $order->save();
125
+ $result['status_updated'] = 2;
126
+ $result['message'] = $this->__('The order cannot be unholded');
127
+ }
128
+
129
+ return $result;
130
+ }
131
+ }
app/code/local/Simi/Simiconnector/Helper/Plugins/Instantcontact.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Scott
6
+ * Date: 6/20/2016
7
+ * Time: 2:09 PM
8
+ */
9
+ class Simi_Simiconnector_Helper_Plugins_Instantcontact extends Mage_Core_Helper_Abstract
10
+ {
11
+
12
+ public function getConfig($value) {
13
+ return Mage::getStoreConfig("simiconnector/instant_contact/" . $value);
14
+ }
15
+ public function isEnabled()
16
+ {
17
+ if($this->getConfig('enable')==1){
18
+ return true;
19
+ }
20
+ return false;
21
+ }
22
+
23
+ public function getContacts(){
24
+ $data = array(
25
+ 'email' => $this->_getEmails(),
26
+ 'phone' => $this->_getPhoneNumbers(),
27
+ 'message' => $this->_getMessageNumbers(),
28
+ 'website' => $this->getConfig("website"),
29
+ 'style' => $this->getConfig("style"),
30
+ 'activecolor' => $this->getConfig("icon_color")
31
+ );
32
+
33
+ return $data;
34
+ }
35
+
36
+ public function _getPhoneNumbers() {
37
+ return explode(",", str_replace(' ', '', $this->getConfig("phone")));
38
+ }
39
+
40
+ public function _getMessageNumbers() {
41
+ return explode(",", str_replace(' ', '', $this->getConfig("message")));
42
+ }
43
+
44
+ public function _getEmails() {
45
+ $emails = explode(",", str_replace(' ', '', $this->getConfig("email")));
46
+ foreach ($emails as $index=>$email) {
47
+ if(!filter_var($email, FILTER_VALIDATE_EMAIL))
48
+ unset($emails[$index]);
49
+ }
50
+ return $emails;
51
+ }
52
+ }
app/code/local/Simi/Simiconnector/Helper/Price.php ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/20/16
7
+ * Time: 8:52 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Price extends Mage_Core_Helper_Abstract
10
+ {
11
+ protected $_product = null;
12
+
13
+ public function helper($helper)
14
+ {
15
+ return Mage::helper($helper);
16
+ }
17
+
18
+ public function getProductAttribute($attribute) {
19
+ return $this->_product->getResource()->getAttribute($attribute);
20
+ }
21
+
22
+ public function formatPriceFromProduct($_product, $is_detail=false)
23
+ {
24
+ $priveV2 = array();
25
+ $this->_product = $_product;
26
+
27
+ $_coreHelper = $this->helper('core');
28
+ $_weeeHelper = $this->helper('weee');
29
+ $_taxHelper = $this->helper('tax');
30
+ /* @var $_coreHelper Mage_Core_Helper_Data */
31
+ /* @var $_weeeHelper Mage_Weee_Helper_Data */
32
+ /* @var $_taxHelper Mage_Tax_Helper_Data */
33
+
34
+ $_storeId = $_product->getStoreId();
35
+ $_store = $_product->getStore();
36
+ $_weeeSeparator = '';
37
+ $_id = $_product->getId();
38
+ $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
39
+ $_minimalPriceValue = $_product->getMinimalPrice();
40
+ $_minimalPriceValue = $_store->roundPrice($_store->convertPrice($_minimalPriceValue));
41
+ $_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
42
+ $_convertedFinalPrice = $_store->roundPrice($_store->convertPrice($_product->getFinalPrice()));
43
+ $_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();
44
+
45
+ if ($_product->getTypeId() == "bundle") {
46
+ return Mage::helper('simiconnector/bundle_price')->formatPriceFromProduct($_product, $is_detail);
47
+ }
48
+
49
+ if (!$_product->isGrouped()) {
50
+ $_weeeTaxAmount = $_weeeHelper->getAmountForDisplay($_product);
51
+ $_weeeTaxAttributes = $_weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true);
52
+ $_weeeTaxAmountInclTaxes = $_weeeTaxAmount;
53
+ if ($_weeeHelper->isTaxable()) {
54
+ $_weeeTaxAmountInclTaxes = $_weeeHelper->getAmountInclTaxes($_weeeTaxAttributes);
55
+ }
56
+ $_weeeTaxAmount = $_store->roundPrice($_store->convertPrice($_weeeTaxAmount));
57
+ $_weeeTaxAmountInclTaxes = $_store->roundPrice($_store->convertPrice($_weeeTaxAmountInclTaxes));
58
+
59
+ //price box
60
+ $_convertedPrice = $_store->roundPrice($_store->convertPrice($_product->getPrice()));
61
+ $_price = $_taxHelper->getPrice($_product, $_convertedPrice);
62
+ $_regularPrice = $_taxHelper->getPrice($_product, $_convertedPrice, $_simplePricesTax);
63
+ $_finalPrice = $_taxHelper->getPrice($_product, $_convertedFinalPrice);
64
+ $_finalPriceInclTax = $_taxHelper->getPrice($_product, $_convertedFinalPrice, true);
65
+ $_weeeDisplayType = $_weeeHelper->getPriceDisplayType();
66
+ if ($_finalPrice >= $_price) {
67
+ $priveV2['has_special_price'] = 0;
68
+ if ($_taxHelper->displayBothPrices()) {
69
+ $priveV2['show_ex_in_price'] = 1;
70
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)) {
71
+ $_exclTax = $_price + $_weeeTaxAmount;
72
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
73
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
74
+ }elseif($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)){
75
+ $wee ='';
76
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
77
+ $wee .= $_weeeTaxAttribute->getName();
78
+ $wee .= ": ";
79
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
80
+ $wee .= " + ";
81
+ $priveV2["weee"] = $wee;
82
+ }
83
+ $this->setWeePrice($priveV2, $wee);
84
+ $_exclTax = $_price + $_weeeTaxAmount;
85
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
86
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
87
+ //$priveV2['show_type'] = 1;
88
+ $priveV2['show_weee_price'] = 1;
89
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)){
90
+ $wee ='';
91
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
92
+ $wee .= $_weeeTaxAttribute->getName();
93
+ $wee .= ": ";
94
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
95
+ $wee .= " + ";
96
+ $priveV2["weee"] = $wee;
97
+ }
98
+ $this->setWeePrice($priveV2, $wee);
99
+ $_exclTax = $_price + $_weeeTaxAmount;
100
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
101
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
102
+ //$priveV2['show_type'] = 2;
103
+ $priveV2['show_weee_price'] = 2;
104
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)){
105
+ $wee ='';
106
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
107
+ $wee .= $_weeeTaxAttribute->getName();
108
+ $wee .= ": ";
109
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
110
+ $wee .= " <br/> ";
111
+ $priveV2["weee"] = $wee;
112
+ }
113
+ $this->setWeePrice($priveV2, $wee);
114
+ $_exclTax = $_price;
115
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
116
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
117
+ //$priveV2['show_type'] = 1;
118
+ $priveV2['show_weee_price'] = 1;
119
+ }else{
120
+ $_exclTax = $_finalPrice;
121
+ if ($_finalPrice == $_price){
122
+ $_exclTax = $_price;
123
+ }
124
+ $_inclTax = $_finalPriceInclTax;
125
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
126
+ }
127
+ }else{
128
+ $priveV2['show_ex_in_price'] = 0;
129
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, array(0, 1))){
130
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
131
+ $weeeAmountToDisplay = $_taxHelper->displayPriceIncludingTax() ? $_weeeTaxAmountInclTaxes : $_weeeTaxAmount;
132
+ $this->setTaxReguarlPrice($priveV2, $_price + $weeeAmountToDisplay);
133
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)){
134
+ $wee ='';
135
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
136
+ $wee .= $_weeeTaxAttribute->getName();
137
+ $wee .= ": ";
138
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
139
+ $wee .= " + ";
140
+ $priveV2["weee"] = $wee;
141
+ }
142
+ //$priveV2['show_type'] = 4;
143
+ $priveV2['show_weee_price'] = 1;
144
+ }
145
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)){
146
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
147
+ $this->setTaxReguarlPrice($priveV2, $_price + $_weeeTaxAmount);
148
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)){
149
+ $wee ='';
150
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
151
+ $wee .= $_weeeTaxAttribute->getName();
152
+ $wee .= ": ";
153
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
154
+ $wee .= " + ";
155
+ $priveV2["weee"] = $wee;
156
+ }
157
+ //$priveV2['show_type'] = 4;
158
+ $priveV2['show_weee_price'] = 1;
159
+ }
160
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)){
161
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
162
+ $weeeAmountToDisplay = $_taxHelper->displayPriceIncludingTax() ? $_weeeTaxAmountInclTaxes : $_weeeTaxAmount;
163
+ $this->setTaxReguarlPrice($priveV2, $_price + $weeeAmountToDisplay);
164
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)){
165
+ $wee ='';
166
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
167
+ $wee .= $_weeeTaxAttribute->getName();
168
+ $wee .= ": ";
169
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
170
+ $wee .= " <br/> ";
171
+ $priveV2["weee"] = $wee;
172
+ }
173
+ $priveV2['show_weee_price'] = 2;
174
+ }
175
+ }else{
176
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
177
+ if ($_finalPrice == $_price){
178
+ $this->setTaxPrice($priveV2, $_finalPrice);
179
+ }else{
180
+ $this->setTaxPrice($priveV2, $_price);
181
+ }
182
+ }
183
+ }
184
+ }else{ /* if ($_finalPrice == $_price): */
185
+ $priveV2['has_special_price'] = 1;
186
+ $_originalWeeeTaxAmount = $_weeeHelper->getOriginalAmount($_product);
187
+ $_originalWeeeTaxAmount = $_store->roundPrice($_store->convertPrice($_originalWeeeTaxAmount));
188
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)){
189
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
190
+ $this->setTaxReguarlPrice($priveV2, $_regularPrice + $_originalWeeeTaxAmount);
191
+ if ($_taxHelper->displayBothPrices()){
192
+ $priveV2['show_ex_in_price'] = 1;
193
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
194
+ $_exclTax = $_finalPrice + $_weeeTaxAmount;
195
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
196
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
197
+ }else{
198
+ $priveV2['show_ex_in_price'] = 0;
199
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
200
+ $this->setTaxPrice($priveV2, $_finalPrice + $_weeeTaxAmountInclTaxes);
201
+ }
202
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)){
203
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
204
+ $this->setTaxReguarlPrice($priveV2, $_regularPrice + $_originalWeeeTaxAmount);
205
+ if ($_taxHelper->displayBothPrices()){
206
+ $priveV2['show_ex_in_price'] = 1;
207
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
208
+ $_exclTax = $_finalPrice + $_weeeTaxAmount;
209
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
210
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
211
+ $wee ='';
212
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
213
+ $wee .= $_weeeTaxAttribute->getName();
214
+ $wee .= ": ";
215
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
216
+ $wee .= " + ";
217
+ $priveV2["weee"] = $wee;
218
+ }
219
+ $this->setWeePrice($priveV2, $wee);
220
+ $priveV2['show_weee_price'] = 1;
221
+ }else{
222
+ $priveV2['show_ex_in_price'] = 0;
223
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
224
+ $this->setTaxPrice($priveV2, $_finalPrice + $_weeeTaxAmountInclTaxes);
225
+ $wee ='';
226
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
227
+ $wee .= $_weeeTaxAttribute->getName();
228
+ $wee .= ": ";
229
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
230
+ $wee .= " + ";
231
+ $priveV2["weee"] = $wee;
232
+ }
233
+ $this->setWeePrice($priveV2, $wee);
234
+ $priveV2['show_weee_price'] = 1;
235
+ }
236
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)){
237
+ $priveV2['show_ex_in_price'] = 1;
238
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
239
+ $this->setTaxReguarlPrice($priveV2, $_regularPrice + $_originalWeeeTaxAmount);
240
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
241
+ $_exclTax = $_finalPrice + $_weeeTaxAmount;
242
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
243
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
244
+ $wee ='';
245
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
246
+ $wee .= $_weeeTaxAttribute->getName();
247
+ $wee .= ": ";
248
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
249
+ $wee .= " + ";
250
+ $priveV2["weee"] = $wee;
251
+ }
252
+ $this->setWeePrice($priveV2, $wee);
253
+ $priveV2['show_weee_price'] = 1;
254
+ }elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)){
255
+ $priveV2['show_ex_in_price'] = 1;
256
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
257
+ $this->setTaxReguarlPrice($priveV2, $_regularPrice);
258
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
259
+ $_exclTax = $_finalPrice;
260
+ $_inclTax = $_finalPriceInclTax + $_weeeTaxAmountInclTaxes;
261
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
262
+ $wee ='';
263
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
264
+ $wee .= $_weeeTaxAttribute->getName();
265
+ $wee .= ": ";
266
+ $wee .= $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false);
267
+ $wee .= " <br/> ";
268
+ $priveV2["weee"] = $wee;
269
+ }
270
+ $this->setWeePrice($priveV2, $wee);
271
+ $priveV2['show_weee_price'] = 1;
272
+ }else{
273
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Regular Price');
274
+ $this->setTaxReguarlPrice($priveV2, $_regularPrice);
275
+ if ($_taxHelper->displayBothPrices()){
276
+ $priveV2['show_ex_in_price'] = 1;
277
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
278
+ $_exclTax = $_finalPrice;
279
+ $_inclTax = $_finalPriceInclTax;
280
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
281
+ }else{
282
+ $priveV2['show_ex_in_price'] = 0;
283
+ $priveV2['special_price_label'] = $_specialPriceStoreLabel;
284
+ $this->setTaxPrice($priveV2, $_finalPrice);
285
+ }
286
+ }
287
+ }//end /* if ($_finalPrice == $_price): */
288
+ if ($this->getDisplayMinimalPrice() && $_minimalPriceValue && $_minimalPriceValue < $_convertedFinalPrice){
289
+ $_minimalPriceDisplayValue = $_minimalPrice;
290
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, array(0, 1, 4))){
291
+ $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount;
292
+ }
293
+
294
+ $priveV2['is_low_price'] = 1;
295
+ $priveV2['low_price_label'] = Mage::helper('catalog')->__('As low as');
296
+ $this->setTaxLowPrice($priveV2, $_minimalPriceDisplayValue);
297
+
298
+ }
299
+ } else { // group product
300
+ $showMinPrice = $this->getDisplayMinimalPrice();
301
+ if ($showMinPrice && $_minimalPriceValue) {
302
+ $_exclTax = $_taxHelper->getPrice($_product, $_minimalPriceValue);
303
+ $_inclTax = $_taxHelper->getPrice($_product, $_minimalPriceValue, true);
304
+ $price = $showMinPrice ? $_minimalPriceValue : 0;
305
+ } else {
306
+ $price = $_convertedFinalPrice;
307
+ $_exclTax = $_taxHelper->getPrice($_product, $price);
308
+ $_inclTax = $_taxHelper->getPrice($_product, $price, true);
309
+ }
310
+
311
+ if ($price) {
312
+ if ($showMinPrice) {
313
+ $priveV2['price_label'] = Mage::helper('catalog')->__('Starting at');
314
+ }
315
+ if ($_taxHelper->displayBothPrices()) {
316
+ $priveV2['show_ex_in_price'] = 1;
317
+ $this->setBothTaxPrice($priveV2, $_exclTax, $_inclTax);
318
+ } else {
319
+ $priveV2['show_ex_in_price'] = 0;
320
+ $_showPrice = $_inclTax;
321
+ if (!$_taxHelper->displayPriceIncludingTax()) {
322
+ $_showPrice = $_exclTax;
323
+ }
324
+ $this->setTaxPrice($priveV2, $_showPrice);
325
+ }
326
+ }
327
+ }
328
+ return $priveV2;
329
+ }
330
+
331
+ public function getDisplayMinimalPrice()
332
+ {
333
+ if ($this->_product)
334
+ return $this->_product->getMinimalPrice();
335
+ return 0;
336
+ }
337
+
338
+ /**
339
+ * @param $price
340
+ * @param $_price
341
+ * show type
342
+ * 3 show price only.
343
+ * 4 show price - wee.
344
+ * 5 show wee - price.
345
+ */
346
+ public function setTaxReguarlPrice(&$price, $_price)
347
+ {
348
+ $_coreHelper = $this->helper('core');
349
+ // $price['show_type'] = 3;
350
+ $price['regular_price'] = $_price;
351
+ }
352
+
353
+ /**
354
+ * @param $price
355
+ * @param $_price
356
+ * show type
357
+ * 3 show price only.
358
+ * 4 show price - wee.
359
+ * 5 show wee - price.
360
+ */
361
+ public function setTaxPrice(&$price, $_price)
362
+ {
363
+ $_coreHelper = $this->helper('core');
364
+ // $price['show_type'] = 3;
365
+ $price['price'] = $_price;
366
+ }
367
+
368
+ public function setTaxLowPrice(&$price, $_price)
369
+ {
370
+ $_coreHelper = $this->helper('core');
371
+ // $price['show_type'] = 3;
372
+ $price['low_price'] = $_price;
373
+ }
374
+ /**
375
+ * @param $price
376
+ * @param $_exclTax
377
+ * @param $_inclTax
378
+ * type
379
+ * 0 show price only
380
+ * 1 show ex + wee + in
381
+ * 2 show ex + in + wee
382
+ */
383
+ public function setBothTaxPrice(&$price, $_exclTax, $_inclTax)
384
+ {
385
+ $price['price_excluding_tax'] = array(
386
+ 'label' => $this->helper('tax')->__('Excl. Tax'),
387
+ 'price' => $_exclTax,
388
+ );
389
+ $price['price_including_tax'] = array(
390
+ 'label' => $this->helper('tax')->__('Incl. Tax'),
391
+ 'price' => $_inclTax,
392
+ );
393
+ }
394
+
395
+ public function setWeePrice(&$price, $wee)
396
+ {
397
+ $price['wee'] = $wee;
398
+ }
399
+ }
app/code/local/Simi/Simiconnector/Helper/Productlabel.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Productlabel extends Mage_Core_Helper_Abstract {
4
+
5
+ static public function getOptionArray() {
6
+ return array(
7
+ 1 => Mage::helper('simiconnector')->__('Top-left'),
8
+ 2 => Mage::helper('simiconnector')->__('Top-center'),
9
+ 3 => Mage::helper('simiconnector')->__('Top-right'),
10
+ 4 => Mage::helper('simiconnector')->__('Middle-left'),
11
+ 5 => Mage::helper('simiconnector')->__('Middle-center'),
12
+ 6 => Mage::helper('simiconnector')->__('Middle-right'),
13
+ 7 => Mage::helper('simiconnector')->__('Bottom-left'),
14
+ 8 => Mage::helper('simiconnector')->__('Bottom-center'),
15
+ 9 => Mage::helper('simiconnector')->__('Bottom-right'),
16
+ );
17
+ }
18
+
19
+ /**
20
+ * get model option hash as array
21
+ *
22
+ * @return array
23
+ */
24
+ static public function getOptionHash() {
25
+ $options = array();
26
+ foreach (self::getOptionArray() as $value => $label) {
27
+ $options[] = array(
28
+ 'value' => $value,
29
+ 'label' => $label
30
+ );
31
+ }
32
+ return $options;
33
+ }
34
+
35
+ public function getProductLabel($product) {
36
+ if (!Mage::getStoreConfig("simiconnector/productlabel/enable"))
37
+ return;
38
+
39
+ foreach (Mage::getModel('simiconnector/simiproductlabel')->getCollection()->setOrder('priority','DESC') as $productLabel) {
40
+ if($productLabel->getData('status') == Simi_Simiconnector_Model_Status::STATUS_DISABLED)
41
+ continue;
42
+ if($productLabel->getData('storeview_id') != Mage::app()->getStore()->getId())
43
+ continue;
44
+
45
+ foreach (explode(',', str_replace(' ', '', $productLabel->getData('product_ids'))) as $productId) {
46
+ if ($product->getId() == $productId) {
47
+ return array(
48
+ 'name'=> $productLabel->getData('name'),
49
+ 'label_id'=> $productLabel->getData('label_id'),
50
+ 'description'=> $productLabel->getData('description'),
51
+ 'text'=> $productLabel->getData('text'),
52
+ 'image'=> $productLabel->getData('image'),
53
+ 'position'=> $productLabel->getData('position'),
54
+ );
55
+ }
56
+ }
57
+
58
+ }
59
+ }
60
+
61
+ }
app/code/local/Simi/Simiconnector/Helper/Productlist.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Productlist extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function getListTypeId()
7
+ {
8
+ return array(
9
+ 1 => Mage::helper('simiconnector')->__('Custom Product List'),
10
+ 2 => Mage::helper('simiconnector')->__('Best Seller'),
11
+ 3 => Mage::helper('simiconnector')->__('Most View'),
12
+ 4 => Mage::helper('simiconnector')->__('Newly Updated'),
13
+ 5 => Mage::helper('simiconnector')->__('Recently Added')
14
+ );
15
+ }
16
+
17
+ public function getTypeOption()
18
+ {
19
+ return array(
20
+ array('value' => 1, 'label' => Mage::helper('simiconnector')->__('Custom Product List')),
21
+ array('value' => 2, 'label' => Mage::helper('simiconnector')->__('Best Seller')),
22
+ array('value' => 3, 'label' => Mage::helper('simiconnector')->__('Most View')),
23
+ array('value' => 4, 'label' => Mage::helper('simiconnector')->__('Newly Updated')),
24
+ array('value' => 5, 'label' => Mage::helper('simiconnector')->__('Recently Added')),
25
+ );
26
+ }
27
+
28
+ public function getProductCollection($listModel)
29
+ {
30
+ $storeId = Mage::app()->getStore()->getId();
31
+ $collection = Mage::getResourceModel('catalog/product_collection')
32
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')
33
+ ->getProductAttributes())
34
+ ->addMinimalPrice()
35
+ ->addFinalPrice()
36
+ ->addTaxPercents()
37
+ ->addUrlRewrite();
38
+ switch ($listModel->getData('list_type')) {
39
+ //Product List
40
+ case 1:
41
+ $collection->addFieldToFilter('entity_id', array('in' => explode(',', $listModel->getData('list_products'))));
42
+ break;
43
+ //Best seller
44
+ case 2:
45
+ $collection = Mage::getResourceModel('reports/product_collection')
46
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
47
+ ->addOrderedQty()->addMinimalPrice()
48
+ ->addTaxPercents()
49
+ ->addStoreFilter()
50
+ ->setOrder('ordered_qty', 'desc');
51
+ $collection->getSelect()->joinInner(array('e2' => 'catalog_product_flat_' . $storeId), 'e2.entity_id = e.entity_id');
52
+ break;
53
+ //Most Viewed
54
+ case 3:
55
+ $collection = Mage::getResourceModel('reports/product_collection')
56
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
57
+ ->addViewsCount()
58
+ ->addMinimalPrice()
59
+ ->addTaxPercents()
60
+ ->addStoreFilter();
61
+ $collection->getSelect()->joinInner(array('e2' => 'catalog_product_flat_' . $storeId), 'e2.entity_id = e.entity_id');
62
+ break;
63
+ //New Updated
64
+ case 4:
65
+ $collection->setOrder('updated_at', 'desc');
66
+ break;
67
+ //Recently Added
68
+ case 5:
69
+ $collection->setOrder('created_at', 'desc');
70
+ break;
71
+ default:
72
+ break;
73
+ }
74
+
75
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
76
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
77
+
78
+ return $collection;
79
+ }
80
+
81
+ /*
82
+ * Matrix Helper Functions
83
+ */
84
+
85
+ public function getMatrixRowOptions()
86
+ {
87
+ $rows = array();
88
+ $highestRow = 0;
89
+ foreach (Mage::getModel('simiconnector/simicategory')->getCollection() as $simicat) {
90
+ $currentIndex = $simicat->getData('matrix_row');
91
+ if (!$rows[$currentIndex])
92
+ $rows[$currentIndex] = array();
93
+ if ($currentIndex >= $highestRow)
94
+ $highestRow = $currentIndex + 1;
95
+ $rows[$currentIndex][] = $simicat->getData('simicategory_name');
96
+ }
97
+ foreach (Mage::getModel('simiconnector/productlist')->getCollection() as $productlist) {
98
+ $currentIndex = $productlist->getData('matrix_row');
99
+ if (!$rows[$currentIndex])
100
+ $rows[$currentIndex] = array();
101
+ if ($currentIndex >= $highestRow)
102
+ $highestRow = $currentIndex + 1;
103
+ $rows[$currentIndex][] = $productlist->getData('list_title');
104
+ }
105
+ ksort($rows);
106
+ $returnArray = array(array('value' => $highestRow, 'label' => 'Create New Row'));
107
+ foreach ($rows as $index => $row)
108
+ $returnArray[] = array('value' => $index, 'label' => $index . '-' . implode(',', $row));
109
+ return $returnArray;
110
+ }
111
+
112
+ public function getMatrixLayoutMockup($storeviewid)
113
+ {
114
+ $rows = array();
115
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('homecategory');
116
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
117
+ $simicategoryCollection = Mage::getModel('simiconnector/simicategory')->getCollection()->setOrder('sort_order', 'desc')->addFieldToFilter('status', '1');;
118
+ $simicategoryCollection->getSelect()
119
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.simicategory_id AND visibility.content_type = ' . $typeID . ' AND visibility.store_view_id =' . $storeviewid);
120
+
121
+
122
+ foreach ($simicategoryCollection as $simicat) {
123
+ if (!$rows[$simicat->getData('matrix_row')])
124
+ $rows[(int)$simicat->getData('matrix_row')] = array();
125
+
126
+ $editUrl = Mage::helper("adminhtml")->getUrl('*/simiconnector_simicategory/edit', array('id' => $simicat->getId()));
127
+ $title = '<a href="' . $editUrl . '" style="background-color:rgba(255,255,255,0.7); text-decoration:none; text-transform: uppercase; color: black">' . $simicat->getData('simicategory_name') . '</a>';
128
+
129
+ $rows[(int)$simicat->getData('matrix_row')][] = array(
130
+ 'id' => $simicat->getId(),
131
+ 'image' => $simicat->getData('simicategory_filename'),
132
+ 'image_tablet' => $simicat->getData('simicategory_filename_tablet'),
133
+ 'matrix_width_percent' => $simicat->getData('matrix_width_percent'),
134
+ 'matrix_height_percent' => $simicat->getData('matrix_height_percent'),
135
+ 'matrix_width_percent_tablet' => $simicat->getData('matrix_width_percent_tablet'),
136
+ 'matrix_height_percent_tablet' => $simicat->getData('matrix_height_percent_tablet'),
137
+ 'title' => $title,
138
+ 'sort_order' => $simicat->getData('sort_order')
139
+ );
140
+ }
141
+
142
+ $listtypeID = Mage::helper('simiconnector')->getVisibilityTypeId('productlist');
143
+ $listCollection = Mage::getModel('simiconnector/productlist')->getCollection()->addFieldToFilter('list_status', '1');
144
+ $listCollection->getSelect()
145
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.productlist_id AND visibility.content_type = ' . $listtypeID . ' AND visibility.store_view_id =' . $storeviewid);
146
+
147
+ foreach ($listCollection as $productlist) {
148
+ if (!$rows[$productlist->getData('matrix_row')])
149
+ $rows[(int)$productlist->getData('matrix_row')] = array();
150
+
151
+ $editUrl = Mage::helper("adminhtml")->getUrl('*/*/edit', array('id' => $productlist->getId()));
152
+ $title = '<a href="' . $editUrl . '" style="background-color:rgba(255,255,255,0.7); text-decoration:none; text-transform: uppercase; color: black">' . $productlist->getData('list_title') . ' </a>';
153
+ $rows[(int)$productlist->getData('matrix_row')][] = array(
154
+ 'id' => $productlist->getId(),
155
+ 'image' => $productlist->getData('list_image'),
156
+ 'image_tablet' => $productlist->getData('list_image_tablet'),
157
+ 'matrix_width_percent' => $productlist->getData('matrix_width_percent'),
158
+ 'matrix_height_percent' => $productlist->getData('matrix_height_percent'),
159
+ 'matrix_width_percent_tablet' => $productlist->getData('matrix_width_percent_tablet'),
160
+ 'matrix_height_percent_tablet' => $productlist->getData('matrix_height_percent_tablet'),
161
+ 'title' => $title,
162
+ 'sort_order' => $productlist->getData('sort_order')
163
+ );
164
+ }
165
+ ksort($rows);
166
+ try {
167
+ foreach ($rows as $index => $row) {
168
+ usort($row, function ($a, $b) {
169
+ return $a['sort_order'] - $b['sort_order'];
170
+ });
171
+ $rows[$index] = $row;
172
+ }
173
+ } catch (Exception $e) {
174
+
175
+ }
176
+ $html = '</br> <b> Matrix Theme Mockup Preview: </b></br>(Save Item to update your Changes)</br></br>';
177
+ $html .= '<table><tr><td style="text-align:center">Phone Screen Mockup Preview: </br>';
178
+ $html .= $this->drawMatrixMockupTable(170, 320, false, $rows);
179
+ $html .= '</td><td> </td><td style="text-align:center">Tablet Screen Mockup Preview: </br>';
180
+ $html .= $this->drawMatrixMockupTable(178, 512, true, $rows) . '</td></tr></table>';
181
+ return $html;
182
+ }
183
+
184
+ public function drawMatrixMockupTable($bannerHeight, $bannerWidth, $is_tablet, $rows)
185
+ {
186
+ if (!$is_tablet) {
187
+ $margin = 8;
188
+ $screenHeight = 568;
189
+ $topmargin = 30;
190
+ $bottommargin = 70;
191
+ } else {
192
+ $margin = 25;
193
+ $screenHeight = 384;
194
+ $topmargin = 10;
195
+ $bottommargin = 50;
196
+ }
197
+ //phone shape
198
+ $html = '<div style="background-color:black; width:' . ($bannerWidth + $margin * 2) . 'px; height:' . ($screenHeight + $topmargin + $bottommargin) . 'px; border-radius: 30px;"><br>';
199
+ //screen
200
+ $html .= '<div style="background-color:white; width:' . $bannerWidth . 'px;margin :' . $margin . 'px; height:' . $screenHeight . 'px ;margin-top: ' . $topmargin . 'px ; overflow-y:scroll; overflow-x:hidden;">';
201
+ //logo (navigation)
202
+ $html .= '<span style="color:white ; font-size: 18px; line-height: 35px; margin: 0 0 24px;"> <div> <div style= "background-color:#FF6347; width:' . $bannerWidth . '; height:' . ($bannerHeight / 6) . 'px ; text-align:center; background-image:url(https://www.simicart.com/skin/frontend/default/simicart2.0/images/menu.jpg); background-repeat:no-repeat;background-size: ' . ($bannerHeight / 6) . 'px ' . ($bannerHeight / 6) . 'px; " ><b>APPLICATION LOGO</b></div></div>';
203
+ //banner
204
+ $html .= '<div style="background-color:#cccccc; height:' . $bannerHeight . 'px; width:' . $bannerWidth . 'px;"><br><br><b>BANNER AREA</b></div>';
205
+ //categories and product lists
206
+ foreach ($rows as $row) {
207
+ $totalWidth = 0;
208
+ $cells = '';
209
+ foreach ($row as $rowItem) {
210
+
211
+ if ($is_tablet) {
212
+ if ($rowItem['image_tablet'] != null)
213
+ $rowItem['image'] = $rowItem['image_tablet'];
214
+ if ($rowItem['matrix_width_percent_tablet'] != null)
215
+ $rowItem['matrix_width_percent'] = $rowItem['matrix_width_percent_tablet'];
216
+ if ($rowItem['matrix_height_percent_tablet'] != null)
217
+ $rowItem['matrix_height_percent'] = $rowItem['matrix_height_percent_tablet'];
218
+ }
219
+
220
+ $rowWidth = $rowItem['matrix_width_percent'] * $bannerWidth / 100;
221
+ $rowHeight = $rowItem['matrix_height_percent'] * $bannerWidth / 100;
222
+ $totalWidth += $rowWidth;
223
+
224
+ $cells .= '<span style="display:inline-block; width:' . $rowWidth . 'px; height: ' . $rowHeight . 'px;
225
+ overflow:hidden; background-image:url(' . $rowItem['image'] . '); background-repeat:no-repeat;
226
+ background-size: ' . $rowWidth . 'px ' . $rowHeight . 'px;">' . $rowItem['title'] . '</span>';
227
+ }
228
+ if ($totalWidth > $rowWidth)
229
+ $style = 'overflow-x: scroll; overflow-y: hidden;';
230
+ else
231
+ $style = 'overflow: hidden;';
232
+ $html .= '<div style="' . $style . 'width: ' . $bannerWidth . 'px"> <div style="width:' . $totalWidth . 'px; height:' . $rowHeight . 'px">' . $cells;
233
+ $html .= '</div></div>';
234
+ }
235
+ $html .= '</span></div></div>';
236
+ return $html;
237
+ }
238
+
239
+ public function autoFillMatrixRowHeight()
240
+ {
241
+ $rows = array();
242
+ foreach (Mage::getModel('simiconnector/simicategory')->getCollection() as $simicat) {
243
+ $currentIndex = $simicat->getData('matrix_row');
244
+ if (!$rows[$currentIndex])
245
+ $rows[$currentIndex] = array('phone' => $simicat->getData('matrix_height_percent'), 'tablet' => $simicat->getData('matrix_height_percent_tablet'));
246
+ }
247
+ foreach (Mage::getModel('simiconnector/productlist')->getCollection() as $productlist) {
248
+ $currentIndex = $productlist->getData('matrix_row');
249
+ if (!$rows[$currentIndex])
250
+ $rows[$currentIndex] = array('phone' => $productlist->getData('matrix_height_percent'), 'tablet' => $productlist->getData('matrix_height_percent_tablet'));
251
+ }
252
+ ksort($rows);
253
+ $script = '
254
+ function autoFillHeight(row){
255
+ var returnValue = 100;
256
+ switch(row) {';
257
+ foreach ($rows as $index => $row) {
258
+ $script .= ' case "' . $index . '":
259
+ $("matrix_height_percent").value = "' . $row['phone'] . '";
260
+ $("matrix_height_percent_tablet").value = "' . $row['tablet'] . '";
261
+ break; ';
262
+ }
263
+ $script .= '}}
264
+ ';
265
+ return $script;
266
+ }
267
+
268
+ public function updateMatrixRowHeight($matrix_row, $matrix_height_percent, $matrix_height_percent_tablet)
269
+ {
270
+ foreach (Mage::getModel('simiconnector/productlist')->getCollection() as $productList) {
271
+ if (($productList->getData('matrix_row') == $matrix_row) && (($productList->getData('matrix_height_percent') != $matrix_height_percent) || ($productList->getData('matrix_height_percent_tablet') != $matrix_height_percent_tablet))) {
272
+ $productList->setData('matrix_height_percent', $matrix_height_percent);
273
+ $productList->setData('matrix_height_percent_tablet', $matrix_height_percent_tablet);
274
+ $productList->save();
275
+ }
276
+ }
277
+ foreach (Mage::getModel('simiconnector/simicategory')->getCollection() as $homecategory) {
278
+ if (($homecategory->getData('matrix_row') == $matrix_row) && (($homecategory->getData('matrix_height_percent') != $matrix_height_percent) || ($homecategory->getData('matrix_height_percent_tablet') != $matrix_height_percent_tablet))) {
279
+ $homecategory->setData('matrix_height_percent', $matrix_height_percent);
280
+ $homecategory->setData('matrix_height_percent_tablet', $matrix_height_percent_tablet);
281
+ $homecategory->save();
282
+ }
283
+ }
284
+ }
285
+
286
+ }
app/code/local/Simi/Simiconnector/Helper/Products.php ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/28/16
7
+ * Time: 4:40 PM
8
+ */
9
+ class Simi_Simiconnector_Helper_Products extends Mage_Core_Helper_Abstract
10
+ {
11
+
12
+ protected $_layer = array();
13
+ protected $builderQuery;
14
+ protected $_data = array();
15
+ protected $_sortOrders = array();
16
+
17
+ public function setData($data)
18
+ {
19
+ $this->_data = $data;
20
+ }
21
+
22
+ public function getData()
23
+ {
24
+ return $this->_data;
25
+ }
26
+
27
+ public function getLayers()
28
+ {
29
+ return $this->_layer;
30
+ }
31
+
32
+ /**
33
+ * @return product collection.
34
+ *
35
+ */
36
+ public function getBuilderQuery()
37
+ {
38
+ return $this->builderQuery;
39
+ }
40
+
41
+ public function getProduct($product_id)
42
+ {
43
+ $this->builderQuery = Mage::getModel('catalog/product')->load($product_id);
44
+ if(!$this->builderQuery->getId()) throw new Exception($this ->__('Resource cannot callable.'), 6);
45
+ return $this->builderQuery;
46
+ }
47
+
48
+ /**
49
+ *
50
+ */
51
+ public function setCategoryProducts($category)
52
+ {
53
+ $category = Mage::getModel('catalog/category')->load($category);
54
+ $this->setLayers(0, $category);
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Related Product
60
+ * @param int $product_id
61
+ */
62
+ public function setRelatedProduct($product_id)
63
+ {
64
+ $product = Mage::getModel('catalog/product')->load($product_id);
65
+ $this->builderQuery = $product->getRelatedProductCollection();
66
+ $this->setAttributeProducts();
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * @param int $is_search
72
+ * @param int $category
73
+ * set Layer and collection on Products
74
+ */
75
+ public function setLayers($is_search = 0, $category = 0)
76
+ {
77
+ $data = $this->getData();
78
+ try {
79
+ Mage::register('current_category', $category);
80
+ }
81
+ catch (Exception $e) {
82
+ }
83
+ $controller = $data['controller'];
84
+ $parameters = $data['params'];
85
+ if (isset($parameters[Simi_Simiconnector_Model_Api_Abstract::FILTER])) {
86
+ $filter = $parameters[Simi_Simiconnector_Model_Api_Abstract::FILTER];
87
+ if ($is_search == 1) {
88
+ $controller->getRequest()->setParam('q', (string)$filter['q']);
89
+ }
90
+ if(isset($filter['q']) && $filter['q'] != ''){
91
+ $controller->getRequest()->setParam('q', (string)$filter['q']);
92
+ $is_search = 1;
93
+ }
94
+ if($category && ($category->getId() || ($category!=0))){
95
+ $controller->getRequest()->setParam('cat', (string)$category->getId());
96
+ }
97
+ if (isset($filter['layer'])) {
98
+ $filter_layer = $filter['layer'];
99
+ $params = array();
100
+ foreach ($filter_layer as $key => $value) {
101
+ $params[(string)$key] = (string)$value;
102
+ // if($key == "cat"){
103
+ // $category = Mage::getModel('catalog/category')->load($value);
104
+ // }
105
+ }
106
+ $controller->getRequest()->setParams($params);
107
+ }
108
+ }
109
+ $layout = $controller->getLayout();
110
+ if ($is_search == 0) {
111
+ $block = $layout->createBlock('catalog/layer_view');
112
+ //setCurrentCate
113
+ //$block->getLayer()->setCurrentCategory($category);
114
+ $design = Mage::getSingleton('catalog/design');
115
+ $settings = $design->getDesignSettings($category);
116
+ //if (!$settings->getPageLayout()) {
117
+ if ($block->canShowBlock() && $category->getData('is_anchor')) {
118
+ $layers = $this->getItemsShopBy($block);
119
+ $this->_layer = $layers;
120
+ }
121
+ //}
122
+
123
+ //update collection
124
+ $block_list = $layout->createBlock('catalog/product_list');
125
+ $block_toolbar = $layout->createBlock('catalog/product_list_toolbar');
126
+ $block_list->setChild('product_list_toolbar', $block_toolbar);
127
+
128
+ $this->builderQuery = $block_list->getLoadedProductCollection();
129
+ $this->setAttributeProducts();
130
+ $this->setStoreOrders($block_list, $block_toolbar);
131
+
132
+ } else {
133
+ $query = Mage::helper('catalogsearch')->getQuery();
134
+ $query->setStoreId(Mage::app()->getStore()->getId());
135
+ if ($query->getQueryText() != '') {
136
+ if (Mage::helper('catalogsearch')->isMinQueryLength()) {
137
+ $query->setId(0)
138
+ ->setIsActive(1)
139
+ ->setIsProcessed(1);
140
+ } else {
141
+ if ($query->getId()) {
142
+ $query->setPopularity($query->getPopularity() + 1);
143
+ } else {
144
+ $query->setPopularity(1);
145
+ }
146
+
147
+ if ($query->getRedirect()) {
148
+ $query->save();
149
+ } else {
150
+ $query->prepare();
151
+ }
152
+ }
153
+
154
+ Mage::helper('catalogsearch')->checkNotes();
155
+
156
+ $block = $layout->createBlock('catalogsearch/layer');
157
+ if ($block->canShowBlock()) {
158
+ $layers = $this->getItemsShopBy($block);
159
+ $this->_layer = $layers;
160
+ }
161
+ //update collection
162
+ // $block_result = $layout->createBlock('catalogsearch/result');
163
+ $block_list = $layout->createBlock('catalog/product_list');
164
+ $block_toolbar = $layout->createBlock('catalog/product_list_toolbar');
165
+
166
+ $block_list->setChild('product_list_toolbar', $block_toolbar);
167
+
168
+ $this->builderQuery = $block_list->getLoadedProductCollection();
169
+ $this->setAttributeProducts(1);
170
+ $this->setStoreOrders($block_list, $block_toolbar, 1);
171
+
172
+ if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
173
+ $query->save();
174
+ }
175
+ }
176
+ }
177
+ }
178
+
179
+ public function setStoreOrders($block_list, $block_toolbar, $is_search = 0)
180
+ {
181
+ if (!$block_toolbar->isExpanded()) return;
182
+ $sort_orders = array();
183
+
184
+ if ($sort = $block_list->getSortBy()) {
185
+ $block_toolbar->setDefaultOrder($sort);
186
+ }
187
+ if ($dir = $block_list->getDefaultDirection()) {
188
+ $block_toolbar->setDefaultDirection($dir);
189
+ }
190
+ $availableOrders = $block_toolbar->getAvailableOrders();
191
+ if ($is_search == 1) {
192
+ unset($availableOrders['position']);
193
+ $availableOrders = array_merge(array(
194
+ 'relevance' => $this->__('Relevance')
195
+ ), $availableOrders);
196
+
197
+ $block_toolbar->setAvailableOrders($availableOrders)
198
+ ->setDefaultDirection('desc')
199
+ ->setSortBy('relevance');
200
+ }
201
+
202
+ foreach ($availableOrders as $_key => $_order) {
203
+ if ($block_toolbar->isOrderCurrent($_key)) {
204
+ if ($block_toolbar->getCurrentDirection() == 'desc') {
205
+ $sort_orders[] = array(
206
+ 'key' => $_key,
207
+ 'value' => $_order,
208
+ 'direction' => 'asc',
209
+ 'default' => '0'
210
+ );
211
+
212
+ $sort_orders[] = array(
213
+ 'key' => $_key,
214
+ 'value' => $_order,
215
+ 'direction' => 'desc',
216
+ 'default' => '1'
217
+ );
218
+ $this->builderQuery->setOrder($_key, 'desc');
219
+ } else {
220
+ $sort_orders[] = array(
221
+ 'key' => $_key,
222
+ 'value' => $_order,
223
+ 'direction' => 'asc',
224
+ 'default' => '1'
225
+ );
226
+ $sort_orders[] = array(
227
+ 'key' => $_key,
228
+ 'value' => $_order,
229
+ 'direction' => 'desc',
230
+ 'default' => '0'
231
+ );
232
+ $this->builderQuery->setOrder($_key, 'asc');
233
+ }
234
+ } else {
235
+ $sort_orders[] = array(
236
+ 'key' => $_key,
237
+ 'value' => $_order,
238
+ 'direction' => 'asc',
239
+ 'default' => '0'
240
+ );
241
+
242
+ $sort_orders[] = array(
243
+ 'key' => $_key,
244
+ 'value' => $_order,
245
+ 'direction' => 'desc',
246
+ 'default' => '0'
247
+ );
248
+ }
249
+ }
250
+ $this->_sortOrders = $sort_orders;
251
+ }
252
+
253
+ public function getStoreQrders()
254
+ {
255
+ return $this->_sortOrders;
256
+ }
257
+
258
+ protected function setAttributeProducts($is_search = 0)
259
+ {
260
+ $storeId = Mage::app()->getStore()->getId();
261
+ $this->builderQuery->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
262
+ $this->builderQuery->setStoreId($storeId);
263
+ $this->builderQuery->addFinalPrice();
264
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->builderQuery);
265
+ if ($is_search == 0) {
266
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->builderQuery);
267
+ } else {
268
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->builderQuery);
269
+ }
270
+ $this->builderQuery->addUrlRewrite(0);
271
+ }
272
+
273
+ protected function getItemsShopBy($block)
274
+ {
275
+ $_children = $block->getChild();
276
+ $refineArray = array();
277
+ foreach ($_children as $index => $_child) {
278
+ if ($index == 'layer_state') {
279
+ // $itemArray = array();
280
+ foreach ($_child->getActiveFilters() as $item) {
281
+ $itemValues = array();
282
+ $itemValues = $item->getValue();
283
+ if (is_array($itemValues)) {
284
+ $itemValues = implode('-', $itemValues);
285
+ }
286
+
287
+ if ($item->getFilter() && ($item->getFilter()->getRequestVar() != null)) {
288
+ $refineArray['layer_state'][] = array(
289
+ 'attribute' => $item->getFilter()->getRequestVar(),
290
+ 'title' => $item->getName(),
291
+ 'label' => (string)strip_tags($item->getLabel()), //filter request var and correlative name
292
+ 'value' => $itemValues,
293
+ ); //value of each option
294
+ }
295
+ }
296
+ // $refineArray[] = $itemArray;
297
+ } else {
298
+ $items = $_child->getItems();
299
+ $itemArray = array();
300
+ foreach ($items as $index => $item) {
301
+ $filter = array();
302
+ if ($index == 0) {
303
+ foreach ($items as $index => $item) {
304
+ $filter[] = array(
305
+ 'value' => $item->getValue(), //value of each option
306
+ 'label' => strip_tags($item->getLabel()),
307
+ );
308
+ }
309
+
310
+ if ($item->getFilter() && ($item->getFilter()->getRequestVar() != null)) {
311
+ $refineArray['layer_filter'][] = array(
312
+ 'attribute' => $item->getFilter()->getRequestVar(),
313
+ 'title' => $item->getName(), //filter request var and correlative name
314
+ 'filter' => $filter,
315
+ );
316
+ }
317
+ }
318
+ }
319
+ }
320
+ }
321
+ return $refineArray;
322
+ }
323
+
324
+ public function getImageProduct($product, $file = null, $width, $height)
325
+ {
326
+ if (!is_null($width) && !is_null($height)) {
327
+ if ($file) {
328
+ return Mage::helper('catalog/image')->init($product, 'thumbnail', $file)->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($width, null)->__toString();
329
+ }
330
+ return Mage::helper('catalog/image')->init($product, 'small_image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($width, null)->__toString();
331
+ }
332
+ if ($file) {
333
+ return Mage::helper('catalog/image')->init($product, 'thumbnail', $file)->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(600, 600)->__toString();
334
+ }
335
+ return Mage::helper('catalog/image')->init($product, 'small_image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(600, 600)->__toString();
336
+ }
337
+
338
+ }
app/code/local/Simi/Simiconnector/Helper/Review.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 8/18/16
7
+ * Time: 9:09 AM
8
+ */
9
+ class Simi_Simiconnector_Helper_Review extends Mage_Core_Helper_Abstract
10
+ {
11
+ public function getTotalRate($rates)
12
+ {
13
+ $total = $rates[0] * 1 + $rates[1] * 2 + $rates[2] * 3 + $rates[3] * 4 + $rates[4] * 5;
14
+ return $total;
15
+ }
16
+
17
+ public function getAvgRate($rates, $total)
18
+ {
19
+ if ($rates[5] != 0)
20
+ $avg = $total / $rates[5];
21
+ else
22
+ $avg = 0;
23
+ return $avg;
24
+ }
25
+
26
+ function getRatingStar($productId)
27
+ {
28
+ $reviews = Mage::getModel('review/review')
29
+ ->getResourceCollection()
30
+ ->addStoreFilter(Mage::app()->getStore()->getId())
31
+ ->addEntityFilter('product', $productId)
32
+ ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
33
+ ->setDateOrder()
34
+ ->addRateVotes();
35
+ /**
36
+ * Getting numbers ratings/reviews
37
+ */
38
+ $star = array();
39
+ $star[0] = 0;
40
+ $star[1] = 0;
41
+ $star[2] = 0;
42
+ $star[3] = 0;
43
+ $star[4] = 0;
44
+ $star[5] = 0;
45
+ if (count($reviews) > 0) {
46
+ foreach ($reviews->getItems() as $review) {
47
+ $star[5]++;
48
+ $y = 0;
49
+ foreach ($review->getRatingVotes() as $vote) {
50
+ $y += ($vote->getPercent() / 20);
51
+ }
52
+ $x = (int)($y / count($review->getRatingVotes()));
53
+ $z = $y % 3;
54
+ $x = $z < 5 ? $x : $x + 1;
55
+ if ($x == 1) {
56
+ $star[0]++;
57
+ } elseif ($x == 2) {
58
+ $star[1]++;
59
+ } elseif ($x == 3) {
60
+ $star[2]++;
61
+ } elseif ($x == 4) {
62
+ $star[3]++;
63
+ } elseif ($x == 5) {
64
+ $star[4]++;
65
+ } elseif ($x == 0) {
66
+ $star[5]--;
67
+ }
68
+ }
69
+ }
70
+ return $star;
71
+ }
72
+
73
+ public function getReviews($productId)
74
+ {
75
+ $storeId = Mage::app()->getStore()->getId();
76
+ $reviews = Mage::getModel('review/review')
77
+ ->getResourceCollection()
78
+ ->addStoreFilter($storeId)
79
+ ->addEntityFilter('product', $productId)
80
+ ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
81
+ ->setDateOrder()
82
+ ->addRateVotes();
83
+
84
+ return $reviews;
85
+ }
86
+
87
+ public function getReview($review_id)
88
+ {
89
+ return Mage::getModel('review/review')->load($review_id);
90
+ }
91
+
92
+ public function getReviewToAdd()
93
+ {
94
+ $block = Mage::getBlockSingleton('review/form');
95
+ $is_allow = $block->getAllowWriteReviewFlag();
96
+ if ($is_allow) {
97
+ $info = array();
98
+ $rates = array();
99
+ if ($block->getRatings() && $block->getRatings()->getSize()) {
100
+ foreach ($block->getRatings() as $_rating) {
101
+ $_options = array();
102
+ foreach ($_rating->getOptions() as $_option) {
103
+ $_options[] = array(
104
+ 'key' => $_rating->getId(),
105
+ 'value' => $_option->getId(),
106
+ );
107
+ }
108
+ $rates[] = array(
109
+ 'rate_code' => $block->escapeHtml($_rating->getRatingCode()),
110
+ 'rate_options' => $_options,
111
+ );
112
+ }
113
+ }
114
+ $info[] = array('rates' => $rates, 'form_review' => array(
115
+ 'key_1' => 'nickname',
116
+ 'key_2' => 'title',
117
+ 'key_3' => 'detail',
118
+ 'form_key'=> array(
119
+ array(
120
+ 'key' => 'nickname',
121
+ 'value' => 'Nickname'
122
+ ),
123
+ array(
124
+ 'key' => 'title',
125
+ 'value' => 'Title'
126
+ ),
127
+ array(
128
+ 'key' => 'detail',
129
+ 'value' => 'Detail'
130
+ ),
131
+ )),
132
+ );
133
+ return $info;
134
+ } else {
135
+ return array($block->__('Only registered users can write reviews'));
136
+ }
137
+ }
138
+
139
+ protected function _initProduct($product_id)
140
+ {
141
+ return Mage::getModel('catalog/product')->load($product_id);
142
+ }
143
+
144
+ public function saveReview($data)
145
+ {
146
+ $allowGuest = Mage::helper('review')->getIsGuestAllowToWrite();
147
+ if (!$allowGuest) {
148
+ throw new Exception(Mage::helper('review')->__('Guest can not write'), 4);
149
+ }
150
+ if (($product = $this->_initProduct($data['product_id'])) && !empty($data)) {
151
+ $rating = $data['ratings'];
152
+ $session = Mage::getSingleton('core/session');
153
+ /* @var $session Mage_Core_Model_Session */
154
+ $review = Mage::getModel('review/review')->setData($data);
155
+ /* @var $review Mage_Review_Model_Review */
156
+
157
+ $validate = $review->validate();
158
+ if ($validate === true) {
159
+ try {
160
+ $review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
161
+ ->setEntityPkValue($product->getId())
162
+ ->setStatusId(Mage_Review_Model_Review::STATUS_PENDING)
163
+ ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
164
+ ->setStoreId(Mage::app()->getStore()->getId())
165
+ ->setStores(array(Mage::app()->getStore()->getId()))
166
+ ->save();
167
+ foreach ($rating as $ratingId => $optionId) {
168
+ Mage::getModel('rating/rating')
169
+ ->setRatingId($ratingId)
170
+ ->setReviewId($review->getId())
171
+ ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
172
+ ->addOptionVote($optionId, $product->getId());
173
+ }
174
+
175
+ $review->aggregate();
176
+ return array(
177
+ 'review' => $review,
178
+ 'message' => Mage::helper('review')->__('Your review has been accepted for moderation.'));
179
+ } catch (Exception $e) {
180
+ throw new Exception(Mage::helper('review')->__('Unable to post the review'), 4);
181
+ }
182
+ } else {
183
+ throw new Exception(Mage::helper('review')->__('Unable to post the review'), 4);
184
+ }
185
+ } else {
186
+ throw new Exception(Mage::helper('review')->__('Invalid method.'), 4);
187
+ }
188
+
189
+ }
190
+ }
app/code/local/Simi/Simiconnector/Helper/Simibarcode.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Helper_Simibarcode extends Mage_Core_Helper_Data {
7
+
8
+ /**
9
+ * Barcode Config
10
+ *
11
+ * return string
12
+ */
13
+ public function getBarcodeConfig($code) {
14
+ $storeId = Mage::app()->getStore()->getId();
15
+ return Mage::getStoreConfig('simiconnector/barcode/' . $code, $storeId);
16
+ }
17
+
18
+ /**
19
+ * Validate code
20
+ *
21
+ * return string
22
+ */
23
+ public function getValidateBarcode() {
24
+ $validate = 'required-entry';
25
+ return $validate;
26
+ }
27
+
28
+ /**
29
+ * Generate code
30
+ *
31
+ * return string
32
+ */
33
+ public function generateCode($string) {
34
+ $barcode = preg_replace_callback('#\[([AN]{1,2})\.([0-9]+)\]#', array($this, 'convertExpression'), $string);
35
+ $checkBarcodeExist = Mage::getModel('simiconnector/simibarcode')->load($barcode, 'barcode');
36
+
37
+ if ($checkBarcodeExist->getId()) {
38
+ $barcode = $this->generateCode($string);
39
+ }
40
+
41
+ return $barcode;
42
+ }
43
+
44
+ /**
45
+ * Random code
46
+ *
47
+ * return string
48
+ */
49
+ public function convertExpression($param) {
50
+ $alphabet = (strpos($param[1], 'A')) === false ? '' : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
51
+ $alphabet .= (strpos($param[1], 'N')) === false ? '' : '0123456789';
52
+ return $this->getRandomString($param[2], $alphabet);
53
+ }
54
+
55
+ /**
56
+ * get All column
57
+ *
58
+ * return Array
59
+ */
60
+ public function getAllColumOfTable($model) {
61
+ $resource = Mage::getSingleton('core/resource');
62
+ $tablename = $resource->getTableName($model);
63
+ $readConnection = $resource->getConnection('core_read');
64
+ $results = $readConnection->fetchAll("SHOW COLUMNS FROM " . $tablename . ";");
65
+ $return = array();
66
+ foreach ($results as $result) {
67
+ $return[] = $result['Field'];
68
+ }
69
+
70
+ return $return;
71
+ }
72
+
73
+ /**
74
+ * get value for barcode
75
+ *
76
+ * param String $table, String $column, int $productId, array $data
77
+ * return Array
78
+ */
79
+ public function getValueForBarcode($table, $column, $productId, $data) {
80
+ if ($table == 'product') {
81
+
82
+ $model = Mage::getModel('catalog/product')->load($productId);
83
+ return $model->getData($column);
84
+ }
85
+ }
86
+
87
+ /**
88
+ * import Product
89
+ *
90
+ * param array()
91
+ */
92
+ public function importProduct($data) {
93
+ if (count($data)) {
94
+ Mage::getModel('admin/session')->setData('null_barcode_product_import', 0);
95
+ } else {
96
+ Mage::getModel('admin/session')->setData('null_barcode_product_import', 1);
97
+ Mage::getModel('admin/session')->setData('barcode_product_import', null);
98
+ }
99
+ }
100
+
101
+ public function createBarcode( $filepath="", $text="0", $size="20", $orientation="horizontal", $code_type="code128", $print=false ) {
102
+ $code_string = "";
103
+ // Translate the $text into barcode the correct $code_type
104
+ if ( in_array(strtolower($code_type), array("code128", "code128b")) ) {
105
+ $chksum = 104;
106
+ // Must not change order of array elements as the checksum depends on the array's key to validate final code
107
+ $code_array = array(" "=>"212222","!"=>"222122","\""=>"222221","#"=>"121223","$"=>"121322","%"=>"131222","&"=>"122213","'"=>"122312","("=>"132212",")"=>"221213","*"=>"221312","+"=>"231212",","=>"112232","-"=>"122132","."=>"122231","/"=>"113222","0"=>"123122","1"=>"123221","2"=>"223211","3"=>"221132","4"=>"221231","5"=>"213212","6"=>"223112","7"=>"312131","8"=>"311222","9"=>"321122",":"=>"321221",";"=>"312212","<"=>"322112","="=>"322211",">"=>"212123","?"=>"212321","@"=>"232121","A"=>"111323","B"=>"131123","C"=>"131321","D"=>"112313","E"=>"132113","F"=>"132311","G"=>"211313","H"=>"231113","I"=>"231311","J"=>"112133","K"=>"112331","L"=>"132131","M"=>"113123","N"=>"113321","O"=>"133121","P"=>"313121","Q"=>"211331","R"=>"231131","S"=>"213113","T"=>"213311","U"=>"213131","V"=>"311123","W"=>"311321","X"=>"331121","Y"=>"312113","Z"=>"312311","["=>"332111","\\"=>"314111","]"=>"221411","^"=>"431111","_"=>"111224","\`"=>"111422","a"=>"121124","b"=>"121421","c"=>"141122","d"=>"141221","e"=>"112214","f"=>"112412","g"=>"122114","h"=>"122411","i"=>"142112","j"=>"142211","k"=>"241211","l"=>"221114","m"=>"413111","n"=>"241112","o"=>"134111","p"=>"111242","q"=>"121142","r"=>"121241","s"=>"114212","t"=>"124112","u"=>"124211","v"=>"411212","w"=>"421112","x"=>"421211","y"=>"212141","z"=>"214121","{"=>"412121","|"=>"111143","}"=>"111341","~"=>"131141","DEL"=>"114113","FNC 3"=>"114311","FNC 2"=>"411113","SHIFT"=>"411311","CODE C"=>"113141","FNC 4"=>"114131","CODE A"=>"311141","FNC 1"=>"411131","Start A"=>"211412","Start B"=>"211214","Start C"=>"211232","Stop"=>"2331112");
108
+ $code_keys = array_keys($code_array);
109
+ $code_values = array_flip($code_keys);
110
+ for ( $X = 1; $X <= strlen($text); $X++ ) {
111
+ $activeKey = substr( $text, ($X-1), 1);
112
+ $code_string .= $code_array[$activeKey];
113
+ $chksum=($chksum + ($code_values[$activeKey] * $X));
114
+ }
115
+ $code_string .= $code_array[$code_keys[($chksum - (intval($chksum / 103) * 103))]];
116
+ $code_string = "211214" . $code_string . "2331112";
117
+ } elseif ( strtolower($code_type) == "code128a" ) {
118
+ $chksum = 103;
119
+ $text = strtoupper($text); // Code 128A doesn't support lower case
120
+ // Must not change order of array elements as the checksum depends on the array's key to validate final code
121
+ $code_array = array(" "=>"212222","!"=>"222122","\""=>"222221","#"=>"121223","$"=>"121322","%"=>"131222","&"=>"122213","'"=>"122312","("=>"132212",")"=>"221213","*"=>"221312","+"=>"231212",","=>"112232","-"=>"122132","."=>"122231","/"=>"113222","0"=>"123122","1"=>"123221","2"=>"223211","3"=>"221132","4"=>"221231","5"=>"213212","6"=>"223112","7"=>"312131","8"=>"311222","9"=>"321122",":"=>"321221",";"=>"312212","<"=>"322112","="=>"322211",">"=>"212123","?"=>"212321","@"=>"232121","A"=>"111323","B"=>"131123","C"=>"131321","D"=>"112313","E"=>"132113","F"=>"132311","G"=>"211313","H"=>"231113","I"=>"231311","J"=>"112133","K"=>"112331","L"=>"132131","M"=>"113123","N"=>"113321","O"=>"133121","P"=>"313121","Q"=>"211331","R"=>"231131","S"=>"213113","T"=>"213311","U"=>"213131","V"=>"311123","W"=>"311321","X"=>"331121","Y"=>"312113","Z"=>"312311","["=>"332111","\\"=>"314111","]"=>"221411","^"=>"431111","_"=>"111224","NUL"=>"111422","SOH"=>"121124","STX"=>"121421","ETX"=>"141122","EOT"=>"141221","ENQ"=>"112214","ACK"=>"112412","BEL"=>"122114","BS"=>"122411","HT"=>"142112","LF"=>"142211","VT"=>"241211","FF"=>"221114","CR"=>"413111","SO"=>"241112","SI"=>"134111","DLE"=>"111242","DC1"=>"121142","DC2"=>"121241","DC3"=>"114212","DC4"=>"124112","NAK"=>"124211","SYN"=>"411212","ETB"=>"421112","CAN"=>"421211","EM"=>"212141","SUB"=>"214121","ESC"=>"412121","FS"=>"111143","GS"=>"111341","RS"=>"131141","US"=>"114113","FNC 3"=>"114311","FNC 2"=>"411113","SHIFT"=>"411311","CODE C"=>"113141","CODE B"=>"114131","FNC 4"=>"311141","FNC 1"=>"411131","Start A"=>"211412","Start B"=>"211214","Start C"=>"211232","Stop"=>"2331112");
122
+ $code_keys = array_keys($code_array);
123
+ $code_values = array_flip($code_keys);
124
+ for ( $X = 1; $X <= strlen($text); $X++ ) {
125
+ $activeKey = substr( $text, ($X-1), 1);
126
+ $code_string .= $code_array[$activeKey];
127
+ $chksum=($chksum + ($code_values[$activeKey] * $X));
128
+ }
129
+ $code_string .= $code_array[$code_keys[($chksum - (intval($chksum / 103) * 103))]];
130
+ $code_string = "211412" . $code_string . "2331112";
131
+ } elseif ( strtolower($code_type) == "code39" ) {
132
+ $code_array = array("0"=>"111221211","1"=>"211211112","2"=>"112211112","3"=>"212211111","4"=>"111221112","5"=>"211221111","6"=>"112221111","7"=>"111211212","8"=>"211211211","9"=>"112211211","A"=>"211112112","B"=>"112112112","C"=>"212112111","D"=>"111122112","E"=>"211122111","F"=>"112122111","G"=>"111112212","H"=>"211112211","I"=>"112112211","J"=>"111122211","K"=>"211111122","L"=>"112111122","M"=>"212111121","N"=>"111121122","O"=>"211121121","P"=>"112121121","Q"=>"111111222","R"=>"211111221","S"=>"112111221","T"=>"111121221","U"=>"221111112","V"=>"122111112","W"=>"222111111","X"=>"121121112","Y"=>"221121111","Z"=>"122121111","-"=>"121111212","."=>"221111211"," "=>"122111211","$"=>"121212111","/"=>"121211121","+"=>"121112121","%"=>"111212121","*"=>"121121211");
133
+ // Convert to uppercase
134
+ $upper_text = strtoupper($text);
135
+ for ( $X = 1; $X<=strlen($upper_text); $X++ ) {
136
+ $code_string .= $code_array[substr( $upper_text, ($X-1), 1)] . "1";
137
+ }
138
+ $code_string = "1211212111" . $code_string . "121121211";
139
+ } elseif ( strtolower($code_type) == "code25" ) {
140
+ $code_array1 = array("1","2","3","4","5","6","7","8","9","0");
141
+ $code_array2 = array("3-1-1-1-3","1-3-1-1-3","3-3-1-1-1","1-1-3-1-3","3-1-3-1-1","1-3-3-1-1","1-1-1-3-3","3-1-1-3-1","1-3-1-3-1","1-1-3-3-1");
142
+ for ( $X = 1; $X <= strlen($text); $X++ ) {
143
+ for ( $Y = 0; $Y < count($code_array1); $Y++ ) {
144
+ if ( substr($text, ($X-1), 1) == $code_array1[$Y] )
145
+ $temp[$X] = $code_array2[$Y];
146
+ }
147
+ }
148
+ for ( $X=1; $X<=strlen($text); $X+=2 ) {
149
+ if ( isset($temp[$X]) && isset($temp[($X + 1)]) ) {
150
+ $temp1 = explode( "-", $temp[$X] );
151
+ $temp2 = explode( "-", $temp[($X + 1)] );
152
+ for ( $Y = 0; $Y < count($temp1); $Y++ )
153
+ $code_string .= $temp1[$Y] . $temp2[$Y];
154
+ }
155
+ }
156
+ $code_string = "1111" . $code_string . "311";
157
+ } elseif ( strtolower($code_type) == "codabar" ) {
158
+ $code_array1 = array("1","2","3","4","5","6","7","8","9","0","-","$",":","/",".","+","A","B","C","D");
159
+ $code_array2 = array("1111221","1112112","2211111","1121121","2111121","1211112","1211211","1221111","2112111","1111122","1112211","1122111","2111212","2121112","2121211","1121212","1122121","1212112","1112122","1112221");
160
+ // Convert to uppercase
161
+ $upper_text = strtoupper($text);
162
+ for ( $X = 1; $X<=strlen($upper_text); $X++ ) {
163
+ for ( $Y = 0; $Y<count($code_array1); $Y++ ) {
164
+ if ( substr($upper_text, ($X-1), 1) == $code_array1[$Y] )
165
+ $code_string .= $code_array2[$Y] . "1";
166
+ }
167
+ }
168
+ $code_string = "11221211" . $code_string . "1122121";
169
+ }
170
+ // Pad the edges of the barcode
171
+ $code_length = 20;
172
+ if ($print) {
173
+ $text_height = 30;
174
+ } else {
175
+ $text_height = 0;
176
+ }
177
+
178
+ for ( $i=1; $i <= strlen($code_string); $i++ ){
179
+ $code_length = $code_length + (integer)(substr($code_string,($i-1),1));
180
+ }
181
+ if ( strtolower($orientation) == "horizontal" ) {
182
+ $img_width = $code_length;
183
+ $img_height = $size;
184
+ } else {
185
+ $img_width = $size;
186
+ $img_height = $code_length;
187
+ }
188
+ $image = imagecreate($img_width, $img_height + $text_height);
189
+ $black = imagecolorallocate ($image, 0, 0, 0);
190
+ $white = imagecolorallocate ($image, 255, 255, 255);
191
+ imagefill( $image, 0, 0, $white );
192
+ if ( $print ) {
193
+ imagestring($image, 5, 31, $img_height, $text, $black );
194
+ }
195
+ $location = 10;
196
+ for ( $position = 1 ; $position <= strlen($code_string); $position++ ) {
197
+ $cur_size = $location + ( substr($code_string, ($position-1), 1) );
198
+ if ( strtolower($orientation) == "horizontal" )
199
+ imagefilledrectangle( $image, $location, 0, $cur_size, $img_height, ($position % 2 == 0 ? $white : $black) );
200
+ else
201
+ imagefilledrectangle( $image, 0, $location, $img_width, $cur_size, ($position % 2 == 0 ? $white : $black) );
202
+ $location = $cur_size;
203
+ }
204
+
205
+ // Draw barcode to the screen or save in a file
206
+ if ( $filepath=="" ) {
207
+ header ('Content-type: image/png');
208
+ imagepng($image);
209
+ imagedestroy($image);
210
+ } else {
211
+ imagepng($image,$filepath);
212
+ imagedestroy($image);
213
+ }
214
+ }
215
+
216
+ }
app/code/local/Simi/Simiconnector/Helper/Siminotification.php ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Siminotification extends Mage_Core_Helper_Abstract {
4
+
5
+ public function sendNotice($data) {
6
+ $trans = $this->send($data);
7
+ // update notification history
8
+ $history = Mage::getModel('simiconnector/history');
9
+ if (!$trans)
10
+ $data['status'] = 0;
11
+ else
12
+ $data['status'] = 1;
13
+
14
+ $history->setData($data);
15
+ $history->save();
16
+ return $trans;
17
+ }
18
+
19
+ public function send(&$data) {
20
+ if ($data['category_id']) {
21
+ $categoryId = $data['category_id'];
22
+ $category = Mage::getModel('catalog/category')->load($categoryId);
23
+ $categoryChildrenCount = $category->getChildrenCount();
24
+ $categoryName = $category->getName();
25
+ $data['category_name'] = $categoryName;
26
+ if ($categoryChildrenCount > 0)
27
+ $categoryChildrenCount = 1;
28
+ else
29
+ $categoryChildrenCount = 0;
30
+ $data['has_child'] = $categoryChildrenCount;
31
+ if (!$data['has_child']) {
32
+ $data['has_child'] = '';
33
+ }
34
+ }
35
+ if ($data['product_id']) {
36
+ $productId = $data['product_id'];
37
+ $productName = Mage::getModel('catalog/product')->load($productId)->getName();
38
+ $data['product_name'] = $productName;
39
+ }
40
+ $deviceArray = explode(',', str_replace(' ', '', $data['devices_pushed']));
41
+
42
+ $collectionDevice = Mage::getModel('simiconnector/device')->getCollection()->addFieldToFilter('device_id', array('in' => $deviceArray));
43
+ $collectionDevice2 = Mage::getModel('simiconnector/device')->getCollection()->addFieldToFilter('device_id', array('in' => $deviceArray));
44
+
45
+ switch ($data['notice_sanbox']) {
46
+ case '1':
47
+ $collectionDevice->addFieldToFilter('is_demo', 1);
48
+ $collectionDevice2->addFieldToFilter('is_demo', 1);
49
+ break;
50
+ case '2':
51
+ $collectionDevice->addFieldToFilter('is_demo', 0);
52
+ $collectionDevice2->addFieldToFilter('is_demo', 0);
53
+ break;
54
+ default:
55
+ }
56
+
57
+ if ((int) $data['device_id'] != 0) {
58
+ if ((int) $data['device_id'] == 2) {
59
+ //send android
60
+ $collectionDevice->addFieldToFilter('plaform_id', array('eq' => 3));
61
+ return $this->sendAndroid($collectionDevice, $data);
62
+ } else {
63
+ //send IOS
64
+ $collectionDevice->addFieldToFilter('plaform_id', array('neq' => 3));
65
+ return $this->sendIOS($collectionDevice, $data);
66
+ }
67
+ } else {
68
+ //send all
69
+ $collectionDevice->addFieldToFilter('plaform_id', array('neq' => 3));
70
+ $collectionDevice2->addFieldToFilter('plaform_id', array('eq' => 3));
71
+ $resultIOS = $this->sendIOS($collectionDevice, $data);
72
+ $resultAndroid = $this->sendAndroid($collectionDevice2, $data);
73
+ if ($resultIOS || $resultAndroid)
74
+ return true;
75
+ else
76
+ return false;
77
+ }
78
+ }
79
+
80
+ public function sendIOS($collectionDevice, $data) {
81
+ $total = count($collectionDevice);
82
+ if ($total == 0)
83
+ return true;
84
+ $ch = $this->getDirPEMfile($data);
85
+ $dir = $this->getDirPEMPassfile();
86
+ $message = $data['notice_content'];
87
+ $body['aps'] = array(
88
+ 'alert' => $data['notice_title'],
89
+ 'sound' => 'default',
90
+ 'badge' => 1,
91
+ 'title' => $data['notice_title'],
92
+ 'message' => $message,
93
+ 'url' => $data['notice_url'],
94
+ 'type' => $data['type'],
95
+ 'productID' => $data['product_id'],
96
+ 'categoryID' => $data['category_id'],
97
+ 'categoryName' => $data['category_name'],
98
+ 'has_child' => $data['has_child'],
99
+ 'imageUrl' => $data['image_url'],
100
+ 'height' => $data['height'],
101
+ 'width' => $data['width'],
102
+ 'show_popup' => $data['show_popup'],
103
+ );
104
+ /*
105
+ echo 'iOS push:';
106
+ zend_debug::dump($body);
107
+ die;
108
+ *
109
+ */
110
+ $payload = json_encode($body);
111
+ $totalDevice = 0;
112
+
113
+ $i = 0;
114
+ $tokenArray = array();
115
+ $sentsuccess = true;
116
+ foreach ($collectionDevice as $item) {
117
+ if ($i == 100) {
118
+ $result = $this->repeatSendiOS($tokenArray, $payload, $ch, $dir);
119
+ if (!$result)
120
+ $sentsuccess = false;
121
+ $i = 0;
122
+ $tokenArray = array();
123
+ }
124
+ if (strlen($item->getDeviceToken()) < 70)
125
+ $tokenArray[] = $item->getDeviceToken();
126
+ $i++;
127
+ $totalDevice++;
128
+ }
129
+ if ($i <= 100)
130
+ $result = $this->repeatSendiOS($tokenArray, $payload, $ch, $dir);
131
+ if (!$result)
132
+ $sentsuccess = false;
133
+
134
+ if ($sentsuccess)
135
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Message successfully delivered to %s devices (IOS)', $totalDevice));
136
+ return true;
137
+ }
138
+
139
+ public function repeatSendiOS($tokenArray, $payload, $ch, $dir) {
140
+ $ctx = stream_context_create();
141
+ stream_context_set_option($ctx, 'ssl', 'local_cert', $ch);
142
+ $fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
143
+ if (!$fp) {
144
+ Mage::getSingleton('adminhtml/session')->addError("Failed to connect:" . $err . $errstr . PHP_EOL . "(IOS)");
145
+ return;
146
+ }
147
+ foreach ($tokenArray as $deviceToken) {
148
+ $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
149
+ // Send it to the server
150
+ $result = fwrite($fp, $msg, strlen($msg));
151
+ if (!$result) {
152
+ Mage::getSingleton('adminhtml/session')->addError('Message not delivered (IOS)' . PHP_EOL);
153
+ return false;
154
+ }
155
+ }
156
+ fclose($fp);
157
+ return true;
158
+ }
159
+
160
+ public function repeatSendAnddroid($total, $collectionDevice, $message) {
161
+ $size = $total;
162
+ while (true) {
163
+ $from_user = 0;
164
+ $check = $total - 999;
165
+ if ($check <= 0) {
166
+ //send to (total+from_user) user from_user
167
+ $is = $this->sendTurnAnroid($collectionDevice, $from_user, $from_user + $total, $message);
168
+ if ($is == false) {
169
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Message not delivered (Android)'));
170
+ return false;
171
+ }
172
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Message successfully delivered to %s devices (Android)', $size));
173
+ return true;
174
+ } else {
175
+ //send to 100 user from_user
176
+ $is = $this->sendTurnAnroid($collectionDevice, $from_user, $from_user + 999, $message);
177
+ if ($is == false) {
178
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Message not delivered (Android)'));
179
+ return false;
180
+ }
181
+ $total = $check;
182
+ $from_user += 999;
183
+ }
184
+ }
185
+ }
186
+
187
+ public function sendTurnAnroid($collectionDevice, $from, $to, $message) {
188
+ $registrationIDs = array();
189
+ for ($i = $from; $i <= $to; $i++) {
190
+ $item = $collectionDevice[$i];
191
+ if (isset($item['device_token']))
192
+ $registrationIDs[] = $item['device_token'];
193
+ }
194
+
195
+ $url = 'https://android.googleapis.com/gcm/send';
196
+ $fields = array(
197
+ 'registration_ids' => $registrationIDs,
198
+ 'data' => array("message" => $message),
199
+ );
200
+
201
+ $api_key = Mage::getStoreConfig('simiconnector/notification/android_secret_key', $collectionDevice[0]['storeview_id']);
202
+ $headers = array(
203
+ 'Authorization: key=' . $api_key,
204
+ 'Content-Type: application/json');
205
+
206
+ $result = '';
207
+ try {
208
+ $ch = curl_init();
209
+ curl_setopt($ch, CURLOPT_URL, $url);
210
+ curl_setopt($ch, CURLOPT_POST, true);
211
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
212
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
213
+ // Disabling SSL Certificate support temporarly
214
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
215
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
216
+ $result = curl_exec($ch);
217
+ curl_close($ch);
218
+ } catch (Exception $e) {
219
+
220
+ }
221
+
222
+ $re = json_decode($result);
223
+
224
+ if ($re == NULL || $re->success == 0) {
225
+ return false;
226
+ }
227
+ return true;
228
+ }
229
+
230
+ public function sendAndroid($collectionDevice, $data) {
231
+ unset($data['devices_pushed']);
232
+ $total = count($collectionDevice);
233
+ if ($total == 0)
234
+ return true;
235
+ $this->checkIndex($data);
236
+ $message = $data;
237
+
238
+ $this->repeatSendAnddroid($total, $collectionDevice->getData(), $message);
239
+ return true;
240
+ }
241
+
242
+ public function checkIndex(&$data) {
243
+ if (!isset($data['type'])) {
244
+ $data['type'] = '';
245
+ }
246
+ if (!isset($data['product_id'])) {
247
+ $data['product_id'] = '';
248
+ }
249
+ if (!isset($data['category_id'])) {
250
+ $data['category_id'] = '';
251
+ }
252
+ if (!isset($data['category_name'])) {
253
+ $data['category_name'] = '';
254
+ }
255
+ if (!isset($data['has_child'])) {
256
+ $data['has_child'] = '';
257
+ }
258
+ if (!isset($data['image_url'])) {
259
+ $data['image_url'] = '';
260
+ }
261
+ if (!isset($data['height'])) {
262
+ $data['height'] = '';
263
+ }
264
+ if (!isset($data['width'])) {
265
+ $data['width'] = '';
266
+ }
267
+ if (!isset($data['show_popup'])) {
268
+ $data['show_popup'] = '';
269
+ }
270
+ }
271
+
272
+ public function getListCountry() {
273
+ $listCountry = array();
274
+
275
+ $collection = Mage::getResourceModel('directory/country_collection')
276
+ ->loadByStore();
277
+
278
+ if (count($collection)) {
279
+ foreach ($collection as $item) {
280
+ $listCountry[$item->getId()] = $item->getName();
281
+ }
282
+ }
283
+
284
+ return $listCountry;
285
+ }
286
+
287
+ public function getDirPEMfile($data) {
288
+ switch ($data['notice_sanbox']) {
289
+ case '1':
290
+ if (!Mage::getStoreConfig("simiconnector/notification/upload_pem_file_test", $data['storeview_id']))
291
+ return Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'pem' . DS . 'push.pem';
292
+ else
293
+ return Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'pem' . DS . Mage::getStoreConfig("simiconnector/notification/upload_pem_file_test", $data['storeview_id']);
294
+ break;
295
+ case '2':
296
+ return Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'pem' . DS . 'manual' . DS . Mage::getStoreConfig("simiconnector/notification/upload_pem_file", $data['storeview_id']);
297
+ break;
298
+ default:
299
+ }
300
+ }
301
+
302
+ public function getDirPEMPassfile() {
303
+ return Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'pem' . DS . 'ios' . DS . 'pass_pem.config';
304
+ }
305
+
306
+ public function getConfig($nameConfig, $storeviewId = null) {
307
+ if (!$storeviewId)
308
+ $storeviewId = Mage::app()->getStore()->getId();
309
+ return Mage::getStoreConfig($nameConfig, $storeviewId);
310
+ }
311
+
312
+ }
app/code/local/Simi/Simiconnector/Helper/Simivideo.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Simivideo extends Mage_Core_Helper_Abstract {
4
+
5
+ public function getProductVideo($product) {
6
+ $videoCollection = Mage::getModel('simiconnector/simivideo')->getCollection();
7
+ if ($videoCollection->count() == 0)
8
+ return;
9
+ $productId = $product->getId();
10
+ if (!$productId)
11
+ return;
12
+ $videoArray = array();
13
+ foreach ($videoCollection as $video) {
14
+ if (in_array($productId, explode(",", $video->getData('product_ids')))) {
15
+ $videoArray[] = $video->getData('video_id');
16
+ }
17
+ }
18
+ $collection = Mage::getModel('simiconnector/simivideo')->getCollection()->addFieldToFilter('status', '1')->addFieldToFilter('video_id', array('in' => $videoArray));
19
+ $returnArray = array();
20
+ foreach ($collection as $productVideo) {
21
+ $returnArray[] = $productVideo->toArray();
22
+ }
23
+ return $returnArray;
24
+ }
25
+
26
+ }
app/code/local/Simi/Simiconnector/Helper/Tierprice.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 11/9/16
7
+ * Time: 1:27 PM
8
+ */
9
+ class Simi_Simiconnector_Helper_Tierprice extends Mage_Core_Helper_Abstract
10
+ {
11
+ private $_product;
12
+
13
+ public function setProduct($product) {
14
+ $this->_product = $product;
15
+ }
16
+
17
+ public function processTierPrices($product, &$tierPrices, $includeIndex = true) {
18
+ $weeeAmount = Mage::helper('weee')->getAmountForDisplay($product);
19
+ $weeeAmountInclTax = $weeeAmount;
20
+ if (version_compare(Mage::getVersion(), '1.9.0.0', '>=') === true) {
21
+ $weeeAmountInclTax = Mage::helper('weee')->getAmountForDisplayInclTaxes($product);
22
+ }
23
+
24
+ $store = Mage::app()->getStore();
25
+ foreach ($tierPrices as $index => &$tier) {
26
+ $html = $store->formatPrice($store->convertPrice(
27
+ Mage::helper('tax')->getPrice($product, $tier['website_price'], true) + $weeeAmountInclTax), false);
28
+ $tier['formated_price_incl_weee'] = $html;
29
+ $html = $store->formatPrice($store->convertPrice(
30
+ Mage::helper('tax')->getPrice($product, $tier['website_price']) + $weeeAmount), false);
31
+ $tier['formated_price_incl_weee_only'] = $html;
32
+ $tier['formated_weee'] = $store->formatPrice($store->convertPrice($weeeAmount), false);
33
+ }
34
+ return $this;
35
+ }
36
+
37
+ public function formatTierPrice($product) {
38
+ $data = array();
39
+ $_product = $product;
40
+ $this->_product = $product;
41
+ $_tierPrices = $this->getTierPrices();
42
+
43
+ /** @var $_catalogHelper Mage_Catalog_Helper_Data */
44
+ $_catalogHelper = Mage::helper('catalog');
45
+
46
+ if (Mage::helper('weee')->typeOfDisplay($_product, array(1, 2, 4))) {
47
+ $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
48
+ }
49
+
50
+ if (count($_tierPrices) > 0) {
51
+ $stringHt = '';
52
+ // if ($_product->isGrouped()) {
53
+ // $_tierPrices = $this->getTierPrices($_product);
54
+ // }
55
+ $this->processTierPrices($_product, $_tierPrices);
56
+
57
+ foreach ($_tierPrices as $_index => $_price) {
58
+ // $_price['formated_price_incl_weee'] = Mage::app()->getStore()->formatPrice($_price['formated_price_incl_weee'], false, false);
59
+ // $_price['formated_price_incl_weee_only'] = Mage::app()->getStore()->formatPrice($_price['formated_price_incl_weee_only'], false, false);
60
+ // $_price['formated_weee'] = Mage::app()->getStore()->formatPrice($_price['formated_weee'], false, false);
61
+ if ($_catalogHelper->canApplyMsrp($_product)) {
62
+ if ($_product->isGrouped()) {
63
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for', $_price['price_qty']);
64
+ } else {
65
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s', $_price['price_qty']);
66
+ }
67
+ } else {
68
+ if (Mage::helper('tax')->displayBothPrices()) {
69
+
70
+ if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
71
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price_incl_weee_only'], $_price['formated_price_incl_weee']);
72
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
73
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
74
+ $stringHt .= " ";
75
+ if ($_weeeTaxAttributes) {
76
+ $stringHt .= Mage::helper('catalog')->__('%1$s incl tax.', $_price['formated_price_incl_weee']);
77
+ $separator = ' + ';
78
+ $stringHt .= " ";
79
+ $stringHt .= $separator;
80
+ foreach ($_weeeTaxAttributes as $_attribute) {
81
+ $stringHt .= " ";
82
+ $stringHt .= $_attribute->getName();
83
+ $stringHt .= ':';
84
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount());
85
+ }
86
+ }
87
+ $stringHt .= " ";
88
+ $stringHt .= Mage::helper('catalog')->__('each');
89
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
90
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
91
+ if ($_weeeTaxAttributes) {
92
+ $stringHt .= Mage::helper('catalog')->__('%1$s incl tax.', $_price['formated_price_incl_weee']);
93
+ $separator = ' + ';
94
+ $stringHt .= " ";
95
+ $stringHt .= $separator;
96
+ foreach ($_weeeTaxAttributes as $_attribute) {
97
+ $stringHt .= " ";
98
+ $stringHt .= $_attribute->getName();
99
+ $stringHt .= ':';
100
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount() + $_attribute->getTaxAmount());
101
+ }
102
+ }
103
+ $stringHt .= " ";
104
+ $stringHt .= Mage::helper('catalog')->__('each');
105
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
106
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);
107
+ if ($_weeeTaxAttributes) {
108
+ foreach ($_weeeTaxAttributes as $_attribute) {
109
+ $stringHt .= " ";
110
+ $stringHt .= $_attribute->getName();
111
+ $stringHt .= ':';
112
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount());
113
+ }
114
+ $stringHt .= " ";
115
+ $stringHt .= Mage::helper('catalog')->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']);
116
+ }
117
+ $stringHt .= " ";
118
+ $stringHt .= Mage::helper('catalog')->__('each');
119
+ } else {
120
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price'], $_price['formated_price_incl_tax']);
121
+ }
122
+ } else {
123
+
124
+ if (Mage::helper('tax')->displayPriceIncludingTax()) {
125
+
126
+ if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
127
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee']);
128
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
129
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);
130
+ if ($_weeeTaxAttributes) {
131
+ $stringHt .= " ";
132
+ $separator = '';
133
+ foreach ($_weeeTaxAttributes as $_attribute) {
134
+ $stringHt .= $separator;
135
+ $stringHt .=$_attribute->getName();
136
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount());
137
+ $separator = ' + ';
138
+ $stringHt .= " ";
139
+ }
140
+ }
141
+ $stringHt .= Mage::helper('catalog')->__('each');
142
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
143
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);
144
+ if ($_weeeTaxAttributes) {
145
+ $stringHt .= " ";
146
+ $separator = '';
147
+ foreach ($_weeeTaxAttributes as $_attribute) {
148
+ $stringHt .= $separator;
149
+ $stringHt .=$_attribute->getName();
150
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount() + $_attribute->getTaxAmount());
151
+ $separator = ' + ';
152
+ $stringHt .= " ";
153
+ }
154
+ }
155
+ $stringHt .= Mage::helper('catalog')->__('each');
156
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
157
+
158
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_tax']);
159
+ if ($_weeeTaxAttributes) {
160
+ foreach ($_weeeTaxAttributes as $_attribute) {
161
+ $stringHt .= " ";
162
+ $stringHt .=$_attribute->getName();
163
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount());
164
+ }
165
+ $stringHt .= " ";
166
+ $stringHt .= Mage::helper('catalog')->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']);
167
+ }
168
+ $stringHt .= " ";
169
+ $stringHt .= Mage::helper('catalog')->__('each');
170
+ } else {
171
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_tax']);
172
+ }
173
+ } else {
174
+ if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
175
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
176
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
177
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
178
+ if ($_weeeTaxAttributes) {
179
+ $stringHt .= " ";
180
+ $separator = '';
181
+ foreach ($_weeeTaxAttributes as $_attribute) {
182
+ $stringHt .= $separator;
183
+ $stringHt .=$_attribute->getName();
184
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount());
185
+ $separator = ' + ';
186
+ $stringHt .= " ";
187
+ }
188
+ }
189
+ $stringHt .= " ";
190
+ $stringHt .= Mage::helper('catalog')->__('each');
191
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
192
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
193
+ if ($_weeeTaxAttributes) {
194
+ $stringHt .= " ";
195
+ $separator = '';
196
+ foreach ($_weeeTaxAttributes as $_attribute) {
197
+ $stringHt .= $separator;
198
+ $stringHt .=$_attribute->getName();
199
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount() + $_attribute->getTaxAmount());
200
+ $separator = ' + ';
201
+ $stringHt .= " ";
202
+ }
203
+ }
204
+ $stringHt .= " ";
205
+ $stringHt .= Mage::helper('catalog')->__('each');
206
+ } elseif (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
207
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);
208
+ if ($_weeeTaxAttributes) {
209
+ foreach ($_weeeTaxAttributes as $_attribute) {
210
+ $stringHt .= " ";
211
+ $stringHt .=$_attribute->getName();
212
+ $stringHt .= Mage::helper('core')->currency($_attribute->getAmount());
213
+ }
214
+ $stringHt .= " ";
215
+ $stringHt .= Mage::helper('catalog')->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee_only']);
216
+ }
217
+ $stringHt .= Mage::helper('catalog')->__('each');
218
+ } else {
219
+ $stringHt = Mage::helper('catalog')->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price']);
220
+ }
221
+ }
222
+ }
223
+
224
+
225
+ if (!$_product->isGrouped()) {
226
+ if (($_product->getPrice() == $_product->getFinalPrice() && $_product->getPrice() > $_price['price'])
227
+ || ($_product->getPrice() != $_product->getFinalPrice() && $_product->getFinalPrice() > $_price['price'])) {
228
+ $stringHt .= " ";
229
+ $stringHt .= Mage::helper('catalog')->__('and');
230
+ $stringHt .= " ";
231
+ $stringHt .= Mage::helper('catalog')->__('save');
232
+ $stringHt .= " ";
233
+ $stringHt .= $_price['savePercent'];
234
+ $stringHt .= '%';
235
+ }
236
+ }
237
+ $stringHt .= " ";
238
+ $stringHt .= $_catalogHelper->getMsrpPriceMessage($_product);
239
+ }
240
+ $data[] = $stringHt;
241
+ }
242
+ }
243
+
244
+ return $data;
245
+ }
246
+
247
+ public function getTierPrices($product = null) {
248
+ if ($product == NULL) {
249
+
250
+ $product = $this->_product;
251
+ }
252
+ $prices = $product->getFormatedTierPrice();
253
+
254
+ $res = array();
255
+ if (is_array($prices)) {
256
+ foreach ($prices as $price) {
257
+
258
+ $price['price_qty'] = $price['price_qty'] * 1;
259
+
260
+ $productPrice = $product->getPrice();
261
+ if ($product->getPrice() != $product->getFinalPrice()) {
262
+ $productPrice = $product->getFinalPrice();
263
+ }
264
+
265
+ // Group price must be used for percent calculation if it is lower
266
+ $groupPrice = $product->getGroupPrice();
267
+
268
+ if ($productPrice > $groupPrice) {
269
+ $productPrice = $groupPrice;
270
+ }
271
+
272
+ if ($price['price'] < $productPrice || $product->getTypeId() == "bundle") {
273
+ $price['savePercent'] = ceil(100 - ((100 / $productPrice) * $price['price']));
274
+
275
+ $tierPrice = Mage::app()->getStore()->convertPrice(
276
+ Mage::helper('tax')->getPrice($product, $price['website_price']), false
277
+ );
278
+ $price['formated_price'] = Mage::app()->getStore()->formatPrice($tierPrice, false, false);
279
+ $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
280
+ Mage::app()->getStore()->convertPrice(
281
+ Mage::helper('tax')->getPrice($product, $price['website_price'], false)
282
+ ), false, false
283
+ );
284
+
285
+ if (Mage::helper('catalog')->canApplyMsrp($product)) {
286
+ $oldPrice = $product->getFinalPrice();
287
+ $product->setPriceCalculation(false);
288
+ $product->setPrice($tierPrice);
289
+ $product->setFinalPrice($tierPrice);
290
+
291
+ Mage::app()->getLayout()->getBlock('product.info')->getPriceHtml($product);
292
+ $product->setPriceCalculation(true);
293
+ $price['real_price_html'] = $product->getRealPriceHtml();
294
+ $product->setFinalPrice($oldPrice);
295
+ }
296
+
297
+ $res[] = $price;
298
+ }
299
+ }
300
+ }
301
+ return $res;
302
+ }
303
+ }
app/code/local/Simi/Simiconnector/Helper/Total.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Helper_Total extends Mage_Core_Helper_Abstract {
7
+
8
+ public $data;
9
+
10
+ protected function _getCart() {
11
+ return Mage::getSingleton('checkout/cart');
12
+ }
13
+
14
+ protected function _getQuote() {
15
+ return $this->_getCart()->getQuote();
16
+ }
17
+
18
+ /*
19
+ * Get Quote Price
20
+ */
21
+
22
+ public function getTotal() {
23
+ $orderTotal = array();
24
+ $total = $this->_getQuote()->getTotals();
25
+ $this->setTotal($total, $orderTotal);
26
+ return $orderTotal;
27
+ }
28
+
29
+ /*
30
+ * For Cart and OnePage Order
31
+ */
32
+
33
+ public function setTotal($total, &$data) {
34
+ if (isset($total['shipping'])) {
35
+ /*
36
+ * tax_cart_display_shipping
37
+ */
38
+ $data['shipping_hand_incl_tax'] = $this->getShippingIncludeTax($total['shipping']);
39
+ $data['shipping_hand_excl_tax'] = $this->getShippingExcludeTax($total['shipping']);
40
+ }
41
+ /*
42
+ * tax_cart_display_zero_tax
43
+ */
44
+ if (isset($total['tax'])) {
45
+ $data['tax'] = $total['tax']->getValue();
46
+ $taxSumarry = array();
47
+ foreach ($total['tax']->getFullInfo() as $info) {
48
+ if (isset($info['hidden']) && $info['hidden'])
49
+ continue;
50
+ $amount = $info['amount'];
51
+ $rates = $info['rates'];
52
+ foreach ($rates as $rate) {
53
+ $title = $rate['title'];
54
+ if (!is_null($rate['percent'])) {
55
+ $title.= ' (' . $rate['percent'] . '%)';
56
+ }
57
+ $taxSumarry[] = array('title' => $title,
58
+ 'amount' => $amount,
59
+ );
60
+ /*
61
+ * SimiCart only show the first Rate for Each Item
62
+ */
63
+ break;
64
+ }
65
+ }
66
+ if (count($taxSumarry))
67
+ $data['tax_summary'] = $taxSumarry;
68
+ }
69
+
70
+ if (isset($total['discount'])) {
71
+ $data['discount'] = abs($total['discount']->getValue());
72
+ }
73
+ /*
74
+ * tax_cart_display_subtotal
75
+ */
76
+ if ($this->displayTypeSubOrder() == 3) {
77
+ $data['subtotal_excl_tax'] = $total['subtotal']->getValueExclTax();
78
+ $data['subtotal_incl_tax'] = $total['subtotal']->getValueInclTax();
79
+ } else if (($this->displayTypeSubOrder() == 1) && isset($data['tax'])) {
80
+ $data['subtotal_excl_tax'] = $total['subtotal']->getValue();
81
+ $data['subtotal_incl_tax'] = $data['subtotal_excl_tax'] + $data['tax'];
82
+ } else if (($this->displayTypeSubOrder() == 2) && isset($data['tax'])) {
83
+ $data['subtotal_incl_tax'] = $total['subtotal']->getValue();
84
+ $data['subtotal_excl_tax'] = $data['subtotal_incl_tax'] - $data['tax'];
85
+ }
86
+
87
+ /*
88
+ * tax_cart_display_grandtotal
89
+ */
90
+ $data['grand_total_excl_tax'] = $this->getTotalExclTaxGrand($total['grand_total']);
91
+ $data['grand_total_incl_tax'] = $total['grand_total']->getValue();
92
+
93
+ $coupon = '';
94
+ if (Mage::getSingleton('checkout/session')->getQuote()->getCouponCode() && ($data['discount'] != 0)) {
95
+ $coupon = Mage::getSingleton('checkout/session')->getQuote()->getCouponCode();
96
+ $data['coupon_code'] = $coupon;
97
+ }
98
+
99
+
100
+ $this->data = $data;
101
+
102
+ /*
103
+ * For Phoenix COD fee adding (as Example as well)
104
+ */
105
+ if ((Mage::getSingleton('checkout/type_onepage')->getQuote()->getPayment()->getMethod()) && (Mage::getSingleton('checkout/type_onepage')->getQuote()->getPayment()->getMethodInstance()->getCode() == 'phoenix_cashondelivery')) {
106
+ $codFee = Mage::getSingleton('checkout/type_onepage')->getQuote()->getCodTaxAmount() + Mage::getSingleton('checkout/type_onepage')->getQuote()->getCodFee();
107
+ $this->addCustomRow(Mage::helper('phoenix_cashondelivery')->__('Cash on Delivery fee'), 4, $codFee);
108
+ }
109
+
110
+ Mage::dispatchEvent('simi_simiconnector_helper_total_settotal_after', array('object' => $this, 'data' => $this->data));
111
+ $data = $this->data;
112
+ }
113
+
114
+ public function displayTypeSubOrder() {
115
+ return Mage::getStoreConfig("tax/cart_display/subtotal");
116
+ }
117
+
118
+ /*
119
+ * For Order History
120
+ */
121
+
122
+ public function showTotalOrder($order) {
123
+ $data = array();
124
+ $data['subtotal_excl_tax'] = $order->getSubtotal();
125
+ $data['subtotal_incl_tax'] = $order->getSubtotalInclTax();
126
+ if ($data['subtotal_incl_tax'] == null) {
127
+ $data['subtotal_incl_tax'] = $order->getSubtotal() + $order->getTaxAmount();
128
+ }
129
+ $data['shipping_hand_excl_tax'] = $order->getShippingAmount();
130
+ $data['shipping_hand_incl_tax'] = $order->getShippingInclTax();
131
+ $data['tax'] = $order->getTaxAmount();
132
+ $data['discount'] = abs($order->getDiscountAmount());
133
+ $data['grand_total_excl_tax'] = $order->getGrandTotal() - $data['tax'];
134
+ $data['grand_total_incl_tax'] = $order->getGrandTotal();
135
+
136
+ if (Mage::app()->getLocale()->currency($order->getOrderCurrency()->getCurrencyCode())->getSymbol() != null) {
137
+ $data['currency_symbol'] = Mage::app()->getLocale()->currency($order->getOrderCurrency()->getCurrencyCode())->getSymbol();
138
+ } else {
139
+ $data['currency_symbol'] = $order->getOrderCurrency()->getCurrencyCode();
140
+ }
141
+ return $data;
142
+ }
143
+
144
+ public function addCustomRow($title, $sortOrder, $value, $valueString = null) {
145
+ if (isset($this->data['custom_rows']))
146
+ $customRows = $this->data['custom_rows'];
147
+ else
148
+ $customRows = array();
149
+ if (!$valueString)
150
+ $customRows[] = array('title' => $title, 'sort_order' => $sortOrder, 'value' => $value);
151
+ else
152
+ $customRows[] = array('title' => $title, 'sort_order' => $sortOrder, 'value' => $value, 'value_string' => $valueString);
153
+ $this->data['custom_rows'] = $customRows;
154
+ }
155
+
156
+ public function displayBothTaxSub() {
157
+ return Mage::getSingleton('tax/config')->displayCartSubtotalBoth(Mage::app()->getStore());
158
+ }
159
+
160
+ public function includeTaxGrand($total) {
161
+ if ($total->getAddress()->getGrandTotal()) {
162
+ return Mage::getSingleton('tax/config')->displayCartTaxWithGrandTotal(Mage::app()->getStore());
163
+ }
164
+ return false;
165
+ }
166
+
167
+ public function getTotalExclTaxGrand($total) {
168
+ $excl = $total->getAddress()->getGrandTotal() - $total->getAddress()->getTaxAmount();
169
+ $excl = max($excl, 0);
170
+ return $excl;
171
+ }
172
+
173
+ public function displayBothTaxShipping() {
174
+ return Mage::getSingleton('tax/config')->displayCartShippingBoth(Mage::app()->getStore());
175
+ }
176
+
177
+ public function displayIncludeTaxShipping() {
178
+ return Mage::getSingleton('tax/config')->displayCartShippingInclTax(Mage::app()->getStore());
179
+ }
180
+
181
+ public function getShippingIncludeTax($total) {
182
+ return $total->getAddress()->getShippingInclTax();
183
+ }
184
+
185
+ public function getShippingExcludeTax($total) {
186
+ return $total->getAddress()->getShippingAmount();
187
+ }
188
+
189
+ }
app/code/local/Simi/Simiconnector/Helper/Wishlist.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Helper_Wishlist extends Mage_Core_Helper_Abstract {
4
+
5
+ /*
6
+ * Get Wishlist Item Id
7
+ *
8
+ * @param Product Model
9
+ */
10
+ public function getWishlistItemId($product) {
11
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
12
+ if ($customer->getId() && ($customer->getId() != '')) {
13
+ $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true);
14
+ foreach ($wishlist->getItemCollection() as $item) {
15
+ if ($item->getProduct()->getId() != $product->getId())
16
+ continue;
17
+ $productOptions = $this->getCustomOptions($product);
18
+ if ($product->getTypeId() == 'configurable') {
19
+ $productOptions = array_merge($productOptions, $this->getConfigurableOptions($product));
20
+ }
21
+ if ($product->getTypeId() == 'downloadable') {
22
+ $productOptions = array_merge($productOptions, $this->getDownloadableOptions($product));
23
+ }
24
+ foreach ($productOptions as $productOption) {
25
+ if ($productOption['is_required'] == 'YES') {
26
+ return;
27
+ }
28
+ }
29
+ return $item->getId();
30
+ }
31
+ }
32
+ }
33
+
34
+ /*
35
+ * @param:
36
+ * $item - Wishlist Item
37
+ */
38
+
39
+ public function checkIfSelectedAllRequiredOptions($item, $options = null) {
40
+ $selected = false;
41
+ $product = $item->getProduct();
42
+ $allowedType = array('simple', 'downloadable', 'configurable');
43
+ if (in_array($product->getTypeId(), $allowedType)) {
44
+ $selected = true;
45
+ $selectedoptions = $this->getOptionsSelectedFromItem($item, $product);
46
+ $productOptions = $this->getCustomOptions($product);
47
+ if ($product->getTypeId() == 'configurable') {
48
+ $productOptions = array_merge($productOptions, $this->getConfigurableOptions($product));
49
+ }
50
+ if ($product->getTypeId() == 'downloadable') {
51
+ $productOptions = array_merge($productOptions, $this->getDownloadableOptions($product));
52
+ }
53
+ foreach ($productOptions as $productOption) {
54
+ if ($productOption['is_required'] == 'YES') {
55
+ $selected = false;
56
+ foreach ($selectedoptions as $option) {
57
+ if (($option['option_title'] == $productOption['option_title']) && ($option['option_value']) && ($option['option_value'] != ''))
58
+ $selected = true;
59
+ }
60
+ }
61
+ }
62
+ }
63
+ return $selected;
64
+ }
65
+
66
+ public function getOptionsSelectedFromItem($item, $product) {
67
+ $options = array();
68
+ if (version_compare(Mage::getVersion(), '1.5.0.0', '>=') === true) {
69
+ $helper = Mage::helper('catalog/product_configuration');
70
+ if ($product->getTypeId() == "simple") {
71
+ $options = Mage::helper('simiconnector/checkout')->convertOptionsCart($helper->getCustomOptions($item));
72
+ } elseif ($product->getTypeId() == "configurable") {
73
+ $options = Mage::helper('simiconnector/checkout')->convertOptionsCart($helper->getConfigurableOptions($item));
74
+ } elseif ($product->getTypeId() == "bundle") {
75
+ $options = Mage::helper('simiconnector/checkout')->getOptions($item);
76
+ }
77
+ } else {
78
+ if ($product->getTypeId() != "bundle") {
79
+ $options = Mage::helper('simiconnector/checkout')->getUsedProductOption($item);
80
+ } else {
81
+ $options = Mage::helper('simiconnector/checkout')->getOptions($item);
82
+ }
83
+ }
84
+ return $options;
85
+ }
86
+
87
+ /*
88
+ * Configurable Options
89
+ */
90
+
91
+ public function getConfigurableOptions($_product) {
92
+ $options = array();
93
+ $currentProduct = $_product;
94
+ $products = $this->getAllowProducts($_product);
95
+ $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product);
96
+
97
+ $information = array();
98
+ foreach ($products as $product) {
99
+ $productId = $product->getId();
100
+ foreach ($attributes as $attribute) {
101
+ $productAttribute = $attribute->getProductAttribute();
102
+ $productAttributeId = $productAttribute->getId();
103
+ $attributeValue = $product->getData($productAttribute->getAttributeCode());
104
+
105
+ if (!isset($options[$productAttributeId])) {
106
+ $options[$productAttributeId] = array();
107
+ }
108
+ if (!isset($options[$productAttributeId][$attributeValue])) {
109
+ $options[$productAttributeId][$attributeValue] = array();
110
+ }
111
+ $options[$productAttributeId][$attributeValue][] = $productId;
112
+ }
113
+ }
114
+
115
+ foreach ($attributes as $attribute) {
116
+ $attributeId = $attribute->getProductAttribute()->getId();
117
+ $prices = $attribute->getPrices();
118
+ if (is_array($prices)) {
119
+ foreach ($prices as $value) {
120
+ if (!isset($options[$attributeId][$value['value_index']])) {
121
+ continue;
122
+ }
123
+ $productsIndex = array();
124
+ if (isset($options[$attributeId][$value['value_index']])) {
125
+ $productsIndex = $options[$attributeId][$value['value_index']];
126
+ }
127
+ $infor = array(
128
+ 'option_id' => $value['value_index'],
129
+ 'option_value' => $value['label'],
130
+ 'option_title' => $attribute->getLabel(),
131
+ 'is_required' => 'YES'
132
+ );
133
+ $information[] = $infor;
134
+ }
135
+ }
136
+ }
137
+ return $information;
138
+ }
139
+
140
+ public function getAllowProducts($_product) {
141
+ $products = array();
142
+ $skipSaleableCheck = true;
143
+ if (version_compare(Mage::getVersion(), '1.7.0.0', '>=') === true) {
144
+ $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
145
+ }
146
+ $allProducts = $_product->getTypeInstance(true)
147
+ ->getUsedProducts(null, $_product);
148
+ foreach ($allProducts as $product) {
149
+ if ($product->isSaleable() || $skipSaleableCheck) {
150
+ $products[] = $product;
151
+ }
152
+ }
153
+ return $products;
154
+ }
155
+
156
+ /*
157
+ * Custom Options
158
+ */
159
+
160
+ public function getCustomOptions($product) {
161
+ $information = array();
162
+ foreach ($product->getOptions() as $_option) {
163
+
164
+ if ($_option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
165
+ foreach ($_option->getValues() as $value) {
166
+ $info = array(
167
+ 'option_id' => $value->getId(),
168
+ 'option_value' => $value->getTitle(),
169
+ 'option_title' => $_option->getTitle(),
170
+ 'is_required' => $_option->getIsRequire() == 1 ? 'YES' : 'No',
171
+ );
172
+ $information[] = $info;
173
+ }
174
+ } else if ($_option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_TEXT) {
175
+ $info = array(
176
+ 'option_title' => $_option->getTitle(),
177
+ 'is_required' => $_option->getIsRequire() == 1 ? 'YES' : 'No',
178
+ );
179
+ $information[] = $info;
180
+ } else if ($_option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_DATE) {
181
+ $info = array(
182
+ 'option_title' => $_option->getTitle(),
183
+ 'is_required' => $_option->getIsRequire() == 1 ? 'YES' : 'No',
184
+ );
185
+
186
+ $information[] = $info;
187
+ }
188
+ }
189
+ return $information;
190
+ }
191
+
192
+ /*
193
+ * Downloadable Options
194
+ */
195
+
196
+ public function getDownloadableOptions($product) {
197
+ $info = array();
198
+ $block = Mage::getBlockSingleton('downloadable/catalog_product_links');
199
+ $block->setProduct($product);
200
+ $_links = $block->getLinks();
201
+ $_isRequired = $block->getLinkSelectionRequired();
202
+ if ($_isRequired == '1')
203
+ $_isRequired = 'YES';
204
+ else
205
+ $_isRequired = 'No';
206
+ if ($product->isSaleable() && $block->hasLinks()) {
207
+ $item = array(
208
+ 'title' => $block->getLinksTitle(),
209
+ 'type' => 'checkbox',
210
+ 'position' => '0',
211
+ 'is_required' => $_isRequired,
212
+ );
213
+ $info[] = $item;
214
+ }
215
+ return $info;
216
+ }
217
+
218
+ }
app/code/local/Simi/Simiconnector/Model/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/Model/Address.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Simi_Simiconnector_Model_Address extends Mage_Core_Model_Abstract {
7
+
8
+ protected function _getSession() {
9
+ return Mage::getSingleton('customer/session');
10
+ }
11
+
12
+ protected function _helperAddress() {
13
+ return Mage::helper('simiconnector/address');
14
+ }
15
+
16
+ /*
17
+ * Save Customer Address
18
+ */
19
+ public function saveAddress($data) {
20
+ $data = $data['contents'];
21
+ $address = Mage::helper('simiconnector/address')->convertDataAddress($data);
22
+ $address['id'] = isset($data->entity_id) == true ? $data->entity_id : null;
23
+ return $this->saveAddressCustomer($address);
24
+
25
+ }
26
+
27
+ public function saveAddressCustomer($data) {
28
+ $errors = false;
29
+ $customer = $this->_getSession()->getCustomer();
30
+ $address = Mage::getModel('customer/address');
31
+ $addressId = $data['id'];
32
+ $address->setData($data);
33
+
34
+ if ($addressId && $addressId != '') {
35
+ $existsAddress = $customer->getAddressById($addressId);
36
+ if ($existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) {
37
+ $address->setId($existsAddress->getId());
38
+ }
39
+ } else {
40
+ $address->setId(null);
41
+ }
42
+
43
+ if (version_compare(Mage::getVersion(), '1.4.2.0', '>=') === true) {
44
+ $addressForm = Mage::getModel('customer/form');
45
+ $addressForm->setFormCode('customer_address_edit')
46
+ ->setEntity($address);
47
+ $addressForm->compactData($data);
48
+ }
49
+ $address->setCustomerId($customer->getId());
50
+ $addressErrors = $address->validate();
51
+ if ($addressErrors !== true) {
52
+ $errors = true;
53
+ }
54
+ if (!$errors) {
55
+ $address->save();
56
+ return $address;
57
+ } else {
58
+ if (is_array($addressErrors))
59
+ throw new Exception($addressErrors[0],7);
60
+ throw new Exception($this->_helperAddress()->__('Can not save address customer'),7);
61
+ }
62
+ }
63
+
64
+ public function getStates($code) {
65
+ $list = array();
66
+ if ($code) {
67
+ $states = Mage::getModel('directory/country')->loadByCode($code)->getRegions();
68
+ foreach ($states as $state) {
69
+ $list[] = array(
70
+ 'state_id' => $state->getRegionId(),
71
+ 'state_name' => $state->getName(),
72
+ 'state_code' => $state->getCode(),
73
+ );
74
+ }
75
+ }
76
+ return $list;
77
+ }
78
+
79
+ }
app/code/local/Simi/Simiconnector/Model/Api/Abstract.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 2:59 PM
8
+ */
9
+ abstract class Simi_Simiconnector_Model_Api_Abstract
10
+ {
11
+ public $FILTER_RESULT = true;
12
+
13
+ const DEFAULT_DIR = 'asc';
14
+ const DEFAULT_LIMIT = 15;
15
+ const DIR = 'dir';
16
+ const ORDER = 'order';
17
+ const PAGE = 'page';
18
+ const LIMIT = 'limit';
19
+ const OFFSET = 'offset';
20
+ const FILTER = 'filter';
21
+ const ALL_IDS = 'all_ids';
22
+ const LIMIT_COUNT = 200;
23
+
24
+ protected $_DEFAULT_ORDER = 'entity_id';
25
+
26
+ protected $_helper;
27
+ /**
28
+ * Singular key.
29
+ *
30
+ * @var string
31
+ */
32
+ protected $singularKey;
33
+ /**
34
+ * Plural key.
35
+ *
36
+ * @var string
37
+ */
38
+ protected $pluralKey;
39
+ /**
40
+ *
41
+ */
42
+ /**
43
+ * @var collection Magento
44
+ */
45
+ protected $builderQuery = null;
46
+
47
+ protected $_data;
48
+
49
+ public function __construct()
50
+ {
51
+ $this->_helper = Mage::helper('simiconnector');
52
+ }
53
+
54
+ abstract public function setBuilderQuery();
55
+
56
+ public function setData($data)
57
+ {
58
+ $this->_data = $data;
59
+ }
60
+
61
+ public function getData()
62
+ {
63
+ return $this->_data;
64
+ }
65
+
66
+ /**
67
+ * Get singular key
68
+ * @return string
69
+ */
70
+ public function getSingularKey()
71
+ {
72
+ return $this->singularKey;
73
+ }
74
+
75
+ /**
76
+ * Set singular query
77
+ * @return $this
78
+ */
79
+ public function setSingularKey($singularKey)
80
+ {
81
+ $this->singularKey = substr($singularKey, 0, -1);
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Get singular key
87
+ * @return string
88
+ */
89
+ public function getPluralKey()
90
+ {
91
+ return $this->pluralKey;
92
+ }
93
+
94
+ /**
95
+ * Set singular query
96
+ * @return $this
97
+ */
98
+ public function setPluralKey($pluralKey)
99
+ {
100
+ $this->pluralKey = $pluralKey;
101
+ return $this;
102
+ }
103
+
104
+ //start
105
+ public function store()
106
+ {
107
+ return $this->getDetail(array());
108
+ }
109
+
110
+ public function index()
111
+ {
112
+ $collection = $this->builderQuery;
113
+ $this->filter();
114
+ $data = $this->getData();
115
+ $parameters = $data['params'];
116
+ $page = 1;
117
+ if (isset($parameters[self::PAGE]) && $parameters[self::PAGE]) {
118
+ $page = $parameters[self::PAGE];
119
+ }
120
+
121
+ $limit = self::DEFAULT_LIMIT;
122
+ if (isset($parameters[self::LIMIT]) && $parameters[self::LIMIT]) {
123
+ $limit = $parameters[self::LIMIT];
124
+ }
125
+
126
+ $offset = $limit * ($page - 1);
127
+ if (isset($parameters[self::OFFSET]) && $parameters[self::OFFSET]) {
128
+ $offset = $parameters[self::OFFSET];
129
+ }
130
+ $collection->setPageSize($offset + $limit);
131
+
132
+ $all_ids = array();
133
+ $info = array();
134
+ $total = $collection->getSize();
135
+
136
+ if ($offset > $total)
137
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
138
+
139
+ $fields = array();
140
+ if (isset($parameters['fields']) && $parameters['fields']) {
141
+ $fields = explode(',', $parameters['fields']);
142
+ }
143
+
144
+ $check_limit = 0;
145
+ $check_offset = 0;
146
+
147
+ foreach ($collection as $entity) {
148
+ if (++$check_offset <= $offset) {
149
+ continue;
150
+ }
151
+ if (++$check_limit > $limit)
152
+ break;
153
+
154
+ $info[] = $entity->toArray($fields);
155
+ $all_ids[] = $entity->getId();
156
+ }
157
+ return $this->getList($info, $all_ids, $total, $limit, $offset);
158
+ }
159
+
160
+ public function show()
161
+ {
162
+ $entity = $this->builderQuery;
163
+ $data = $this->getData();
164
+ $parameters = $data['params'];
165
+ $fields = array();
166
+ if (isset($parameters['fields']) && $parameters['fields']) {
167
+ $fields = explode(',', $parameters['fields']);
168
+ }
169
+ $info = $entity->toArray($fields);
170
+ return $this->getDetail($info);
171
+ }
172
+
173
+ public function update()
174
+ {
175
+ return $this->getDetail(array());
176
+ }
177
+
178
+ public function destroy()
179
+ {
180
+ return $this->getDetail(array());
181
+ }
182
+
183
+ //end
184
+ public function getBuilderQuery()
185
+ {
186
+ return $this->builderQuery;
187
+ }
188
+
189
+ public function callApi($data)
190
+ {
191
+ $this->renewCustomerSesssion($data);
192
+ $this->setData($data);
193
+ $this->setBuilderQuery(null);
194
+ $this->setPluralKey($data['resource']);
195
+ $this->setSingularKey($data['resource']);
196
+ if ($data['is_method'] == 1) {
197
+ if (isset($data['resourceid']) && $data['resourceid'] != '') {
198
+ return $this->show($data['resourceid']);
199
+ } else {
200
+ return $this->index();
201
+ }
202
+ } elseif ($data['is_method'] == 2) {
203
+ return $this->store();
204
+ } elseif ($data['is_method'] == 3) {
205
+ return $this->update($data['resourceid']);
206
+ } elseif ($data['is_method'] == 4) {
207
+ return $this->destroy($data['resourceid']);
208
+ }
209
+ }
210
+
211
+ public function getList($info, $all_ids, $total, $page_size, $from)
212
+ {
213
+ return array(
214
+ 'all_ids' => $all_ids,
215
+ $this->getPluralKey() => $this->motifyFields($info),
216
+ 'total' => $total,
217
+ 'page_size' => $page_size,
218
+ 'from' => $from,
219
+ );
220
+ }
221
+
222
+ public function getDetail($info)
223
+ {
224
+ return array($this->getSingularKey() => $this->motifyFields($info));
225
+ }
226
+
227
+ protected function filter()
228
+ {
229
+ if (!$this->FILTER_RESULT)
230
+ return;
231
+ $data = $this->_data;
232
+ $parameters = $data['params'];
233
+ $query = $this->builderQuery;
234
+ $this->_whereFilter($query, $parameters);
235
+ $this->_order($parameters);
236
+
237
+ return $query;
238
+ }
239
+
240
+ protected function _order($parameters)
241
+ {
242
+ $query = $this->builderQuery;
243
+ $order = isset($parameters[self::ORDER]) ? $parameters[self::ORDER] : $this->_DEFAULT_ORDER;
244
+ $order = str_replace('|', '.', $order);
245
+ $dir = isset($parameters[self::DIR]) ? $parameters[self::DIR] : self::DEFAULT_DIR;
246
+ $query->setOrder($order, $dir);
247
+ }
248
+
249
+ protected function _whereFilter(&$query, $parameters)
250
+ {
251
+ if (isset($parameters[self::FILTER])) {
252
+ foreach ($parameters[self::FILTER] as $key => $value) {
253
+ if ($key == 'or') {
254
+ $filters = array();
255
+ foreach ($value as $k => $v) {
256
+ $filters[] = $this->_addCondition($k, $v, true);
257
+ }
258
+ if (count($filters)) $query->addAttributeToFilter($filters);
259
+ } else {
260
+ $filter = $this->_addCondition($key, $value);
261
+ $query->addAttributeToFilter($key, $filter);
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ protected function _addCondition($key, $value, $isOr = false)
268
+ {
269
+ $key = str_replace('|', '.', $key);
270
+ if (is_array($value)) {
271
+ foreach ($value as $operator => $v) {
272
+ if ($operator == 'in' || $operator == 'nin') {
273
+ return $isOr ? array('attribute' => $key, $operator => explode(',', $v)) : array($operator => explode(',', $v));
274
+ } else {
275
+ return $isOr ? array('attribute' => $key, $operator => $v) : array($operator => $v);
276
+ }
277
+ }
278
+ } else {
279
+ if (strlen($value) > 0) {
280
+ return $isOr ? array('attribute' => $key, 'eq' => $value) : array('eq' => $value);
281
+ }
282
+ }
283
+ }
284
+
285
+ protected function motifyFields($content)
286
+ {
287
+ $data = $this->getData();
288
+ $parameters = $data['params'];
289
+ if (isset($parameters['fields']) && $parameters['fields']) {
290
+ $fields = explode(',', $parameters['fields']);
291
+ $motify = array();
292
+ foreach ($content as $key => $item) {
293
+ if (in_array($key, $fields)) {
294
+ $motify[$key] = $item;
295
+ }
296
+ }
297
+ return $motify;
298
+ }else{
299
+ return $content;
300
+ }
301
+ }
302
+
303
+ protected function renewCustomerSesssion($data){
304
+ Mage::helper('simiconnector/customer')->renewCustomerSesssion($data);
305
+ }
306
+ }
app/code/local/Simi/Simiconnector/Model/Api/Addresses.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Simi_Simiconnector_Model_Api_Addresses extends Simi_Simiconnector_Model_Api_Abstract {
7
+
8
+ protected $_DEFAULT_ORDER = 'entity_id';
9
+
10
+ public function setSingularKey($singularKey) {
11
+ $this->singularKey = 'Address';
12
+ return $this;
13
+ }
14
+
15
+ public function setBuilderQuery() {
16
+ $data = $this->getData();
17
+ if (isset($data['resourceid']) && $data['resourceid']) {
18
+
19
+ } else {
20
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
21
+ throw new Exception($this->_helper->__('You have not logged in'), 4);
22
+ } else {
23
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
24
+ $addressArray = array();
25
+ $billing = $customer->getPrimaryBillingAddress();
26
+ if ($billing) {
27
+ $addressArray[] = $billing->getId();
28
+ }
29
+ $shipping = $customer->getPrimaryShippingAddress();
30
+ if ($shipping) {
31
+ $addressArray[] = $shipping->getId();
32
+ }
33
+ foreach ($customer->getAddresses() as $index => $address) {
34
+ $addressArray[] = $index;
35
+ }
36
+ $this->builderQuery = Mage::getModel('customer/address')->getCollection()
37
+ ->addFieldToFilter('entity_id', array('in' => $addressArray));
38
+ }
39
+ }
40
+ }
41
+
42
+ /*
43
+ * Add Address
44
+ */
45
+
46
+ public function store() {
47
+ $data = $this->getData();
48
+ $address = Mage::getModel('simiconnector/address')->saveAddress($data);
49
+ $this->builderQuery = $address;
50
+ return $this->show();
51
+ }
52
+
53
+ /*
54
+ * Edit Address
55
+ */
56
+
57
+ public function update() {
58
+ $data = $this->getData();
59
+ $address = Mage::getModel('simiconnector/address')->saveAddress($data);
60
+ $this->builderQuery = $address;
61
+ return $this->show();
62
+ }
63
+
64
+ /*
65
+ * Remove Address
66
+ */
67
+
68
+ public function destroy() {
69
+ $data = $this->getData();
70
+ if ($data['resourceid']) {
71
+ $this->builderQuery = Mage::getModel('customer/address')->load($data['resourceid']);
72
+ $this->builderQuery->delete();
73
+ return $this->show();
74
+ }
75
+ throw new Exception($this->_helper->__('No Address ID sent'), 4);
76
+ }
77
+
78
+
79
+ /*
80
+ * View Address Detail
81
+ */
82
+
83
+ public function index() {
84
+ $result = parent::index();
85
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
86
+ $addresses = $result['addresses'];
87
+ foreach ($addresses as $index => $address) {
88
+ $addressModel = Mage::getModel('customer/address')->load($address['entity_id']);
89
+ $addresses[$index] = array_merge($address, Mage::helper('simiconnector/address')->getAddressDetail($addressModel, $customer));
90
+ }
91
+ $result['addresses'] = $addresses;
92
+ return $result;
93
+ }
94
+
95
+ /*
96
+ * Geocoding
97
+ */
98
+
99
+ public function show() {
100
+ $data = $this->getData();
101
+ if ($data['resourceid']) {
102
+ if ($data['resourceid'] == 'geocoding') {
103
+ $result = array();
104
+ $addressDetail = array();
105
+ $longitude = $data['params']['longitude'];
106
+ $latitude = $data['params']['latitude'];
107
+ $dataresult = Mage::helper('simiconnector/address')->getLocationInfo($latitude, $longitude);
108
+ $dataresult = $dataresult['geocoding'];
109
+ for ($j = 0; $j < count($dataresult->results[0]->address_components); $j++) {
110
+ $addressComponents = $dataresult->results[0]->address_components[$j];
111
+ $types = $addressComponents->types;
112
+ if (in_array('street_number', $types)) {
113
+ $address .= $addressComponents->long_name;
114
+ }
115
+ if (in_array('route', $types)) {
116
+ $address .= ' ' . $addressComponents->long_name;
117
+ }
118
+ if (in_array('locality', $types)) {
119
+ $address .= ', ' . $addressComponents->long_name;
120
+ }
121
+ $addressDetail['street'] = $address;
122
+ if (in_array('postal_town', $types) || in_array('administrative_area_level_1', $types)) {
123
+ $addressDetail['region'] = $addressComponents->long_name;
124
+ $addressDetail['region_id'] = $addressComponents->short_name;
125
+ }
126
+
127
+ if (in_array('administrative_area_level_2', $types)) {
128
+ $addressDetail['city'] = $addressComponents->short_name;
129
+ }
130
+
131
+ if (in_array('country', $types)) {
132
+ $addressDetail['country_name'] = $addressComponents->long_name;
133
+ $addressDetail['country_id'] = $addressComponents->short_name;
134
+ }
135
+ if (in_array('postal_code', $types)) {
136
+ $addressDetail['postcode'] = $addressComponents->long_name;
137
+ }
138
+ }
139
+ $result['address'] = $addressDetail;
140
+ return $result;
141
+ }
142
+ }
143
+ return parent::show();
144
+ }
145
+
146
+ }
app/code/local/Simi/Simiconnector/Model/Api/Categories.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Scott
6
+ * Date: 5/19/2016
7
+ * Time: 4:47 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Categories extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'position';
12
+ protected $_visible_array;
13
+
14
+ public function setBuilderQuery() {
15
+ $data = $this->getData();
16
+ if (!$data['resourceid']) {
17
+ $data['resourceid'] = Mage::app()->getStore()->getRootCategoryId();
18
+ }
19
+ if (Mage::getStoreConfig('simiconnector/general/categories_in_app'))
20
+ $this->_visible_array = explode(',', Mage::getStoreConfig('simiconnector/general/categories_in_app'));
21
+
22
+ $category = Mage::getModel('catalog/category')->load($data['resourceid']);
23
+ if (is_array($category->getChildrenCategories())) {
24
+ $idArray =explode(',', $category->getChildren());
25
+ if ($this->_visible_array)
26
+ $idArray = array_intersect($idArray, $this->_visible_array);
27
+ $this->builderQuery = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('entity_id', array('in' => $idArray));
28
+ }else {
29
+ $this->builderQuery = $this->_getChildrenCategories($category)->addAttributeToSelect('*');
30
+ }
31
+ }
32
+
33
+ public function index() {
34
+ $data = $this->getData();
35
+ $result = parent::index();
36
+ foreach ($result['categories'] as $index => $catData) {
37
+ $childCollection = Mage::getModel('catalog/category')->getCollection()->addFieldToFilter('parent_id', $catData['entity_id']);
38
+ if ($this->_visible_array)
39
+ $childCollection->addFieldToFilter('entity_id', array('in' => $this->_visible_array));
40
+ if ($childCollection->count() > 0)
41
+ $result['categories'][$index]['has_children'] = TRUE;
42
+ else
43
+ $result['categories'][$index]['has_children'] = FALSE;
44
+ }
45
+ return $result;
46
+ }
47
+
48
+ public function show() {
49
+ return $this->index();
50
+ }
51
+
52
+ public function _getChildrenCategories($category){
53
+ $idFilter = $category->getChildren();
54
+
55
+ if($this->_visible_array){
56
+ $ids = explode(',', $idFilter);
57
+ $idFilter = array_intersect($ids, $this->_visible_array);
58
+ $idFilter = implode(',',$idFilter);
59
+ }
60
+
61
+ $collection = $this->_getChildrenCategoriesBase($category);
62
+ $collection->addAttributeToFilter('is_active', 1)
63
+ ->addIdFilter($idFilter)
64
+ ->load();
65
+
66
+ return $collection;
67
+ }
68
+
69
+ private function _getChildrenCategoriesBase($category)
70
+ {
71
+ $collection = $category->getCollection();
72
+ $collection->addAttributeToSelect('url_key')
73
+ ->addAttributeToSelect('name')
74
+ ->addAttributeToSelect('all_children')
75
+ ->addAttributeToSelect('is_anchor')
76
+ ->setOrder('position', Varien_Db_Select::SQL_ASC)
77
+ ->joinUrlRewrite();
78
+
79
+ return $collection;
80
+ }
81
+ }
app/code/local/Simi/Simiconnector/Model/Api/Cmspages.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Cmspages extends Simi_Simiconnector_Model_Api_Abstract {
4
+
5
+ protected $_DEFAULT_ORDER = 'sort_order';
6
+
7
+ public function setBuilderQuery() {
8
+ $data = $this->getData();
9
+ if (isset($data['resourceid']) && $data['resourceid']) {
10
+ $this->builderQuery = Mage::getModel('simiconnector/cms')->load($data['resourceid']);
11
+ } else {
12
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('cms');
13
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
14
+ $cmsCollection = Mage::getModel('simiconnector/cms')->getCollection()->addFieldToFilter('type','1');
15
+ $cmsCollection->getSelect()
16
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.cms_id AND visibility.content_type = '.$typeID.' AND visibility.store_view_id =' . Mage::app()->getStore()->getId());
17
+ $this->builderQuery = $cmsCollection;
18
+ }
19
+ }
20
+
21
+ }
app/code/local/Simi/Simiconnector/Model/Api/Customers.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Simi_Simiconnector_Model_Api_Customers extends Simi_Simiconnector_Model_Api_Abstract {
7
+
8
+ protected $_DEFAULT_ORDER = 'entity_id';
9
+ protected $_RETURN_MESSAGE;
10
+
11
+ public function setBuilderQuery() {
12
+ $data = $this->getData();
13
+ if (isset($data['resourceid']) && $data['resourceid']) {
14
+ switch ($data['resourceid']) {
15
+ case 'forgetpassword':
16
+ Mage::getModel('simiconnector/customer')->forgetPassword($data);
17
+ $email = $data['params']['email'];
18
+ $this->builderQuery = Mage::getSingleton('customer/session')->getCustomer();
19
+ $this->_RETURN_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));
20
+ break;
21
+ case 'profile':
22
+ $this->builderQuery = Mage::getSingleton('customer/session')->getCustomer();
23
+ break;
24
+ case 'login':
25
+ if (Mage::getModel('simiconnector/customer')->login($data))
26
+ $this->builderQuery = Mage::getSingleton('customer/session')->getCustomer();
27
+ else
28
+ throw new Exception($this->_helper->__('Login Failed'), 4);
29
+ break;
30
+ case 'sociallogin':
31
+ $this->builderQuery = Mage::getModel('simiconnector/customer')->socialLogin($data);
32
+ case 'logout':
33
+ if (Mage::getModel('simiconnector/customer')->logout($data))
34
+ $this->builderQuery = Mage::getSingleton('customer/session')->getCustomer();
35
+ else
36
+ throw new Exception($this->_helper->__('Logout Failed'), 4);
37
+ break;
38
+ default:
39
+ $this->builderQuery = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->load($data['resourceid']);
40
+ if (!$this->builderQuery->getId())
41
+ $this->builderQuery = Mage::getModel("customer/customer")->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($data['resourceid']);
42
+ break;
43
+ }
44
+ } else {
45
+ $currentCustomerId = 0;
46
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
47
+ $currentCustomerId = Mage::getSingleton('customer/session')->getId();
48
+ }
49
+ $this->builderQuery = Mage::getModel('customer/customer')->getCollection()
50
+ ->addFieldToFilter('entity_id', $currentCustomerId);
51
+ }
52
+ }
53
+
54
+ /*
55
+ * Register
56
+ */
57
+
58
+ public function store() {
59
+ $data = $this->getData();
60
+ $customer = Mage::getModel('simiconnector/customer')->register($data);
61
+ $this->builderQuery = $customer;
62
+ $this->_RETURN_MESSAGE = Mage::helper('customer')->__("Thank you for registering with " . Mage::app()->getStore()->getName() . " store");
63
+ return $this->show();
64
+ }
65
+
66
+ /*
67
+ * Update Profile
68
+ */
69
+
70
+ public function update() {
71
+ $data = $this->getData();
72
+ $customer = Mage::getModel('simiconnector/customer')->updateProfile($data);
73
+ $this->builderQuery = $customer;
74
+ $this->_RETURN_MESSAGE = Mage::helper('customer')->__('The account information has been saved.');
75
+ return $this->show();
76
+ }
77
+
78
+ /*
79
+ * Add Message
80
+ */
81
+
82
+ public function getDetail($info) {
83
+ //$info['dob'] = date("Y-m-d H:i:s", strtotime($info['dob']));
84
+ if ($this->_RETURN_MESSAGE) {
85
+ $resultArray = parent::getDetail($info);
86
+ $resultArray['message'] = array($this->_RETURN_MESSAGE);
87
+ return $resultArray;
88
+ }
89
+ return parent::getDetail($info);
90
+ }
91
+
92
+ }
app/code/local/Simi/Simiconnector/Model/Api/Devices.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Devices extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'device_id';
12
+
13
+ public function setBuilderQuery() {
14
+ $data = $this->getData();
15
+ if (isset($data['resourceid']) && $data['resourceid']) {
16
+ $this->builderQuery = Mage::getModel('simiconnector/device')->load($data['resourceid']);
17
+ } else {
18
+ $this->builderQuery = Mage::getModel('simiconnector/device')->getCollection();
19
+ }
20
+ }
21
+
22
+ public function store() {
23
+ $data = $this->getData();
24
+ $device = Mage::getModel('simiconnector/device');
25
+ $device->saveDevice($data);
26
+ $this->builderQuery = $device;
27
+ return $this->show();
28
+ }
29
+
30
+ }
app/code/local/Simi/Simiconnector/Model/Api/Downloadableproducts.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Simi_Simiconnector_Model_Api_Downloadableproducts extends Simi_Simiconnector_Model_Api_Abstract {
5
+
6
+ protected $_DEFAULT_ORDER = 'item_id';
7
+ protected $_purchased = '';
8
+
9
+ public function setBuilderQuery() {
10
+ $data = $this->getData();
11
+ if (isset($data['resourceid']) && $data['resourceid']) {
12
+
13
+ } else {
14
+ $this->builderQuery = $this->getCollectionItems();
15
+ }
16
+ }
17
+
18
+ public function index() {
19
+ $result = parent::index();
20
+ foreach ($result['downloadableproducts'] as $index => $item) {
21
+ $_item = $this->getCollectionItems()->addFieldToFilter('item_id', $item['item_id'])->getFirstItem();
22
+ $fileName = '';
23
+ if ($_item->getData('link_file')) {
24
+ $fileName = $_item->getData('link_file');
25
+ $fileName = explode('/', $fileName);
26
+ $fileName = end($fileName);
27
+ }
28
+ $itDe = $this->getPurchased()->getItemById($_item->getPurchasedId());
29
+ $data = array(
30
+ 'order_id' => $itDe->getOrderIncrementId(),
31
+ 'order_date' => $itDe->getCreatedAt(),
32
+ 'order_name' => $itDe->getProductName(),
33
+ 'order_link' => $this->getDownloadUrl($_item),
34
+ 'order_file' => $fileName,
35
+ 'order_status' => $_item->getStatus(),
36
+ 'order_remain' => $this->getRemainingDownloads($_item)
37
+ );
38
+ $item = array_merge($item, $data);
39
+ $result['downloadableproducts'][$index] = $item;
40
+ }
41
+ return $result;
42
+ }
43
+
44
+ public function getCollectionItems() {
45
+ $session = Mage::getSingleton('customer/session');
46
+ $purchased = Mage::getResourceModel('downloadable/link_purchased_collection')
47
+ ->addFieldToFilter('customer_id', $session->getCustomerId())
48
+ ->addOrder('created_at', 'desc');
49
+
50
+ $this->setPurchased($purchased);
51
+ $purchasedIds = array();
52
+ foreach ($purchased as $_item) {
53
+ $purchasedIds[] = $_item->getId();
54
+ }
55
+ if (empty($purchasedIds)) {
56
+ $purchasedIds = array(null);
57
+ }
58
+
59
+ $purchasedItems = Mage::getResourceModel('downloadable/link_purchased_item_collection')
60
+ ->addFieldToFilter('purchased_id', array('in' => $purchasedIds))
61
+ ->addFieldToFilter('status', array(
62
+ 'nin' => array(
63
+ Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PENDING_PAYMENT,
64
+ Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PAYMENT_REVIEW
65
+ )
66
+ )
67
+ )
68
+ ->setOrder('item_id', 'desc');
69
+ return $purchasedItems;
70
+ }
71
+
72
+ public function getDownloadUrl($item) {
73
+ return Mage::getUrl('downloadable/download/link', array('id' => $item->getLinkHash(), '_secure' => true));
74
+ }
75
+
76
+ public function getRemainingDownloads($item) {
77
+ if ($item->getNumberOfDownloadsBought()) {
78
+ $downloads = $item->getNumberOfDownloadsBought() - $item->getNumberOfDownloadsUsed();
79
+ return $downloads;
80
+ }
81
+ return Mage::helper('downloadable')->__('Unlimited');
82
+ }
83
+
84
+ public function getPurchased() {
85
+ return $this->_purchased;
86
+ }
87
+
88
+ public function setPurchased($value) {
89
+ $this->_purchased = $value;
90
+ }
91
+
92
+ }
app/code/local/Simi/Simiconnector/Model/Api/Homebanners.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Homebanners extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'sort_order';
12
+
13
+ public function setBuilderQuery() {
14
+ $data = $this->getData();
15
+ if (isset($data['resourceid']) && $data['resourceid']) {
16
+ $this->builderQuery = Mage::getModel('simiconnector/banner')->load($data['resourceid']);
17
+ } else {
18
+ $this->builderQuery = $this->getCollection();
19
+ }
20
+ }
21
+
22
+ public function getCollection() {
23
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('banner');
24
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
25
+ $bannerCollection = Mage::getModel('simiconnector/banner')->getCollection()->addFieldToFilter('status','1');
26
+ $bannerCollection->getSelect()
27
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.banner_id AND visibility.content_type = ' . $typeID . ' AND visibility.store_view_id =' . Mage::app()->getStore()->getId());
28
+
29
+ return $bannerCollection;
30
+ }
31
+
32
+ public function index() {
33
+
34
+
35
+
36
+ $result = parent::index();
37
+ foreach ($result['homebanners'] as $index => $item) {
38
+ $imageBaseDir = explode('/simi/', $item['banner_name']);
39
+ $imagesize = @getimagesize(Mage::getBaseDir('media').'/simi/'.$imageBaseDir[1]);
40
+ $item['width'] = $imagesize[0];
41
+ $item['height'] = $imagesize[1];
42
+
43
+ if (!$item['banner_name_tablet'])
44
+ $item['banner_name_tablet'] = $item['banner_name'];
45
+
46
+ if ($item['banner_name_tablet']) {
47
+ $imageBaseDir = explode('/simi/', $item['banner_name_tablet']);
48
+ $imagesize = @getimagesize(Mage::getBaseDir('media').'/simi/'.$imageBaseDir[1]);
49
+ $item['width_tablet'] = $imagesize[0];
50
+ $item['height_tablet'] = $imagesize[1];
51
+ }
52
+ if ($item['type'] == 2) {
53
+ $categoryModel = Mage::getModel('catalog/category')->load($item['category_id']);
54
+ $item['has_children'] = $categoryModel->hasChildren();
55
+ $item['cat_name'] = $categoryModel->getName();
56
+ }
57
+ $result['homebanners'][$index] = $item;
58
+ }
59
+ return $result;
60
+ }
61
+
62
+ }
app/code/local/Simi/Simiconnector/Model/Api/Homecategories.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Homecategories extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'sort_order';
12
+ protected $_visible_array;
13
+
14
+ public function setSingularKey($singularKey) {
15
+ $this->singularKey = 'Homecategory';
16
+ return $this;
17
+ }
18
+
19
+ public function setBuilderQuery() {
20
+ $data = $this->getData();
21
+ if (isset($data['resourceid']) && $data['resourceid']) {
22
+ $this->builderQuery = Mage::getModel('simiconnector/simicategory')->load($data['resourceid']);
23
+ } else {
24
+ $this->builderQuery = $this->getCollection();
25
+ }
26
+ }
27
+
28
+ public function getCollection() {
29
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('homecategory');
30
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
31
+ $simicategoryCollection = Mage::getModel('simiconnector/simicategory')->getCollection()->addFieldToFilter('status', '1');
32
+ $simicategoryCollection->getSelect()
33
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.simicategory_id AND visibility.content_type = ' . $typeID . ' AND visibility.store_view_id =' . Mage::app()->getStore()->getId());
34
+ return $simicategoryCollection;
35
+ }
36
+
37
+ public function index() {
38
+ $result = parent::index();
39
+ $data = $this->getData();
40
+
41
+ foreach ($result['homecategories'] as $index => $item) {
42
+ $imageBaseDir = explode('/simi/', $item['simicategory_filename']);
43
+ $imagesize = @getimagesize(Mage::getBaseDir('media') . '/simi/' . $imageBaseDir[1]);
44
+ $item['width'] = $imagesize[0];
45
+ $item['height'] = $imagesize[1];
46
+ if (!$item['simicategory_filename_tablet'])
47
+ $item['simicategory_filename_tablet'] = $item['simicategory_filename'];
48
+ if ($item['simicategory_filename_tablet']) {
49
+ $imageBaseDir = explode('/simi/', $item['simicategory_filename_tablet']);
50
+ $imagesize = @getimagesize(Mage::getBaseDir('media') . '/simi/' . $imageBaseDir[1]);
51
+ $item['width_tablet'] = $imagesize[0];
52
+ $item['height_tablet'] = $imagesize[1];
53
+ }
54
+ $categoryModel = Mage::getModel('catalog/category')->load($item['category_id']);
55
+ $item['cat_name'] = $categoryModel->getName();
56
+ $childCollection = $this->getVisibleChildren($item['category_id']);
57
+ if ($childCollection->count() > 0) {
58
+ $item['has_children'] = TRUE;
59
+ if ($data['params']['get_child_cat']) {
60
+ $childArray = array();
61
+ foreach ($childCollection as $childCat) {
62
+ $childInfo = $childCat->toArray();
63
+ $grandchildCollection = $this->getVisibleChildren($childCat->getId());
64
+ if ($grandchildCollection->count() > 0)
65
+ $childInfo['has_children'] = TRUE;
66
+ else
67
+ $childInfo['has_children'] = FALSE;
68
+ $childArray[] = $childInfo;
69
+ }
70
+ $item['children'] = $childArray;
71
+ }
72
+ } else {
73
+ $item['has_children'] = FALSE;
74
+ }
75
+ $result['homecategories'][$index] = $item;
76
+ }
77
+ return $result;
78
+ }
79
+
80
+ /*
81
+ * @param Cat ID
82
+ * Return Child Cat collection
83
+ */
84
+
85
+ public function getVisibleChildren($catId) {
86
+ $category = Mage::getModel('catalog/category')->load($catId);
87
+ if (is_array($category->getChildrenCategories())) {
88
+ $childArray = $category->getChildrenCategories();
89
+ $idArray = array();
90
+ foreach ($childArray as $childArrayItem) {
91
+ $idArray[] = $childArrayItem->getId();
92
+ }
93
+ return Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('entity_id', array('in' => $idArray));
94
+ }
95
+ return $category->getChildrenCategories()->addAttributeToSelect('*');
96
+ }
97
+
98
+ }
app/code/local/Simi/Simiconnector/Model/Api/Homeproductlists.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Homeproductlists extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'sort_order';
12
+ public $SHOW_PRODUCT_ARRAY = TRUE;
13
+
14
+ public function setBuilderQuery() {
15
+ $data = $this->getData();
16
+ if (isset($data['resourceid']) && $data['resourceid']) {
17
+ $this->builderQuery = Mage::getModel('simiconnector/productlist')->load($data['resourceid']);
18
+ } else {
19
+ $this->builderQuery = $this->getCollection();
20
+ }
21
+ }
22
+
23
+ public function getCollection() {
24
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('productlist');
25
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
26
+ $listCollection = Mage::getModel('simiconnector/productlist')->getCollection()->addFieldToFilter('list_status','1');
27
+ $listCollection->getSelect()
28
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.productlist_id AND visibility.content_type = ' . $typeID . ' AND visibility.store_view_id =' . Mage::app()->getStore()->getId());
29
+ return $listCollection;
30
+ }
31
+
32
+ public function show() {
33
+ $result = parent::show();
34
+ $result['homeproductlist'] = $this->_addInfo($result['homeproductlist']);
35
+ return $result;
36
+ }
37
+
38
+ public function index() {
39
+ $result = parent::index();
40
+ foreach ($result['homeproductlists'] as $index => $item) {
41
+ $result['homeproductlists'][$index] = $this->_addInfo($item);
42
+ }
43
+ return $result;
44
+ }
45
+
46
+ private function _addInfo($dataArray) {
47
+ $listModel = Mage::getModel('simiconnector/productlist')->load($dataArray['productlist_id']);
48
+ $imageBaseDir = explode('/simi/', $listModel->getData('list_image'));
49
+ $imagesize = @getimagesize(Mage::getBaseDir('media').'/simi/'.$imageBaseDir[1]);
50
+ $dataArray['width'] = $imagesize[0];
51
+ $dataArray['height'] = $imagesize[1];
52
+
53
+ if (!$dataArray['list_image_tablet'])
54
+ $dataArray['list_image_tablet'] = $dataArray['list_image'];
55
+
56
+ if ($dataArray['list_image_tablet']) {
57
+ $imageBaseDir = explode('/simi/', $dataArray['list_image_tablet']);
58
+ $imagesize = @getimagesize(Mage::getBaseDir('media').'/simi/'.$imageBaseDir[1]);
59
+ $dataArray['width_tablet'] = $imagesize[0];
60
+ $dataArray['height_tablet'] = $imagesize[1];
61
+ }
62
+ $typeArray = Mage::helper('simiconnector/productlist')->getListTypeId();
63
+ $dataArray['type_name'] = $typeArray[$listModel->getData('list_type')];
64
+ if ($this->SHOW_PRODUCT_ARRAY) {
65
+ $productCollection = Mage::helper('simiconnector/productlist')->getProductCollection($listModel);
66
+ $productListAPIModel = Mage::getModel('simiconnector/api_products');
67
+ $productListAPIModelData = $this->getData();
68
+ unset($productListAPIModelData['resourceid']);
69
+ $productListAPIModel->setData($productListAPIModelData);
70
+ $productListAPIModel->setBuilderQuery();
71
+ $productListAPIModel->FILTER_RESULT = false;
72
+ $productListAPIModel->builderQuery = $productCollection;
73
+ $productListAPIModel->pluralKey = 'products';
74
+ $listAPI = $productListAPIModel->index();
75
+ $dataArray['product_array'] = $listAPI;
76
+ }
77
+ return $dataArray;
78
+ }
79
+
80
+ }
app/code/local/Simi/Simiconnector/Model/Api/Homes.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Homes extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'sort_order';
12
+
13
+ public function setBuilderQuery() {
14
+
15
+ }
16
+
17
+ public function index() {
18
+ return $this->show();
19
+ }
20
+
21
+ public function show() {
22
+ $data = $this->getData();
23
+ /*
24
+ * Get Banners
25
+ */
26
+ $banners = Mage::getModel('simiconnector/api_homebanners');
27
+ $banners->builderQuery = $banners->getCollection();
28
+ $banners->setPluralKey('homebanners');
29
+ $banners = $banners->index();
30
+
31
+ /*
32
+ * Get Categories
33
+ */
34
+ $categories = Mage::getModel('simiconnector/api_homecategories');
35
+ $categories->setData($this->getData());
36
+ $categories->builderQuery = $categories->getCollection();
37
+ $categories->setPluralKey('homecategories');
38
+ $categories = $categories->index();
39
+
40
+ /*
41
+ * Get Product List
42
+ */
43
+ $productlists = Mage::getModel('simiconnector/api_homeproductlists');
44
+ $productlists->builderQuery = $productlists->getCollection();
45
+ if ($data['resourceid'] == 'lite') {
46
+ $productlists->SHOW_PRODUCT_ARRAY = FALSE;
47
+ }
48
+ $productlists->setPluralKey('homeproductlists');
49
+ $productlists->setData($this->getData());
50
+ $productlists = $productlists->index();
51
+
52
+
53
+ $information = array('home' => array(
54
+ 'homebanners' => $banners,
55
+ 'homecategories' => $categories,
56
+ 'homeproductlists' => $productlists,
57
+ ));
58
+ return $information;
59
+ }
60
+
61
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Abstract.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 2:59 PM
8
+ */
9
+ abstract class Simi_Simiconnector_Model_Api_Migrate_Abstract extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ public $FILTER_RESULT = false;
12
+ const DEFAULT_LIMIT = PHP_INT_MAX;
13
+
14
+ public function index()
15
+ {
16
+ $collection = $this->builderQuery;
17
+ $this->filter();
18
+ $data = $this->getData();
19
+ $parameters = $data['params'];
20
+ $page = 1;
21
+ if (isset($parameters[self::PAGE]) && $parameters[self::PAGE]) {
22
+ $page = $parameters[self::PAGE];
23
+ }
24
+
25
+ $limit = self::DEFAULT_LIMIT;
26
+ if (isset($parameters[self::LIMIT]) && $parameters[self::LIMIT]) {
27
+ $limit = $parameters[self::LIMIT];
28
+ }
29
+
30
+ $offset = $limit * ($page - 1);
31
+ if (isset($parameters[self::OFFSET]) && $parameters[self::OFFSET]) {
32
+ $offset = $parameters[self::OFFSET];
33
+ }
34
+ if ($limit) {
35
+ $collection->setPageSize($offset + $limit);
36
+ }
37
+ //$all_ids = array();
38
+ $info = array();
39
+ $total = $collection->getSize();
40
+
41
+ if ($offset > $total)
42
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
43
+
44
+ $fields = array();
45
+ if (isset($parameters['fields']) && $parameters['fields']) {
46
+ $fields = explode(',', $parameters['fields']);
47
+ }
48
+
49
+ $check_limit = 0;
50
+ $check_offset = 0;
51
+
52
+ foreach ($collection as $entity) {
53
+ if ($limit) {
54
+ if (++$check_offset <= $offset) {
55
+ continue;
56
+ }
57
+ if (++$check_limit > $limit)
58
+ break;
59
+ }
60
+ $info[] = $entity->toArray($fields);
61
+ //$all_ids[] = $entity->getId();
62
+ }
63
+ return $this->getList($info, $all_ids, $total, $limit, $offset);
64
+ }
65
+
66
+ public function getList($info, $all_ids, $total, $page_size, $from)
67
+ {
68
+ return array(
69
+ //'all_ids' => $all_ids,
70
+ $this->getPluralKey() => $this->motifyFields($info),
71
+ 'total' => $total,
72
+ 'page_size' => $page_size,
73
+ 'from' => $from,
74
+ );
75
+ }
76
+
77
+
78
+ protected function renewCustomerSesssion($data){
79
+ return;
80
+ }
81
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Categories.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Categories extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('catalog/category')
8
+ ->getCollection()
9
+ ->addAttributeToSelect('url_path')
10
+ ->addAttributeToSelect('name');
11
+ } else {
12
+ $this->builderQuery = Mage::getModel('catalog/category')->load($data['resourceid']);
13
+ }
14
+ }
15
+
16
+ public function index()
17
+ {
18
+ $result = parent::index();
19
+ $storeIds = $this->getAllStoreIds();
20
+ foreach ($result['migrate_categories'] as $index=>$category) {
21
+ $nameArray = array();
22
+ foreach ($storeIds as $storeId) {
23
+ $nameByStore = Mage::getModel('catalog/category')
24
+ ->setStoreId($storeId)->load($category['entity_id'])->getName();
25
+ if ($nameByStore) {
26
+ $nameArray[] = array($storeId, $nameByStore);
27
+ }
28
+ }
29
+ if (count($nameArray)) {
30
+ $result['migrate_categories'][$index]['json_name'] = json_encode($nameArray);
31
+ }
32
+ }
33
+ return $result;
34
+ }
35
+
36
+ public function getAllStoreIds()
37
+ {
38
+ return Mage::getModel('core/store')
39
+ ->getCollection()->getAllIds();
40
+ }
41
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Categorytrees.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Categorytrees extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('catalog/category')
8
+ ->getCollection()
9
+ ->addAttributeToSelect('url_path')
10
+ ->addAttributeToSelect('name');
11
+ } else {
12
+ $this->builderQuery = Mage::getModel('catalog/category')->load($data['resourceid']);
13
+ }
14
+ }
15
+
16
+ public function index()
17
+ {
18
+ $result = parent::index();
19
+ $returnedTree = array();
20
+ foreach ($result['migrate_categorytrees'] as $tree) {
21
+ $paths = explode("/", $tree['path']);
22
+ $script = "\$returnedTree";
23
+ foreach($paths as $path) {
24
+ $script.="[".$path."]";
25
+ }
26
+ $script.= " = \$tree;";
27
+ eval($script);
28
+ }
29
+ $result['migrate_categorytrees'] = $returnedTree;
30
+ $result['total'] = count($returnedTree);
31
+ return $result;
32
+ }
33
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Customers.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Customers extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('customer/customer')
8
+ ->getCollection();
9
+ } else {
10
+ $this->builderQuery = Mage::getModel('customer/customer')->load($data['resourceid']);
11
+ }
12
+ }
13
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Orders.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Orders extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('sales/order')
8
+ ->getCollection();
9
+ } else {
10
+ $this->builderQuery = Mage::getModel('sales/order')->load($data['resourceid']);
11
+ }
12
+ }
13
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Packages.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Packages extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ throw new Exception($this->_helper->__('No Package Sent'), 4);
8
+ } else {
9
+ $data = $this->getData();
10
+ if ($data['resourceid'] == 'all') {
11
+ return;
12
+ }
13
+ throw new Exception($this->_helper->__('Package Invalid'), 4);
14
+ }
15
+ }
16
+
17
+
18
+ public function show() {
19
+ $result = array();
20
+
21
+ $storetModel = Mage::getSingleton('simiconnector/api_migrate_stores');
22
+ $storetModel->setBuilderQuery();
23
+ $storetModel->pluralKey = 'migrate_stores';
24
+ $result['stores'] = $storetModel->index();
25
+
26
+ $storeviewtModel = Mage::getSingleton('simiconnector/api_migrate_storeviews');
27
+ $storeviewtModel->setBuilderQuery();
28
+ $storeviewtModel->pluralKey = 'migrate_storeviews';
29
+ $result['storeviews'] = $storeviewtModel->index();
30
+
31
+ $productModel = Mage::getSingleton('simiconnector/api_migrate_products');
32
+ $productModel->setBuilderQuery();
33
+ $productModel->pluralKey = 'migrate_products';
34
+ $result['products'] = $productModel->index();
35
+
36
+ $categoryModel = Mage::getSingleton('simiconnector/api_migrate_categories');
37
+ $categoryModel->setBuilderQuery();
38
+ $categoryModel->pluralKey = 'migrate_categories';
39
+ $result['categories'] = $categoryModel->index();
40
+
41
+ $customerModel = Mage::getSingleton('simiconnector/api_migrate_customers');
42
+ $customerModel->setBuilderQuery();
43
+ $customerModel->pluralKey = 'migrate_customers';
44
+ $result['customers'] = $customerModel->index();
45
+
46
+ return array('migrate_package'=>$result);
47
+ }
48
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Products.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Products extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('catalog/product')
8
+ ->getCollection()
9
+ ->addAttributeToSelect('name');
10
+ } else {
11
+ $this->builderQuery = Mage::getModel('catalog/product')->load($data['resourceid']);
12
+ }
13
+ }
14
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Stores.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Stores extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('core/store_group')
8
+ ->getCollection();
9
+ } else {
10
+ $this->builderQuery = Mage::getModel('core/store_group')->load($data['resourceid']);
11
+ }
12
+ }
13
+ }
app/code/local/Simi/Simiconnector/Model/Api/Migrate/Storeviews.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Migrate_Storeviews extends Simi_Simiconnector_Model_Api_Migrate_Abstract {
4
+ public function setBuilderQuery() {
5
+ $data = $this->getData();
6
+ if (!$data['resourceid']) {
7
+ $this->builderQuery = Mage::getModel('core/store')
8
+ ->getCollection();
9
+ } else {
10
+ $this->builderQuery = Mage::getModel('core/store')->load($data['resourceid']);
11
+ }
12
+ }
13
+ }
app/code/local/Simi/Simiconnector/Model/Api/Notifications.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Notifications extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'notice_id';
12
+
13
+ public function setBuilderQuery() {
14
+ $data = $this->getData();
15
+ if (isset($data['resourceid']) && $data['resourceid']) {
16
+ $this->builderQuery = Mage::getModel('simiconnector/siminotification')->load($data['resourceid']);
17
+ } else {
18
+ $deviceModel = Mage::getModel('simiconnector/device')->getCollection()->addFieldToFilter('device_token', $data['params']['device_token'])->getFirstItem();
19
+ if (!($deviceModel->getId())) {
20
+ $this->builderQuery = Mage::getModel('simiconnector/siminotification')->getCollection();
21
+ return;
22
+ }
23
+ $shownList = array();
24
+ foreach (Mage::getModel('simiconnector/history')->getCollection() as $noticeHistory) {
25
+ $noticeId = $noticeHistory->getData('notice_id');
26
+ if ($noticeId && !in_array($noticeId, $shownList)) {
27
+ if (in_array($deviceModel->getId(), explode(',', str_replace(' ', '', $noticeHistory->getData('devices_pushed'))))) {
28
+ $shownList[] = $noticeHistory->getData('notice_id');
29
+ }
30
+ }
31
+ }
32
+ $this->builderQuery = Mage::getModel('simiconnector/siminotification')->getCollection()->addFieldToFilter('notice_id', array('in' => $shownList));
33
+ }
34
+ }
35
+
36
+ public function index() {
37
+ $result = parent::index();
38
+ foreach ($result['notifications'] as $index => $notification) {
39
+ if (!$notification['type'])
40
+ $notification['type'] = '1';
41
+ if ($notification['image_url']) {
42
+ $notification['image_url'] = Mage::getBaseUrl('media') . $notification['image_url'];
43
+ $list = @getimagesize($notification['image_url']);
44
+ $notification['width'] = $list[0];
45
+ $notification['height'] = $list[1];
46
+ }
47
+ if ($notification['category_id']) {
48
+ $categoryId = $notification['category_id'];
49
+ $category = Mage::getModel('catalog/category')->load($categoryId);
50
+ $categoryChildrenCount = $category->getChildrenCount();
51
+ $categoryName = $category->getName();
52
+ $notification['category_name'] = $categoryName;
53
+ if ($categoryChildrenCount > 0)
54
+ $categoryChildrenCount = 1;
55
+ else
56
+ $categoryChildrenCount = 0;
57
+ $notification['has_child'] = $categoryChildrenCount;
58
+ if (!$notification['has_child']) {
59
+ $notification['has_child'] = '';
60
+ }
61
+ }
62
+ if ($notification['product_id']) {
63
+ $productId = $notification['product_id'];
64
+ $productName = Mage::getModel('catalog/product')->load($productId)->getName();
65
+ $notification['product_name'] = $productName;
66
+ }
67
+ $result['notifications'][$index] = $notification;
68
+ }
69
+
70
+ return $result;
71
+ }
72
+
73
+ }
app/code/local/Simi/Simiconnector/Model/Api/Orders.php ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Orders extends Simi_Simiconnector_Model_Api_Abstract
4
+ {
5
+
6
+ protected $_DEFAULT_ORDER = 'entity_id';
7
+ protected $_RETURN_MESSAGE;
8
+ protected $_QUOTE_INITED = FALSE;
9
+ public $detail_onepage;
10
+ public $place_order;
11
+ public $order_placed_info;
12
+
13
+ protected function _getCart()
14
+ {
15
+ return Mage::getSingleton('checkout/cart');
16
+ }
17
+
18
+ protected function _getQuote()
19
+ {
20
+ return $this->_getCart()->getQuote();
21
+ }
22
+
23
+ protected function _getCheckoutSession()
24
+ {
25
+ return Mage::getSingleton('checkout/session');
26
+ }
27
+
28
+ public function _getOnepage()
29
+ {
30
+ return Mage::getSingleton('checkout/type_onepage');
31
+ }
32
+
33
+ public function setBuilderQuery()
34
+ {
35
+ $data = $this->getData();
36
+ if (isset($data['resourceid']) && $data['resourceid']) {
37
+ if ($data['resourceid'] == 'onepage') {
38
+
39
+ } else {
40
+ $this->builderQuery = Mage::getModel('sales/order')->load($data['resourceid']);
41
+ if (!$this->builderQuery->getId()) {
42
+ $this->builderQuery = Mage::getModel('sales/order')->loadByIncrementId($data['resourceid']);
43
+ }
44
+ if (!$this->builderQuery->getId()) {
45
+ throw new Exception(Mage::helper('simiconnector')->__('Cannot find the Order'), 6);
46
+ }
47
+ }
48
+ } else {
49
+ $this->builderQuery = Mage::getModel('sales/order')->getCollection()
50
+ ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
51
+ ->setOrder('entity_id', 'DESC');
52
+ }
53
+ }
54
+
55
+ /*
56
+ * Update Checkout Order (onepage) Information
57
+ */
58
+
59
+ public function update()
60
+ {
61
+ $data = $this->getData();
62
+ if ($data['resourceid'] == 'onepage') {
63
+ $this->_updateOrder();
64
+ return $this->show();
65
+ } else {
66
+ $order = $this->builderQuery;
67
+ $param = $data['contents'];
68
+ $order_helper = Mage::helper('simiconnector/orders');
69
+ $result = null;
70
+ if ($param->status == 'cancel') {
71
+ $result = $order_helper->cancelOrder($order);
72
+ } elseif ($param->status == 'invoice') {
73
+ $result = $order_helper->invoiceOrder($order);
74
+ } elseif ($param->status == 'ship') {
75
+ $result = $order_helper->shipOrder($order);
76
+ } elseif ($param->status == 'hold') {
77
+ $result = $order_helper->holdOrder($order);
78
+ } elseif ($param->status == 'unhold') {
79
+ $result = $order_helper->unHoldOrder($order);
80
+ } else {
81
+ $order->setState($param->status, true);
82
+ $order->save();
83
+ }
84
+ if (null != $result) {
85
+ $return_data = $this->show();
86
+ $return_data[$this->getSingularKey()]['message'] = $result['message'];
87
+ return $return_data;
88
+ }
89
+ return $this->show();
90
+ }
91
+ }
92
+
93
+ private function _updateOrder()
94
+ {
95
+ $data = $this->getData();
96
+ $parameters = (array)$data['contents'];
97
+
98
+ if (isset($parameters['b_address'])) {
99
+ $this->_initCheckout();
100
+ Mage::helper('simiconnector/address')->saveBillingAddress($parameters['b_address']);
101
+ if (!isset($parameters['s_address']))
102
+ $parameters['s_address'] = $parameters['b_address'];
103
+ }
104
+ if (isset($parameters['s_address'])) {
105
+ $this->_initCheckout();
106
+ Mage::helper('simiconnector/address')->saveShippingAddress($parameters['s_address']);
107
+ }
108
+
109
+ if (isset($parameters['coupon_code'])) {
110
+ $this->_RETURN_MESSAGE = Mage::helper('simiconnector/coupon')->setCoupon($parameters['coupon_code']);
111
+ }
112
+ if (isset($parameters['s_method'])) {
113
+ Mage::helper('simiconnector/checkout_shipping')->saveShippingMethod($parameters['s_method']);
114
+ }
115
+ if (isset($parameters['p_method'])) {
116
+ Mage::helper('simiconnector/checkout_payment')->savePaymentMethod($parameters['p_method']);
117
+ }
118
+ $this->_getOnepage()->getQuote()->collectTotals()->save();
119
+ }
120
+
121
+ private function _initCheckout()
122
+ {
123
+ if (!$this->_QUOTE_INITED) {
124
+ $this->_getCheckoutSession()->setCartWasUpdated(false);
125
+ $this->_getOnepage()->initCheckout();
126
+ $this->_QUOTE_INITED = TRUE;
127
+ }
128
+ }
129
+
130
+ /*
131
+ * Place Order
132
+ */
133
+
134
+ public function store()
135
+ {
136
+ $this->_updateOrder();
137
+
138
+ $this->place_order = TRUE;
139
+ Mage::dispatchEvent('simi_simiconnector_model_api_orders_onepage_store_before', array('object' => $this, 'data' => $this->getData()));
140
+ if (!$this->place_order) {
141
+ $result = array('order' => $this->order_placed_info);
142
+ return $result;
143
+ }
144
+
145
+ $quote = $this->_getQuote();
146
+ if (!$quote->validateMinimumAmount()) {
147
+ throw new Exception(Mage::getStoreConfig('sales/minimum_order/error_message'), 4);
148
+ }
149
+ $this->_getOnepage()->saveOrder();
150
+ $this->_getOnepage()->getQuote()->save();
151
+ $order = array('invoice_number' => $this->_getCheckoutSession()->getLastRealOrderId(),
152
+ 'payment_method' => $this->_getOnepage()->getQuote()->getPayment()->getMethodInstance()->getCode()
153
+ );
154
+
155
+ $incrementId = $this->_getCheckoutSession()->getLastRealOrderId();
156
+ $orderId = Mage::getModel('sales/order')->loadByIncrementId($incrementId)->getId();
157
+ Mage::helper('simiconnector/checkout')->processOrderAfter($orderId, $order);
158
+ $this->order_placed_info = $order;
159
+ Mage::dispatchEvent('simi_simiconnector_model_api_orders_onepage_store_after', array('object' => $this, 'data' => $order));
160
+ $result = array('order' => $this->order_placed_info);
161
+ $this->cleanSession();
162
+ return $result;
163
+ }
164
+
165
+ /*
166
+ * Return Order Detail (History and Onepage)
167
+ */
168
+
169
+ public function show()
170
+ {
171
+ $data = $this->getData();
172
+ if ($data['resourceid'] == 'onepage') {
173
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
174
+ $quote = $this->_getQuote();
175
+ $list_payment = array();
176
+ /*
177
+ * Get Detail Payment
178
+ */
179
+ $paymentHelper = Mage::helper('simiconnector/checkout_payment');
180
+ foreach (Mage::helper('simiconnector/checkout_payment')->getMethods() as $method) {
181
+ $list_payment[] = $paymentHelper->getDetailsPayment($method);
182
+ }
183
+
184
+ $order = array();
185
+ $order['billing_address'] = Mage::helper('simiconnector/address')->getAddressDetail($quote->getBillingAddress(), $customer);
186
+ $order['shipping_address'] = Mage::helper('simiconnector/address')->getAddressDetail($quote->getShippingAddress(), $customer);
187
+ $order['shipping'] = Mage::helper('simiconnector/checkout_shipping')->getMethods();
188
+ $order['payment'] = $list_payment;
189
+ $order['total'] = Mage::helper('simiconnector/total')->getTotal();
190
+ $detail_onepage = array('order' => $order);
191
+ if ($this->_RETURN_MESSAGE) {
192
+ $detail_onepage['message'] = array($this->_RETURN_MESSAGE);
193
+ }
194
+ $this->detail_onepage = $detail_onepage;
195
+ Mage::dispatchEvent('simi_simiconnector_model_api_orders_onepage_show_after', array('object' => $this, 'data' => $this->detail_onepage));
196
+ return $this->detail_onepage;
197
+ } else {
198
+ $result = parent::show();
199
+ if ($data['params']['reorder'] == 1) {
200
+ $order = Mage::getModel('sales/order')->load($data['resourceid']);
201
+ $cart = Mage::getSingleton('checkout/cart');
202
+ $items = $order->getItemsCollection();
203
+ foreach ($items as $item) {
204
+ $cart->addOrderItem($item);
205
+ }
206
+ $cart->save();
207
+ $result['message'] = Mage::helper('simiconnector')->__('Reorder Succeeded');
208
+ }
209
+ $order = $result['order'];
210
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
211
+ $this->_updateOrderInformation($order, $customer);
212
+ $result['order'] = $order;
213
+ return $result;
214
+ }
215
+ }
216
+
217
+ /*
218
+ * Order History
219
+ */
220
+
221
+ public function index()
222
+ {
223
+ $result = parent::index();
224
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
225
+ foreach ($result['orders'] as $index => $order) {
226
+ $this->_updateOrderInformation($order, $customer);
227
+ $result['orders'][$index] = $order;
228
+ }
229
+ return $result;
230
+ }
231
+
232
+ private function _updateOrderInformation(&$order, $customer)
233
+ {
234
+ $orderModel = Mage::getModel('sales/order')->load($order['entity_id']);
235
+ $order['payment_method'] = $orderModel->getPayment()->getMethodInstance()->getTitle();
236
+ $order['shipping_method'] = $orderModel->getShippingDescription();
237
+ $order['billing_address'] = Mage::helper('simiconnector/address')->getAddressDetail($orderModel->getBillingAddress(), $customer);
238
+ if (!$orderModel->getShippingAddress())
239
+ $order['shipping_address'] = $order['billing_address'];
240
+ else
241
+ $order['shipping_address'] = Mage::helper('simiconnector/address')->getAddressDetail($orderModel->getShippingAddress(), $customer);
242
+ $order['order_items'] = $this->_getProductFromOrderHistoryDetail($orderModel);
243
+ $order['total'] = Mage::helper('simiconnector/total')->showTotalOrder($orderModel);
244
+ }
245
+
246
+ public function _getProductFromOrderHistoryDetail($order)
247
+ {
248
+ $productInfo = array();
249
+ $itemCollection = $order->getAllVisibleItems();
250
+ foreach ($itemCollection as $item) {
251
+ $options = array();
252
+ if ($item->getProductOptions()) {
253
+ $options = $this->_getOptions($item->getProductType(), $item->getProductOptions());
254
+ }
255
+ $product_id = $item->getProductId();
256
+ $product = $item->getProduct();
257
+ if (version_compare(Mage::getVersion(), '1.7.0.0', '<') === true) {
258
+ $product = Mage::getModel('catalog/product')->load($product_id);
259
+ }
260
+ $productInfo[] = array_merge(array('option' => $options), $item->toArray(), array('image' => Mage::helper('simiconnector/products')->getImageProduct($item->getProduct()))
261
+ );
262
+ }
263
+
264
+ return $productInfo;
265
+ }
266
+
267
+ public function _getOptions($type, $options)
268
+ {
269
+ $list = array();
270
+ if ($type == 'bundle') {
271
+ foreach ($options['bundle_options'] as $option) {
272
+ foreach ($option['value'] as $value) {
273
+ $list[] = array(
274
+ 'option_title' => $option['label'],
275
+ 'option_value' => $value['title'],
276
+ 'option_price' => $value['price'],
277
+ );
278
+ }
279
+ }
280
+ } else {
281
+ $options = array();
282
+ $optionsList = array();
283
+ if (isset($options['additional_options'])) {
284
+ $optionsList = $options['additional_options'];
285
+ } elseif (isset($options['attributes_info'])) {
286
+ $optionsList = $options['attributes_info'];
287
+ } elseif (isset($options['options'])) {
288
+ $optionsList = $options['options'];
289
+ }
290
+ foreach ($optionsList as $option) {
291
+ $list[] = array(
292
+ 'option_title' => $option['label'],
293
+ 'option_value' => $option['value'],
294
+ 'option_price' => isset($option['price']) == true ? $option['price'] : 0,
295
+ );
296
+ }
297
+ }
298
+ return $list;
299
+ }
300
+
301
+ public function cleanSession()
302
+ {
303
+ $session = $this->_getOnepage()->getCheckout();
304
+ $lastOrderId = $session->getLastOrderId();
305
+ $session->clear();
306
+ Mage::dispatchEvent('simiconnector_checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
307
+ }
308
+
309
+ }
app/code/local/Simi/Simiconnector/Model/Api/Products.php ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Products extends Simi_Simiconnector_Model_Api_Abstract
10
+ {
11
+
12
+ protected $_layer = array();
13
+ protected $_allow_filter_core = false;
14
+ protected $_helperProduct;
15
+ protected $_sortOrders = array();
16
+ public $detail_info;
17
+
18
+ /**
19
+ * override
20
+ */
21
+ public function setBuilderQuery()
22
+ {
23
+ $data = $this->getData();
24
+ $parameters = $data['params'];
25
+ $this->_helperProduct = Mage::helper('simiconnector/products');
26
+ $this->_helperProduct->setData($data);
27
+
28
+ if (isset($data['resourceid']) && $data['resourceid']) {
29
+ $this->builderQuery = $this->_helperProduct->getProduct($data['resourceid']);
30
+ } else {
31
+ if (isset($parameters[self::FILTER])) {
32
+ $filter = $parameters[self::FILTER];
33
+ if (isset($filter['cat_id'])) {
34
+ $this->setFilterByCategoryId($filter['cat_id']);
35
+ } elseif (isset($filter['q'])) {
36
+ $this->setFilterByQuery();
37
+ } elseif (isset($filter['related_to_id'])) {
38
+ $this->setFilterByRelated($filter['related_to_id']);
39
+ } else {
40
+ $this->setFilterByCategoryId(Mage::app()->getStore()->getRootCategoryId());
41
+ // $this->_allow_filter_core = true;
42
+ }
43
+ } else {
44
+ //all products
45
+ $this->setFilterByCategoryId(Mage::app()->getStore()->getRootCategoryId());
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * @param $info
52
+ * @param $all_ids
53
+ * @param $total
54
+ * @param $page_size
55
+ * @param $from
56
+ * @return array
57
+ * override
58
+ */
59
+ public function getList($info, $all_ids, $total, $page_size, $from)
60
+ {
61
+ return array(
62
+ 'all_ids' => $all_ids,
63
+ $this->getPluralKey() => $info,
64
+ 'total' => $total,
65
+ 'page_size' => $page_size,
66
+ 'from' => $from,
67
+ 'layers' => $this->_layer,
68
+ 'orders' => $this->_sortOrders,
69
+ );
70
+ }
71
+
72
+ /**
73
+ * @return collection
74
+ * override
75
+ */
76
+ protected function filter()
77
+ {
78
+ if (!$this->FILTER_RESULT)
79
+ return;
80
+ $data = $this->_data;
81
+ $parameters = $data['params'];
82
+ if ($this->_allow_filter_core) {
83
+ $query = $this->builderQuery;
84
+ $this->_whereFilter($query, $parameters);
85
+
86
+ }
87
+
88
+ if (isset($parameters['dir']) && isset($parameters['order']))
89
+ $this->_order($parameters);
90
+
91
+ return null;
92
+ }
93
+
94
+ /**
95
+ * @return array
96
+ * @throws Exception
97
+ * override
98
+ */
99
+ public function index()
100
+ {
101
+ $collection = $this->builderQuery;
102
+ $this->filter();
103
+ $data = $this->getData();
104
+ $parameters = $data['params'];
105
+ $page = 1;
106
+ if (isset($parameters[self::PAGE]) && $parameters[self::PAGE]) {
107
+ $page = $parameters[self::PAGE];
108
+ }
109
+
110
+ $limit = self::DEFAULT_LIMIT;
111
+ if (isset($parameters[self::LIMIT]) && $parameters[self::LIMIT]) {
112
+ $limit = $parameters[self::LIMIT];
113
+ }
114
+
115
+ $offset = $limit * ($page - 1);
116
+ if (isset($parameters[self::OFFSET]) && $parameters[self::OFFSET]) {
117
+ $offset = $parameters[self::OFFSET];
118
+ }
119
+ $collection->setPageSize($offset + $limit);
120
+
121
+ $all_ids = array();
122
+ $info = array();
123
+ $total = $collection->getSize();
124
+
125
+ if ($offset > $total)
126
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
127
+
128
+ $fields = array();
129
+ if (isset($parameters['fields']) && $parameters['fields']) {
130
+ $fields = explode(',', $parameters['fields']);
131
+ }
132
+
133
+ $check_limit = 0;
134
+ $check_offset = 0;
135
+
136
+ if (isset($parameters['image_width'])){
137
+ $image_width = $parameters['image_width'];
138
+ $image_height = $parameters['image_height'];
139
+ } else {
140
+ $image_width = 600;
141
+ $image_height = 600;
142
+ }
143
+
144
+ foreach ($collection as $entity) {
145
+ if (++$check_offset <= $offset) {
146
+ continue;
147
+ }
148
+ if (++$check_limit > $limit)
149
+ break;
150
+ $info_detail = $entity->toArray($fields);
151
+ $all_ids[] = $entity->getId();
152
+ $images = array();
153
+ $imagelink = $this->_helperProduct->getImageProduct($entity, null, $image_width, $image_height);
154
+ //$sizes = getimagesize($imagelink);
155
+ $images[] = array(
156
+ 'url' => $imagelink,
157
+ 'position' => 1,
158
+ // 'image_width' => $sizes[0],
159
+ // 'image_height' => $sizes[1],
160
+ );
161
+ $ratings = Mage::helper('simiconnector/review')->getRatingStar($entity->getId());
162
+ $total_rating = Mage::helper('simiconnector/review')->getTotalRate($ratings);
163
+ $avg = Mage::helper('simiconnector/review')->getAvgRate($ratings, $total_rating);
164
+
165
+ $info_detail['images'] = $images;
166
+ $info_detail['app_prices'] = Mage::helper('simiconnector/price')->formatPriceFromProduct($entity);
167
+ $info_detail['app_reviews'] = array(
168
+ 'rate' => $avg,
169
+ 'number' => $ratings[5],
170
+ );
171
+ $info_detail['product_label'] = Mage::helper('simiconnector/productlabel')->getProductLabel($entity);
172
+ $info[] = $info_detail;
173
+ }
174
+ return $this->getList($info, $all_ids, $total, $limit, $offset);
175
+ }
176
+
177
+ /**
178
+ * @return array
179
+ * override
180
+ */
181
+ public function show()
182
+ {
183
+ $entity = $this->builderQuery;
184
+ $data = $this->getData();
185
+ $parameters = $data['params'];
186
+ $fields = array();
187
+ if (isset($parameters['fields']) && $parameters['fields']) {
188
+ $fields = explode(',', $parameters['fields']);
189
+ }
190
+ $info = $entity->toArray($fields);
191
+ $media_gallery = $entity->getMediaGallery();
192
+ $images = array();
193
+
194
+ if (isset($parameters['image_width'])){
195
+ $image_width = $parameters['image_width'];
196
+ $image_height = $parameters['image_height'];
197
+ } else {
198
+ $image_width = 600;
199
+ $image_height = 600;
200
+ }
201
+
202
+ foreach ($media_gallery['images'] as $image) {
203
+ // Zend_debug::dump($image['disabled']);
204
+ if ($image['disabled'] == 0) {
205
+ $imagelink = $this->_helperProduct->getImageProduct($entity, $image['file'], $image_width, $image_height);
206
+ //$sizes = getimagesize($imagelink);
207
+ $images[] = array(
208
+ 'url' => $imagelink,
209
+ 'position' => $image['position'],
210
+ // 'image_width' => $sizes[0],
211
+ // 'image_height' => $sizes[1],
212
+ );
213
+ }
214
+ }
215
+ if (count($images) == 0) {
216
+ $imagelink = $this->_helperProduct->getImageProduct($entity, null, $image_width, $image_height);
217
+ //$sizes = getimagesize($imagelink);
218
+ $images[] = array(
219
+ 'url' => $imagelink,
220
+ 'position' => 1,
221
+ // 'image_width' => $sizes[0],
222
+ // 'image_height' => $sizes[1],
223
+ );
224
+ }
225
+ if (!Mage::registry('product') && $entity->getId()) {
226
+ Mage::register('product', $entity);
227
+ }
228
+
229
+ $block_att = Mage::getBlockSingleton('catalog/product_view_attributes');
230
+ $_additional = $block_att->getAdditionalData();
231
+
232
+ $ratings = Mage::helper('simiconnector/review')->getRatingStar($entity->getId());
233
+ $total_rating = Mage::helper('simiconnector/review')->getTotalRate($ratings);
234
+ $avg = Mage::helper('simiconnector/review')->getAvgRate($ratings, $total_rating);
235
+
236
+ $info['description'] = Mage::helper('catalog/output')->productAttribute($entity, $entity->getDescription(), 'description');
237
+ $info['additional'] = $_additional;
238
+ $info['images'] = $images;
239
+ $info['app_prices'] = Mage::helper('simiconnector/price')->formatPriceFromProduct($entity, true);
240
+ $info['app_tier_prices'] = Mage::helper('simiconnector/tierprice')->formatTierPrice($entity);
241
+ $info['app_reviews'] = array(
242
+ 'rate' => $avg,
243
+ 'number' => $ratings[5],
244
+ '5_star_number' => $ratings[4],
245
+ '4_star_number' => $ratings[3],
246
+ '3_star_number' => $ratings[2],
247
+ '2_star_number' => $ratings[1],
248
+ '1_star_number' => $ratings[0],
249
+ 'form_add_reviews' => Mage::helper('simiconnector/review')->getReviewToAdd(),
250
+ );
251
+
252
+ $info['app_options'] = Mage::helper('simiconnector/options')->getOptions($entity);
253
+ $info['wishlist_item_id'] = Mage::helper('simiconnector/wishlist')->getWishlistItemId($entity);
254
+ $info['product_label'] = Mage::helper('simiconnector/productlabel')->getProductLabel($entity);
255
+ $info['product_video'] = Mage::helper('simiconnector/simivideo')->getProductVideo($entity);
256
+ $this->detail_info = $this->getDetail($info);
257
+ Mage::dispatchEvent('simi_simiconnector_model_api_products_show_after', array('object' => $this, 'data' => $this->detail_info));
258
+ return $this->detail_info;
259
+ }
260
+
261
+ public function setFilterByCategoryId($cat_id)
262
+ {
263
+ $this->_helperProduct->setCategoryProducts($cat_id);
264
+ $this->_layer = $this->_helperProduct->getLayers();
265
+ $this->builderQuery = $this->_helperProduct->getBuilderQuery();
266
+ $this->_sortOrders = $this->_helperProduct->getStoreQrders();
267
+ }
268
+
269
+ public function setFilterByQuery()
270
+ {
271
+ $this->_helperProduct->setLayers(1);
272
+ $this->_layer = $this->_helperProduct->getLayers();
273
+ $this->builderQuery = $this->_helperProduct->getBuilderQuery();
274
+ $this->_sortOrders = $this->_helperProduct->getStoreQrders();
275
+ }
276
+
277
+ public function setFilterByRelated($product_id)
278
+ {
279
+ $this->_helperProduct->setRelatedProduct($product_id);
280
+ $this->_layer = $this->_helperProduct->getLayers();
281
+ $this->builderQuery = $this->_helperProduct->getBuilderQuery();
282
+ $this->_sortOrders = $this->_helperProduct->getStoreQrders();
283
+ }
284
+
285
+ }
app/code/local/Simi/Simiconnector/Model/Api/Quoteitems.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Quoteitems extends Simi_Simiconnector_Model_Api_Abstract {
4
+
5
+ protected $_DEFAULT_ORDER = 'item_id';
6
+ protected $_RETURN_MESSAGE;
7
+ protected $_removed_items;
8
+ public $detail_list;
9
+
10
+ protected function _getSession() {
11
+ return Mage::getSingleton('checkout/session');
12
+ }
13
+
14
+ protected function _getCart() {
15
+ return Mage::getSingleton('checkout/cart');
16
+ }
17
+
18
+ protected function _getQuote() {
19
+ return $this->_getCart()->getQuote();
20
+ }
21
+
22
+ public function setBuilderQuery() {
23
+ $quote = $this->_getQuote();
24
+ $this->builderQuery = $quote->getItemsCollection();
25
+ }
26
+
27
+ /*
28
+ * Change Qty, Add/remove Coupon Code
29
+ */
30
+
31
+ public function update() {
32
+ $data = $this->getData();
33
+ $parameters = (array) $data['contents'];
34
+ if (isset($parameters['coupon_code'])) {
35
+ $this->_RETURN_MESSAGE = Mage::helper('simiconnector/coupon')->setCoupon($parameters['coupon_code']);
36
+ }
37
+ $this->_updateItems($parameters);
38
+ return $this->index();
39
+ }
40
+
41
+ private function _updateItems($parameters) {
42
+ $cartData = array();
43
+ foreach ($parameters as $index => $qty) {
44
+ $cartData[$index] = array('qty' => $qty);
45
+ }
46
+ if (count($cartData)) {
47
+ $filter = new Zend_Filter_LocalizedToNormalized(
48
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
49
+ );
50
+ $removedItems = array();
51
+ foreach ($cartData as $index => $data) {
52
+ if (isset($data['qty'])) {
53
+ $cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
54
+ if ($data['qty'] == 0) {
55
+ $removedItems[] = $index;
56
+ }
57
+ }
58
+ }
59
+ $this->_removed_items = $removedItems;
60
+ $cart = $this->_getCart();
61
+ if (!$cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
62
+ $cart->getQuote()->setCustomerId(null);
63
+ }
64
+
65
+ if (version_compare(Mage::getVersion(), '1.4.2.0', '>=') === true) {
66
+ $cartData = $cart->suggestItemsQty($cartData);
67
+ }
68
+ $cart->updateItems($cartData)
69
+ ->save();
70
+ Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
71
+ }
72
+ }
73
+
74
+ /*
75
+ * Add To Cart
76
+ */
77
+
78
+ public function store() {
79
+ $this->addToCart();
80
+ return $this->index();
81
+ }
82
+
83
+ public function addToCart() {
84
+ $data = $this->getData();
85
+ $cart = $this->_getCart();
86
+
87
+ $controller = $data['controller'];
88
+ $contents = $controller->getRequest()->getRawBody(); // using without GET method
89
+ if ($contents && strlen($contents)) {
90
+ $contents = urldecode($contents);
91
+ $params = json_decode($contents, true);
92
+ }
93
+ $params = $this->convertParams($params);
94
+ if (isset($params['qty'])) {
95
+ $filter = new Zend_Filter_LocalizedToNormalized(
96
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
97
+ );
98
+ $params['qty'] = $filter->filter($params['qty']);
99
+ }
100
+ $product = $this->_initProduct($params['product']);
101
+ $cart->addProduct($product, $params);
102
+ $cart->save();
103
+ $this->_getSession()->setCartWasUpdated(true);
104
+ Mage::dispatchEvent('checkout_cart_add_product_complete', array('product' => $product, 'request' => Mage::app()->getRequest(), 'response' => Mage::app()->getResponse()));
105
+ $this->_RETURN_MESSAGE = Mage::helper('simiconnector')->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
106
+ }
107
+
108
+ public function convertParams($params) {
109
+ $convertList = array(
110
+ //Custom Option (Simple/Virtual/Downloadable)
111
+ 'options',
112
+ //Configurable Product
113
+ 'super_attribute',
114
+ //Group Product
115
+ 'super_group',
116
+ //Bundle Product
117
+ 'bundle_option',
118
+ //Bundle Product Qty
119
+ 'bundle_option_qty',
120
+ );
121
+ foreach ($convertList as $type) {
122
+ if (!isset($params[$type])) {
123
+ continue;
124
+ }
125
+ $params[$type] = (array) $params[$type];
126
+ $convertedParam = array();
127
+ foreach ($params[$type] as $index => $item) {
128
+ $convertedParam[(int) $index] = $item;
129
+ }
130
+ $params[$type] = $convertedParam;
131
+ }
132
+ return $params;
133
+ }
134
+
135
+ protected function _initProduct($productId) {
136
+ if ($productId) {
137
+ $product = Mage::getModel('catalog/product')
138
+ ->setStoreId(Mage::app()->getStore()->getId())
139
+ ->load($productId);
140
+ if ($product->getId()) {
141
+ return $product;
142
+ }
143
+ }
144
+ return false;
145
+ }
146
+
147
+ /*
148
+ * Return Cart Detail
149
+ */
150
+
151
+ public function show() {
152
+ return $this->index();
153
+ }
154
+
155
+ public function index() {
156
+ $this->_getQuote()->collectTotals()->save();
157
+ $collection = $this->builderQuery;
158
+ $collection->addFieldToFilter('item_id', array('nin' => $this->_removed_items))
159
+ ->addFieldToFilter('parent_item_id', array('null' => true));
160
+
161
+ $this->filter();
162
+ $data = $this->getData();
163
+ $parameters = $data['params'];
164
+ $page = 1;
165
+ if (isset($parameters[self::PAGE]) && $parameters[self::PAGE]) {
166
+ $page = $parameters[self::PAGE];
167
+ }
168
+
169
+ $limit = self::DEFAULT_LIMIT;
170
+ if (isset($parameters[self::LIMIT]) && $parameters[self::LIMIT]) {
171
+ $limit = $parameters[self::LIMIT];
172
+ }
173
+
174
+ $offset = $limit * ($page - 1);
175
+ if (isset($parameters[self::OFFSET]) && $parameters[self::OFFSET]) {
176
+ $offset = $parameters[self::OFFSET];
177
+ }
178
+ $collection->setPageSize($offset + $limit);
179
+
180
+ $all_ids = array();
181
+ $info = array();
182
+ $total = $collection->getSize();
183
+
184
+ if ($offset > $total) {
185
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
186
+ }
187
+
188
+ $fields = array();
189
+ if (isset($parameters['fields']) && $parameters['fields']) {
190
+ $fields = explode(',', $parameters['fields']);
191
+ }
192
+
193
+ $check_limit = 0;
194
+ $check_offset = 0;
195
+
196
+ /*
197
+ * Add options and image
198
+ */
199
+ foreach ($collection as $entity) {
200
+ if (++$check_offset <= $offset) {
201
+ continue;
202
+ }
203
+ /*
204
+ if (++$check_limit > $limit)
205
+ break;
206
+
207
+ */
208
+ if ($entity->getData('parent_item_id') != NULL)
209
+ continue;
210
+
211
+ if ($this->_removed_items) {
212
+ if (in_array($entity->getData('item_id'), $this->_removed_items)) {
213
+ continue;
214
+ }
215
+ }
216
+
217
+ $options = array();
218
+ if (version_compare(Mage::getVersion(), '1.5.0.0', '>=') === true) {
219
+ $helper = Mage::helper('catalog/product_configuration');
220
+ if ($entity->getProductType() == "simple") {
221
+ $options = Mage::helper('simiconnector/checkout')->convertOptionsCart($helper->getCustomOptions($entity));
222
+ } elseif ($entity->getProductType() == "configurable") {
223
+ $options = Mage::helper('simiconnector/checkout')->convertOptionsCart($helper->getConfigurableOptions($entity));
224
+ } elseif ($entity->getProductType() == "bundle") {
225
+ $options = Mage::helper('simiconnector/checkout')->getOptions($entity);
226
+ }
227
+ } else {
228
+ if ($entity->getProductType() != "bundle") {
229
+ $options = Mage::helper('simiconnector/checkout')->getUsedProductOption($entity);
230
+ } else {
231
+ $options = Mage::helper('simiconnector/checkout')->getOptions($entity);
232
+ }
233
+ }
234
+
235
+ $pro_price = $entity->getCalculationPrice();
236
+ if (Mage::helper('tax')->displayCartPriceInclTax() || Mage::helper('tax')->displayCartBothPrices()) {
237
+ $pro_price = Mage::helper('checkout')->getSubtotalInclTax($entity);
238
+ }
239
+
240
+ $quoteitem = $entity->toArray($fields);
241
+ $quoteitem['option'] = $options;
242
+ if (isset($parameters['image_width'])){
243
+ $image_width = $parameters['image_width'];
244
+ $image_height = $parameters['image_height'];
245
+ } else {
246
+ $image_width = 600;
247
+ $image_height = 600;
248
+ }
249
+ $quoteitem['image'] = Mage::helper('simiconnector/products')->getImageProduct($entity->getProduct(), null, $image_width, $image_height);
250
+ $info[] = $quoteitem;
251
+ $all_ids[] = $entity->getId();
252
+ }
253
+
254
+ $this->detail_list = $this->getList($info, $all_ids, $total, $limit, $offset);
255
+ Mage::dispatchEvent('simi_simiconnector_model_api_quoteitems_index_after', array('object' => $this, 'data' => $this->detail_list));
256
+ return $this->detail_list;
257
+ }
258
+
259
+ /*
260
+ * Add Message
261
+ */
262
+
263
+ public function getList($info, $all_ids, $total, $page_size, $from) {
264
+ $result = parent::getList($info, $all_ids, $total, $page_size, $from);
265
+ $result['total'] = Mage::helper('simiconnector/total')->getTotal();
266
+ if ($this->_RETURN_MESSAGE) {
267
+ $result['message'] = array($this->_RETURN_MESSAGE);
268
+ }
269
+ $session = Mage::getSingleton('checkout/session');
270
+ $result['cart_total'] = Mage::helper('checkout/cart')->getItemsCount();
271
+ $result['quote_id'] = $session->getQuoteId();
272
+ return $result;
273
+ }
274
+
275
+ }
app/code/local/Simi/Simiconnector/Model/Api/Reviews.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 8/18/16
7
+ * Time: 9:31 AM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Reviews extends Simi_Simiconnector_Model_Api_Abstract
10
+ {
11
+ protected $_helper;
12
+ protected $_allow_filter_core = false;
13
+
14
+ public function setBuilderQuery()
15
+ {
16
+ // TODO: Implement setBuilderQuery() method.
17
+ $this->_helper = Mage::helper('simiconnector/review');
18
+ $data = $this->getData();
19
+ $parameters = $data['params'];
20
+ if (isset($data['resourceid']) && $data['resourceid']) {
21
+ $this->builderQuery = $this->_helper->getReview($data['resourceid']);
22
+ } else {
23
+ if (isset($parameters[self::FILTER])) {
24
+ $filter = $parameters[self::FILTER];
25
+ $this->builderQuery = $this->_helper->getReviews($filter['product_id']);
26
+ }
27
+ }
28
+ }
29
+
30
+ /**
31
+ * @return collection
32
+ * override
33
+ */
34
+ protected function filter()
35
+ {
36
+ $data = $this->_data;
37
+ $parameters = $data['params'];
38
+ if ($this->_allow_filter_core) {
39
+ $query = $this->builderQuery;
40
+ $this->_whereFilter($query, $parameters);
41
+
42
+ }
43
+ if (isset($parameters['dir']) && isset($parameters['order']))
44
+ $this->_order($parameters);
45
+
46
+ return null;
47
+ }
48
+
49
+ /**
50
+ * @return override
51
+ */
52
+ public function store()
53
+ {
54
+ $data = $this->getData();
55
+ $content = $data['contents_array'];
56
+ $review = $this->_helper->saveReview($content);
57
+ $entity = $review['review'];
58
+ $parameters = $data['params'];
59
+ $fields = array();
60
+ if (isset($parameters['fields']) && $parameters['fields']) {
61
+ $fields = explode(',', $parameters['fields']);
62
+ }
63
+ $info = $entity->toArray($fields);
64
+ $detail = $this->getDetail($info);
65
+ $detail['message'] = $review['message'];
66
+ return $detail;
67
+ }
68
+
69
+ /**
70
+ * @param $info
71
+ * @param $all_ids
72
+ * @param $total
73
+ * @param $page_size
74
+ * @param $from
75
+ * @return array
76
+ * override
77
+ */
78
+ public function getList($info, $all_ids, $total, $page_size, $from, $count)
79
+ {
80
+ return array(
81
+ 'all_ids' => $all_ids,
82
+ $this->getPluralKey() => $info,
83
+ 'total' => $total,
84
+ 'page_size' => $page_size,
85
+ 'from' => $from,
86
+ 'count' => $count,
87
+ );
88
+ }
89
+
90
+ /**
91
+ * @return array
92
+ * @throws Exception
93
+ * override
94
+ */
95
+ public function index()
96
+ {
97
+ $collection = $this->builderQuery;
98
+ $this->filter();
99
+ $data = $this->getData();
100
+ $parameters = $data['params'];
101
+ $page = 1;
102
+ if (isset($parameters[self::PAGE]) && $parameters[self::PAGE]) {
103
+ $page = $parameters[self::PAGE];
104
+ }
105
+
106
+ $limit = self::DEFAULT_LIMIT;
107
+ if (isset($parameters[self::LIMIT]) && $parameters[self::LIMIT]) {
108
+ $limit = $parameters[self::LIMIT];
109
+ }
110
+
111
+ $offset = $limit * ($page - 1);
112
+ if (isset($parameters[self::OFFSET]) && $parameters[self::OFFSET]) {
113
+ $offset = $parameters[self::OFFSET];
114
+ }
115
+ $collection->setPageSize($offset + $limit);
116
+ $all_ids = $collection->getAllIds();
117
+ $info = array();
118
+ $total = $collection->getSize();
119
+
120
+ if ($offset > $total)
121
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
122
+
123
+ $fields = array();
124
+ if (isset($parameters['fields']) && $parameters['fields']) {
125
+ $fields = explode(',', $parameters['fields']);
126
+ }
127
+ $star = array();
128
+ $count = null;
129
+ $star[0] = 0;
130
+ $star[1] = 0;
131
+ $star[2] = 0;
132
+ $star[3] = 0;
133
+ $star[4] = 0;
134
+ $star[5] = 0;
135
+
136
+ $check_limit = 0;
137
+ $check_offset = 0;
138
+ foreach ($collection as $entity) {
139
+ if (++$check_offset <= $offset) {
140
+ continue;
141
+ }
142
+ if (++$check_limit > $limit)
143
+ break;
144
+ $star[5]++;
145
+ $y = 0;
146
+ foreach ($entity->getRatingVotes() as $vote) {
147
+ $y += ($vote->getPercent() / 20);
148
+ }
149
+ $x = (int) ($y / count($entity->getRatingVotes()));
150
+ $info_detail = $entity->toArray($fields);
151
+ $info_detail['rate_points'] = $x;
152
+ $info[] = $info_detail;
153
+
154
+ $z = $y % 3;
155
+ $x = $z < 5 ? $x : $x + 1;
156
+ if ($x == 1) {
157
+ $star[0]++;
158
+ } elseif ($x == 2) {
159
+ $star[1]++;
160
+ } elseif ($x == 3) {
161
+ $star[2]++;
162
+ } elseif ($x == 4) {
163
+ $star[3]++;
164
+ } elseif ($x == 5) {
165
+ $star[4]++;
166
+ } elseif ($x == 0) {
167
+ $star[5]--;
168
+ }
169
+ }
170
+ $count = array(
171
+ '1_star' => $star[0],
172
+ '2_star' => $star[1],
173
+ '3_star' => $star[2],
174
+ '4_star' => $star[3],
175
+ '5_star' => $star[4],
176
+ );
177
+ return $this->getList($info, $all_ids, $total, $limit, $offset, $count);
178
+ }
179
+
180
+ /**
181
+ * @return array
182
+ * override
183
+ */
184
+ public function show()
185
+ {
186
+ $entity = $this->builderQuery;
187
+ $data = $this->getData();
188
+ $parameters = $data['params'];
189
+ $fields = array();
190
+ if (isset($parameters['fields']) && $parameters['fields']) {
191
+ $fields = explode(',', $parameters['fields']);
192
+ }
193
+ $info = $entity->toArray($fields);
194
+ return $this->getDetail($info);
195
+ }
196
+ }
app/code/local/Simi/Simiconnector/Model/Api/Simibarcodes.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Simibarcodes extends Simi_Simiconnector_Model_Api_Abstract {
4
+
5
+ protected $_DEFAULT_ORDER = 'barcode_id';
6
+
7
+ public function setBuilderQuery() {
8
+ $data = $this->getData();
9
+ if (isset($data['resourceid']) && $data['resourceid']) {
10
+ $this->builderQuery = Mage::getModel('simiconnector/simibarcode')->getCollection()->addFieldToFilter('barcode_status', '1')->addFieldToFilter('barcode', $data['resourceid'])->getFirstItem();
11
+ if (!$this->builderQuery->getId())
12
+ $this->builderQuery = Mage::getModel('simiconnector/simibarcode')->getCollection()->addFieldToFilter('barcode_status', '1')->addFieldToFilter('qrcode', $data['resourceid'])->getFirstItem();
13
+ if (!$this->builderQuery->getId())
14
+ throw new Exception(Mage::helper('catalog')->__('There is No Product Matchs your Code'), 4);
15
+ } else {
16
+ $this->builderQuery = Mage::getModel('simiconnector/simibarcode')->getCollection();
17
+ }
18
+ }
19
+
20
+ }
app/code/local/Simi/Simiconnector/Model/Api/Simivideos.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Api_Simivideos extends Simi_Simiconnector_Model_Api_Abstract {
4
+
5
+ protected $_DEFAULT_ORDER = 'video_id';
6
+
7
+ public function setBuilderQuery() {
8
+ $data = $this->getData();
9
+ $productId = $data['params']['product_id'];
10
+ if (!$productId)
11
+ throw new Exception(Mage::helper('catalog')->__('There is No Product ID sent'), 4);
12
+
13
+ $videoCollection = Mage::getModel('simiconnector/simivideo')->getCollection();
14
+ $videoArray = array();
15
+ foreach ($videoCollection as $video) {
16
+ if (in_array($productId, explode(",", $video->getData('product_ids')))) {
17
+ $videoArray[] = $video->getData('video_id');
18
+ }
19
+ }
20
+ $this->builderQuery = Mage::getModel('simiconnector/simivideo')->getCollection()->addFieldToFilter('status', '1')->addFieldToFilter('video_id', array('in'=> $videoArray));
21
+ }
22
+
23
+ }
app/code/local/Simi/Simiconnector/Model/Api/Stores.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Stores extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'group_id';
12
+
13
+ public function setBuilderQuery() {
14
+ $data = $this->getData();
15
+ if (isset($data['resourceid']) && $data['resourceid']) {
16
+ $this->builderQuery = Mage::getModel('core/store_group')->load($data['resourceid']);
17
+ } else {
18
+ $this->builderQuery = $collection = Mage::getModel('core/store_group')->getCollection()->addFieldToFilter('website_id', Mage::app()->getStore()->getWebsiteId());
19
+ }
20
+ }
21
+
22
+ public function index() {
23
+ $result = parent::index();
24
+ foreach ($result['stores'] as $index => $store) {
25
+ $storeViewAPIModel = Mage::getModel('simiconnector/api_storeviews');
26
+ $storeViewAPIModel->setData($this->getData());
27
+ $storeViewAPIModel->builderQuery = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id', $store['group_id']);
28
+ $storeViewAPIModel->pluralKey = 'storeviews';
29
+ $result['stores'][$index]['storeviews'] = $storeViewAPIModel->index();
30
+ }
31
+ return $result;
32
+ }
33
+
34
+ }
app/code/local/Simi/Simiconnector/Model/Api/Storeviews.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Storeviews extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ public $storeviewInfo;
12
+ protected $_DEFAULT_ORDER = 'store_id';
13
+ protected $_method = 'callApi';
14
+ protected $group_id;
15
+
16
+ public function setBuilderQuery() {
17
+ $data = $this->getData();
18
+ if (isset($data['resourceid']) && $data['resourceid']) {
19
+ $this->setStoreView($data);
20
+ $this->setCurrency($data);
21
+ $this->builderQuery = Mage::getModel('core/store')->load($data['resourceid']);
22
+ } else {
23
+ $this->builderQuery = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id', Mage::app()->getStore()->getGroupId());
24
+ }
25
+ }
26
+
27
+ public function index() {
28
+ $result = parent::index();
29
+ foreach ($result['storeviews'] as $index => $storeView) {
30
+ $result['storeviews'][$index]['base_url'] = Mage::getStoreConfig('simiconnector/general/base_url', $storeView['store_id']);
31
+ }
32
+ return $result;
33
+ }
34
+
35
+ public function show() {
36
+ //$information = parent::show();
37
+ $country_code = Mage::getStoreConfig('general/country/default');
38
+ $country = Mage::getModel('directory/country')->loadByCode($country_code);
39
+ $locale = Mage::app()->getLocale()->getLocaleCode();
40
+ $currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
41
+ $currencySymbol = Mage::app()->getLocale()->currency($currencyCode)->getSymbol();
42
+ $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
43
+ $values = array();
44
+ foreach ($options as $option) {
45
+ if ($option['value']) {
46
+ $values[] = array(
47
+ 'label' => $option['label'],
48
+ 'value' => $option['value'],
49
+ );
50
+ }
51
+ }
52
+
53
+ $currencies = $this->getCurrencies();
54
+
55
+ $cmsData = $this->getData();
56
+ $cmsData['resourceid'] = NULL;
57
+ $cmsData['resource'] = 'cmspages';
58
+ $model = Mage::getSingleton('simiconnector/api_cmspages');
59
+ $cmsPageList = call_user_func_array(array(&$model, $this->_method), array($cmsData));
60
+ $additionInfo = array(
61
+ 'base' => array(
62
+ 'country_code' => $country->getId(),
63
+ 'country_name' => $country->getName(),
64
+ 'locale_identifier' => $locale,
65
+ 'store_id' => $this->getCurrentStoreId(),
66
+ 'store_name' => Mage::app()->getStore()->getName(),
67
+ 'store_code' => Mage::app()->getStore()->getCode(),
68
+ 'group_id' => Mage::app()->getStore()->getGroupId(),
69
+ 'base_url' => Mage::getStoreConfig('simiconnector/general/base_url'),
70
+ 'use_store' => Mage::getStoreConfig('web/url/use_store'),
71
+ 'is_rtl' => Mage::getStoreConfig('simiconnector/general/is_rtl'),
72
+ 'is_show_sample_data' => Mage::getStoreConfig('simiconnector/general/is_show_sample_data'),
73
+ 'android_sender' => Mage::getStoreConfig('simiconnector/notification/android_app_key'),
74
+ 'currency_symbol' => $currencySymbol,
75
+ 'currency_code' => $currencyCode,
76
+ 'currency_position' => $this->getCurrencyPosition(),
77
+ 'thousand_separator' => Mage::getStoreConfig('simiconnector/currency/thousand_separator'),
78
+ 'decimal_separator' => Mage::getStoreConfig('simiconnector/currency/decimal_separator'),
79
+ 'min_number_of_decimals' => Mage::getStoreConfig('simiconnector/currency/min_number_of_decimals'),
80
+ 'max_number_of_decimals' => Mage::getStoreConfig('simiconnector/currency/max_number_of_decimals'),
81
+ 'currencies' => $currencies,
82
+ 'is_show_home_title' => Mage::getStoreConfig('simiconnector/general/is_show_home_title'),
83
+ 'cust_group' => Mage::getSingleton('customer/session')->getCustomerGroupId(),
84
+ 'customer_identity' => Mage::getSingleton('core/session')->getEncryptedSessionId(),
85
+ 'customer_ip'=>$_SERVER["REMOTE_ADDR"],
86
+ ),
87
+ 'sales' => array(
88
+ 'sales_reorder_allow' => Mage::getStoreConfig('sales/reorder/allow'),
89
+ 'sales_totals_sort_subtotal' => Mage::getStoreConfig('sales/totals_sort/subtotal'),
90
+ 'sales_totals_sort_discount' => Mage::getStoreConfig('sales/totals_sort/discount'),
91
+ 'sales_totals_sort_shipping' => Mage::getStoreConfig('sales/totals_sort/shipping'),
92
+ 'sales_totals_sort_weee' => Mage::getStoreConfig('sales/totals_sort/weee'),
93
+ 'sales_totals_sort_tax' => Mage::getStoreConfig('sales/totals_sort/tax'),
94
+ 'sales_totals_sort_grand_total' => Mage::getStoreConfig('sales/totals_sort/grand_total'),
95
+ ),
96
+ 'checkout' => array(
97
+ 'enable_guest_checkout' => Mage::getStoreConfig('checkout/options/guest_checkout'),
98
+ 'enable_agreements' => is_null(Mage::getStoreConfig('checkout/options/enable_agreements')) ? 0 : Mage::getStoreConfig('checkout/options/enable_agreements'),
99
+ ),
100
+ 'tax' => array(
101
+ 'tax_display_type' => Mage::getStoreConfig('tax/display/type'),
102
+ 'tax_display_shipping' => Mage::getStoreConfig('tax/display/shipping'),
103
+ 'tax_cart_display_price' => Mage::getStoreConfig('tax/cart_display/price'),
104
+ 'tax_cart_display_subtotal' => Mage::getStoreConfig('tax/cart_display/subtotal'),
105
+ 'tax_cart_display_shipping' => Mage::getStoreConfig('tax/cart_display/shipping'),
106
+ 'tax_cart_display_grandtotal' => Mage::getStoreConfig('tax/cart_display/grandtotal'),
107
+ 'tax_cart_display_full_summary' => Mage::getStoreConfig('tax/cart_display/full_summary'),
108
+ 'tax_cart_display_zero_tax' => Mage::getStoreConfig('tax/cart_display/zero_tax'),
109
+ 'tax_sales_display_price' => Mage::getStoreConfig('tax/sales_display/price'),
110
+ 'tax_sales_display_subtotal' => Mage::getStoreConfig('tax/sales_display/subtotal'),
111
+ 'tax_sales_display_shipping' => Mage::getStoreConfig('tax/sales_display/shipping'),
112
+ 'tax_sales_display_grandtotal' => Mage::getStoreConfig('tax/sales_display/grandtotal'),
113
+ 'tax_sales_display_full_summary' => Mage::getStoreConfig('tax/sales_display/full_summary'),
114
+ 'tax_sales_display_zero_tax' => Mage::getStoreConfig('tax/sales_display/zero_tax'),
115
+ ),
116
+ 'google_analytics' => array(
117
+ 'google_analytics_active' => Mage::getStoreConfig('google/analytics/active'),
118
+ 'google_analytics_type' => Mage::getStoreConfig('google/analytics/type'),
119
+ 'google_analytics_account' => Mage::getStoreConfig('google/analytics/account'),
120
+ 'google_analytics_anonymization' => Mage::getStoreConfig('google/analytics/anonymization'),
121
+ ),
122
+ 'customer' => array(
123
+ 'address_option' => array(
124
+ 'prefix_show' => Mage::getStoreConfig('customer/address/prefix_show'),
125
+ 'middlename_show' => Mage::getStoreConfig('customer/address/middlename_show'),
126
+ 'suffix_show' => Mage::getStoreConfig('customer/address/suffix_show'),
127
+ 'dob_show' => Mage::getStoreConfig('customer/address/dob_show'),
128
+ 'taxvat_show' => Mage::getStoreConfig('customer/address/taxvat_show'),
129
+ 'gender_show' => Mage::getStoreConfig('customer/address/gender_show'),
130
+ 'gender_value' => $values,
131
+ 'region_state_required' => Mage::getStoreConfig('general/region/state_required'),
132
+ 'region_display_all' => Mage::getStoreConfig('general/region/display_all'),
133
+ ),
134
+ 'account_option' => array(
135
+ 'taxvat_show' => Mage::getStoreConfig('customer/create_account/vat_frontend_visibility'),
136
+ ),
137
+ ),
138
+ 'wishlist' => array(
139
+ 'wishlist_general_active' => Mage::getStoreConfig('wishlist/general/active'),
140
+ 'wishlist_wishlist_link_use_qty' => Mage::getStoreConfig('wishlist/wishlist_link/use_qty'),
141
+ ),
142
+ 'catalog' => array(
143
+ 'frontend' => array(
144
+ 'view_products_default' => Mage::getStoreConfig('simiconnector/general/show_product_type'),
145
+ 'is_show_zero_price' => Mage::getStoreConfig('simiconnector/general/is_show_price_zero'),
146
+ 'is_show_link_all_product' => Mage::getStoreConfig('simiconnector/general/is_show_all_product'),
147
+ 'catalog_frontend_list_mode' => Mage::getStoreConfig('catalog/frontend/list_mode'),
148
+ 'catalog_frontend_grid_per_page_values' => Mage::getStoreConfig('catalog/frontend/grid_per_page_values'),
149
+ 'catalog_frontend_list_per_page' => Mage::getStoreConfig('catalog/frontend/list_per_page'),
150
+ 'catalog_frontend_list_allow_all' => Mage::getStoreConfig('catalog/frontend/list_allow_all'),
151
+ 'catalog_frontend_default_sort_by' => Mage::getStoreConfig('catalog/frontend/default_sort_by'),
152
+ 'catalog_frontend_flat_catalog_category' => Mage::getStoreConfig('catalog/frontend/flat_catalog_category'),
153
+ 'catalog_frontend_flat_catalog_product' => Mage::getStoreConfig('catalog/frontend/flat_catalog_product'),
154
+ 'catalog_frontend_parse_url_directives' => Mage::getStoreConfig('catalog/frontend/parse_url_directives'),
155
+ ),
156
+ 'review' => array(
157
+ 'catalog_review_allow_guest' => Mage::getStoreConfig('catalog/review/allow_guest'),
158
+ ),
159
+ 'cataloginventory' => array(
160
+ 'cataloginventory_item_options_manage_stock' => Mage::getStoreConfig('cataloginventory/item_options/manage_stock'),
161
+ 'cataloginventory_item_options_backorders' => Mage::getStoreConfig('cataloginventory/item_options/backorders'),
162
+ 'cataloginventory_item_options_max_sale_qty' => Mage::getStoreConfig('cataloginventory/item_options/max_sale_qty'),
163
+ 'cataloginventory_item_options_min_qty' => Mage::getStoreConfig('cataloginventory/item_options/options_min_qty'),
164
+ 'cataloginventory_item_options_min_sale_qty' => Mage::getStoreConfig('cataloginventory/item_options/min_sale_qty'),
165
+ 'cataloginventory_item_options_notify_stock_qty' => Mage::getStoreConfig('cataloginventory/item_options/notify_stock_qty'),
166
+ 'cataloginventory_item_options_enable_qty_increments' => Mage::getStoreConfig('cataloginventory/item_options/enable_qty_increments'),
167
+ 'cataloginventory_item_options_qty_increments' => Mage::getStoreConfig('cataloginventory/item_options/qty_increments'),
168
+ 'cataloginventory_item_options_auto_return' => Mage::getStoreConfig('cataloginventory/item_options/auto_return'),
169
+ )
170
+ ),
171
+ 'cms' => $cmsPageList,
172
+ 'category_cmspages' => Mage::getModel('simiconnector/cms')->getCategoryCMSPages(),
173
+ 'zopim_config' => array(
174
+ 'enable' => Mage::getStoreConfig('simiconnector/zopim/enable'),
175
+ 'account_key' => Mage::getStoreConfig('simiconnector/zopim/account_key'),
176
+ 'show_profile' => Mage::getStoreConfig('simiconnector/zopim/show_profile'),
177
+ 'name' => Mage::getStoreConfig('simiconnector/zopim/name'),
178
+ 'email' => Mage::getStoreConfig('simiconnector/zopim/email'),
179
+ 'phone' => Mage::getStoreConfig('simiconnector/zopim/phone'),
180
+ ),
181
+ 'mixpanel_config' => array(
182
+ 'token' => Mage::getStoreConfig('simiconnector/mixpanel/token'),
183
+ ),
184
+ 'allowed_countries' => $this->getAllowedCountries(),
185
+ 'stores' => $this->getStores(),
186
+ );
187
+ if ($checkout_info_setting = Mage::helper('simiconnector/address')->getCheckoutAddressSetting())
188
+ $additionInfo['customer']['address_fields_config'] = $checkout_info_setting;
189
+
190
+ if ($checkout_terms = Mage::helper('simiconnector/checkout')->getCheckoutTermsAndConditions())
191
+ $additionInfo['checkout']['checkout_terms_and_conditions'] = $checkout_terms;
192
+ //Scott add to get instant contacts
193
+ if (Mage::helper('simiconnector/plugins_instantcontact')->isEnabled())
194
+ $additionInfo['instant_contact'] = Mage::helper('simiconnector/plugins_instantcontact')->getContacts();
195
+
196
+ $this->storeviewInfo = $additionInfo;
197
+ Mage::dispatchEvent('simiconnector_get_storeview_info_after', array('object' => $this));
198
+ return $this->getDetail($this->storeviewInfo);
199
+ }
200
+
201
+ public function getAllowedCountries() {
202
+ $list = array();
203
+ $country_default = Mage::getStoreConfig('general/country/default');
204
+ $countries = Mage::getResourceModel('directory/country_collection')->loadByStore();
205
+ $cache = null;
206
+ foreach ($countries as $country) {
207
+ if ($country_default == $country->getId()) {
208
+ $cache = array(
209
+ 'country_code' => $country->getId(),
210
+ 'country_name' => $country->getName(),
211
+ 'states' => Mage::helper('simiconnector/address')->getStates($country->getId()),
212
+ );
213
+ } else {
214
+ $list[] = array(
215
+ 'country_code' => $country->getId(),
216
+ 'country_name' => $country->getName(),
217
+ 'states' => Mage::helper('simiconnector/address')->getStates($country->getId()),
218
+ );
219
+ }
220
+ }
221
+ if ($cache) {
222
+ array_unshift($list, $cache);
223
+ }
224
+ return $list;
225
+ }
226
+
227
+ public function getCurrencyPosition() {
228
+ $formated = Mage::app()->getStore()->getCurrentCurrency()->formatTxt(0);
229
+ $number = Mage::app()->getStore()->getCurrentCurrency()->formatTxt(0, array('display' => Zend_Currency::NO_SYMBOL));
230
+ $ar_curreny = explode($number, $formated);
231
+ if ($ar_curreny['0'] != '') {
232
+ return 'before';
233
+ }
234
+ return 'after';
235
+ }
236
+
237
+ public function getCurrencies() {
238
+ $currencies = array();
239
+ $codes = Mage::app()->getStore()->getAvailableCurrencyCodes(true);
240
+ if (is_array($codes) && count($codes) > 1) {
241
+
242
+ $rates = Mage::getModel('directory/currency')->getCurrencyRates(
243
+ Mage::app()->getStore()->getBaseCurrency(), $codes
244
+ );
245
+ foreach ($codes as $code) {
246
+ if (isset($rates[$code])) {
247
+ if (!$title = Mage::app()->getLocale()->getTranslation($code, 'nametocurrency'))
248
+ $title = $code;
249
+ $currencies[] = array(
250
+ 'value' => $code,
251
+ 'title' => $title,
252
+ );
253
+ }
254
+ }
255
+ } elseif (count($codes) == 1) {
256
+ $currencies[] = array(
257
+ 'value' => $codes[0],
258
+ 'title' => Mage::app()->getLocale()->getTranslation($codes[0], 'nametocurrency'),
259
+ );
260
+ }
261
+ return $currencies;
262
+ }
263
+
264
+ public function setCurrency($data) {
265
+ if (isset($data['params']['currency'])) {
266
+ $currency = $data['params']['currency'];
267
+ if ($currency) {
268
+ Mage::app()->getStore()->setCurrentCurrencyCode($currency);
269
+ Mage::app()->getCookie()->set('currency_code', $currency, TRUE);
270
+ }
271
+ }
272
+ }
273
+
274
+ public function setStoreView($data) {
275
+ if (($data['resourceid'] == 'default') || ($data['resourceid'] == Mage::app()->getStore()))
276
+ return;
277
+ Mage::app()->getCookie()->set(Mage_Core_Model_Store::COOKIE_NAME, Mage::app()->getStore($data['resourceid'])->getCode(), TRUE);
278
+ Mage::app()->setCurrentStore(
279
+ Mage::app()->getStore($data['resourceid'])->getCode()
280
+ );
281
+ Mage::getSingleton('core/locale')->emulate($data['resourceid']);
282
+ }
283
+
284
+ public function getCurrentStoreId() {
285
+ return Mage::app()->getStore()->getId();
286
+ }
287
+
288
+ public function getStores() {
289
+ $storeAPIModel = Mage::getModel('simiconnector/api_stores');
290
+ $storeAPIModel->setData($this->getData());
291
+ $storeAPIModel->builderQuery = Mage::getModel('core/store_group')->getCollection()->addFieldToFilter('website_id', Mage::app()->getStore()->getWebsiteId());
292
+ $storeAPIModel->pluralKey = 'stores';
293
+ return $storeAPIModel->index();
294
+ }
295
+
296
+ }
app/code/local/Simi/Simiconnector/Model/Api/Wishlistitems.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/3/16
7
+ * Time: 9:37 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Api_Wishlistitems extends Simi_Simiconnector_Model_Api_Abstract {
10
+
11
+ protected $_DEFAULT_ORDER = 'wishlist_item_id';
12
+ protected $_RETURN_MESSAGE;
13
+ protected $_RETURN_URL;
14
+ protected $_WISHLIST;
15
+
16
+ public function setBuilderQuery() {
17
+ $data = $this->getData();
18
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
19
+ if ($customer->getId() && ($customer->getId() != '')) {
20
+ $this->_WISHLIST = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true);
21
+ //check if not shared
22
+ if (!$this->_WISHLIST->getShared()) {
23
+ $this->_WISHLIST->setShared('1');
24
+ $this->_WISHLIST->save();
25
+ }
26
+ $sharingUrl = $this->_WISHLIST->getSharingCode();
27
+ $this->_RETURN_MESSAGE = Mage::getStoreConfig('appwishlist/general/sharing_message') . ' ' . Mage::getUrl('wishlist/shared/index/code/' . $sharingUrl);
28
+ $this->_RETURN_URL = Mage::getUrl('wishlist/shared/index/code/' . $sharingUrl);
29
+ } else
30
+ throw new Exception(Mage::helper('customer')->__('Please login First.'), 4);
31
+
32
+ if (isset($data['resourceid']) && $data['resourceid']) {
33
+ $this->builderQuery = Mage::getModel('wishlist/item')->load($data['resourceid']);
34
+ if (isset($data['params']['add_to_cart']) && $data['params']['add_to_cart']) {
35
+ $this->addWishlistItemToCart($data['resourceid']);
36
+ $this->builderQuery = $this->_WISHLIST->getItemCollection();
37
+ }
38
+ } else {
39
+ $this->builderQuery = $this->_WISHLIST->getItemCollection();
40
+ }
41
+ }
42
+
43
+ public function index() {
44
+ $result = parent::index();
45
+ $addition_info = array();
46
+ foreach ($this->builderQuery as $itemModel) {
47
+ $product = $itemModel->getProduct();
48
+ $isSaleAble = $product->isSaleable();
49
+ if ($isSaleAble) {
50
+ $itemOptions = Mage::getModel('wishlist/item_option')->getCollection()
51
+ ->addItemFilter(array($itemModel->getData('wishlist_item_id')));
52
+ foreach ($itemOptions as $itemOption) {
53
+ $optionProduct = Mage::getModel('catalog/product')->load($itemOption->getProductId());
54
+ if (!$optionProduct->isSaleable()) {
55
+ $isSaleAble = false;
56
+ break;
57
+ }
58
+ }
59
+ }
60
+
61
+ $productSharingMessage = implode(' ', array(Mage::getStoreConfig('simiconnector/wishlist/product_sharing_message'), $product->getProductUrl()));
62
+ $options = Mage::helper('simiconnector/wishlist')->getOptionsSelectedFromItem($itemModel, $product);
63
+ $addition_info[$itemModel->getData('wishlist_item_id')] = array(
64
+ 'type_id' => $product->getTypeId(),
65
+ 'product_regular_price' => Mage::app()->getStore()->convertPrice($product->getPrice(), false),
66
+ 'product_price' => Mage::app()->getStore()->convertPrice($product->getFinalPrice(), false),
67
+ 'stock_status' => $isSaleAble,
68
+ 'product_image' => Mage::helper('catalog/image')->init($product, 'small_image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(600, 600)->__toString(),
69
+ 'is_show_price' => true,
70
+ 'options' => $options,
71
+ 'selected_all_required_options' => Mage::helper('simiconnector/wishlist')->checkIfSelectedAllRequiredOptions($itemModel, $options),
72
+ 'product_sharing_message' => $productSharingMessage,
73
+ 'product_sharing_url' => $product->getProductUrl(),
74
+ 'app_prices' => Mage::helper('simiconnector/price')->formatPriceFromProduct($product),
75
+ );
76
+ }
77
+ foreach ($result['wishlistitems'] as $index => $item) {
78
+ $result['wishlistitems'][$index] = array_merge($item, $addition_info[$item['wishlist_item_id']]);
79
+ }
80
+ return $result;
81
+ }
82
+
83
+ /*
84
+ * Add To Wishlist
85
+ */
86
+
87
+ public function store() {
88
+ $data = $this->getData();
89
+ $params = Mage::getModel('simiconnector/api_quoteitems')->convertParams((array) $data['contents']);
90
+ $product = Mage::getModel('catalog/product')->load(($params['product']));
91
+ if (isset($params['qty'])) {
92
+ $filter = new Zend_Filter_LocalizedToNormalized(
93
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
94
+ );
95
+ $params['qty'] = $filter->filter($params['qty']);
96
+ }
97
+ $buyRequest = new Varien_Object($params);
98
+ $this->builderQuery = $this->_WISHLIST->addNewItem($product, $buyRequest);
99
+ return $this->show();
100
+ }
101
+
102
+ /*
103
+ * Remove From Wishlist
104
+ */
105
+
106
+ public function destroy() {
107
+ $data = $this->getData();
108
+ $item = Mage::getModel('wishlist/item')->load($data['resourceid']);
109
+ if ($item->getId()) {
110
+ $item->delete();
111
+ $this->_WISHLIST->save();
112
+ Mage::helper('wishlist')->calculate();
113
+ }
114
+ $this->builderQuery = $this->_WISHLIST->getItemCollection();
115
+ return $this->index();
116
+ }
117
+
118
+ /*
119
+ * Add From Wishlist To Cart
120
+ */
121
+
122
+ public function addWishlistItemToCart($itemId) {
123
+ foreach ($this->_WISHLIST->getItemCollection() as $wishlistItem) {
124
+ if ($wishlistItem->getData('wishlist_item_id') == $itemId)
125
+ $item = $wishlistItem;
126
+ }
127
+ $product = $item->getProduct();
128
+ $options = Mage::helper('simiconnector/wishlist')->getOptionsSelectedFromItem($item, $product);
129
+ if ($item && (Mage::helper('simiconnector/wishlist')->checkIfSelectedAllRequiredOptions($item, $options))) {
130
+ $isSaleAble = $product->isSaleable();
131
+ if ($isSaleAble) {
132
+ $item = Mage::getModel('wishlist/item')->load($itemId);
133
+ $item->setQty('1');
134
+ $cart = Mage::getSingleton('checkout/cart');
135
+ $options = Mage::getModel('wishlist/item_option')->getCollection()
136
+ ->addItemFilter(array($itemId));
137
+ $item->setOptions($options->getOptionsByItem($itemId));
138
+ if ($item->addToCart($cart, true)) {
139
+ $cart->save()->getQuote()->collectTotals();
140
+ }
141
+ $this->_WISHLIST->save();
142
+ Mage::helper('wishlist')->calculate();
143
+ }
144
+ }
145
+ }
146
+
147
+ /*
148
+ * Show An Item
149
+ */
150
+
151
+ public function show() {
152
+ $data = $this->getData();
153
+ if (isset($data['params']) && isset($data['params']['add_to_cart']) && $data['params']['add_to_cart']) {
154
+ $this->builderQuery = $this->_WISHLIST->getItemCollection();
155
+ return $this->index();
156
+ }
157
+ return parent::show();
158
+ }
159
+
160
+ /*
161
+ * Add Message
162
+ */
163
+
164
+ public function getList($info, $all_ids, $total, $page_size, $from) {
165
+ $result = parent::getList($info, $all_ids, $total, $page_size, $from);
166
+ if ($this->_RETURN_MESSAGE) {
167
+ $result['message'] = array($this->_RETURN_MESSAGE);
168
+ }
169
+ if ($this->_RETURN_URL) {
170
+ $result['sharing_url'] = array($this->_RETURN_URL);
171
+ }
172
+ return $result;
173
+ }
174
+
175
+ }
app/code/local/Simi/Simiconnector/Model/Appreport.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Appreport extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('simiconnector/appreport');
9
+ }
10
+ }
app/code/local/Simi/Simiconnector/Model/Banner.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Model
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Model_Banner extends Mage_Core_Model_Abstract {
24
+
25
+ protected $_website_id = null;
26
+
27
+ public function _construct() {
28
+ parent::_construct();
29
+ $this->_init('simiconnector/banner');
30
+ }
31
+
32
+ public function getBannerList() {
33
+ $website_id = Mage::app()->getStore()->getWebsiteId();
34
+ $list = array();
35
+ $collection = $this->getCollection()
36
+ ->addFieldToFilter('status', 1)
37
+ ->addFieldToFilter('website_id', array('in' => array($website_id, 0)));
38
+
39
+ foreach ($collection as $item) {
40
+ $path = Mage::getBaseUrl('media') . 'simi/simiconnector/banner' . '/' . $item->getWebsiteId() . '/' . $item->getBannerName();
41
+ $categoryName = '';
42
+ $categoryChildrenCount = '';
43
+ if ($item->getCategoryId()) {
44
+ $category = Mage::getModel('catalog/category')->load($item->getCategoryId());
45
+ $categoryName = $category->getName();
46
+ $categoryChildrenCount = $category->getChildrenCount();
47
+ if ($categoryChildrenCount > 0)
48
+ $categoryChildrenCount = 1;
49
+ else
50
+ $categoryChildrenCount = 0;
51
+ }
52
+ $list[] = array(
53
+ 'image_path' => $path,
54
+ 'url' => $item->getBannerUrl(),
55
+ 'type' => $item->getType(),
56
+ 'categoryID' => $item->getCategoryId(),
57
+ 'categoryName' => $categoryName,
58
+ 'productID' => $item->getProductId(),
59
+ 'has_child' => $categoryChildrenCount,
60
+ );
61
+ }
62
+ return $list;
63
+ }
64
+
65
+ public function toOptionArray() {
66
+ $platform = array(
67
+ '1' => Mage::helper('simiconnector')->__('Product In-app'),
68
+ '2' => Mage::helper('simiconnector')->__('Category In-app'),
69
+ '3' => Mage::helper('simiconnector')->__('Website Page'),
70
+ );
71
+ return $platform;
72
+ }
73
+
74
+ public function delete() {
75
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('banner');
76
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
77
+ ->addFieldToFilter('content_type', $typeID)
78
+ ->addFieldToFilter('item_id', $this->getId());
79
+ foreach ($visibleStoreViews as $visibilityItem)
80
+ $visibilityItem->delete();
81
+ return parent::delete();
82
+ }
83
+
84
+ }
app/code/local/Simi/Simiconnector/Model/Cms.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Model
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Model_Cms extends Mage_Core_Model_Abstract {
24
+
25
+ public function _construct() {
26
+ parent::_construct();
27
+ $this->_init('simiconnector/cms');
28
+ }
29
+
30
+ public function delete() {
31
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('cms');
32
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
33
+ ->addFieldToFilter('content_type', $typeID)
34
+ ->addFieldToFilter('item_id', $this->getId());
35
+ foreach ($visibleStoreViews as $visibilityItem)
36
+ $visibilityItem->delete();
37
+ return parent::delete();
38
+ }
39
+
40
+ public function toOptionArray() {
41
+ $platform = array(
42
+ '1' => Mage::helper('simiconnector')->__('Left Menu'),
43
+ '2' => Mage::helper('simiconnector')->__('Category In-app')
44
+ );
45
+ return $platform;
46
+ }
47
+
48
+ public function getCmsForCategory($catId) {
49
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('cms');
50
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
51
+ $cmsCollection = Mage::getModel('simiconnector/cms')->getCollection()->addFieldToFilter('type', '2')->setOrder('sort_order','ASC');
52
+ $cmsCollection->getSelect()
53
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.cms_id AND visibility.content_type = ' . $typeID . ' AND visibility.store_view_id =' . Mage::app()->getStore()->getId());
54
+ foreach ($cmsCollection as $cms) {
55
+ foreach (explode(',', str_replace(' ', '', $cms->getData('category_id'))) as $categoryId){
56
+ if ($categoryId == $catId)
57
+ return $cms->toArray();
58
+ }
59
+ }
60
+ }
61
+ public function getCategoryCMSPages(){
62
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('cms');
63
+ $visibilityTable = Mage::getSingleton('core/resource')->getTableName('simiconnector/visibility');
64
+ $cmsCollection = Mage::getModel('simiconnector/cms')->getCollection()->addFieldToFilter('type', '2')->setOrder('sort_order','ASC');
65
+ $cmsCollection->getSelect()
66
+ ->join(array('visibility' => $visibilityTable), 'visibility.item_id = main_table.cms_id AND visibility.content_type = ' . $typeID . ' AND visibility.store_view_id =' . Mage::app()->getStore()->getId());
67
+ $cmsArray = array();
68
+ foreach ($cmsCollection as $cms) {
69
+ $cmsArray[] = $cms->toArray();
70
+ }
71
+ return $cmsArray;
72
+ }
73
+
74
+ }
app/code/local/Simi/Simiconnector/Model/Config/Source/Addressrequiretype.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Config_Source_Addressrequiretype {
4
+
5
+ public function toOptionArray() {
6
+ return array(
7
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Required')),
8
+ array('value' => 2, 'label' => Mage::helper('adminhtml')->__('Optional')),
9
+ array('value' => 3, 'label' => Mage::helper('adminhtml')->__('Hide')),
10
+ );
11
+ }
12
+
13
+ public function toArray() {
14
+ return array(
15
+ 1 => Mage::helper('adminhtml')->__('Required'),
16
+ 2 => Mage::helper('adminhtml')->__('Optional'),
17
+ 3 => Mage::helper('adminhtml')->__('Hide'),
18
+ );
19
+ }
20
+
21
+ }
app/code/local/Simi/Simiconnector/Model/Config/Source/Productsviewtype.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ class Simi_Simiconnector_Model_Config_Source_Productsviewtype
6
+ {
7
+ const LIST_TYPE = 0;
8
+ const GRID_TYPE = 1;
9
+
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ self::LIST_TYPE => Mage::helper('simiconnector')->__('List'),
14
+ self::GRID_TYPE => Mage::helper('simiconnector')->__('Grid'),
15
+ );
16
+ }
17
+ }
app/code/local/Simi/Simiconnector/Model/Config/Source/Qrcodetypes.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Simi_Simiconnector_Model_Config_Source_Qrcodetypes extends Varien_Object {
5
+
6
+ /**
7
+ * get model option as array
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray() {
12
+ return array(
13
+ array('value' => '1', 'label' => Mage::helper('simibarcode')->__('L - smallest')),
14
+ array('value' => '0', 'label' => Mage::helper('simibarcode')->__('M')),
15
+ array('value' => '2', 'label' => Mage::helper('simibarcode')->__('Q')),
16
+ array('value' => '3', 'label' => Mage::helper('simibarcode')->__('H - best')),
17
+ );
18
+ }
19
+
20
+ /**
21
+ * get model option as array
22
+ *
23
+ * @return array
24
+ */
25
+ public function getSizes() {
26
+ return array(
27
+ array('value' => '50', 'label' => Mage::helper('simibarcode')->__('1')),
28
+ array('value' => '100', 'label' => Mage::helper('simibarcode')->__('2')),
29
+ array('value' => '150', 'label' => Mage::helper('simibarcode')->__('3')),
30
+ array('value' => '200', 'label' => Mage::helper('simibarcode')->__('4')),
31
+ array('value' => '250', 'label' => Mage::helper('simibarcode')->__('5')),
32
+ array('value' => '300', 'label' => Mage::helper('simibarcode')->__('6')),
33
+ array('value' => '350', 'label' => Mage::helper('simibarcode')->__('7')),
34
+ array('value' => '400', 'label' => Mage::helper('simibarcode')->__('8')),
35
+ array('value' => '450', 'label' => Mage::helper('simibarcode')->__('9')),
36
+ array('value' => '500', 'label' => Mage::helper('simibarcode')->__('10')),
37
+ );
38
+ }
39
+
40
+ }
app/code/local/Simi/Simiconnector/Model/Config/Source/Showandhideoption.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Livechatzopim
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Livechatzopim Model
17
+ *
18
+ * @category
19
+ * @package Livechatzopim
20
+ * @author Developer
21
+ */
22
+
23
+ /**
24
+ * Used in creating options for Yes|No config value selection
25
+ *
26
+ */
27
+ class Simi_Simiconnector_Model_Config_Source_Showandhideoption
28
+ {
29
+
30
+ /**
31
+ * Options getter
32
+ *
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ return array(
38
+ array('value' => 4, 'label'=>Mage::helper('adminhtml')->__('Required')),
39
+ array('value' => 3, 'label'=>Mage::helper('adminhtml')->__('Optional')),
40
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Hide')),
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Get options in "key-value" format
46
+ *
47
+ * @return array
48
+ */
49
+ public function toArray()
50
+ {
51
+ return array(
52
+ 4 => Mage::helper('adminhtml')->__('Required'),
53
+ 3 => Mage::helper('adminhtml')->__('Optional'),
54
+ 0 => Mage::helper('adminhtml')->__('Hide'),
55
+ );
56
+ }
57
+
58
+ }
59
+
app/code/local/Simi/Simiconnector/Model/Customer.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Simi_Simiconnector_Model_Customer extends Mage_Core_Model_Abstract {
7
+
8
+ protected function _helperCustomer() {
9
+ return Mage::helper('simiconnector/customer');
10
+ }
11
+
12
+ protected function _getSession() {
13
+ return Mage::getSingleton('customer/session');
14
+ }
15
+
16
+ public function getCustomerByEmail($email) {
17
+ return Mage::getModel('customer/customer')->getCollection()
18
+ ->addFieldToFilter('email', $email)
19
+ ->getFirstItem();
20
+ }
21
+
22
+ public function forgetPassword($data) {
23
+ $data = $data['params'];
24
+ $email = $data['email'];
25
+ if (is_null($email)) {
26
+ throw new Exception($this->_helperCustomer()->__('No email was sent'), 4);
27
+ } else {
28
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
29
+ throw new Exception($this->_helperCustomer()->__('Invalid email address.'), 4);
30
+ }
31
+ $customer = Mage::helper('simiconnector/customer')->getCustomerByEmail($email);
32
+ if ($customer->getId()) {
33
+ $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
34
+ $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
35
+ $customer->sendPasswordResetConfirmationEmail();
36
+ } else {
37
+ throw new Exception($this->_helperCustomer()->__('Customer is not exist'));
38
+ }
39
+ }
40
+ }
41
+
42
+ public function login($data) {
43
+ return Mage::helper('simiconnector/customer')->loginByEmailAndPass($data['params']['email'], $data['params']['password']);
44
+ }
45
+
46
+ public function logout() {
47
+ $this->_getSession()->logout()
48
+ ->setBeforeAuthUrl(Mage::getUrl());
49
+ return true;
50
+ }
51
+
52
+ public function register($data) {
53
+ $data = $data['contents'];
54
+ $message = array();
55
+ $checkCustomer = $this->getCustomerByEmail($data->email);
56
+ if ($checkCustomer->getId()) {
57
+ throw new Exception($this->_helperCustomer()->__('Account already exists'), 4);
58
+ }
59
+ $customer = $this->_createCustomer($data);
60
+ $result = array();
61
+ $result['user_id'] = $customer->getId();
62
+ $session = $this->_getSession();
63
+ if ($customer->isConfirmationRequired()) {
64
+ $app = Mage::app();
65
+ $store = $app->getStore();
66
+ $customer->sendNewAccountEmail(
67
+ 'confirmation', $session->getBeforeAuthUrl(), $store->getId()
68
+ );
69
+ throw new Exception($this->_helperCustomer()->__('Account confirmation is required. Please, check your email.'), 4);
70
+ } else {
71
+ $customer->setConfirmation(null);
72
+ $customer->save();
73
+ $customer->sendNewAccountEmail();
74
+ }
75
+ return $customer;
76
+ }
77
+
78
+ public function updateProfile($data) {
79
+ $data = $data['contents'];
80
+ $result = array();
81
+ $currPass = $data->old_password;
82
+ $newPass = $data->new_password;
83
+ $confPass = $data->com_password;
84
+
85
+ $customer = Mage::getModel('customer/customer');
86
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
87
+ $customer->loadByEmail($data->email);
88
+
89
+ $customerData = array(
90
+ 'firstname' => $data->firstname,
91
+ 'lastname' => $data->lastname,
92
+ 'email' => $data->email,
93
+ );
94
+ if (version_compare(Mage::getVersion(), '1.4.2.0', '<') === true) {
95
+ $customer = Mage::getModel('customer/customer')
96
+ ->setId($this->_getSession()->getCustomerId())
97
+ ->setWebsiteId($this->_getSession()->getCustomer()->getWebsiteId());
98
+ }
99
+ $fields = Mage::getConfig()->getFieldset('customer_account');
100
+ foreach ($fields as $code => $node) {
101
+ if ($node->is('update') && isset($customerData[$code])) {
102
+ $customer->setData($code, $customerData[$code]);
103
+ }
104
+ }
105
+
106
+ if ($data->change_password == 1) {
107
+ $customer->setChangePassword(1);
108
+ $oldPass = $this->_getSession()->getCustomer()->getPasswordHash();
109
+ if (Mage::helper('core/string')->strpos($oldPass, ':')) {
110
+ list($_salt, $salt) = explode(':', $oldPass);
111
+ } else {
112
+ $salt = false;
113
+ }
114
+ if ($customer->hashPassword($currPass, $salt) == $oldPass) {
115
+ if (strlen($newPass)) {
116
+ $customer->setPassword($newPass);
117
+ $customer->setConfirmation($confPass);
118
+ $customer->setPasswordConfirmation($confPass);
119
+ } else {
120
+ throw new Exception($this->_helperCustomer()->__('New password field cannot be empty'), 4);
121
+ }
122
+ } else {
123
+ throw new Exception($this->_helperCustomer()->__('Invalid current password'), 4);
124
+ }
125
+ }
126
+
127
+ if (isset($data->taxvat)) {
128
+ $customer->setTaxvat($data->taxvat);
129
+ }
130
+
131
+ if (isset($data->day) && $data->day != "") {
132
+ $birthday = $data->year . "-" . $data->month . "-" . $data->day;
133
+ $customer->setDob($birthday);
134
+ }
135
+
136
+ if (isset($data->gender) && $data->gender) {
137
+ $customer->setGender($data->gender);
138
+ }
139
+ if (isset($data->prefix) && $data->prefix) {
140
+ $customer->setPrefix($data->prefix);
141
+ }
142
+
143
+ if (isset($data->middlename) && $data->middlename) {
144
+ $customer->setMiddlename($data->middlename);
145
+ }
146
+
147
+ if (isset($data->suffix) && $data->suffix) {
148
+ $customer->setSuffix($data->suffix);
149
+ }
150
+
151
+ $customerErrors = $customer->validate();
152
+ if (is_array($customerErrors))
153
+ throw new Exception($this->_helperCustomer()->__('Invalid profile information'), 4);
154
+ $customer->setConfirmation(null);
155
+ $customer->save();
156
+ $this->_getSession()->setCustomer($customer);
157
+ return $customer;
158
+ }
159
+
160
+ /*
161
+ * Social Login
162
+ * @param
163
+ * $data - Object with at least:
164
+ * $data->firstname
165
+ * $data->lastname
166
+ * $data->email
167
+ */
168
+
169
+ public function socialLogin($data) {
170
+ $data = (object) $data['params'];
171
+ if (!isset($data->password) || !Mage::helper('simiconnector/customer')->validateSimiPass($data->email, $data->password))
172
+ throw new Exception($this->_helperCustomer()->__('Password is not Valid'), 4);
173
+ if (!$data->email)
174
+ throw new Exception($this->_helperCustomer()->__('Cannot Get Your Email'), 4);
175
+ $customer = Mage::helper('simiconnector/customer')->getCustomerByEmail($data->email);
176
+ if (!$customer->getId()) {
177
+ if (!$data->firstname)
178
+ $data->firstname = $this->_helperCustomer()->__('Firstname');
179
+ if (!$data->lastname)
180
+ $data->lastname = $this->_helperCustomer()->__('Lastname');
181
+ $customer = $this->_createCustomer($data);
182
+ $customer->setConfirmation(null);
183
+ $customer->save();
184
+ $customer->sendPasswordReminderEmail();
185
+ }
186
+ Mage::helper('simiconnector/customer')->loginByCustomer($customer);
187
+ return $customer;
188
+ }
189
+
190
+ /*
191
+ * Create Customer
192
+ * @param
193
+ * $data - Object with at least:
194
+ * $data->firstname
195
+ * $data->lastname
196
+ * $data->email
197
+ * $data->password
198
+ */
199
+
200
+ private function _createCustomer($data) {
201
+ $customer = Mage::getModel('customer/customer')
202
+ ->setFirstname($data->firstname)
203
+ ->setLastname($data->lastname)
204
+ ->setEmail($data->email);
205
+ if (isset($data->day) && $data->day != "") {
206
+ $birthday = $data->year . "-" . $data->month . "-" . $data->day;
207
+ $customer->setDob($birthday);
208
+ }
209
+
210
+ if (isset($data->taxvat)) {
211
+ $customer->setTaxvat($data->taxvat);
212
+ }
213
+
214
+ if (isset($data->gender) && $data->gender) {
215
+ $customer->setGender($data->gender);
216
+ }
217
+ if (isset($data->prefix) && $data->prefix) {
218
+ $customer->setPrefix($data->prefix);
219
+ }
220
+
221
+ if (isset($data->middlename) && $data->middlename) {
222
+ $customer->setMiddlename($data->middlename);
223
+ }
224
+
225
+ if (isset($data->suffix) && $data->suffix) {
226
+ $customer->setSuffix($data->suffix);
227
+ }
228
+ if (!$data->password)
229
+ $data->password = $customer->generatePassword();
230
+ $customer->setPassword($data->password);
231
+ $customer->save();
232
+
233
+ if (isset($data->news_letter) && ($data->news_letter == '1'))
234
+ Mage::getModel('newsletter/subscriber')->subscribe($data->email);
235
+ else
236
+ Mage::getModel('newsletter/subscriber')->loadByEmail($data->email)->unsubscribe();
237
+ return $customer;
238
+ }
239
+
240
+ }
app/code/local/Simi/Simiconnector/Model/Device.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Device extends Mage_Core_Model_Abstract {
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $this->_init('simiconnector/device');
11
+ }
12
+
13
+ public function detectMobile() {
14
+ $user_agent = '';
15
+ if ($_SERVER["HTTP_USER_AGENT"]) {
16
+ $user_agent = $_SERVER["HTTP_USER_AGENT"];
17
+ }
18
+ if (strstr($user_agent, 'iPhone') || strstr($user_agent, 'iPod')) {
19
+ return 1;
20
+ } elseif (strstr($user_agent, 'iPad')) {
21
+ return 2;
22
+ } elseif (strstr($user_agent, 'Android')) {
23
+ return 3;
24
+ } else {
25
+ return 1;
26
+ }
27
+ }
28
+
29
+ public function saveDevice($data) {
30
+
31
+ $deviceData = $data['contents'];
32
+ if (!$deviceData->device_token)
33
+ throw new Exception(Mage::helper('simiconnector')->__('No Device Token Sent'), 4);
34
+ $device_id = $deviceData->plaform_id;
35
+ if (!$device_id)
36
+ $device_id = $this->detectMobile();
37
+ $latitude = $deviceData->latitude;
38
+ $longitude = $deviceData->longitude;
39
+ $addresses = Mage::helper('simiconnector/address')->getLocationInfo($latitude, $longitude);
40
+ if ($addresses) {
41
+ $this->setData('address', $addresses['address']);
42
+ $this->setData('city', $addresses['city']);
43
+ $this->setData('state', $addresses['state']);
44
+ $this->setData('country', $addresses['country']);
45
+ $this->setData('zipcode', $addresses['zipcode']);
46
+ }
47
+ $this->setData('device_token', $deviceData->device_token);
48
+ $this->setData('plaform_id', $device_id);
49
+ $this->setData('storeview_id', Mage::app()->getStore()->getStoreId());
50
+ $this->setData('latitude', $deviceData->latitude);
51
+ $this->setData('longitude', $deviceData->longitude);
52
+ $this->setData('created_time', now());
53
+ $this->setData('user_email', $deviceData->user_email);
54
+ $this->setData('app_id', $deviceData->app_id);
55
+ $this->setData('device_ip', $_SERVER['REMOTE_ADDR']);
56
+ $this->setData('device_user_agent', $_SERVER['HTTP_USER_AGENT']);
57
+ $this->setData('build_version', $deviceData->build_version);
58
+ if (is_null($deviceData->is_demo)) {
59
+ $this->setData('is_demo', 3);
60
+ } else
61
+ $this->setData('is_demo', $deviceData->is_demo);
62
+ $existed_device = $this->getCollection()->addFieldToFilter('device_token', $deviceData->device_token)->getFirstItem();
63
+ if ($existed_device->getId()) {
64
+ $this->setId($existed_device->getId());
65
+ }
66
+ $this->save();
67
+ }
68
+
69
+ }
app/code/local/Simi/Simiconnector/Model/History.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_History extends Mage_Core_Model_Abstract {
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $this->_init('simiconnector/history');
11
+ }
12
+
13
+ public function toOptionArray() {
14
+ return Mage::getResourceModel('customer/group_collection')->load()
15
+ ->toOptionArray();
16
+ }
17
+
18
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Appreport.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
5
+ * version in the future.
6
+ *
7
+ * @category
8
+ * @package Appreport
9
+ * @copyright Copyright (c) 2012
10
+ * @license
11
+ */
12
+
13
+ /**
14
+ * Appreport Resource Model
15
+ *
16
+ * @category
17
+ * @package Appreport
18
+ * @author Developer
19
+ */
20
+ class Simi_Simiconnector_Model_Mysql4_Appreport extends Mage_Core_Model_Mysql4_Abstract
21
+ {
22
+ public function _construct()
23
+ {
24
+ $this->_init('simiconnector/appreport', 'appreport_id');
25
+ }
26
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Appreport/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Appreport_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('simiconnector/appreport');
9
+ }
10
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Banner.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Resource Model
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Model_Mysql4_Banner extends Mage_Core_Model_Mysql4_Abstract
23
+ {
24
+ public function _construct(){
25
+ $this->_init('simiconnector/banner', 'banner_id');
26
+ }
27
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Banner/Collection.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Resource Collection
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Model_Mysql4_Banner_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
24
+
25
+ public function _construct() {
26
+ parent::_construct();
27
+ $this->_init('simiconnector/banner');
28
+ }
29
+
30
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Cms.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Cms extends Mage_Core_Model_Mysql4_Abstract {
7
+
8
+ public function _construct() {
9
+ $this->_init('simiconnector/cms', 'cms_id');
10
+ }
11
+
12
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Cms/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Cms_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $this->_init('simiconnector/cms');
11
+ }
12
+
13
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Device.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Device extends Mage_Core_Model_Mysql4_Abstract {
7
+
8
+ public function _construct() {
9
+ $this->_init('simiconnector/device', 'device_id');
10
+ }
11
+
12
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Device/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Device_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $this->_init('simiconnector/device');
11
+ }
12
+
13
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/History.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_History extends Mage_Core_Model_Mysql4_Abstract
7
+ {
8
+ public function _construct(){
9
+ $this->_init('simiconnector/history', 'history_id');
10
+ }
11
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/History/Collection.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Model_Mysql4_History_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
8
+
9
+ public function _construct() {
10
+ parent::_construct();
11
+ $this->_init('simiconnector/history');
12
+ }
13
+
14
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Productlist.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Productlist extends Mage_Core_Model_Mysql4_Abstract {
7
+
8
+ public function _construct() {
9
+ $this->_init('simiconnector/productlist', 'productlist_id');
10
+ }
11
+
12
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Productlist/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Productlist_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $this->_init('simiconnector/productlist');
11
+ }
12
+
13
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simibarcode.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simibarcode extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('simiconnector/simibarcode', 'barcode_id');
8
+ }
9
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simibarcode/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simibarcode_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simibarcode');
8
+ }
9
+
10
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simicategory.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simicategory extends Mage_Core_Model_Mysql4_Abstract {
4
+
5
+ public function _construct() {
6
+ $this->_init('simiconnector/simicategory', 'simicategory_id');
7
+ }
8
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simicategory/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simicategory_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simicategory');
8
+ }
9
+
10
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Siminotification.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Model_Mysql4_Siminotification extends Mage_Core_Model_Mysql4_Abstract {
8
+
9
+ public function _construct() {
10
+ $this->_init('simiconnector/siminotification', 'notice_id');
11
+ }
12
+
13
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Siminotification/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+
5
+ */
6
+ class Simi_Simiconnector_Model_Mysql4_Siminotification_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $this->_init('simiconnector/siminotification');
11
+ }
12
+
13
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simiproductlabel.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simiproductlabel extends Mage_Core_Model_Mysql4_Abstract {
4
+
5
+ public function _construct() {
6
+ $this->_init('simiconnector/simiproductlabel', 'label_id');
7
+ }
8
+
9
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simiproductlabel/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simiproductlabel_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simiproductlabel');
8
+ }
9
+
10
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simivideo.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simivideo extends Mage_Core_Model_Mysql4_Abstract {
4
+
5
+ public function _construct() {
6
+ $this->_init('simiconnector/simivideo', 'video_id');
7
+ }
8
+
9
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Simivideo/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Mysql4_Simivideo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simivideo');
8
+ }
9
+
10
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Visibility.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Resource Model
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Model_Mysql4_Visibility extends Mage_Core_Model_Mysql4_Abstract
23
+ {
24
+ public function _construct(){
25
+ $this->_init('simiconnector/visibility', 'entity_id');
26
+ }
27
+ }
app/code/local/Simi/Simiconnector/Model/Mysql4/Visibility/Collection.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Connector Resource Collection
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Model_Mysql4_Visibility_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
24
+
25
+ public function _construct() {
26
+ parent::_construct();
27
+ $this->_init('simiconnector/visibility');
28
+ }
29
+
30
+ }
app/code/local/Simi/Simiconnector/Model/Observer.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Siminotification
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Siminotification Model
18
+ *
19
+ * @category
20
+ * @package Siminotification
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Model_Observer {
24
+
25
+ /**
26
+ * process catalog_product_save_after event
27
+ *
28
+ * @return Simi_Siminotification_Model_Observer
29
+ */
30
+ public function sendNotificationProductChangePrice($observer) {
31
+ $helper = Mage::helper('simiconnector/siminotification');
32
+ $storeViewCollection = Mage::getModel('core/store')->getCollection();
33
+ foreach ($storeViewCollection as $storeview) {
34
+ $storeviewId = $storeview->getId();
35
+ if ($helper->getConfig('simiconnector/notification/noti_price_enable', $storeviewId)) {
36
+ $newProduct = $observer->getProduct();
37
+ if (!in_array($storeview->getWebsiteId(), $newProduct->getWebsiteIds()))
38
+ continue;
39
+ $newPrice = $newProduct->getData('price');
40
+ $newSpecialPrice = $newProduct->getData('special_price');
41
+ $oldProduct = Mage::getModel('catalog/product')->load($newProduct->getId());
42
+ $oldPrice = $oldProduct->getData('price');
43
+ $oldSpecialPrice = $oldProduct->getData('special_price');
44
+ if ($oldSpecialPrice != $newSpecialPrice && $newProduct->getId() > 0 && $newProduct->getStatus() == '1' && $newProduct->getVisibility() != '1') {
45
+ $data = array();
46
+ $content = Mage::helper('simiconnector/siminotification')->__(
47
+ $helper->getConfig('simiconnector/notification/noti_price_message', $storeviewId), $newProduct->getName(), $this->formatPrice($oldSpecialPrice), $this->formatPrice($newSpecialPrice));
48
+ $data['website_id'] = $helper->getConfig('simiconnector/notification/noti_price_website', $storeviewId);
49
+ $data['show_popup'] = $helper->getConfig('simiconnector/notification/noti_price_showpopup', $storeviewId);
50
+ $data['notice_title'] = $helper->getConfig('simiconnector/notification/noti_price_title', $storeviewId);
51
+ $data['notice_url'] = $helper->getConfig('simiconnector/notification/noti_price_url', $storeviewId);
52
+ $data['notice_content'] = $content;
53
+ $data['device_id'] = $helper->getConfig('simiconnector/notification/noti_price_platform', $storeviewId);
54
+ $data['notice_sanbox'] = $helper->getConfig('simiconnector/notification/noti_price_sandbox', $storeviewId);
55
+ $data['type'] = $helper->getConfig('simiconnector/notification/noti_price_type', $storeviewId);
56
+ $data['product_id'] = $newProduct->getId();
57
+ $data['category_id'] = $helper->getConfig('simiconnector/notification/noti_price_category_id', $storeviewId);
58
+ $data['category_name'] = $this->getCategoryName($helper->getConfig('simiconnector/notification/noti_price_category_id', $storeviewId));
59
+ $data['has_child'] = $this->getCategoryChildrenCount($helper->getConfig('simiconnector/notification/noti_price_category_id', $storeviewId));
60
+ $data['created_time'] = now();
61
+ $data['notice_type'] = 1;
62
+ $data['notice_sanbox'] = '2';
63
+ $data['storeview_id'] = $storeviewId;
64
+ $data['devices_pushed'] = $this->getAllDeviceToPush($storeviewId);
65
+ if ($data['devices_pushed']) {
66
+ Mage::helper('simiconnector/siminotification')->sendNotice($data);
67
+ }
68
+ } elseif ($oldPrice != $newPrice && $newProduct->getId() > 0 && $newProduct->getStatus() == '1' && $newProduct->getVisibility() != '1') {
69
+ $data = array();
70
+ $content = Mage::helper('simiconnector/siminotification')->__(
71
+ $helper->getConfig('simiconnector/notification/noti_price_message', $storeviewId), $newProduct->getName(), $this->formatPrice($oldPrice), $this->formatPrice($newPrice));
72
+ $data['website_id'] = $helper->getConfig('simiconnector/notification/noti_price_website', $storeviewId);
73
+ $data['show_popup'] = $helper->getConfig('simiconnector/notification/noti_price_showpopup', $storeviewId);
74
+ $data['notice_title'] = $helper->getConfig('simiconnector/notification/noti_price_title', $storeviewId);
75
+ $data['notice_url'] = $helper->getConfig('simiconnector/notification/noti_price_url', $storeviewId);
76
+ $data['notice_content'] = $content;
77
+ $data['device_id'] = $helper->getConfig('simiconnector/notification/noti_price_platform', $storeviewId);
78
+ $data['notice_sanbox'] = $helper->getConfig('simiconnector/notification/noti_price_sandbox', $storeviewId);
79
+ $data['type'] = $helper->getConfig('simiconnector/notification/noti_price_type', $storeviewId);
80
+ $data['product_id'] = $newProduct->getId();
81
+ $data['category_id'] = $helper->getConfig('simiconnector/notification/noti_price_category_id', $storeviewId);
82
+ $data['category_name'] = $this->getCategoryName($helper->getConfig('simiconnector/notification/noti_price_category_id', $storeviewId));
83
+ $data['has_child'] = $this->getCategoryChildrenCount($helper->getConfig('simiconnector/notification/noti_price_category_id', $storeviewId));
84
+ $data['created_time'] = now();
85
+ $data['notice_type'] = 1;
86
+ $data['notice_sanbox'] = '2';
87
+ $data['storeview_id'] = $storeviewId;
88
+ $data['devices_pushed'] = $this->getAllDeviceToPush($storeviewId);
89
+ if ($data['devices_pushed']) {
90
+ Mage::helper('simiconnector/siminotification')->sendNotice($data);
91
+ }
92
+ } elseif (!$newProduct->getId()) {
93
+ Mage::getSingleton('core/session')->setData('new_added_product_sku', $newProduct->getSku());
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ public function sendNotificationNewProduct($observer) {
100
+ $helper = Mage::helper('simiconnector/siminotification');
101
+ $storeViewCollection = Mage::getModel('core/store')->getCollection();
102
+ foreach ($storeViewCollection as $storeview) {
103
+ $storeviewId = $storeview->getId();
104
+ if ($helper->getConfig('simiconnector/notification/new_product_enable', $storeviewId)) {
105
+ $newProduct = $observer->getProduct();
106
+ if (!in_array($storeview->getWebsiteId(), $newProduct->getWebsiteIds()))
107
+ continue;
108
+ $lastProductId = Mage::getModel('catalog/product')->getCollection()
109
+ ->setOrder('entity_id', 'desc')->getFirstItem()->getId();
110
+ if ($newProduct->getId() && $newProduct->getId() == $lastProductId && $newProduct->getStatus() == '1' && $newProduct->getVisibility() != '1' && $newProduct->getSku() == Mage::getSingleton('core/session')->getData('new_added_product_sku')) {
111
+ $content = Mage::helper('simiconnector/siminotification')->__(
112
+ $helper->getConfig('simiconnector/notification/new_product_message', $storeviewId), $newProduct->getName());
113
+ $data = array();
114
+ $data['website_id'] = $helper->getConfig('simiconnector/notification/new_product_website', $storeviewId);
115
+ $data['show_popup'] = $helper->getConfig('simiconnector/notification/new_product_showpopup', $storeviewId);
116
+ $data['notice_title'] = $helper->getConfig('simiconnector/notification/new_product_title', $storeviewId);
117
+ $data['notice_url'] = $helper->getConfig('simiconnector/notification/new_product_url', $storeviewId);
118
+ $data['notice_content'] = $content;
119
+ $data['device_id'] = $helper->getConfig('simiconnector/notification/new_product_platform', $storeviewId);
120
+ $data['notice_sanbox'] = $helper->getConfig('simiconnector/notification/new_product_sandbox', $storeviewId);
121
+ $data['type'] = $helper->getConfig('simiconnector/notification/new_product_type', $storeviewId);
122
+ $data['product_id'] = $newProduct->getId();
123
+ $data['category_id'] = $helper->getConfig('simiconnector/notification/new_product_category_id', $storeviewId);
124
+ $data['category_name'] = $this->getCategoryName($helper->getConfig('simiconnector/notification/new_product_category_id', $storeviewId));
125
+ $data['has_child'] = $this->getCategoryChildrenCount($helper->getConfig('simiconnector/notification/new_product_category_id', $storeviewId));
126
+ $data['created_time'] = now();
127
+ $data['notice_type'] = 2;
128
+ $data['notice_sanbox'] = '2';
129
+ Mage::getSingleton('core/session')->setData('new_added_product_sku', NULL);
130
+ $data['storeview_id'] = $storeviewId;
131
+ $data['devices_pushed'] = $this->getAllDeviceToPush($storeviewId);
132
+ if ($data['devices_pushed']) {
133
+ Mage::helper('simiconnector/siminotification')->sendNotice($data);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ public function getCategoryName($categoryId) {
141
+ $category = Mage::getModel('catalog/category')->load($categoryId);
142
+ $categoryName = $category->getName();
143
+ return $categoryName;
144
+ }
145
+
146
+ public function getCategoryChildrenCount($categoryId) {
147
+ $category = Mage::getModel('catalog/category')->load($categoryId);
148
+ $categoryChildrenCount = $category->getChildrenCount();
149
+ if ($categoryChildrenCount > 0)
150
+ $categoryChildrenCount = 1;
151
+ else
152
+ $categoryChildrenCount = 0;
153
+ return $categoryChildrenCount;
154
+ }
155
+
156
+ public function formatPrice($price) {
157
+ return Mage::helper('core')->currency($price, true, false);
158
+ }
159
+
160
+ public function getAllDeviceToPush($storeview_id) {
161
+ $idArray = array();
162
+ $tokenArray = array();
163
+ foreach (Mage::getModel('simiconnector/device')->getCollection()->addFieldToFilter('storeview_id', $storeview_id) as $device) {
164
+ if (!in_array($device->getData('device_token'), $idArray)) {
165
+ $idArray[] = $device->getId();
166
+ $tokenArray[] = $device->getData('device_token');
167
+ }
168
+ }
169
+ return implode(',', $idArray);
170
+ }
171
+
172
+ /*
173
+ * Remove coupon on Cart (coupon for app only)
174
+ */
175
+ public function sales_quote_collect_totals_before($observer) {
176
+ $quote = $observer->getQuote();
177
+ $coupon = $quote->getCouponCode();
178
+ $isApp = strpos(Mage::getUrl('*/*'), 'simiconnector');
179
+ $pre_fix = (string) Mage::getStoreConfig('simiconnector/general/app_dedicated_coupon');
180
+
181
+ if (($isApp == false) && $coupon) {
182
+ if (strpos($coupon, $pre_fix) !== false) {
183
+ $quote->setCouponCode('');
184
+ }
185
+ }
186
+ }
187
+
188
+ }
app/code/local/Simi/Simiconnector/Model/Platform.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Siminotification
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Siminotification Model
18
+ *
19
+ * @category
20
+ * @package Siminotification
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Model_Platform extends Mage_Core_Model_Abstract {
24
+
25
+ public function _construct() {
26
+ parent::_construct();
27
+ $this->_init('simiconnector/platform');
28
+ }
29
+
30
+ public function toOptionArray() {
31
+ $platform = array(
32
+ Mage::helper('simiconnector')->__('All'),
33
+ Mage::helper('simiconnector')->__('IOS'),
34
+ Mage::helper('simiconnector')->__('Android'),
35
+ );
36
+ return $platform;
37
+ }
38
+
39
+ }
app/code/local/Simi/Simiconnector/Model/Productlist.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ Custom Product list on Home Screen
6
+ */
7
+ class Simi_Simiconnector_Model_Productlist extends Mage_Core_Model_Abstract {
8
+
9
+ public function _construct() {
10
+ parent::_construct();
11
+ $this->_init('simiconnector/productlist');
12
+ }
13
+
14
+ public function delete() {
15
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('productlist');
16
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
17
+ ->addFieldToFilter('content_type', $typeID)
18
+ ->addFieldToFilter('item_id', $this->getId());
19
+ foreach ($visibleStoreViews as $visibilityItem)
20
+ $visibilityItem->delete();
21
+ return parent::delete();
22
+ }
23
+
24
+ }
app/code/local/Simi/Simiconnector/Model/Server.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/2/16
7
+ * Time: 4:20 PM
8
+ */
9
+ class Simi_Simiconnector_Model_Server
10
+ {
11
+
12
+ protected $_helper;
13
+ protected $_data = array();
14
+ protected $_method = 'callApi';
15
+
16
+ public function __construct()
17
+ {
18
+ $this->_helper = Mage::helper('simiconnector');
19
+ }
20
+
21
+ public function init(Simi_Simiconnector_Controller_Action $controller)
22
+ {
23
+ $this->initialize($controller);
24
+ return $this;
25
+ }
26
+
27
+ public function setData($data)
28
+ {
29
+ $this->_data = $data;
30
+ }
31
+
32
+ public function getData()
33
+ {
34
+ return $this->_data;
35
+ }
36
+
37
+ /**
38
+ * @return mixed|string
39
+ * @throws Exception
40
+ * error code
41
+ * 1 Not Login
42
+ * 2 Miss username or password to login
43
+ * 3 Access Denied
44
+ * 4 Invalid method
45
+ * 5 Login failed
46
+ * 6 Resource cannot callable
47
+ * 7 Missed input Value
48
+ */
49
+ public function run()
50
+ {
51
+ $data = $this->_data;
52
+
53
+ if (count($data) == 0) {
54
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
55
+ }
56
+
57
+ if (!isset($data['resource'])) throw new Exception($this->_helper->__('Invalid method.'), 4);
58
+
59
+ $model = Mage::getSingleton($data['module'] . '/api_' . $data['resource']);
60
+
61
+ if (!$model) {
62
+ throw new Exception($this->_helper->__('Invalid method.'), 4);
63
+ }
64
+
65
+ if (is_callable(array(&$model, $this->_method))) {
66
+ return call_user_func_array(array(&$model, $this->_method), array($data));
67
+ }
68
+ throw new Exception($this->_helper->__('Resource cannot callable.'), 6);
69
+ }
70
+
71
+ /**
72
+ * @param Simi_Simiconnector_Controller_Action $controller
73
+ * $is_method = 1 - get
74
+ * $is_method = 2 - post
75
+ * $is_method = 3 - update
76
+ * $is_method = 4 - delete
77
+ */
78
+ public function initialize(Simi_Simiconnector_Controller_Action $controller)
79
+ {
80
+
81
+ $request_string = $controller->getRequest()->getRequestString();
82
+ $action_string = $controller->getRequest()->getActionName() . '/';
83
+ $cache = explode($action_string, $request_string);
84
+ $resources_string = $cache[1];
85
+ $resources = explode('/', $resources_string);
86
+
87
+ $resource = isset($resources[0]) ? $resources[0] : null;
88
+ $resourceid = isset($resources[1]) ? $resources[1] : null;
89
+ $nestedresource = isset($resources[2]) ? $resources[2] : null;
90
+ $nestedid = isset($resources[3]) ? $resources[3] : null;
91
+
92
+ $module = $controller->getRequest()->getModuleName();
93
+ $params = $controller->getRequest()->getQuery();
94
+ $contents = $controller->getRequest()->getRawBody(); // using without GET method
95
+ $contents_array = array();
96
+ if ($contents && strlen($contents)) {
97
+ $contents_paser = urldecode($contents);
98
+ $contents = json_decode($contents_paser);
99
+ $contents_array = json_decode($contents_paser, true);
100
+ }
101
+
102
+ $is_method = 1;
103
+ if ($controller->getRequest()->isPost()) {
104
+ $is_method = 2;
105
+ } elseif ($controller->getRequest()->isPut()) {
106
+ $is_method = 3;
107
+ } elseif ($controller->getRequest()->isDelete()) {
108
+ $is_method = 4;
109
+ }
110
+ $this->_data = array(
111
+ 'resource' => $resource,
112
+ 'resourceid' => $resourceid,
113
+ 'nestedresource' => $nestedresource,
114
+ 'nestedid' => $nestedid,
115
+ 'params' => $params,
116
+ 'contents' => $contents,
117
+ 'contents_array' => $contents_array,
118
+ 'is_method' => $is_method,
119
+ 'module' => $module,
120
+ 'controller' => $controller,
121
+ );
122
+ Mage::dispatchEvent('simi_simiconnector_model_server_initialize', array('object' => $this, 'data' => $this->_data));
123
+ }
124
+
125
+ }
app/code/local/Simi/Simiconnector/Model/Simibarcode.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Simibarcode extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simibarcode');
8
+ }
9
+
10
+ /*
11
+ public function checkCode($data) {
12
+ $code = $data->code;
13
+ $type = $data->type;
14
+ $arrayReturn = array();
15
+ $information = $this->statusError(array(Mage::helper('simibarcode')->__('No Product matching the code')));
16
+ if (isset($code) && $code != '') {
17
+ if ($type == '1') {
18
+ $qrcode = Mage::getModel('simibarcode/simibarcode')->load($code, 'qrcode');
19
+ if ($qrcode->getId() && $qrcode->getBarcodeStatus() == '1') {
20
+ // if($code == 'King'){
21
+ $productId = $qrcode->getProductEntityId();
22
+ $product = Mage::getModel('catalog/product')->load($productId);
23
+ if ($product->getStatus() == '1') {
24
+ $information = $this->statusSuccess();
25
+ $arrayReturn[] = array('product_id' => $productId);
26
+ $information['data'] = $arrayReturn;
27
+ }
28
+ }
29
+ } else {
30
+ $barcode = Mage::getModel('simibarcode/simibarcode')->load($code, 'barcode');
31
+ if ($barcode->getId() && $barcode->getBarcodeStatus() == '1') {
32
+ $productId = $barcode->getProductEntityId();
33
+ $product = Mage::getModel('catalog/product')->load($productId);
34
+ if ($product->getStatus() == '1') {
35
+ $information = $this->statusSuccess();
36
+ $arrayReturn[] = array('product_id' => $productId);
37
+ $information['data'] = $arrayReturn;
38
+ }
39
+ }
40
+ }
41
+ }
42
+ return $information;
43
+ }
44
+ *
45
+ */
46
+ }
app/code/local/Simi/Simiconnector/Model/Simicategory.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Simicategory extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simicategory');
8
+ }
9
+
10
+ public function getCategories() {
11
+ $data = array();
12
+ try {
13
+ $collection = $this->getCollection();
14
+ foreach ($collection as $item) {
15
+ if ($item->getStatus() == 1) {
16
+ $info = array(
17
+ 'category_id' => $item->getCategoryId(),
18
+ 'category_image' => $item->getSimicategoryFilename(),
19
+ 'category_name' => $item->getSimicategoryName(),
20
+ );
21
+ $data[] = $info;
22
+ }
23
+ }
24
+
25
+ $information = $this->statusSuccess();
26
+ $information['data'] = $data;
27
+ return $information;
28
+ } catch (Expetion $e) {
29
+ $message = $e->getMessage();
30
+ $information = $this->statusError();
31
+ $information['message'] = array($message);
32
+ if (is_array($message)) {
33
+ $information['message'] = $message;
34
+ }
35
+ return $information;
36
+ }
37
+ }
38
+ public function delete() {
39
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('homecategory');
40
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
41
+ ->addFieldToFilter('content_type', $typeID)
42
+ ->addFieldToFilter('item_id', $this->getId());
43
+ foreach ($visibleStoreViews as $visibilityItem)
44
+ $visibilityItem->delete();
45
+ return parent::delete();
46
+ }
47
+
48
+ }
app/code/local/Simi/Simiconnector/Model/Simiconnector.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Simiconnector extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('simiconnector/simiconnector');
8
+ }
9
+
10
+ }
app/code/local/Simi/Simiconnector/Model/Siminotification.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+
6
+ */
7
+ class Simi_Simiconnector_Model_Siminotification extends Mage_Core_Model_Abstract {
8
+
9
+ public function _construct() {
10
+ parent::_construct();
11
+ $this->_init('simiconnector/siminotification');
12
+ }
13
+
14
+ public function toOptionArray() {
15
+ $platform = array(
16
+ '1' => Mage::helper('simiconnector')->__('Product In-app'),
17
+ '2' => Mage::helper('simiconnector')->__('Category In-app'),
18
+ '3' => Mage::helper('simiconnector')->__('Website Page'),
19
+ );
20
+ return $platform;
21
+ }
22
+
23
+ }
app/code/local/Simi/Simiconnector/Model/Simiproductlabel.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Simiproductlabel extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('simiconnector/simiproductlabel');
9
+ }
10
+ }
app/code/local/Simi/Simiconnector/Model/Simivideo.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Simivideo extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('simiconnector/simivideo');
9
+ }
10
+ }
app/code/local/Simi/Simiconnector/Model/Status.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Model_Status extends Varien_Object {
4
+
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray() {
9
+ return array(
10
+ self::STATUS_ENABLED => Mage::helper('simiconnector')->__('Enabled'),
11
+ self::STATUS_DISABLED => Mage::helper('simiconnector')->__('Disabled')
12
+ );
13
+ }
14
+
15
+ static public function getOptionHash() {
16
+ $options = array();
17
+ foreach (self::getOptionArray() as $value => $label)
18
+ $options[] = array(
19
+ 'value' => $value,
20
+ 'label' => $label
21
+ );
22
+ return $options;
23
+ }
24
+
25
+ static public function getWebsite() {
26
+ $options = array();
27
+ $options[] = array(
28
+ 'value' => 0,
29
+ 'label' => Mage::helper('core')->__('All'),
30
+ );
31
+ $collection = Mage::helper('simiconnector')->getWebsites();
32
+ foreach ($collection as $item) {
33
+ $options[] = array(
34
+ 'value' => $item->getId(),
35
+ 'label' => $item->getName(),
36
+ );
37
+ }
38
+ return $options;
39
+ }
40
+
41
+ }
app/code/local/Simi/Simiconnector/Model/Visibility.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Connector Model
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Model_Visibility extends Mage_Core_Model_Abstract {
23
+
24
+ public function _construct() {
25
+ parent::_construct();
26
+ $this->_init('simiconnector/visibility');
27
+ }
28
+ }
app/code/local/Simi/Simiconnector/controllers/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/controllers/Adminhtml/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/AppreportController.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_AppreportController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * init layout and set active for current menu
7
+ *
8
+ * @return Simi_Appreport_Adminhtml_AppreportController
9
+ */
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('simiconnector/appreport')
13
+ ->_addBreadcrumb(
14
+ Mage::helper('adminhtml')->__('Transactions'), Mage::helper('adminhtml')->__('App Transactions')
15
+ );
16
+ return $this;
17
+ }
18
+
19
+ /**
20
+ * index action
21
+ */
22
+ public function indexAction() {
23
+ $this->_initAction()
24
+ ->renderLayout();
25
+ }
26
+
27
+ /**
28
+ * export grid item to CSV type
29
+ */
30
+ public function exportCsvAction() {
31
+ $fileName = 'appreport.csv';
32
+ $content = $this->getLayout()
33
+ ->createBlock('simiconnector/adminhtml_appreport_grid')
34
+ ->getCsv();
35
+ $this->_prepareDownloadResponse($fileName, $content);
36
+ }
37
+
38
+ /**
39
+ * export grid item to XML type
40
+ */
41
+ public function exportXmlAction() {
42
+ $fileName = 'appreport.xml';
43
+ $content = $this->getLayout()
44
+ ->createBlock('simiconnector/adminhtml_appreport_grid')
45
+ ->getXml();
46
+ $this->_prepareDownloadResponse($fileName, $content);
47
+ }
48
+
49
+ protected function _isAllowed() {
50
+ return Mage::getSingleton('admin/session')->isAllowed('simiconnector');
51
+ }
52
+
53
+ /**
54
+ * gird action
55
+ */
56
+ public function gridAction() {
57
+ $this->loadLayout();
58
+ $this->renderLayout();
59
+ }
60
+
61
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/BannerController.php ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+
15
+ /**
16
+ * Banner Adminhtml Controller
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Adminhtml_Simiconnector_BannerController extends Mage_Adminhtml_Controller_Action {
23
+
24
+ /**
25
+ * init layout and set active for current menu
26
+ *
27
+ * @return Simi_Connector_Adminhtml_BannerController
28
+ */
29
+ protected function _initAction() {
30
+ $this->loadLayout()
31
+ ->_setActiveMenu('simiconnector/banner')
32
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Banners Manager'), Mage::helper('adminhtml')->__('Banner Manager'));
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * index action
38
+ */
39
+ public function indexAction() {
40
+ $this->_initAction()
41
+ ->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * view and edit item action
46
+ */
47
+ public function editAction() {
48
+ $id = $this->getRequest()->getParam('id');
49
+ $model = Mage::getModel('simiconnector/banner')->load($id);
50
+ if ($model->getId() || $id == 0) {
51
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
52
+ if (!empty($data))
53
+ $model->setData($data);
54
+
55
+ Mage::register('banner_data', $model);
56
+
57
+ $this->loadLayout();
58
+ $this->_setActiveMenu('simiconnector/banner');
59
+
60
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Banner'), Mage::helper('adminhtml')->__('Item banner'));
61
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
62
+
63
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
64
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_banner_edit'))
65
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_banner_edit_tabs'));
66
+
67
+ $this->renderLayout();
68
+ } else {
69
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Item does not exist'));
70
+ $this->_redirect('*/*/');
71
+ }
72
+ }
73
+
74
+ public function newAction() {
75
+ $this->_forward('edit');
76
+ }
77
+
78
+ /**
79
+ * save item action
80
+ */
81
+ public function saveAction() {
82
+ if ($data = $this->getRequest()->getPost()) {
83
+ /*
84
+ * Banner Image
85
+ */
86
+ if (isset($_FILES['banner_name_co']['name']) && $_FILES['banner_name_co']['name'] != '') {
87
+ try {
88
+ /* Starting upload */
89
+ $uploader = new Varien_File_Uploader('banner_name_co');
90
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
91
+ $uploader->setAllowRenameFiles(false);
92
+ $uploader->setFilesDispersion(false);
93
+ str_replace(" ", "_", $_FILES['banner_name_co']['name']);
94
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'banner' ;
95
+ if (!is_dir($path)) {
96
+ try {
97
+ mkdir($path, 0777, TRUE);
98
+ } catch (Exception $e) {
99
+
100
+ }
101
+ }
102
+ $result = $uploader->save($path, $_FILES['banner_name_co']['name']);
103
+ try {
104
+ chmod($path.'/'.$result['file'], 0777);
105
+ } catch (Exception $e) {
106
+
107
+ }
108
+ $data['banner_name'] = Mage::getBaseUrl('media') . 'simi/simiconnector/banner/' . $result['file'];
109
+ } catch (Exception $e) {
110
+ $data['banner_name'] = Mage::getBaseUrl('media') . 'simi/simiconnector/banner/' . $_FILES['banner_name_co']['name'];
111
+ }
112
+ }
113
+ if (isset($data['banner_name_co']['delete']) && $data['banner_name_co']['delete'] == 1) {
114
+ Mage::helper('simiconnector')->deleteBanner($data['banner_name_co']['value']);
115
+ $data['banner_name'] = '';
116
+ }
117
+
118
+
119
+ /*
120
+ * Tablet Banner Image
121
+ */
122
+
123
+ if (isset($_FILES['banner_name_tablet_co']['name']) && $_FILES['banner_name_tablet_co']['name'] != '') {
124
+ try {
125
+ /* Starting upload */
126
+ $uploader = new Varien_File_Uploader('banner_name_tablet_co');
127
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
128
+ $uploader->setAllowRenameFiles(false);
129
+ $uploader->setFilesDispersion(false);
130
+ str_replace(" ", "_", $_FILES['banner_name_tablet_co']['name']);
131
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'banner' ;
132
+ if (!is_dir($path)) {
133
+ try {
134
+ mkdir($path, 0777, TRUE);
135
+ } catch (Exception $e) {
136
+
137
+ }
138
+ }
139
+ $result = $uploader->save($path, $_FILES['banner_name_tablet_co']['name']);
140
+ try {
141
+ chmod($path.'/'.$result['file'], 0777);
142
+ } catch (Exception $e) {
143
+
144
+ }
145
+ $data['banner_name_tablet'] = Mage::getBaseUrl('media') . 'simi/simiconnector/banner/' . $result['file'];
146
+ } catch (Exception $e) {
147
+ $data['banner_name_tablet'] = Mage::getBaseUrl('media') . 'simi/simiconnector/banner/' . $_FILES['banner_name_tablet_co']['name'];
148
+ }
149
+ }
150
+ if (isset($data['banner_name_tablet_co']['delete']) && $data['banner_name_tablet_co']['delete'] == 1) {
151
+ Mage::helper('simiconnector')->deleteBanner($data['banner_name_tablet_co']['value']);
152
+ $data['banner_name_tablet'] = '';
153
+ }
154
+
155
+
156
+ if(isset($data['type']) && $data['type'] != 2 && $data['type'] != 3){
157
+ $data['type'] = 1;
158
+ }
159
+ $model = Mage::getModel('simiconnector/banner');
160
+ $model->setData($data)
161
+ ->setId($this->getRequest()->getParam('id'));
162
+
163
+ try {
164
+ $model->save();
165
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Banner was successfully saved'));
166
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
167
+ if ($data['storeview_id'] && is_array($data['storeview_id'])) {
168
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('banner');
169
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
170
+ ->addFieldToFilter('content_type', $typeID)
171
+ ->addFieldToFilter('item_id', $model->getId());
172
+ foreach ($visibleStoreViews as $visibilityItem)
173
+ $visibilityItem->delete();
174
+ foreach ($data['storeview_id'] as $storeViewId){
175
+ $visibilityItem = Mage::getModel('simiconnector/visibility');
176
+ $visibilityItem->setData('content_type',$typeID);
177
+ $visibilityItem->setData('item_id',$model->getId());
178
+ $visibilityItem->setData('store_view_id',$storeViewId);
179
+ $visibilityItem->save();
180
+ }
181
+ }
182
+
183
+ if ($this->getRequest()->getParam('back')) {
184
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
185
+ return;
186
+ }
187
+ $this->_redirect('*/*/');
188
+ return;
189
+ } catch (Exception $e) {
190
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
191
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
192
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
193
+ return;
194
+ }
195
+ }
196
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Unable to find item to save'));
197
+ $this->_redirect('*/*/');
198
+ }
199
+
200
+ /**
201
+ * delete item action
202
+ */
203
+ public function deleteAction() {
204
+ if ($this->getRequest()->getParam('id') > 0) {
205
+ try {
206
+ $model = Mage::getModel('simiconnector/banner');
207
+ $model->setId($this->getRequest()->getParam('id'))
208
+ ->delete();
209
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Banner was successfully deleted'));
210
+ $this->_redirect('*/*/');
211
+ } catch (Exception $e) {
212
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
213
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
214
+ }
215
+ }
216
+ $this->_redirect('*/*/');
217
+ }
218
+
219
+ /**
220
+ * mass delete item(s) action
221
+ */
222
+ public function massDeleteAction() {
223
+ $bannerIds = $this->getRequest()->getParam('simiconnector');
224
+ if (!is_array($bannerIds)) {
225
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
226
+ } else {
227
+ try {
228
+ foreach ($bannerIds as $bannerId) {
229
+ $madapter = Mage::getModel('simiconnector/banner')->load($bannerId);
230
+ $madapter->delete();
231
+ }
232
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($bannerIds)));
233
+ } catch (Exception $e) {
234
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
235
+ }
236
+ }
237
+ $this->_redirect('*/*/index');
238
+ }
239
+
240
+ /**
241
+ * mass change status for item(s) action
242
+ */
243
+ public function massStatusAction() {
244
+ $bannerIds = $this->getRequest()->getParam('simiconnector');
245
+ if (!is_array($bannerIds)) {
246
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
247
+ } else {
248
+ try {
249
+ foreach ($bannerIds as $bannerId) {
250
+ $bannerId = Mage::getSingleton('simiconnector/banner')
251
+ ->load($bannerId)
252
+ ->setStatus($this->getRequest()->getParam('status'))
253
+ ->setIsMassupdate(true)
254
+ ->save();
255
+ }
256
+ $this->_getSession()->addSuccess(
257
+ $this->__('Total of %d record(s) were successfully updated', count($bannerIds))
258
+ );
259
+ } catch (Exception $e) {
260
+ $this->_getSession()->addError($e->getMessage());
261
+ }
262
+ }
263
+ $this->_redirect('*/*/index');
264
+ }
265
+
266
+ /**
267
+ * export grid item to CSV type
268
+ */
269
+ public function exportCsvAction() {
270
+ $fileName = 'banner.csv';
271
+ $content = $this->getLayout()->createBlock('simiconnector/adminhtml_banner_grid')->getCsv();
272
+ $this->_prepareDownloadResponse($fileName, $content);
273
+ }
274
+
275
+ /**
276
+ * export grid item to XML type
277
+ */
278
+ public function exportXmlAction() {
279
+ $fileName = 'banner.xml';
280
+ $content = $this->getLayout()->createBlock('simiconnector/adminhtml_banner_grid')->getXml();
281
+ $this->_prepareDownloadResponse($fileName, $content);
282
+ }
283
+
284
+ protected function _isAllowed() {
285
+ return Mage::getSingleton('admin/session')->isAllowed('simiconnector');
286
+ }
287
+
288
+ public function chooserMainCategoriesAction(){
289
+ $request = $this->getRequest();
290
+ $id = $request->getParam('selected', array());
291
+ $block = $this->getLayout()->createBlock('simiconnector/adminhtml_banner_edit_tab_categories','maincontent_category', array('js_form_object' => $request->getParam('form')))
292
+ ->setCategoryIds($id);
293
+ if ($block) {
294
+ $this->getResponse()->setBody($block->toHtml());
295
+ }
296
+ }
297
+
298
+ public function chooserMainProductsAction() {
299
+ $request = $this->getRequest();
300
+ $block = $this->getLayout()->createBlock(
301
+ 'simiconnector/adminhtml_banner_edit_tab_products', 'promo_widget_chooser_sku', array('js_form_object' => $request->getParam('form'),
302
+ ));
303
+ if ($block) {
304
+ $this->getResponse()->setBody($block->toHtml());
305
+ }
306
+ }
307
+
308
+ /**
309
+ * Get tree node (Ajax version)
310
+ */
311
+ public function categoriesJsonAction() {
312
+ if ($categoryId = (int) $this->getRequest()->getPost('id')) {
313
+ $this->getRequest()->setParam('id', $categoryId);
314
+
315
+ if (!$category = $this->_initCategory()) {
316
+ return;
317
+ }
318
+ $this->getResponse()->setBody(
319
+ $this->getLayout()->createBlock('adminhtml/catalog_category_tree')
320
+ ->getTreeJson($category)
321
+ );
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Initialize category object in registry
327
+ *
328
+ * @return Mage_Catalog_Model_Category
329
+ */
330
+ protected function _initCategory() {
331
+ $categoryId = (int) $this->getRequest()->getParam('id', false);
332
+ $storeId = (int) $this->getRequest()->getParam('store');
333
+
334
+ $category = Mage::getModel('catalog/category');
335
+ $category->setStoreId($storeId);
336
+
337
+ if ($categoryId) {
338
+ $category->load($categoryId);
339
+ if ($storeId) {
340
+ $rootId = Mage::app()->getStore($storeId)->getRootCategoryId();
341
+ if (!in_array($rootId, $category->getPathIds())) {
342
+ $this->_redirect('*/*/', array('_current' => true, 'id' => null));
343
+ return false;
344
+ }
345
+ }
346
+ }
347
+
348
+ Mage::register('category', $category);
349
+ Mage::register('current_category', $category);
350
+
351
+ return $category;
352
+ }
353
+
354
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/CmsController.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ * Cms Adminhtml Controller
18
+ *
19
+ * @category
20
+ * @package Connector
21
+ * @author Developer
22
+ */
23
+ class Simi_Simiconnector_Adminhtml_Simiconnector_CmsController extends Mage_Adminhtml_Controller_Action {
24
+
25
+ /**
26
+ * init layout and set active for current menu
27
+ *
28
+ * @return Simi_Connector_Adminhtml_BannerController
29
+ */
30
+ protected function _initAction() {
31
+ $this->loadLayout()
32
+ ->_setActiveMenu('simiconnector/cms')
33
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('CMS Manager'), Mage::helper('adminhtml')->__('CMS Manager'));
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * index action
39
+ */
40
+ public function indexAction() {
41
+ $this->_initAction()
42
+ ->renderLayout();
43
+ }
44
+
45
+ /**
46
+ * view and edit item action
47
+ */
48
+ public function editAction() {
49
+ $id = $this->getRequest()->getParam('id');
50
+ $model = Mage::getModel('simiconnector/cms')->load($id);
51
+
52
+ if ($model->getId() || $id == 0) {
53
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
54
+ if (!empty($data))
55
+ $model->setData($data);
56
+
57
+ Mage::register('cms_data', $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu('simiconnector/cms');
61
+
62
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Notice'), Mage::helper('adminhtml')->__('Item Notice'));
63
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
64
+
65
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
66
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_cms_edit'))
67
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_cms_edit_tabs'));
68
+
69
+ $this->renderLayout();
70
+ } else {
71
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Item does not exist'));
72
+ $this->_redirect('*/*/');
73
+ }
74
+ }
75
+
76
+ public function newAction() {
77
+ $this->_forward('edit');
78
+ }
79
+
80
+ /**
81
+ * save item action
82
+ */
83
+ public function saveAction() {
84
+ if ($data = $this->getRequest()->getPost()) {
85
+ if (isset($_FILES['cms_image_o']['name']) && $_FILES['cms_image_o']['name'] != '') {
86
+ try {
87
+ /* Starting upload */
88
+ $uploader = new Varien_File_Uploader('cms_image_o');
89
+
90
+ // Any extention would work
91
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
92
+ $uploader->setAllowRenameFiles(false);
93
+
94
+ // Set the file upload mode
95
+ // false -> get the file directly in the specified folder
96
+ // true -> get the file in the product like folders
97
+ // (file.jpg will go in something like /media/f/i/file.jpg)
98
+ $uploader->setFilesDispersion(false);
99
+
100
+ // We set media as the upload dir
101
+ str_replace(" ", "_", $_FILES['cms_image_o']['name']);
102
+
103
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'cms';
104
+ if (!is_dir($path)) {
105
+ try {
106
+ mkdir($path, 0777, TRUE);
107
+ } catch (Exception $e) {
108
+
109
+ }
110
+ }
111
+ $file_name = explode(".", $_FILES['cms_image_o']['name']);
112
+ $fName = $file_name[0] . "@2x." . $file_name[1];
113
+ $result = $uploader->save($path, $fName);
114
+ rename($path . DS . $result['file'], $path . DS . $fName);
115
+ $data['cms_image'] = Mage::getBaseUrl('media') . 'simi/simiconnector/cms/' . $fName;
116
+ } catch (Exception $e) {
117
+ $data['cms_image'] = Mage::getBaseUrl('media') . 'simi/simiconnector/cms/' . $_FILES['cms_image_o']['name'];
118
+ }
119
+ }
120
+
121
+ if (isset($data['cms_image_o']['delete']) && $data['cms_image_o']['delete'] == 1) {
122
+ Mage::helper('simiconnector')->deleteFile($data['cms_image_o']['value']);
123
+ $data['cms_image'] = '';
124
+ }
125
+
126
+ $model = Mage::getModel('simiconnector/cms');
127
+ $model->setData($data)
128
+ ->setId($this->getRequest()->getParam('id'));
129
+
130
+ try {
131
+ $model->save();
132
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('CMS Page was successfully saved'));
133
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
134
+
135
+ if ($data['storeview_id'] && is_array($data['storeview_id'])) {
136
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('cms');
137
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
138
+ ->addFieldToFilter('content_type', $typeID)
139
+ ->addFieldToFilter('item_id', $model->getId());
140
+ foreach ($visibleStoreViews as $visibilityItem)
141
+ $visibilityItem->delete();
142
+ foreach ($data['storeview_id'] as $storeViewId){
143
+ $visibilityItem = Mage::getModel('simiconnector/visibility');
144
+ $visibilityItem->setData('content_type',$typeID);
145
+ $visibilityItem->setData('item_id',$model->getId());
146
+ $visibilityItem->setData('store_view_id',$storeViewId);
147
+ $visibilityItem->save();
148
+ }
149
+ }
150
+
151
+ if ($this->getRequest()->getParam('back')) {
152
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
153
+ return;
154
+ }
155
+ $this->_redirect('*/*/');
156
+ return;
157
+ } catch (Exception $e) {
158
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
159
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
160
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
161
+ return;
162
+ }
163
+ }
164
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Unable to find item to save'));
165
+ $this->_redirect('*/*/');
166
+ }
167
+
168
+ /**
169
+ * delete item action
170
+ */
171
+ public function deleteAction() {
172
+ if ($this->getRequest()->getParam('id') > 0) {
173
+ try {
174
+ $model = Mage::getModel('simiconnector/cms');
175
+ $model->setId($this->getRequest()->getParam('id'))
176
+ ->delete();
177
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('CMS was successfully deleted'));
178
+ $this->_redirect('*/*/');
179
+ } catch (Exception $e) {
180
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
181
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
182
+ }
183
+ }
184
+ $this->_redirect('*/*/');
185
+ }
186
+
187
+ /**
188
+ * mass delete item(s) action
189
+ */
190
+ public function massDeleteAction() {
191
+ $bannerIds = $this->getRequest()->getParam('simiconnector');
192
+
193
+ if (!is_array($bannerIds)) {
194
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
195
+ } else {
196
+ try {
197
+ foreach ($bannerIds as $bannerId) {
198
+ $notice = Mage::getModel('simiconnector/cms')->load($bannerId);
199
+ $notice->delete();
200
+ }
201
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($bannerIds)));
202
+ } catch (Exception $e) {
203
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
204
+ }
205
+ }
206
+ $this->_redirect('*/*/index');
207
+ }
208
+
209
+ protected function _isAllowed() {
210
+ return Mage::getSingleton('admin/session')->isAllowed('simiconnector');
211
+ }
212
+
213
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/ConfigController.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Scott
6
+ * Date: 5/20/2016
7
+ * Time: 11:15 AM
8
+ */
9
+ class Simi_Simiconnector_Adminhtml_Simiconnector_ConfigController extends Mage_Adminhtml_Controller_Action {
10
+
11
+ protected function _initItem() {
12
+ if (!Mage::registry('simiconnector_categories')) {
13
+ if ($storecode = Mage::app()->getRequest()->getParam('store')) {
14
+ $storeviewModel = Mage::getModel('core/store')->getCollection()->addFieldToFilter('code', $storecode)->getFirstItem();
15
+ Mage::register('simiconnector_categories', Mage::getStoreConfig('simiconnector/general/categories_in_app', $storeviewModel->getId()));
16
+ } else
17
+ Mage::register('simiconnector_categories', Mage::getStoreConfig('simiconnector/general/categories_in_app'));
18
+ }
19
+ }
20
+
21
+ public function categoriesAction() {
22
+ $this->_initItem();
23
+ $this->getResponse()->setBody(
24
+ $this->getLayout()->createBlock('simiconnector/adminhtml_system_config_category_categories')->toHtml()
25
+ );
26
+ }
27
+
28
+ public function categoriesJsonAction() {
29
+ $this->_initItem();
30
+ $this->getResponse()->setBody(
31
+ $this->getLayout()->createBlock('simiconnector/adminhtml_system_config_category_categories')
32
+ ->getCategoryChildrenJson($this->getRequest()->getParam('category')));
33
+ }
34
+
35
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/DeviceController.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_DeviceController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _initAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('simiconnector/device')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Devices Manager'), Mage::helper('adminhtml')->__('Devices Manager'));
9
+ return $this;
10
+ }
11
+
12
+ /**
13
+ * index action
14
+ */
15
+ public function indexAction() {
16
+ $this->_initAction()
17
+ ->renderLayout();
18
+ }
19
+
20
+ /**
21
+ * view and edit item action
22
+ */
23
+ public function editAction() {
24
+ $id = $this->getRequest()->getParam('id');
25
+ $model = Mage::getModel('simiconnector/device')->load($id);
26
+
27
+ if ($model->getId() || $id == 0) {
28
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
29
+ if (!empty($data))
30
+ $model->setData($data);
31
+
32
+ Mage::register('device_data', $model);
33
+
34
+ $this->loadLayout();
35
+ $this->_setActiveMenu('simiconnector/device');
36
+
37
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Device Manager'), Mage::helper('adminhtml')->__('Device Manager'));
38
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Device News'), Mage::helper('adminhtml')->__('Device News'));
39
+
40
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
41
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_device_edit'))
42
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_device_edit_tabs'));
43
+
44
+ $this->renderLayout();
45
+ } else {
46
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Device does not exist'));
47
+ $this->_redirect('*/*/');
48
+ }
49
+ }
50
+
51
+ public function newAction() {
52
+ $this->_forward('edit');
53
+ }
54
+
55
+ /**
56
+ * delete item action
57
+ */
58
+ public function deleteAction() {
59
+ if ($this->getRequest()->getParam('id') > 0) {
60
+ try {
61
+ $model = Mage::getModel('simiconnector/device');
62
+ $model->setId($this->getRequest()->getParam('id'))
63
+ ->delete();
64
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Device was successfully deleted'));
65
+ $this->_redirect('*/*/');
66
+ } catch (Exception $e) {
67
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
68
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
69
+ }
70
+ }
71
+ $this->_redirect('*/*/');
72
+ }
73
+
74
+ /**
75
+ * mass delete item(s) action
76
+ */
77
+ public function massDeleteAction() {
78
+ $deviceIds = $this->getRequest()->getParam('siminotification');
79
+
80
+ if (!is_array($deviceIds)) {
81
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
82
+ } else {
83
+ try {
84
+ foreach ($deviceIds as $deviceId) {
85
+ $device = Mage::getModel('simiconnector/device')->load($deviceId);
86
+ $device->delete();
87
+ }
88
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d device(s) were successfully deleted', count($bannerIds)));
89
+ } catch (Exception $e) {
90
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
91
+ }
92
+ }
93
+ $this->_redirect('*/*/index');
94
+ }
95
+
96
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/HistoryController.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_HistoryController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _initAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('simiconnector/history')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Notification History Manager'), Mage::helper('adminhtml')->__('Notification History Manager'));
9
+ return $this;
10
+ }
11
+
12
+ /**
13
+ * index action
14
+ */
15
+ public function indexAction() {
16
+ $this->_initAction()
17
+ ->renderLayout();
18
+ }
19
+
20
+ /**
21
+ * view and edit item action
22
+ */
23
+ public function editAction() {
24
+ $id = $this->getRequest()->getParam('id');
25
+ $model = Mage::getModel('simiconnector/history')->load($id);
26
+
27
+ if ($model->getId() || $id == 0) {
28
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
29
+ if (!empty($data))
30
+ $model->setData($data);
31
+
32
+ Mage::register('history_data', $model);
33
+
34
+ $this->loadLayout();
35
+ $this->_setActiveMenu('simiconnector/history');
36
+
37
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Notification History Manager'), Mage::helper('adminhtml')->__('Notification History Manager'));
38
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Notification History News'), Mage::helper('adminhtml')->__('Notification History News'));
39
+
40
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
41
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_history_edit'))
42
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_history_edit_tabs'));
43
+
44
+ $this->renderLayout();
45
+ } else {
46
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Notification history does not exist'));
47
+ $this->_redirect('*/*/');
48
+ }
49
+ }
50
+
51
+ public function newAction() {
52
+ $this->_forward('edit');
53
+ }
54
+
55
+ /**
56
+ * delete item action
57
+ */
58
+ public function deleteAction() {
59
+ if ($this->getRequest()->getParam('id') > 0) {
60
+ try {
61
+ $model = Mage::getModel('simiconnector/history');
62
+ $model->setId($this->getRequest()->getParam('id'))
63
+ ->delete();
64
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Notification history was successfully deleted'));
65
+ $this->_redirect('*/*/');
66
+ } catch (Exception $e) {
67
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
68
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
69
+ }
70
+ }
71
+ $this->_redirect('*/*/');
72
+ }
73
+
74
+ /**
75
+ * mass delete item(s) action
76
+ */
77
+ public function massDeleteAction() {
78
+ $notificationIds = $this->getRequest()->getParam('history');
79
+
80
+ if (!is_array($notificationIds)) {
81
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
82
+ } else {
83
+ try {
84
+ foreach ($notificationIds as $notificationId) {
85
+ $history = Mage::getModel('simiconnector/history')->load($notificationId);
86
+ $history->delete();
87
+ }
88
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d notification(s) were successfully deleted', count($notificationIds)));
89
+ } catch (Exception $e) {
90
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
91
+ }
92
+ }
93
+ $this->_redirect('*/*/index');
94
+ }
95
+
96
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/ProductlistController.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DISCLAIMER
6
+ *
7
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
8
+ * version in the future.
9
+ *
10
+ * @category
11
+ * @package Connector
12
+ * @copyright Copyright (c) 2012
13
+ * @license
14
+ */
15
+
16
+ /**
17
+ *
18
+ * @category
19
+ * @package Connector
20
+ * @author Developer
21
+ */
22
+ class Simi_Simiconnector_Adminhtml_Simiconnector_ProductlistController extends Mage_Adminhtml_Controller_Action {
23
+
24
+ /**
25
+ * init layout and set active for current menu
26
+ *
27
+ * @return Simi_Connector_Adminhtml_BannerController
28
+ */
29
+ protected function _initAction() {
30
+ $this->loadLayout()
31
+ ->_setActiveMenu('simiconnector/productlist')
32
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Custom Product List Manager'), Mage::helper('adminhtml')->__('Product List Manager'));
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * index action
38
+ */
39
+ public function indexAction() {
40
+ $this->_initAction()
41
+ ->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * view and edit item action
46
+ */
47
+ public function editAction() {
48
+ $id = $this->getRequest()->getParam('id');
49
+ $model = Mage::getModel('simiconnector/productlist')->load($id);
50
+
51
+ if ($model->getId() || $id == 0) {
52
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
53
+ if (!empty($data))
54
+ $model->setData($data);
55
+
56
+ Mage::register('productlist_data', $model);
57
+
58
+ $this->loadLayout();
59
+ $this->_setActiveMenu('simiconnector/productlist');
60
+
61
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Notice'), Mage::helper('adminhtml')->__('Item Notice'));
62
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
63
+
64
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
65
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_productlist_edit'))
66
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_productlist_edit_tabs'));
67
+
68
+ $this->renderLayout();
69
+ } else {
70
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Item does not exist'));
71
+ $this->_redirect('*/*/');
72
+ }
73
+ }
74
+
75
+ public function newAction() {
76
+ $this->_forward('edit');
77
+ }
78
+
79
+ /**
80
+ * save item action
81
+ */
82
+ public function saveAction() {
83
+ if ($data = $this->getRequest()->getPost()) {
84
+ if (isset($_FILES['productlist_image_o']['name']) && $_FILES['productlist_image_o']['name'] != '') {
85
+ try {
86
+ $uploader = new Varien_File_Uploader('productlist_image_o');
87
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
88
+ $uploader->setAllowRenameFiles(false);
89
+ $uploader->setFilesDispersion(false);
90
+ str_replace(" ", "_", $_FILES['productlist_image_o']['name']);
91
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'productlist';
92
+ if (!is_dir($path)) {
93
+ try {
94
+ mkdir($path, 0777, TRUE);
95
+ } catch (Exception $e) {
96
+
97
+ }
98
+ }
99
+ $file_name = explode(".", $_FILES['productlist_image_o']['name']);
100
+ $fName = $file_name[0] . "@2x." . $file_name[1];
101
+ $fName = str_replace(" ", "_", $fName);
102
+ $result = $uploader->save($path, $fName);
103
+ rename($path . DS . $result['file'], $path . DS . $fName);
104
+ $data['list_image'] = Mage::getBaseUrl('media') . 'simi/simiconnector/productlist/' . $fName;
105
+ } catch (Exception $e) {
106
+ $data['list_image'] = Mage::getBaseUrl('media') . 'simi/simiconnector/productlist/' . $_FILES['productlist_image_o']['name'];
107
+ }
108
+ }
109
+
110
+ if (isset($data['productlist_image_o']['delete']) && $data['productlist_image_o']['delete'] == 1) {
111
+ Mage::helper('simiconnector')->deleteFile($data['productlist_image_o']['value']);
112
+ $data['list_image'] = '';
113
+ }
114
+
115
+ if (isset($_FILES['productlist_image_tablet_o']['name']) && $_FILES['productlist_image_tablet_o']['name'] != '') {
116
+ try {
117
+ $uploader = new Varien_File_Uploader('productlist_image_tablet_o');
118
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
119
+ $uploader->setAllowRenameFiles(false);
120
+ $uploader->setFilesDispersion(false);
121
+ str_replace(" ", "_", $_FILES['productlist_image_tablet_o']['name']);
122
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'productlist';
123
+ if (!is_dir($path)) {
124
+ try {
125
+ mkdir($path, 0777, TRUE);
126
+ } catch (Exception $e) {
127
+
128
+ }
129
+ }
130
+ $file_name = explode(".", $_FILES['productlist_image_tablet_o']['name']);
131
+ $fName = $file_name[0] . "@2x." . $file_name[1];
132
+ $fName = str_replace(" ", "_", $fName);
133
+ $result = $uploader->save($path, $fName);
134
+ rename($path . DS . $result['file'], $path . DS . $fName);
135
+ $data['list_image_tablet'] = Mage::getBaseUrl('media') . 'simi/simiconnector/productlist/' . $fName;
136
+ } catch (Exception $e) {
137
+ $data['list_image_tablet'] = Mage::getBaseUrl('media') . 'simi/simiconnector/productlist/' . $_FILES['productlist_image_tablet_o']['name'];
138
+ }
139
+ }
140
+
141
+ if (isset($data['productlist_image_tablet_o']['delete']) && $data['productlist_image_tablet_o']['delete'] == 1) {
142
+ Mage::helper('simiconnector')->deleteFile($data['productlist_image_tablet_o']['value']);
143
+ $data['list_image_tablet'] = '';
144
+ }
145
+
146
+ if (!$data['matrix_width_percent_tablet'])
147
+ $data['matrix_width_percent_tablet'] = $data['matrix_width_percent'];
148
+ if (!$data['matrix_height_percent_tablet'])
149
+ $data['matrix_height_percent_tablet'] = $data['matrix_height_percent'];
150
+
151
+ $model = Mage::getModel('simiconnector/productlist');
152
+ $model->setData($data)
153
+ ->setId($this->getRequest()->getParam('id'));
154
+
155
+ try {
156
+ $model->save();
157
+ Mage::helper('simiconnector/productlist')->updateMatrixRowHeight($data['matrix_row'], $data['matrix_height_percent'], $data['matrix_height_percent_tablet'] );
158
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Product List was successfully saved'));
159
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
160
+
161
+ if ($data['storeview_id'] && is_array($data['storeview_id'])) {
162
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('productlist');
163
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
164
+ ->addFieldToFilter('content_type', $typeID)
165
+ ->addFieldToFilter('item_id', $model->getId());
166
+ foreach ($visibleStoreViews as $visibilityItem)
167
+ $visibilityItem->delete();
168
+ foreach ($data['storeview_id'] as $storeViewId) {
169
+ $visibilityItem = Mage::getModel('simiconnector/visibility');
170
+ $visibilityItem->setData('content_type', $typeID);
171
+ $visibilityItem->setData('item_id', $model->getId());
172
+ $visibilityItem->setData('store_view_id', $storeViewId);
173
+ $visibilityItem->save();
174
+ }
175
+ }
176
+
177
+ if ($this->getRequest()->getParam('back')) {
178
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
179
+ return;
180
+ }
181
+ $this->_redirect('*/*/');
182
+ return;
183
+ } catch (Exception $e) {
184
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
185
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
186
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
187
+ return;
188
+ }
189
+ }
190
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Unable to find item to save'));
191
+ $this->_redirect('*/*/');
192
+ }
193
+
194
+ /**
195
+ * delete item action
196
+ */
197
+ public function deleteAction() {
198
+ if ($this->getRequest()->getParam('id') > 0) {
199
+ try {
200
+ $model = Mage::getModel('simiconnector/productlist');
201
+ $model->setId($this->getRequest()->getParam('id'))
202
+ ->delete();
203
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
204
+ $this->_redirect('*/*/');
205
+ } catch (Exception $e) {
206
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
207
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
208
+ }
209
+ }
210
+ $this->_redirect('*/*/');
211
+ }
212
+
213
+ /**
214
+ * mass delete item(s) action
215
+ */
216
+ public function massDeleteAction() {
217
+ $bannerIds = $this->getRequest()->getParam('simiconnector');
218
+
219
+ if (!is_array($bannerIds)) {
220
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
221
+ } else {
222
+ try {
223
+ foreach ($bannerIds as $bannerId) {
224
+ $notice = Mage::getModel('simiconnector/productlist')->load($bannerId);
225
+ $notice->delete();
226
+ }
227
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($bannerIds)));
228
+ } catch (Exception $e) {
229
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
230
+ }
231
+ }
232
+ $this->_redirect('*/*/index');
233
+ }
234
+
235
+ protected function _isAllowed() {
236
+ return Mage::getSingleton('admin/session')->isAllowed('simiconnector');
237
+ }
238
+
239
+ public function chooserMainProductsAction() {
240
+ $request = $this->getRequest();
241
+ $block = $this->getLayout()->createBlock(
242
+ 'simiconnector/adminhtml_productlist_edit_tab_products', 'promo_widget_chooser_sku', array('js_form_object' => $request->getParam('form'),
243
+ ));
244
+ if ($block) {
245
+ $this->getResponse()->setBody($block->toHtml());
246
+ }
247
+ }
248
+
249
+ public function getMockupAction() {
250
+ $storeviewid = $this->getRequest()->getParam('storeview_id');
251
+ echo Mage::helper('simiconnector/productlist')->getMatrixLayoutMockup($storeviewid);
252
+ exit();
253
+ }
254
+
255
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimibarcodeController.php ADDED
@@ -0,0 +1,465 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_SimibarcodeController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * init layout and set active for current menu
7
+ *
8
+ * @return Simi_Simibarcode_Adminhtml_SimibarcodeController
9
+ */
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('simiconnector/simibarcode')
13
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
14
+ return $this;
15
+ }
16
+
17
+ /**
18
+ * index action
19
+ */
20
+ public function indexAction() {
21
+ $this->_initAction()
22
+ ->renderLayout();
23
+ }
24
+
25
+ /**
26
+ * view and edit item action
27
+ */
28
+ public function editAction() {
29
+ $simibarcodeId = $this->getRequest()->getParam('id');
30
+ $model = Mage::getModel('simiconnector/simibarcode')->load($simibarcodeId);
31
+ $this->_title($this->__('Barcode'));
32
+ if (!$simibarcodeId) {
33
+ $this->_title($this->__('Add New Barcode'));
34
+ } else {
35
+ $this->_title($this->__('Edit Barcode'));
36
+ }
37
+ if ($model->getId() || $simibarcodeId == 0) {
38
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
39
+ if (!empty($data)) {
40
+ $model->setData($data);
41
+ }
42
+ Mage::register('simibarcode_data', $model);
43
+
44
+ $this->loadLayout();
45
+ $this->_setActiveMenu('simiconnector/simibarcode');
46
+
47
+ $this->_addBreadcrumb(
48
+ Mage::helper('adminhtml')->__('Manage Barcodes'), Mage::helper('adminhtml')->__('Manage Barcodes')
49
+ );
50
+ $this->_addBreadcrumb(
51
+ Mage::helper('adminhtml')->__('Add New Custom Barcode'), Mage::helper('adminhtml')->__('Add New Custom Barcode')
52
+ );
53
+ if (!$simibarcodeId) {
54
+ $this->getLayout()->getBlock('head')
55
+ ->addCss('css/simi/simibarcode/hiddenleftslide.css');
56
+ }
57
+
58
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_simibarcode_edit'))
59
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_simibarcode_edit_tabs'));
60
+
61
+ $this->renderLayout();
62
+ } else {
63
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')
64
+ ->__('Barcode does not exist'));
65
+ $this->_redirect('*/*/');
66
+ }
67
+ }
68
+
69
+ public function newAction() {
70
+ $this->_forward('edit');
71
+ }
72
+
73
+ /**
74
+ * products action
75
+ */
76
+ public function productsAction() {
77
+ $this->loadLayout();
78
+ $this->getLayout()->getBlock('barcode.edit.tab.products')
79
+ ->setProducts($this->getRequest()->getPost('barcode_products', null));
80
+ $this->getLayout()->getBlock('related_grid_serializer')->addColumnInputName('barcode_status');
81
+ $this->getLayout()->getBlock('related_grid_serializer')->addColumnInputName('barcode_auto');
82
+ $this->getLayout()->getBlock('related_grid_serializer')->addColumnInputName('barcode');
83
+ $this->getLayout()->getBlock('related_grid_serializer')->addColumnInputName('qrcode');
84
+
85
+ $this->renderLayout();
86
+ }
87
+
88
+ /**
89
+ * products Grid action
90
+ */
91
+ public function productsGridAction() {
92
+ $this->loadLayout();
93
+ $this->getLayout()->getBlock('barcode.edit.tab.products')
94
+ ->setProducts($this->getRequest()->getPost('barcode_products', null));
95
+ $this->renderLayout();
96
+ }
97
+
98
+ /**
99
+ * check barcode dupplicate
100
+ */
101
+ public function checkDupplicate($barcode) {
102
+ $code = Mage::helper('simiconnector/simibarcode')->generateCode(Mage::getStoreConfig('simiconnector/barcode/pattern'));
103
+ if (in_array($code, $barcode)) {
104
+ $code = $this->checkDupplicate($barcode);
105
+ }
106
+ return $code;
107
+ }
108
+
109
+ /**
110
+ * check QRcode dupplicate
111
+ */
112
+ public function checkDupplicateQrcode($qrcode) {
113
+ $code = Mage::helper('simiconnector/simibarcode')->generateCode(Mage::getStoreConfig('simiconnector/barcode/qrcode_pattern'));
114
+ if (in_array($code, $qrcode)) {
115
+ $code = $this->checkDupplicate($qrcode);
116
+ }
117
+ return $code;
118
+ }
119
+
120
+ /**
121
+ * save item action
122
+ */
123
+ public function saveAction() {
124
+ if ($post = $this->getRequest()->getPost()) {
125
+ $model = Mage::getModel('simiconnector/simibarcode')->load($this->getRequest()->getParam('id'));
126
+ try {
127
+ if ($model->getId()) {
128
+ $model->setData('barcode_status', $post['barcode_status'])
129
+ ->setData('barcode', $post['barcode'])
130
+ ->setData('qrcode', $post['qrcode'])
131
+ ->save()
132
+ ;
133
+ if ($this->getRequest()->getParam('back')) {
134
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Barcode "%s" was successfully edited.', $model->getBarcode()));
135
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
136
+ return;
137
+ }
138
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Barcode "%s" was successfully edited.', $model->getBarcode()));
139
+
140
+ $this->_redirect('*/*');
141
+ return;
142
+ }
143
+ $resource = Mage::getSingleton('core/resource');
144
+ $writeConnection = $resource->getConnection('core_write');
145
+
146
+ $sqlNews = array();
147
+ $sqlOlds = '';
148
+ $countSqlOlds = 0;
149
+
150
+ $tablename = 'simiconnector/simibarcode';
151
+
152
+ $results = Mage::helper('simiconnector/simibarcode')->getAllColumOfTable($tablename);
153
+
154
+ $columns = array();
155
+ $string = '';
156
+ $type = '';
157
+
158
+ foreach ($results as $result) {
159
+ $fields = explode('_', $result);
160
+ if ($fields[0] == 'barcode' || $fields[0] == 'qrcode')
161
+ continue;
162
+ foreach ($fields as $id => $field) {
163
+ if ($id == 0)
164
+ $type = $field;
165
+ if ($id == 1) {
166
+ $string = $field;
167
+ }
168
+ if ($id > 1)
169
+ $string = $string . '_' . $field;
170
+ }
171
+ $columns[] = array($type => $string);
172
+ $string = '';
173
+ $type = '';
174
+ }
175
+
176
+
177
+ if (isset($post['barcode_products'])) {
178
+ $products = array();
179
+ $productsExplodes = explode('&', urldecode($post['barcode_products']));
180
+
181
+ if (count($productsExplodes) <= 900) {
182
+ parse_str(urldecode($post['barcode_products']), $products);
183
+ } else {
184
+ foreach ($productsExplodes as $productsExplode) {
185
+ $product = '';
186
+ parse_str($supplierProductsExplode, $product);
187
+ $products = $products + $product;
188
+ }
189
+ }
190
+
191
+ if (count($products)) {
192
+ $productIds = '';
193
+ $count = 0;
194
+ $j = 0;
195
+ $barcode = array();
196
+ $qrcode = array();
197
+ foreach ($products as $pId => $enCoded) {
198
+ $codeArr = array();
199
+ parse_str(base64_decode($enCoded), $codeArr);
200
+ //auto generate barcode
201
+ if ($codeArr['barcode'] == '') {
202
+ //check barcode dupplicate
203
+ $codeArr['barcode'] = $this->checkDupplicate($barcode);
204
+ $barcode[] = $codeArr['barcode'];
205
+ } else {
206
+ //generate barcode by hand
207
+ //check barcode already exist
208
+ if (!$model->getId()) {
209
+ $checkBarcodeExist = Mage::getModel('simiconnector/simibarcode')->load($codeArr['barcode'], 'barcode');
210
+ if ($checkBarcodeExist->getId()) {
211
+ Mage::getSingleton('adminhtml/session')->addError(
212
+ Mage::helper('simiconnector')->__('The barcode "%s" was already exist!', $codeArr['barcode'])
213
+ );
214
+ Mage::getSingleton('adminhtml/session')->setFormData($post);
215
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
216
+ return;
217
+ }
218
+ }
219
+ //check barcode dupplicate
220
+ if (in_array($codeArr['barcode'], $barcode)) {
221
+ Mage::getSingleton('adminhtml/session')->addError(
222
+ Mage::helper('simiconnector')->__('The barcode "%s" was already duplicate!', $codeArr['barcode'])
223
+ );
224
+ Mage::getSingleton('adminhtml/session')->setFormData($post);
225
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
226
+ return;
227
+ } else {
228
+ $barcode[] = $codeArr['barcode'];
229
+ }
230
+ }
231
+ //auto generate QRcode
232
+ if ($codeArr['qrcode'] == '') {
233
+ //check barcode dupplicate
234
+ $codeArr['qrcode'] = $this->checkDupplicateQrcode($qrcode);
235
+ $qrcode[] = $codeArr['qrcode'];
236
+ } else {
237
+ //generate barcode by hand
238
+ //check barcode already exist
239
+ if (!$model->getId()) {
240
+ $checkQrcodeExist = Mage::getModel('simiconnector/simibarcode')->load($codeArr['qrcode'], 'qrcode');
241
+ if ($checkQrcodeExist->getId()) {
242
+ Mage::getSingleton('adminhtml/session')->addError(
243
+ Mage::helper('simiconnector')->__('The QRcode "%s" was already exist!', $codeArr['qrcode'])
244
+ );
245
+ Mage::getSingleton('adminhtml/session')->setFormData($post);
246
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
247
+ return;
248
+ }
249
+ }
250
+ //check QRcode dupplicate
251
+ if (in_array($codeArr['qrcode'], $qrcode)) {
252
+ Mage::getSingleton('adminhtml/session')->addError(
253
+ Mage::helper('simiconnector')->__('The QRcode "%s" was already duplicate!', $codeArr['qrcode'])
254
+ );
255
+ Mage::getSingleton('adminhtml/session')->setFormData($post);
256
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
257
+ return;
258
+ } else {
259
+ $qrcode[] = $codeArr['qrcode'];
260
+ }
261
+ }
262
+ $sqlNews[$j] = array(
263
+ 'barcode' => $codeArr['barcode'],
264
+ 'qrcode' => $codeArr['qrcode'],
265
+ 'barcode_status' => 1,
266
+ // 'barcode_status' => $codeArr['barcode_status'],
267
+ );
268
+
269
+ foreach ($columns as $id => $column) {
270
+ $i = 0;
271
+ $columnName = '';
272
+
273
+ foreach ($column as $_id => $key) {
274
+ if ($i == 0)
275
+ $columnName = $_id . '_' . $key;
276
+ if ($i > 0)
277
+ $columnName = $columnName . '_' . $key;
278
+
279
+ $i++;
280
+ }
281
+
282
+ if ($_id != 'custom') {
283
+
284
+ $return = Mage::helper('simiconnector/simibarcode')->getValueForBarcode($_id, $key, $pId, $codeArr);
285
+ if (is_array($return)) {
286
+ foreach ($return as $_columns) {
287
+ foreach ($_columns as $_column => $value) {
288
+ if (!isset($sqlNews[$_id . '_' . $_column])) {
289
+ $sqlNews[$j][$_id . '_' . $_column] = $value;
290
+ } else {
291
+ $sqlNews[$j][$_id . '_' . $_column] .= ',' . $value;
292
+ }
293
+ }
294
+ }
295
+ } else {
296
+ $sqlNews[$j][$columnName] = $return;
297
+ }
298
+ } else {
299
+ if (isset($codeArr[$columnName]))
300
+ $sqlNews[$j][$columnName] = $codeArr[$columnName];
301
+ }
302
+ }
303
+ $sqlNews[$j]['created_date'] = now();
304
+ if (count($sqlNews) == 1000) {
305
+ $writeConnection->insertMultiple($resource->getTableName('simiconnector/simibarcode'), $sqlNews);
306
+ $sqlNews = array();
307
+ }
308
+
309
+ $j++;
310
+ }
311
+ }
312
+ }
313
+
314
+ if (!empty($sqlNews)) {
315
+ $writeConnection->insertMultiple($resource->getTableName('simiconnector/simibarcode'), $sqlNews);
316
+ }
317
+
318
+ Mage::getModel('admin/session')->setData('barcode_product_import', null);
319
+
320
+ if ($this->getRequest()->getParam('back')) {
321
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Barcode was successfully saved.'));
322
+ $this->_redirect('*/*/new');
323
+ return;
324
+ }
325
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Barcode was successfully saved.'));
326
+
327
+ $this->_redirect('*/*');
328
+ return;
329
+ } catch (Exception $e) {
330
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
331
+ Mage::getSingleton('adminhtml/session')->setFormData($post);
332
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
333
+ return;
334
+ }
335
+ }
336
+ Mage::getSingleton('adminhtml/session')->addError(
337
+ Mage::helper('simiconnector')->__('Unable to find barcode to save!')
338
+ );
339
+ $this->_redirect('*/*/');
340
+ }
341
+
342
+ /**
343
+ * delete item action
344
+ */
345
+ public function deleteAction() {
346
+ if ($this->getRequest()->getParam('id') > 0) {
347
+ try {
348
+ $model = Mage::getModel('simiconnector/simibarcode');
349
+ $model->setId($this->getRequest()->getParam('id'))
350
+ ->delete();
351
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
352
+ $this->_redirect('*/*/');
353
+ } catch (Exception $e) {
354
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
355
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
356
+ }
357
+ }
358
+ $this->_redirect('*/*/');
359
+ }
360
+
361
+ /**
362
+ * mass delete item(s) action
363
+ */
364
+ public function massDeleteAction() {
365
+ $simibarcodeIds = $this->getRequest()->getParam('simibarcode');
366
+ if (!is_array($simibarcodeIds)) {
367
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
368
+ } else {
369
+ try {
370
+ foreach ($simibarcodeIds as $simibarcodeId) {
371
+ $simibarcode = Mage::getModel('simiconnector/simibarcode')->load($simibarcodeId);
372
+ $simibarcode->delete();
373
+ }
374
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($simibarcodeIds)));
375
+ } catch (Exception $e) {
376
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
377
+ }
378
+ }
379
+ $this->_redirect('*/*/index');
380
+ }
381
+
382
+ /**
383
+ * mass change status for item(s) action
384
+ */
385
+ public function massStatusAction() {
386
+ $simibarcodeIds = $this->getRequest()->getParam('simibarcode');
387
+ if (!is_array($simibarcodeIds)) {
388
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
389
+ } else {
390
+ try {
391
+ foreach ($simibarcodeIds as $simibarcodeId) {
392
+ $simibarcode = Mage::getSingleton('simiconnector/simibarcode')
393
+ ->load($simibarcodeId)
394
+ ->setBarcodeStatus($this->getRequest()->getParam('status'))
395
+ ->setIsMassupdate(true)
396
+ ->save();
397
+ }
398
+ $this->_getSession()->addSuccess(
399
+ $this->__('Total of %d record(s) were successfully updated', count($simibarcodeIds))
400
+ );
401
+ } catch (Exception $e) {
402
+ $this->_getSession()->addError($e->getMessage());
403
+ }
404
+ }
405
+ $this->_redirect('*/*/index');
406
+ }
407
+
408
+ protected function _isAllowed() {
409
+ return Mage::getSingleton('admin/session')->isAllowed('simiconnector');
410
+ }
411
+
412
+ /**
413
+ * export grid item to XML type
414
+ */
415
+ public function getImportCsvAction() {
416
+ if (isset($_FILES['fileToUpload']['name']) && $_FILES['fileToUpload']['name'] != '') {
417
+
418
+ try {
419
+ $fileName = $_FILES['fileToUpload']['tmp_name'];
420
+ $Object = new Varien_File_Csv();
421
+ $dataFile = $Object->getData($fileName);
422
+ $product = array();
423
+ $products = array();
424
+ $fields = array();
425
+ $count = 0;
426
+ $helper = Mage::helper('simiconnector/simibarcode');
427
+
428
+ if (count($dataFile))
429
+ foreach ($dataFile as $col => $row) {
430
+ if ($col == 0) {
431
+ if (count($row))
432
+ foreach ($row as $index => $cell)
433
+ $fields[$index] = (string) $cell;
434
+ }elseif ($col > 0) {
435
+
436
+ if (count($row))
437
+ foreach ($row as $index => $cell) {
438
+
439
+ if (isset($fields[$index])) {
440
+ $product[$fields[$index]] = $cell;
441
+ }
442
+ }
443
+
444
+ $productId = Mage::getModel('catalog/product')->getIdBySku($product['SKU']);
445
+ $product['PRODUCT_ID'] = $productId;
446
+
447
+ if ($productId) {
448
+ $products[] = $product;
449
+ }
450
+ }
451
+ }
452
+
453
+ $helper->importProduct($products);
454
+ } catch (Exception $e) {
455
+
456
+ }
457
+ }
458
+ }
459
+
460
+ public function barcodeAction(){
461
+ $code = $this->getRequest()->getParam('code');
462
+ Mage::helper('simiconnector/simibarcode')->createBarcode(null, $code, "100", "horizontal", "code128", false);
463
+ }
464
+
465
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimicategoryController.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_SimicategoryController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _initAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('simiconnector/simicategory')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Categories Manager'), Mage::helper('adminhtml')->__('Category Manager'));
9
+ return $this;
10
+ }
11
+
12
+ public function indexAction() {
13
+ $this->_initAction()
14
+ ->renderLayout();
15
+ }
16
+
17
+ public function editAction() {
18
+ $id = $this->getRequest()->getParam('id');
19
+ $model = Mage::getModel('simiconnector/simicategory')->load($id);
20
+
21
+ if ($model->getId() || $id == 0) {
22
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
23
+ if (!empty($data))
24
+ $model->setData($data);
25
+
26
+ Mage::register('simicategory_data', $model);
27
+
28
+ $this->loadLayout();
29
+ $this->_setActiveMenu('simiconnector/simicategory');
30
+
31
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Category Manager'), Mage::helper('adminhtml')->__('Category Manager'));
32
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Category News'), Mage::helper('adminhtml')->__('Category News'));
33
+
34
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
35
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_simicategory_edit'))
36
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_simicategory_edit_tabs'));
37
+
38
+ $this->renderLayout();
39
+ } else {
40
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Category does not exist'));
41
+ $this->_redirect('*/*/');
42
+ }
43
+ }
44
+
45
+ public function newAction() {
46
+ $this->_forward('edit');
47
+ }
48
+
49
+ public function saveAction() {
50
+ if ($data = $this->getRequest()->getPost()) {
51
+ if (isset($_FILES['simicategory_filename']['name']) && $_FILES['simicategory_filename']['name'] != '') {
52
+ try {
53
+ $uploader = new Varien_File_Uploader('simicategory_filename');
54
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
55
+ $uploader->setAllowRenameFiles(false);
56
+ $uploader->setFilesDispersion(false);
57
+ str_replace(" ", "_", $_FILES['simicategory_filename']['name']);
58
+ $website = $data['website_id'];
59
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'simicategory' . DS . $website;
60
+ if (!is_dir($path)) {
61
+ try {
62
+ mkdir($path, 0777, TRUE);
63
+ } catch (Exception $e) {
64
+
65
+ }
66
+ }
67
+ $result = $uploader->save($path, $_FILES['simicategory_filename']['name']);
68
+ $data['simicategory_filename'] = Mage::getBaseUrl('media') . 'simi/simiconnector/simicategory/' . $result['file'];
69
+ } catch (Exception $e) {
70
+ $data['simicategory_filename'] = Mage::getBaseUrl('media') . 'simi/simiconnector/simicategory/' . $_FILES['simicategory_filename']['name'];
71
+ }
72
+ }
73
+
74
+ if (is_array($data['simicategory_filename'])) {
75
+ if ($data['simicategory_filename']['delete'] == 1) {
76
+ $data['simicategory_filename'] = "";
77
+ } else {
78
+ $data['simicategory_filename'] = $data['simicategory_filename']['value'];
79
+ }
80
+ }
81
+
82
+ if (isset($_FILES['simicategory_filename_tablet']['name']) && $_FILES['simicategory_filename_tablet']['name'] != '') {
83
+ try {
84
+ $uploader = new Varien_File_Uploader('simicategory_filename_tablet');
85
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
86
+ $uploader->setAllowRenameFiles(false);
87
+ $uploader->setFilesDispersion(false);
88
+ str_replace(" ", "_", $_FILES['simicategory_filename_tablet']['name']);
89
+ $website = $data['website_id'];
90
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'simicategory' . DS . $website;
91
+ if (!is_dir($path)) {
92
+ try {
93
+ mkdir($path, 0777, TRUE);
94
+ } catch (Exception $e) {
95
+
96
+ }
97
+ }
98
+ $result = $uploader->save($path, $_FILES['simicategory_filename_tablet']['name']);
99
+ $data['simicategory_filename_tablet'] = Mage::getBaseUrl('media') . 'simi/simiconnector/simicategory/' . $result['file'];
100
+ } catch (Exception $e) {
101
+ $data['simicategory_filename_tablet'] = Mage::getBaseUrl('media') . 'simi/simiconnector/simicategory/' . $_FILES['simicategory_filename_tablet']['name'];
102
+ }
103
+ }
104
+
105
+ if (is_array($data['simicategory_filename_tablet'])) {
106
+ if ($data['simicategory_filename_tablet']['delete'] == 1) {
107
+ $data['simicategory_filename_tablet'] = "";
108
+ } else {
109
+ $data['simicategory_filename_tablet'] = $data['simicategory_filename_tablet']['value'];
110
+ }
111
+ }
112
+
113
+ if (isset($data['category_id']) && $data['category_id']) {
114
+ $category_name = Mage::getModel('catalog/category')->load($data['category_id'])->getName();
115
+ $data['simicategory_name'] = $category_name;
116
+ }
117
+
118
+ if (!$data['matrix_width_percent_tablet'])
119
+ $data['matrix_width_percent_tablet'] = $data['matrix_width_percent'];
120
+ if (!$data['matrix_height_percent_tablet'])
121
+ $data['matrix_height_percent_tablet'] = $data['matrix_height_percent'];
122
+
123
+ $model = Mage::getModel('simiconnector/simicategory');
124
+ $model->setData($data)
125
+ ->setId($this->getRequest()->getParam('id'));
126
+
127
+ try {
128
+
129
+ $model->save();
130
+ Mage::helper('simiconnector/productlist')->updateMatrixRowHeight($data['matrix_row'], $data['matrix_height_percent'], $data['matrix_height_percent_tablet'] );
131
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Category was successfully saved'));
132
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
133
+ if ($data['storeview_id'] && is_array($data['storeview_id'])) {
134
+ $typeID = Mage::helper('simiconnector')->getVisibilityTypeId('homecategory');
135
+ $visibleStoreViews = Mage::getModel('simiconnector/visibility')->getCollection()
136
+ ->addFieldToFilter('content_type', $typeID)
137
+ ->addFieldToFilter('item_id', $model->getId());
138
+ foreach ($visibleStoreViews as $visibilityItem)
139
+ $visibilityItem->delete();
140
+ foreach ($data['storeview_id'] as $storeViewId) {
141
+ $visibilityItem = Mage::getModel('simiconnector/visibility');
142
+ $visibilityItem->setData('content_type', $typeID);
143
+ $visibilityItem->setData('item_id', $model->getId());
144
+ $visibilityItem->setData('store_view_id', $storeViewId);
145
+ $visibilityItem->save();
146
+ }
147
+ }
148
+ if ($this->getRequest()->getParam('back')) {
149
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
150
+ return;
151
+ }
152
+ $this->_redirect('*/*/');
153
+ return;
154
+ } catch (Exception $e) {
155
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
156
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
157
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
158
+ return;
159
+ }
160
+ }
161
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Unable to find item to save'));
162
+ $this->_redirect('*/*/');
163
+ }
164
+
165
+ public function deleteAction() {
166
+ if ($this->getRequest()->getParam('id') > 0) {
167
+ try {
168
+ $model = Mage::getModel('simiconnector/simicategory');
169
+ $model->setId($this->getRequest()->getParam('id'))
170
+ ->delete();
171
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
172
+ $this->_redirect('*/*/');
173
+ } catch (Exception $e) {
174
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
175
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
176
+ }
177
+ }
178
+ $this->_redirect('*/*/');
179
+ }
180
+
181
+ public function massDeleteAction() {
182
+ $simicategoryIds = $this->getRequest()->getParam('simicategory');
183
+ if (!is_array($simicategoryIds)) {
184
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
185
+ } else {
186
+ try {
187
+ foreach ($simicategoryIds as $simicategoryId) {
188
+ $simicategory = Mage::getModel('simiconnector/simicategory')->load($simicategoryId);
189
+ $simicategory->delete();
190
+ }
191
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($simicategoryIds)));
192
+ } catch (Exception $e) {
193
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
194
+ }
195
+ }
196
+ $this->_redirect('*/*/index');
197
+ }
198
+
199
+ public function massStatusAction() {
200
+ $simicategoryIds = $this->getRequest()->getParam('simicategory');
201
+ if (!is_array($simicategoryIds)) {
202
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
203
+ } else {
204
+ try {
205
+ foreach ($simicategoryIds as $simicategoryId) {
206
+ $simicategory = Mage::getSingleton('simiconnector/simicategory')
207
+ ->load($simicategoryId)
208
+ ->setStatus($this->getRequest()->getParam('status'))
209
+ ->setIsMassupdate(true)
210
+ ->save();
211
+ }
212
+ $this->_getSession()->addSuccess(
213
+ $this->__('Total of %d record(s) were successfully updated', count($simicategoryIds))
214
+ );
215
+ } catch (Exception $e) {
216
+ $this->_getSession()->addError($e->getMessage());
217
+ }
218
+ }
219
+ $this->_redirect('*/*/index');
220
+ }
221
+
222
+ public function exportCsvAction() {
223
+ $fileName = 'simicategory.csv';
224
+ $content = $this->getLayout()->createBlock('simiconnector/adminhtml_simicategory_grid')->getCsv();
225
+ $this->_prepareDownloadResponse($fileName, $content);
226
+ }
227
+
228
+ public function exportXmlAction() {
229
+ $fileName = 'simicategory.xml';
230
+ $content = $this->getLayout()->createBlock('simiconnector/adminhtml_simicategory_grid')->getXml();
231
+ $this->_prepareDownloadResponse($fileName, $content);
232
+ }
233
+
234
+ public function chooserMainCategoriesAction() {
235
+ $request = $this->getRequest();
236
+ $id = $request->getParam('selected', array());
237
+ $block = $this->getLayout()->createBlock('simiconnector/adminhtml_banner_edit_tab_categories', 'maincontent_category', array('js_form_object' => $request->getParam('form')))
238
+ ->setCategoryIds($id);
239
+ if ($block) {
240
+ $this->getResponse()->setBody($block->toHtml());
241
+ }
242
+ }
243
+
244
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SiminotificationController.php ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_SiminotificationController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _initAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('simiconnector/siminotification')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
9
+ return $this;
10
+ }
11
+
12
+ /**
13
+ * index action
14
+ */
15
+ public function indexAction() {
16
+ $this->_initAction()
17
+ ->renderLayout();
18
+ }
19
+
20
+ /**
21
+ * view and edit item action
22
+ */
23
+ public function editAction() {
24
+ $id = $this->getRequest()->getParam('id');
25
+ $model = Mage::getModel('simiconnector/siminotification')->load($id);
26
+
27
+ if ($model->getId() || $id == 0) {
28
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
29
+ if (!empty($data))
30
+ $model->setData($data);
31
+
32
+ Mage::register('siminotification_data', $model);
33
+
34
+ $this->loadLayout();
35
+ $this->_setActiveMenu('simiconnector/siminotification');
36
+
37
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Notification Manager'), Mage::helper('adminhtml')->__('Notification Manager'));
38
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Notification News'), Mage::helper('adminhtml')->__('Notification News'));
39
+
40
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
41
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_siminotification_edit'))
42
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_siminotification_edit_tabs'));
43
+
44
+ $this->renderLayout();
45
+ } else {
46
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Notification does not exist'));
47
+ $this->_redirect('*/*/');
48
+ }
49
+ }
50
+
51
+ public function newAction() {
52
+ $this->_forward('edit');
53
+ }
54
+
55
+ /**
56
+ * save item action
57
+ */
58
+ public function saveAction() {
59
+ if ($data = $this->getRequest()->getPost()) {
60
+ // Zend_debug::dump($_FILES['image_url']['name']);die();
61
+ if (isset($_FILES['image_url']['name']) && $_FILES['image_url']['name'] != '') {
62
+ try {
63
+ /* Starting upload */
64
+ $uploader = new Varien_File_Uploader('image_url');
65
+
66
+ // Any extention would work
67
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
68
+ $uploader->setAllowRenameFiles(false);
69
+
70
+ // Set the file upload mode
71
+ // false -> get the file directly in the specified folder
72
+ // true -> get the file in the product like folders
73
+ // (file.jpg will go in something like /media/f/i/file.jpg)
74
+ $uploader->setFilesDispersion(false);
75
+
76
+ // We set media as the upload dir
77
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'notification' . DS . 'images';
78
+ // $result = $uploader->save($path, $_FILES['image_url']['name'] );
79
+ $result = $uploader->save($path, md5(time()) . '.png');
80
+ $imageUrl = 'simi/simiconnector/notification/images/' . md5(time()) . '.png';
81
+ } catch (Exception $e) {
82
+ $imageUrl = 'simi/simiconnector/notification/images/' . md5(time()) . '.png';
83
+ }
84
+ }
85
+ // Zend_debug::dump($data);die();
86
+
87
+ $data['created_time'] = now();
88
+ $model = Mage::getModel('simiconnector/siminotification');
89
+ $data['device_id'] = $data['device_type'];
90
+ $model->setData($data)
91
+ ->setId($this->getRequest()->getParam('id'));
92
+ if (!$imageUrl && is_array($data['image_url'])) {
93
+ if ($data['image_url']['delete'])
94
+ $data['delete'] = $data['image_url']['delete'];
95
+ $data['image_url'] = $data['image_url']['value'];
96
+ $imageUrl = $data['image_url'];
97
+ }
98
+
99
+ if ($data['delete']) {
100
+ $data['image_url'] = null;
101
+ $imageUrl = null;
102
+ }
103
+ if ($imageUrl) {
104
+ $data['image_url'] = $imageUrl;
105
+ $model->setImageUrl($imageUrl);
106
+ }
107
+ try {
108
+ $model->save();
109
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('simiconnector')->__('Message was successfully saved'));
110
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
111
+ } catch (Exception $e) {
112
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
113
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
114
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
115
+ return;
116
+ }
117
+ if ($this->getRequest()->getParam('back')) {
118
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
119
+ return;
120
+ } else {
121
+ if ($data['image_url'])
122
+ $data['image_url'] = Mage::getBaseUrl('media') . $data['image_url'];
123
+
124
+ $data['notice_type'] = 0;
125
+ $data['notice_id'] = $model->getId();
126
+ $list = @getimagesize($data['image_url']);
127
+ $data['width'] = $list[0];
128
+ $data['height'] = $list[1];
129
+ $resultSend = Mage::helper('simiconnector/siminotification')->sendNotice($data);
130
+ }
131
+ if (!$resultSend) {
132
+ $this->_redirect('*/*/');
133
+ return;
134
+ }
135
+ $this->_redirect('*/*/');
136
+ return;
137
+ }
138
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('Unable to find item to send'));
139
+ $this->_redirect('*/*/');
140
+ }
141
+
142
+ /**
143
+ * delete item action
144
+ */
145
+ public function deleteAction() {
146
+ if ($this->getRequest()->getParam('id') > 0) {
147
+ try {
148
+ $model = Mage::getModel('simiconnector/siminotification');
149
+ $model->setId($this->getRequest()->getParam('id'))
150
+ ->delete();
151
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Message was successfully deleted'));
152
+ $this->_redirect('*/*/');
153
+ } catch (Exception $e) {
154
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
155
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
156
+ }
157
+ }
158
+ $this->_redirect('*/*/');
159
+ }
160
+
161
+ /**
162
+ * mass delete item(s) action
163
+ */
164
+ public function massDeleteAction() {
165
+ $messageIds = $this->getRequest()->getParam('simiconnector');
166
+
167
+ if (!is_array($messageIds)) {
168
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
169
+ } else {
170
+ try {
171
+ foreach ($messageIds as $messageId) {
172
+ $notice = Mage::getModel('simiconnector/siminotification')->load($messageId);
173
+ $notice->delete();
174
+ }
175
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($bannerIds)));
176
+ } catch (Exception $e) {
177
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
178
+ }
179
+ }
180
+ $this->_redirect('*/*/index');
181
+ }
182
+
183
+
184
+ protected function _isAllowed() {
185
+ return Mage::getSingleton('admin/session')->isAllowed('simiconnector');
186
+ }
187
+
188
+
189
+ public function guideAction() {
190
+ $this->loadLayout();
191
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Google Application Guide'));
192
+ $this->renderLayout();
193
+ }
194
+
195
+ public function chooserMainCategoriesAction() {
196
+ $request = $this->getRequest();
197
+ $id = $request->getParam('selected', array());
198
+ $block = $this->getLayout()->createBlock('simiconnector/adminhtml_siminotification_edit_tab_categories', 'maincontent_category', array('js_form_object' => $request->getParam('form')))
199
+ ->setCategoryIds($id)
200
+ ;
201
+
202
+ if ($block) {
203
+ $this->getResponse()->setBody($block->toHtml());
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Get tree node (Ajax version)
209
+ */
210
+ public function categoriesJsonAction() {
211
+ if ($categoryId = (int) $this->getRequest()->getPost('id')) {
212
+ $this->getRequest()->setParam('id', $categoryId);
213
+
214
+ if (!$category = $this->_initCategory()) {
215
+ return;
216
+ }
217
+ $this->getResponse()->setBody(
218
+ $this->getLayout()->createBlock('adminhtml/catalog_category_tree')
219
+ ->getTreeJson($category)
220
+ );
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Initialize category object in registry
226
+ *
227
+ * @return Mage_Catalog_Model_Category
228
+ */
229
+ protected function _initCategory() {
230
+ $categoryId = (int) $this->getRequest()->getParam('id', false);
231
+ $storeId = (int) $this->getRequest()->getParam('store');
232
+
233
+ $category = Mage::getModel('catalog/category');
234
+ $category->setStoreId($storeId);
235
+
236
+ if ($categoryId) {
237
+ $category->load($categoryId);
238
+ if ($storeId) {
239
+ $rootId = Mage::app()->getStore($storeId)->getRootCategoryId();
240
+ if (!in_array($rootId, $category->getPathIds())) {
241
+ $this->_redirect('*/*/', array('_current' => true, 'id' => null));
242
+ return false;
243
+ }
244
+ }
245
+ }
246
+
247
+ Mage::register('category', $category);
248
+ Mage::register('current_category', $category);
249
+
250
+ return $category;
251
+ }
252
+
253
+ public function categoriesJson2Action() {
254
+ $this->_initItem();
255
+ $this->getResponse()->setBody(
256
+ $this->getLayout()->createBlock('simiconnector/adminhtml_siminotification_edit_tab_categories')
257
+ ->getCategoryChildrenJson($this->getRequest()->getParam('category'))
258
+ );
259
+ }
260
+
261
+ public function chooserMainProductsAction() {
262
+ $request = $this->getRequest();
263
+ $block = $this->getLayout()->createBlock(
264
+ 'simiconnector/adminhtml_siminotification_edit_tab_products', 'promo_widget_chooser_sku', array('js_form_object' => $request->getParam('form'),
265
+ ));
266
+ if ($block) {
267
+ $this->getResponse()->setBody($block->toHtml());
268
+ }
269
+ }
270
+
271
+
272
+ /*
273
+ * Get Device to Push Notification
274
+ */
275
+
276
+ public function chooseDevicesAction() {
277
+ $request = $this->getRequest();
278
+ echo '<p class="note"><span id="note_devices_pushed_number"> </span> <span> '.Mage::helper('simiconnector')->__('Device(s) Selected').'</span></p>';
279
+ $block = $this->getLayout()->createBlock(
280
+ 'simiconnector/adminhtml_siminotification_edit_tab_devices', 'promo_widget_chooser_device_id', array('js_form_object' => $request->getParam('form'),
281
+ ));
282
+ if ($block) {
283
+ $block->storeview_id = $this->getRequest()->getParam('storeview_id');
284
+ $this->getResponse()->setBody($block->toHtml());
285
+ }
286
+ }
287
+
288
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimiproductlabelController.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_SimiproductlabelController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ */
7
+ protected function _initAction() {
8
+ $this->loadLayout()
9
+ ->_setActiveMenu('simiconnector/simiproductlabel')
10
+ ->_addBreadcrumb(
11
+ Mage::helper('adminhtml')->__('Labels'), Mage::helper('adminhtml')->__('Labels')
12
+ );
13
+ return $this;
14
+ }
15
+
16
+ public function editAction() {
17
+ $labelId = $this->getRequest()->getParam('label_id');
18
+ $model = Mage::getModel('simiconnector/simiproductlabel')->load($labelId);
19
+ if ($model->getId() || $labelId == 0) {
20
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
21
+ if (!empty($data)) {
22
+ $model->setData($data);
23
+ }
24
+ Mage::register('simiproductlabel_data', $model);
25
+
26
+ $this->loadLayout();
27
+ $this->_setActiveMenu('simiconnector/simiproductlabel');
28
+
29
+ $this->_addBreadcrumb(
30
+ Mage::helper('adminhtml')->__('Label Manager'), Mage::helper('adminhtml')->__('Label Manager')
31
+ );
32
+
33
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
34
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_simiproductlabel_edit'))
35
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_simiproductlabel_edit_tabs'));
36
+ $this->renderLayout();
37
+ } else {
38
+ Mage::getSingleton('adminhtml/session')->addError(
39
+ Mage::helper('simiconnector')->__('Label does not exist')
40
+ );
41
+ $this->_redirect('*/*/');
42
+ }
43
+ }
44
+
45
+ public function newAction() {
46
+ $this->_forward('edit');
47
+ }
48
+
49
+ /**
50
+ * save item action
51
+ */
52
+ public function saveAction() {
53
+ if ($data = $this->getRequest()->getPost()) {
54
+
55
+ if (isset($_FILES['image_name_co']['name']) && $_FILES['image_name_co']['name'] != '') {
56
+ try {
57
+ /* Starting upload */
58
+ $uploader = new Varien_File_Uploader('image_name_co');
59
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
60
+ $uploader->setAllowRenameFiles(false);
61
+ $uploader->setFilesDispersion(false);
62
+ str_replace(" ", "_", $_FILES['image_name_co']['name']);
63
+ $path = Mage::getBaseDir('media') . DS . 'simi' . DS . 'simiconnector' . DS . 'productlabel';
64
+ if (!is_dir($path)) {
65
+ try {
66
+ mkdir($path, 0777, TRUE);
67
+ } catch (Exception $e) {
68
+
69
+ }
70
+ }
71
+ $result = $uploader->save($path, $_FILES['image_name_co']['name']);
72
+ try {
73
+ chmod($path . '/' . $result['file'], 0777);
74
+ } catch (Exception $e) {
75
+
76
+ }
77
+ $data['image'] = Mage::getBaseUrl('media') . 'simi/simiconnector/productlabel/' . $result['file'];
78
+ } catch (Exception $e) {
79
+ $data['image'] = Mage::getBaseUrl('media') . 'simi/simiconnector/productlabel/' . $_FILES['image_name_co']['name'];
80
+ }
81
+ }
82
+ if (isset($data['image_name_co']['delete']) && $data['image_name_co']['delete'] == 1) {
83
+ try {
84
+ unlink($data['image_name_co']['value']);
85
+ } catch (Exception $e) {
86
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
87
+ }
88
+ $data['image'] = '';
89
+ }
90
+
91
+ $model = Mage::getModel('simiconnector/simiproductlabel');
92
+ $model->setData($data)
93
+ ->setId($this->getRequest()->getParam('label_id'));
94
+
95
+ try {
96
+ $model->save();
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(
98
+ Mage::helper('simiconnector')->__('Label was successfully saved')
99
+ );
100
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
101
+
102
+ if ($this->getRequest()->getParam('back')) {
103
+ $this->_redirect('*/*/edit', array('label_id' => $model->getId()));
104
+ return;
105
+ }
106
+ $this->_redirect('*/*/');
107
+ return;
108
+ } catch (Exception $e) {
109
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
110
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
111
+ $this->_redirect('*/*/edit', array('label_id' => $this->getRequest()->getParam('label_id')));
112
+ return;
113
+ }
114
+ }
115
+ Mage::getSingleton('adminhtml/session')->addError(
116
+ Mage::helper('simiconnector')->__('Unable to find item to save')
117
+ );
118
+ $this->_redirect('*/*/');
119
+ }
120
+
121
+ /**
122
+ * delete item action
123
+ */
124
+ public function deleteAction() {
125
+ if ($this->getRequest()->getParam('label_id') > 0) {
126
+ try {
127
+ $model = Mage::getModel('simiconnector/simiproductlabel');
128
+ $model->setId($this->getRequest()->getParam('label_id'))
129
+ ->delete();
130
+ Mage::getSingleton('adminhtml/session')->addSuccess(
131
+ Mage::helper('adminhtml')->__('Label was successfully deleted')
132
+ );
133
+ $this->_redirect('*/*/');
134
+ } catch (Exception $e) {
135
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
136
+ $this->_redirect('*/*/edit', array('label_id' => $this->getRequest()->getParam('label_id')));
137
+ }
138
+ }
139
+ $this->_redirect('*/*/');
140
+ }
141
+
142
+ /**
143
+ * mass delete item(s) action
144
+ */
145
+ public function massDeleteAction() {
146
+ $labelIds = $this->getRequest()->getParam('label_id');
147
+ if (!is_array($labelIds)) {
148
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
149
+ } else {
150
+ try {
151
+ foreach ($labelIds as $labelId) {
152
+ $label = Mage::getModel('simiconnector/simiproductlabel')->load($labelId);
153
+ $label->delete();
154
+ }
155
+ Mage::getSingleton('adminhtml/session')->addSuccess(
156
+ Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($labelIds))
157
+ );
158
+ } catch (Exception $e) {
159
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
160
+ }
161
+ }
162
+ $this->_redirect('*/*/index');
163
+ }
164
+
165
+ /**
166
+ * mass change status for item(s) action
167
+ */
168
+ public function massStatusAction() {
169
+ $labelIds = $this->getRequest()->getParam('label_id');
170
+ if (!is_array($labelIds)) {
171
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
172
+ } else {
173
+ try {
174
+ foreach ($labelIds as $labelId) {
175
+ Mage::getSingleton('simiconnector/simiproductlabel')
176
+ ->load($labelId)
177
+ ->setStatus($this->getRequest()->getParam('status'))
178
+ ->setIsMassupdate(true)
179
+ ->save();
180
+ }
181
+ $this->_getSession()->addSuccess(
182
+ $this->__('Total of %d record(s) were successfully updated', count($labelIds))
183
+ );
184
+ } catch (Exception $e) {
185
+ $this->_getSession()->addError($e->getMessage());
186
+ }
187
+ }
188
+ $this->_redirect('*/*/index');
189
+ }
190
+
191
+ /**
192
+ * index action
193
+ */
194
+ public function indexAction() {
195
+ $this->_initAction()
196
+ ->renderLayout();
197
+ }
198
+
199
+ protected function _isAllowed() {
200
+ return Mage::getSingleton('admin/session')->isAllowed('connector');
201
+ }
202
+
203
+ public function chooserMainProductsAction() {
204
+ $request = $this->getRequest();
205
+ $block = $this->getLayout()->createBlock(
206
+ 'simiconnector/adminhtml_simiproductlabel_edit_tab_products', 'simiproductlabel_widget_chooser_sku', array('js_form_object' => $request->getParam('form'),
207
+ ));
208
+ if ($block) {
209
+ $this->getResponse()->setBody($block->toHtml());
210
+ }
211
+ }
212
+
213
+ }
app/code/local/Simi/Simiconnector/controllers/Adminhtml/Simiconnector/SimivideoController.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_Adminhtml_Simiconnector_SimivideoController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * init layout and set active for current menu
7
+ *
8
+ * @return Simi_Simivideo_Adminhtml_SimivideoController
9
+ */
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('simiconnector/simivideo')
13
+ ->_addBreadcrumb(
14
+ Mage::helper('adminhtml')->__('Videos'), Mage::helper('adminhtml')->__('Videos')
15
+ );
16
+ return $this;
17
+ }
18
+
19
+
20
+
21
+ public function editAction()
22
+ {
23
+ $videoId = $this->getRequest()->getParam('video_id');
24
+ $model = Mage::getModel('simiconnector/simivideo')->load($videoId);
25
+ if ($model->getId() || $videoId == 0) {
26
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
27
+ if (!empty($data)) {
28
+ $model->setData($data);
29
+ }
30
+ Mage::register('simivideo_data', $model);
31
+
32
+ $this->loadLayout();
33
+ $this->_setActiveMenu('simiconnector/simivideo');
34
+
35
+ $this->_addBreadcrumb(
36
+ Mage::helper('adminhtml')->__('Video Manager'),
37
+ Mage::helper('adminhtml')->__('Video Manager')
38
+ );
39
+
40
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
41
+ $this->_addContent($this->getLayout()->createBlock('simiconnector/adminhtml_simivideo_edit'))
42
+ ->_addLeft($this->getLayout()->createBlock('simiconnector/adminhtml_simivideo_edit_tabs'));
43
+ $this->renderLayout();
44
+ } else {
45
+ Mage::getSingleton('adminhtml/session')->addError(
46
+ Mage::helper('simiconnector')->__('Video does not exist')
47
+ );
48
+ $this->_redirect('*/*/');
49
+ }
50
+ }
51
+
52
+ public function newAction()
53
+ {
54
+ $this->_forward('edit');
55
+ }
56
+
57
+ /**
58
+ * save item action
59
+ */
60
+ public function saveAction()
61
+ {
62
+ if ($data = $this->getRequest()->getPost()) {
63
+ $model = Mage::getModel('simiconnector/simivideo');
64
+ $model->setData($data)
65
+ ->setId($this->getRequest()->getParam('video_id'));
66
+ $url = $model->getData('video_url');
67
+ parse_str( parse_url($url, PHP_URL_QUERY ), $my_array_of_vars);
68
+ if ($my_array_of_vars['v'])
69
+ $model->setData('video_key',$my_array_of_vars['v']);
70
+ else {
71
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('simiconnector')->__('The url you used is not a Full and Valid Youtube video url'));
72
+ $model->setData('video_key', null);
73
+ //Mage::getSingleton('adminhtml/session')->setFormData($data);
74
+ //$this->_redirect('*/*/edit', array('video_id' => $this->getRequest()->getParam('video_id')));
75
+ //return;
76
+ }
77
+ try {
78
+ $model->save();
79
+ Mage::getSingleton('adminhtml/session')->addSuccess(
80
+ Mage::helper('simiconnector')->__('Video was successfully saved')
81
+ );
82
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
83
+
84
+ if ($this->getRequest()->getParam('back')) {
85
+ $this->_redirect('*/*/edit', array('video_id' => $model->getId()));
86
+ return;
87
+ }
88
+ $this->_redirect('*/*/');
89
+ return;
90
+ } catch (Exception $e) {
91
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
92
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
93
+ $this->_redirect('*/*/edit', array('video_id' => $this->getRequest()->getParam('video_id')));
94
+ return;
95
+ }
96
+ }
97
+ Mage::getSingleton('adminhtml/session')->addError(
98
+ Mage::helper('simiconnector')->__('Unable to find item to save')
99
+ );
100
+ $this->_redirect('*/*/');
101
+ }
102
+
103
+ /**
104
+ * delete item action
105
+ */
106
+ public function deleteAction()
107
+ {
108
+ if ($this->getRequest()->getParam('video_id') > 0) {
109
+ try {
110
+ $model = Mage::getModel('simiconnector/simivideo');
111
+ $model->setId($this->getRequest()->getParam('video_id'))
112
+ ->delete();
113
+ Mage::getSingleton('adminhtml/session')->addSuccess(
114
+ Mage::helper('adminhtml')->__('Video was successfully deleted')
115
+ );
116
+ $this->_redirect('*/*/');
117
+ } catch (Exception $e) {
118
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
119
+ $this->_redirect('*/*/edit', array('video_id' => $this->getRequest()->getParam('video_id')));
120
+ }
121
+ }
122
+ $this->_redirect('*/*/');
123
+ }
124
+
125
+ /**
126
+ * mass delete item(s) action
127
+ */
128
+ public function massDeleteAction()
129
+ {
130
+ $videoIds = $this->getRequest()->getParam('video_id');
131
+ if (!is_array($videoIds)) {
132
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
133
+ } else {
134
+ try {
135
+ foreach ($videoIds as $videoId) {
136
+ $video = Mage::getModel('simiconnector/simivideo')->load($videoId);
137
+ $video->delete();
138
+ }
139
+ Mage::getSingleton('adminhtml/session')->addSuccess(
140
+ Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted',
141
+ count($videoIds))
142
+ );
143
+ } catch (Exception $e) {
144
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
145
+ }
146
+ }
147
+ $this->_redirect('*/*/index');
148
+ }
149
+
150
+ /**
151
+ * mass change status for item(s) action
152
+ */
153
+ public function massStatusAction()
154
+ {
155
+ $videoIds = $this->getRequest()->getParam('video_id');
156
+ if (!is_array($videoIds)) {
157
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
158
+ } else {
159
+ try {
160
+ foreach ($videoIds as $videoId) {
161
+ Mage::getSingleton('simiconnector/simivideo')
162
+ ->load($videoId)
163
+ ->setStatus($this->getRequest()->getParam('status'))
164
+ ->setIsMassupdate(true)
165
+ ->save();
166
+ }
167
+ $this->_getSession()->addSuccess(
168
+ $this->__('Total of %d record(s) were successfully updated', count($videoIds))
169
+ );
170
+ } catch (Exception $e) {
171
+ $this->_getSession()->addError($e->getMessage());
172
+ }
173
+ }
174
+ $this->_redirect('*/*/index');
175
+ }
176
+
177
+ /**
178
+ * index action
179
+ */
180
+ public function indexAction() {
181
+ $this->_initAction()
182
+ ->renderLayout();
183
+ }
184
+
185
+ protected function _isAllowed() {
186
+ return Mage::getSingleton('admin/session')->isAllowed('connector');
187
+ }
188
+
189
+ public function chooserMainProductsAction() {
190
+ $request = $this->getRequest();
191
+ $block = $this->getLayout()->createBlock(
192
+ 'simiconnector/adminhtml_simivideo_edit_tab_products', 'simivideo_widget_chooser_sku', array('js_form_object' => $request->getParam('form'),
193
+ ));
194
+ if ($block) {
195
+ $this->getResponse()->setBody($block->toHtml());
196
+ }
197
+ }
198
+
199
+ }
app/code/local/Simi/Simiconnector/controllers/IndexController.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Simi_Simiconnector_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ public function indexAction()
7
+ {
8
+ $this->loadLayout();
9
+ $this->renderLayout();
10
+ }
11
+
12
+ public function checkInstallAction()
13
+ {
14
+ $arr = array();
15
+ $arr['is_install'] = "1";
16
+ $key = $this->getRequest()->getParam('key');
17
+ if ($key == null || $key == '') {
18
+ $arr["website_key"] = "0";
19
+
20
+ } else {
21
+ $keySecret = md5(Mage::getStoreConfig('simiconnector/general/secret_key'));
22
+ if (strcmp($key, $keySecret) == 0)
23
+ $arr["website_key"] = "1";
24
+ else
25
+ $arr["website_key"] = "0";
26
+ }
27
+ echo json_encode($arr);
28
+ exit();
29
+ }
30
+
31
+ public function installDBAction()
32
+ {
33
+ $setup = new Mage_Core_Model_Resource_Setup('core_setup');
34
+ $installer = $setup;
35
+ $installer->startSetup();
36
+
37
+ $installer->run("
38
+
39
+ ");
40
+ $installer->endSetup();
41
+ echo 'success';
42
+ }
43
+
44
+
45
+ public function checkPortAction()
46
+ {
47
+ $host = 'gateway.sandbox.push.apple.com';
48
+ $port = 2195;
49
+ $hostip = @gethostbyname($host);
50
+
51
+ if ($hostip == $host) {
52
+ echo "Server is down or does not exist";
53
+ } else {
54
+ if (!$x = @fsockopen($hostip, $port, $errno, $errstr, 5)) {
55
+ echo "Port $port is closed.";
56
+ } else {
57
+ echo "Port $port is open.";
58
+ if ($x) {
59
+ @fclose($x);
60
+ }
61
+ }
62
+ }
63
+ exit();
64
+ }
65
+ }
app/code/local/Simi/Simiconnector/controllers/RestController.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: Max
6
+ * Date: 5/2/16
7
+ * Time: 4:17 PM
8
+ */
9
+ class Simi_Simiconnector_RestController extends Simi_Simiconnector_Controller_Action
10
+ {
11
+ public function v2Action()
12
+ {
13
+ ob_start();
14
+ try {
15
+ $result = $this->_getServer()
16
+ ->init($this)->run();
17
+ $this->_printData($result);
18
+ } catch (Exception $e) {
19
+ $results = array();
20
+ $result = array();
21
+ if (is_array($e->getMessage())) {
22
+ $messages = $e->getMessage();
23
+ foreach ($messages as $message) {
24
+ $result[] = array(
25
+ 'code' => $e->getCode(),
26
+ 'message' => $message,
27
+ );
28
+ }
29
+ } else {
30
+ $result[] = array(
31
+ 'code' => $e->getCode(),
32
+ 'message' => $e->getMessage(),
33
+ );
34
+ }
35
+ $results['errors'] = $result;
36
+ $this->_printData($results);
37
+ }
38
+ exit();
39
+ ob_end_flush();
40
+ }
41
+
42
+ }
app/code/local/Simi/Simiconnector/etc/adminhtml.xml ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <simiconnector module="simiconnector" translate="title">
5
+ <title>Simiconnector</title>
6
+ <sort_order>71</sort_order>
7
+ <children>
8
+ <core module="simiconnector" translate="title">
9
+ <title>Connector Settings</title>
10
+ <sort_order>0</sort_order>
11
+ <children>
12
+ <siminotification module="simiconnector" translate="title">
13
+ <title>Notifications</title>
14
+ <sort_order>2</sort_order>
15
+ <children>
16
+ <notification module="simiconnector" translate="title">
17
+ <title>Manage Notifications</title>
18
+ <sort_order>10</sort_order>
19
+ <action>adminhtml/simiconnector_siminotification</action>
20
+ </notification>
21
+ <device_list module="simiconnector" translate="title">
22
+ <title>View Devices</title>
23
+ <sort_order>20</sort_order>
24
+ <action>adminhtml/simiconnector_device</action>
25
+ </device_list>
26
+ <history module="simiconnector" translate="title">
27
+ <title>History</title>
28
+ <sort_order>30</sort_order>
29
+ <action>adminhtml/simiconnector_history</action>
30
+ </history>
31
+ </children>
32
+ </siminotification>
33
+ <settings module="simiconnector" translate="title">
34
+ <title>General Settings</title>
35
+ <sort_order>1000</sort_order>
36
+ <action>adminhtml/system_config/edit/section/simiconnector</action>
37
+ </settings>
38
+ <simitransactions module="simiconnector" translate="title">
39
+ <title>App Transactions</title>
40
+ <sort_order>40</sort_order>
41
+ <action>adminhtml/simiconnector_appreport</action>
42
+ </simitransactions>
43
+ </children>
44
+ </core>
45
+ <!-- start payment -->
46
+ <simi_payment module="simiconnector" translate="title">
47
+ <title>Payment</title>
48
+ <sort_order>5</sort_order>
49
+ <children>
50
+ <trasfersimi module="simiconnector" translate="title">
51
+ <title>Mobile Bank Transfer</title>
52
+ <sort_order>180</sort_order>
53
+ <action>adminhtml/system_config/edit/section/payment</action>
54
+ </trasfersimi>
55
+ </children>
56
+ </simi_payment>
57
+ <!-- end payment -->
58
+
59
+ <simi_theme module="simiconnector" translate="title">
60
+ <title>Themes</title>
61
+ <sort_order>10</sort_order>
62
+ <children>
63
+ <default_theme module="simiconnector" translate="title">
64
+ <title>Home Content</title>
65
+ <sort_order>0</sort_order>
66
+ <children>
67
+ <banner module="simiconnector" translate="title">
68
+ <title>Banners</title>
69
+ <sort_order>10</sort_order>
70
+ <action>adminhtml/simiconnector_banner</action>
71
+ </banner>
72
+ <simicategory module="simiconnector" translate="title">
73
+ <title>Home Categories</title>
74
+ <sort_order>50</sort_order>
75
+ <action>adminhtml/simiconnector_simicategory</action>
76
+ </simicategory>
77
+ <spotproduct module="simiconnector" translate="title">
78
+ <title>Product Lists</title>
79
+ <sort_order>160</sort_order>
80
+ <action>adminhtml/simiconnector_productlist</action>
81
+ </spotproduct>
82
+ </children>
83
+ </default_theme>
84
+ <cms module="simiconnector" translate="title">
85
+ <title>CMS Pages</title>
86
+ <sort_order>150</sort_order>
87
+ <action>adminhtml/simiconnector_cms</action>
88
+ </cms>
89
+ </children>
90
+ </simi_theme>
91
+ <simi_rich_content module="simiconnector" translate="title">
92
+ <title>Rich Content</title>
93
+ <sort_order>30</sort_order>
94
+ <children>
95
+ <simivideo module="simiconnector" translate="title">
96
+ <title>Videos</title>
97
+ <sort_order>99</sort_order>
98
+ <action>adminhtml/simiconnector_simivideo</action>
99
+ </simivideo>
100
+ <simiproductlabel module="simiconnector" translate="title">
101
+ <title>Product Labels</title>
102
+ <sort_order>199</sort_order>
103
+ <action>adminhtml/simiconnector_simiproductlabel</action>
104
+ </simiproductlabel>
105
+ </children>
106
+ </simi_rich_content>
107
+ <simi_user_experience module="simiconnector" translate="title">
108
+ <title>User Experience</title>
109
+ <sort_order>40</sort_order>
110
+ <children>
111
+ <simibarcode module="simiconnector" translate="title">
112
+ <title><![CDATA[Manage QR & Barcodes]]></title>
113
+ <sort_order>99</sort_order>
114
+ <action>adminhtml/simiconnector_simibarcode</action>
115
+ </simibarcode>
116
+ </children>
117
+ </simi_user_experience>
118
+ </children>
119
+ </simiconnector>
120
+ </menu>
121
+ <acl>
122
+ <resources>
123
+ <all>
124
+ <title>Allow Everything</title>
125
+ </all>
126
+ <admin>
127
+ <children>
128
+ <system>
129
+ <children>
130
+ <config>
131
+ <children>
132
+ <simiconnector module="simiconnector" translate="title">
133
+ <title>SimiCart Connector</title>
134
+ <sort_order>1</sort_order>
135
+ </simiconnector>
136
+ </children>
137
+ </config>
138
+ </children>
139
+ </system>
140
+ <simiconnector module="simiconnector" translate="title">
141
+ <title>Simiconnector</title>
142
+ <sort_order>71</sort_order>
143
+ <children>
144
+ <core module="simiconnector" translate="title">
145
+ <title>Connector Settings</title>
146
+ <sort_order>0</sort_order>
147
+ <children>
148
+ <connector_app module="simiconnector" translate="title">
149
+ <title>Apps</title>
150
+ <sort_order>0</sort_order>
151
+ </connector_app>
152
+ <siminotification module="simiconnector" translate="title">
153
+ <title>Notifications</title>
154
+ <sort_order>2</sort_order>
155
+ <children>
156
+ <notification module="simiconnector" translate="title">
157
+ <title>Manage Notifications</title>
158
+ <sort_order>10</sort_order>
159
+ </notification>
160
+ <device_list module="simiconnector" translate="title">
161
+ <title>View Devices</title>
162
+ <sort_order>20</sort_order>
163
+ </device_list>
164
+ <history module="simiconnector" translate="title">
165
+ <title>History</title>
166
+ <sort_order>30</sort_order>
167
+ </history>
168
+ </children>
169
+ </siminotification>
170
+ <notice module="simiconnector" translate="title">
171
+ <title>Notifications</title>
172
+ <sort_order>100</sort_order>
173
+ </notice>
174
+ <promoteapp module="simiconnector" translate="title">
175
+ <title>Promote Apps</title>
176
+ <sort_order>170</sort_order>
177
+ </promoteapp>
178
+ <settings module="simiconnector" translate="title">
179
+ <title>General Settings</title>
180
+ <sort_order>1000</sort_order>
181
+ </settings>
182
+ </children>
183
+ </core>
184
+ <simi_theme>
185
+ <title>Themes</title>
186
+ <sort_order>10</sort_order>
187
+ <children>
188
+ <default_theme>
189
+ <title>Default Theme</title>
190
+ <sort_order>0</sort_order>
191
+ <children>
192
+ <banner module="simiconnector" translate="title">
193
+ <title>Banners</title>
194
+ <sort_order>10</sort_order>
195
+ </banner>
196
+ <simicategory module="simiconnector" translate="title">
197
+ <title>Home Category</title>
198
+ <sort_order>50</sort_order>
199
+ </simicategory>
200
+ <spotproduct module="simiconnector" translate="title">
201
+ <title>Product List</title>
202
+ <sort_order>160</sort_order>
203
+ </spotproduct>
204
+ </children>
205
+ </default_theme>
206
+ <cms module="simiconnector" translate="title">
207
+ <title>CMS Pages</title>
208
+ <sort_order>150</sort_order>
209
+ </cms>
210
+ </children>
211
+ </simi_theme>
212
+ </children>
213
+ </simiconnector>
214
+ <simi_user_experience module="simiconnector" translate="title">
215
+ <title>User Experience</title>
216
+ <sort_order>40</sort_order>
217
+ <children>
218
+ <simibarcode module="simiconnector" translate="title">
219
+ <title>QR Barcode Scanner</title>
220
+ <sort_order>71</sort_order>
221
+ <children>
222
+ <simibarcode module="simiconnector" translate="title">
223
+ <title><![CDATA[Manage QR & Barcodes]]></title>
224
+ <sort_order>99</sort_order>
225
+ </simibarcode>
226
+ <settings module="simiconnector" translate="title">
227
+ <title>Settings</title>
228
+ <sort_order>199</sort_order>
229
+ </settings>
230
+ </children>
231
+ </simibarcode>
232
+ </children>
233
+ </simi_user_experience>
234
+ </children>
235
+ </admin>
236
+ </resources>
237
+ </acl>
238
+ </config>
app/code/local/Simi/Simiconnector/etc/config.xml ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Simi_Simiconnector>
5
+ <version>0.1.0</version>
6
+ </Simi_Simiconnector>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <simiconnector>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Simi_Simiconnector</module>
14
+ <frontName>simiconnector</frontName>
15
+ </args>
16
+ </simiconnector>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <simiconnector>
21
+ <file>simiconnector.xml</file>
22
+ </simiconnector>
23
+ </updates>
24
+ </layout>
25
+ <translate>
26
+ <modules>
27
+ <Simi_Simiconnector>
28
+ <files>
29
+ <default>Simi_Simiconnector.csv</default>
30
+ </files>
31
+ </Simi_Simiconnector>
32
+ </modules>
33
+ </translate>
34
+ </frontend>
35
+ <admin>
36
+ <routers>
37
+ <adminhtml>
38
+ <args>
39
+ <modules>
40
+ <Simi_Simiconnector after="Mage_Adminhtml">Simi_Simiconnector_Adminhtml</Simi_Simiconnector>
41
+ </modules>
42
+ </args>
43
+ </adminhtml>
44
+ </routers>
45
+ </admin>
46
+ <adminhtml>
47
+ <layout>
48
+ <updates>
49
+ <simiconnector>
50
+ <file>simiconnector.xml</file>
51
+ </simiconnector>
52
+ </updates>
53
+ </layout>
54
+ <translate>
55
+ <modules>
56
+ <Simi_Simiconnector>
57
+ <files>
58
+ <default>Simi_Simiconnector.csv</default>
59
+ </files>
60
+ </Simi_Simiconnector>
61
+ </modules>
62
+ </translate>
63
+ <events>
64
+ <catalog_product_save_before>
65
+ <observers>
66
+ <siminotification_product_save_before>
67
+ <class>simiconnector/observer</class>
68
+ <method>sendNotificationProductChangePrice</method>
69
+ </siminotification_product_save_before>
70
+ </observers>
71
+ </catalog_product_save_before>
72
+ <catalog_product_save_after>
73
+ <observers>
74
+ <siminotification_product_save_after>
75
+ <class>simiconnector/observer</class>
76
+ <method>sendNotificationNewProduct</method>
77
+ </siminotification_product_save_after>
78
+ </observers>
79
+ </catalog_product_save_after>
80
+ </events>
81
+ </adminhtml>
82
+ <global>
83
+ <models>
84
+ <simiconnector>
85
+ <class>Simi_Simiconnector_Model</class>
86
+ <resourceModel>simiconnector_mysql4</resourceModel>
87
+ </simiconnector>
88
+ <simiconnector_mysql4>
89
+ <class>Simi_Simiconnector_Model_Mysql4</class>
90
+ <entities>
91
+ <appreport>
92
+ <table>simiconnector_transactions</table>
93
+ </appreport>
94
+ <simicategory>
95
+ <table>simiconnector_simicategory</table>
96
+ </simicategory>
97
+ <banner>
98
+ <table>simiconnector_banner</table>
99
+ </banner>
100
+ <cms>
101
+ <table>simiconnector_cms</table>
102
+ </cms>
103
+ <productlist>
104
+ <table>simiconnector_product_list</table>
105
+ </productlist>
106
+ <visibility>
107
+ <table>simiconnector_visibility</table>
108
+ </visibility>
109
+ <device>
110
+ <table>simiconnector_device</table>
111
+ </device>
112
+ <siminotification>
113
+ <table>simiconnector_notice</table>
114
+ </siminotification>
115
+ <history>
116
+ <table>simiconnector_notice_history</table>
117
+ </history>
118
+ <simibarcode>
119
+ <table>simiconnector_simibarcode</table>
120
+ </simibarcode>
121
+ <simivideo>
122
+ <table>simiconnector_videos</table>
123
+ </simivideo>
124
+ <simiproductlabel>
125
+ <table>simiconnector_productlabels</table>
126
+ </simiproductlabel>
127
+ </entities>
128
+ </simiconnector_mysql4>
129
+ </models>
130
+ <resources>
131
+ <simiconnector_setup>
132
+ <setup>
133
+ <module>Simi_Simiconnector</module>
134
+ </setup>
135
+ <connection>
136
+ <use>core_setup</use>
137
+ </connection>
138
+ </simiconnector_setup>
139
+ <simiconnector_write>
140
+ <connection>
141
+ <use>core_write</use>
142
+ </connection>
143
+ </simiconnector_write>
144
+ <simiconnector_read>
145
+ <connection>
146
+ <use>core_read</use>
147
+ </connection>
148
+ </simiconnector_read>
149
+ </resources>
150
+ <blocks>
151
+ <simiconnector>
152
+ <class>Simi_Simiconnector_Block</class>
153
+ </simiconnector>
154
+ <simicategory>
155
+ <class>Simi_Simicategory_Block</class>
156
+ </simicategory>
157
+ </blocks>
158
+ <helpers>
159
+ <simiconnector>
160
+ <class>Simi_Simiconnector_Helper</class>
161
+ </simiconnector>
162
+ </helpers>
163
+ <events>
164
+ <sales_quote_collect_totals_before>
165
+ <observers>
166
+ <simi_connector_sales_quote_collect_totals_before>
167
+ <class>simiconnector/observer</class>
168
+ <method>sales_quote_collect_totals_before</method>
169
+ </simi_connector_sales_quote_collect_totals_before>
170
+ </observers>
171
+ </sales_quote_collect_totals_before>
172
+ </events>
173
+ </global>
174
+ <default>
175
+ <simiconnector>
176
+ <magestore>0</magestore>
177
+ <check_first>0</check_first>
178
+ <general>
179
+ <enable>1</enable>
180
+ <upload_pem_file>0</upload_pem_file>
181
+ <is_show_price_zero>1</is_show_price_zero>
182
+ <is_show_all_product>1</is_show_all_product>
183
+ <cms_shipping_condition></cms_shipping_condition>
184
+ <show_product_type>0</show_product_type>
185
+ <is_show_sample_data>1</is_show_sample_data>
186
+ <base_url></base_url>
187
+ <is_show_home_title>1</is_show_home_title>
188
+ <is_rtl>0</is_rtl>
189
+ <secret_key backend_model="adminhtml/system_config_backend_encrypted"></secret_key>
190
+ <token_key backend_model="adminhtml/system_config_backend_encrypted"></token_key>
191
+ </general>
192
+ <currency>
193
+ <thousand_separator>,</thousand_separator>
194
+ <decimal_separator>.</decimal_separator>
195
+ <min_number_of_decimals translate="label">0</min_number_of_decimals>
196
+ <max_number_of_decimals translate="label">2</max_number_of_decimals>
197
+ </currency>
198
+ <notification>
199
+ <android_app_key></android_app_key>
200
+ <android_secret_key></android_secret_key>
201
+ <noti_price_enable>0</noti_price_enable>
202
+ <new_product_enable>0</new_product_enable>
203
+ <noti_purchase_enable>0</noti_purchase_enable>
204
+ </notification>
205
+ <hideaddress>
206
+ <hideaddress_enable>0</hideaddress_enable>
207
+ <firstname>2</firstname>
208
+ <lastname>2</lastname>
209
+ <email>2</email>
210
+ <company>2</company>
211
+ <street>2</street>
212
+ <country_id>2</country_id>
213
+ <region_id>2</region_id>
214
+ <city>2</city>
215
+ <zipcode>2</zipcode>
216
+ <telephone>2</telephone>
217
+ <fax>2</fax>
218
+ <prefix>2</prefix>
219
+ <suffix>2</suffix>
220
+ <dob>2</dob>
221
+ <gender>2</gender>
222
+ <taxvat>2</taxvat>
223
+ </hideaddress>
224
+ <terms_conditions>
225
+ <enable_terms>0</enable_terms>
226
+ </terms_conditions>
227
+ <instant_contact>
228
+ <email>sales@simicart.com</email>
229
+ <phone>84 - 04 - 3217 - 1357 (GMT+7)</phone>
230
+ <message>84 - 04 - 3217 - 1357 (GMT+7)</message>
231
+ <website>84 - 04 - 3217 - 1357 (GMT+7)</website>
232
+ <icon_color>FF9900</icon_color>
233
+ </instant_contact>
234
+ <barcode>
235
+ <pattern>BAR[A.4][AN.6]</pattern>
236
+ <qrcode_pattern>QR[A.4][AN.6]</qrcode_pattern>
237
+ </barcode>
238
+ <productlabel>
239
+ <enable>0</enable>
240
+ </productlabel>
241
+ <zopim>
242
+ <enable>1</enable>
243
+ <account_key>3WlAvERBApxnMZGdc40no5lmvt1mJCQ8</account_key>
244
+ <show_profile>0</show_profile>
245
+ <name>3</name>
246
+ <email>3</email>
247
+ <phone>3</phone>
248
+ </zopim>
249
+ <mixpanel>
250
+ <token></token>
251
+ </mixpanel>
252
+ </simiconnector>
253
+ </default>
254
+ </config>
app/code/local/Simi/Simiconnector/etc/system.xml ADDED
@@ -0,0 +1,1114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <simiconnector translate="label">
5
+ <label>SimiCart Connector</label>
6
+ <sort_order>400</sort_order>
7
+ </simiconnector>
8
+ </tabs>
9
+ <sections>
10
+ <simiconnector translate="label" module="simiconnector">
11
+ <class>separator-top</class>
12
+ <label>General Settings</label>
13
+ <tab>simiconnector</tab>
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
+ <groups>
20
+ <general translate="label">
21
+ <label>General Configuration</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <enable translate="label">
29
+ <label>Enable</label>
30
+ <frontend_type>select</frontend_type>
31
+ <sort_order>1</sort_order>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <comment></comment>
37
+ </enable>
38
+ <secret_key translate="label">
39
+ <label>Secret Key</label>
40
+ <!--<frontend_type>password</frontend_type>-->
41
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>99</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <comment>Your secret key (get from your Building Dashboard)</comment>
48
+ </secret_key>
49
+ <token_key translate="label">
50
+ <label>Token Key</label>
51
+ <!--<frontend_type>password</frontend_type>-->
52
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>100</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <comment>Your token key (get from your Building Dashboard)</comment>
59
+ </token_key>
60
+ <base_url translate="label">
61
+ <label>Base URL</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>199</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ <comment>eg. http://simicart.com/, leave it blank if you want to use default value from Building Dashboard</comment>
68
+ </base_url>
69
+ <is_show_price_zero translate="label">
70
+ <label>Show option price if it's $0.00?</label>
71
+ <frontend_type>select</frontend_type>
72
+ <sort_order>299</sort_order>
73
+ <source_model>adminhtml/system_config_source_yesno</source_model>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </is_show_price_zero>
78
+ <is_show_all_product translate="label">
79
+ <label>Show "All Products" link in Category?</label>
80
+ <frontend_type>select</frontend_type>
81
+ <sort_order>399</sort_order>
82
+ <source_model>adminhtml/system_config_source_yesno</source_model>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </is_show_all_product>
87
+ <cms_shipping_condition translate="label">
88
+ <label>Show CMS content in product detail</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>499</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ <comment>Please enter its CMS ID SimiCart Connector/CMS</comment>
95
+ </cms_shipping_condition>
96
+ <is_show_sample_data translate="label">
97
+ <label>Show Sample Data on Home Screen</label>
98
+ <frontend_type>select</frontend_type>
99
+ <sort_order>599</sort_order>
100
+ <source_model>adminhtml/system_config_source_yesno</source_model>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </is_show_sample_data>
105
+ <show_product_type translate="label">
106
+ <label>Products Screen Display Default By:</label>
107
+ <frontend_type>select</frontend_type>
108
+ <sort_order>699</sort_order>
109
+ <source_model>simiconnector/config_source_productsviewtype</source_model>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ </show_product_type>
114
+ <is_rtl translate="label">
115
+ <label>Use RTL language</label>
116
+ <frontend_type>select</frontend_type>
117
+ <sort_order>799</sort_order>
118
+ <source_model>adminhtml/system_config_source_yesno</source_model>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </is_rtl>
123
+ <categories_in_app translate="label">
124
+ <label>Display categories on app</label>
125
+ <frontend_type>label</frontend_type>
126
+ <sort_order>899</sort_order>
127
+ <frontend_model>simiconnector/adminhtml_system_config_category_categorytree</frontend_model>
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
+ </categories_in_app>
132
+ <is_show_home_title translate="label">
133
+ <label>Show Title For Banners, Categories and Product Lists on Home Screen</label>
134
+ <frontend_type>select</frontend_type>
135
+ <sort_order>999</sort_order>
136
+ <source_model>adminhtml/system_config_source_yesno</source_model>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ </is_show_home_title>
141
+ <app_dedicated_coupon translate="label">
142
+ <label>Mobile App Dedicated Coupon</label>
143
+ <frontend_type>text</frontend_type>
144
+ <sort_order>1099</sort_order>
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
+ </app_dedicated_coupon>
149
+ </fields>
150
+ </general>
151
+ <currency translate="label">
152
+ <label>Currency Display Configuration</label>
153
+ <frontend_type>text</frontend_type>
154
+ <sort_order>99</sort_order>
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
+ <fields>
159
+ <thousand_separator translate="label">
160
+ <label>Thousand Separator</label>
161
+ <frontend_type>text</frontend_type>
162
+ <sort_order>1</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ </thousand_separator>
167
+ <decimal_separator translate="label">
168
+ <label>Decimal Separator</label>
169
+ <frontend_type>text</frontend_type>
170
+ <sort_order>99</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>1</show_in_store>
174
+ </decimal_separator>
175
+ <min_number_of_decimals translate="label">
176
+ <label>Minimum Number of Decimals</label>
177
+ <frontend_type>text</frontend_type>
178
+ <sort_order>199</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
+ </min_number_of_decimals>
183
+ <max_number_of_decimals translate="label">
184
+ <label>Maximum Number of Decimals</label>
185
+ <frontend_type>text</frontend_type>
186
+ <sort_order>299</sort_order>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>1</show_in_store>
190
+ </max_number_of_decimals>
191
+ </fields>
192
+ </currency>
193
+ <notification translate="label">
194
+ <label>Notification Settings</label>
195
+ <frontend_type>text</frontend_type>
196
+ <sort_order>199</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
+ <upload_pem_file translate="label tooltip comment">
202
+ <label>Upload Apple PEM file</label>
203
+ <comment>Certificate (PEM) for Apple Device Notification Sending</comment>
204
+ <frontend_type>file</frontend_type>
205
+ <sort_order>1</sort_order>
206
+ <backend_model>adminhtml/system_config_backend_file</backend_model>
207
+ <upload_dir config="system/filesystem/media" scope_info="1">simi/simiconnector/pem/manual</upload_dir>
208
+ <base_url type="media" scope_info="1">admin-config-uploads</base_url>
209
+ <show_in_default>1</show_in_default>
210
+ <show_in_website>1</show_in_website>
211
+ <show_in_store>1</show_in_store>
212
+ </upload_pem_file>
213
+ <upload_pem_file_test translate="label tooltip comment">
214
+ <label>Upload Apple Demo PEM file</label>
215
+ <comment>Certificate (PEM) for Demo Apple Device Notification Sending</comment>
216
+ <frontend_type>file</frontend_type>
217
+ <sort_order>10</sort_order>
218
+ <backend_model>adminhtml/system_config_backend_file</backend_model>
219
+ <upload_dir config="system/filesystem/media" scope_info="1">simi/simiconnector/pem</upload_dir>
220
+ <base_url type="media" scope_info="1">admin-config-uploads</base_url>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>1</show_in_website>
223
+ <show_in_store>1</show_in_store>
224
+ </upload_pem_file_test>
225
+ <android_app_key translate="label tooltip comment">
226
+ <label>Android App Key</label>
227
+ <comment>App Key for Android Notification Sending</comment>
228
+ <frontend_type>text</frontend_type>
229
+ <sort_order>20</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ </android_app_key>
234
+ <android_secret_key translate="label tooltip comment">
235
+ <label>Android Secret Key</label>
236
+ <comment>Secret Key for Android Notification Sending</comment>
237
+ <frontend_type>text</frontend_type>
238
+ <sort_order>30</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>1</show_in_store>
242
+ </android_secret_key>
243
+
244
+ <noti_price_separator translate="label">
245
+ <label>Send Notification when Price Updated</label>
246
+ <sort_order>99</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>1</show_in_store>
250
+ <frontend_model>simiconnector/adminhtml_system_config_form_field_separator</frontend_model>
251
+ <comment></comment>
252
+ </noti_price_separator>
253
+ <noti_price_enable translate="label">
254
+ <label>Send notification to all users when price of product is changed</label>
255
+ <frontend_type>select</frontend_type>
256
+ <sort_order>100</sort_order>
257
+ <source_model>adminhtml/system_config_source_yesno</source_model>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ <comment></comment>
262
+ </noti_price_enable>
263
+ <noti_price_showpopup translate="label">
264
+ <label>Show Popup</label>
265
+ <frontend_type>select</frontend_type>
266
+ <sort_order>101</sort_order>
267
+ <source_model>adminhtml/system_config_source_yesno</source_model>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>1</show_in_store>
271
+ <depends>
272
+ <noti_price_enable>1</noti_price_enable>
273
+ </depends>
274
+ <comment></comment>
275
+ </noti_price_showpopup>
276
+ <noti_price_title translate="label">
277
+ <label>Title</label>
278
+ <frontend_type>text</frontend_type>
279
+ <sort_order>102</sort_order>
280
+ <source_model>adminhtml/system_config_source_yesno</source_model>
281
+ <show_in_default>1</show_in_default>
282
+ <show_in_website>1</show_in_website>
283
+ <show_in_store>1</show_in_store>
284
+ <depends>
285
+ <noti_price_enable>1</noti_price_enable>
286
+ </depends>
287
+ <comment></comment>
288
+ </noti_price_title>
289
+ <noti_price_message translate="label">
290
+ <label>Message</label>
291
+ <frontend_type>textarea</frontend_type>
292
+ <sort_order>103</sort_order>
293
+ <source_model>adminhtml/system_config_source_yesno</source_model>
294
+ <show_in_default>1</show_in_default>
295
+ <show_in_website>1</show_in_website>
296
+ <show_in_store>1</show_in_store>
297
+ <depends>
298
+ <noti_price_enable>1</noti_price_enable>
299
+ </depends>
300
+ <comment><![CDATA[Characters recommended: < 250]]></comment>
301
+ </noti_price_message>
302
+ <noti_price_type translate="label">
303
+ <label>Direct Viewers to</label>
304
+ <frontend_type>select</frontend_type>
305
+ <sort_order>104</sort_order>
306
+ <source_model>simiconnector/siminotification</source_model>
307
+ <show_in_default>1</show_in_default>
308
+ <show_in_website>1</show_in_website>
309
+ <show_in_store>1</show_in_store>
310
+ <depends>
311
+ <noti_price_enable>1</noti_price_enable>
312
+ </depends>
313
+ <comment></comment>
314
+ </noti_price_type>
315
+ <noti_price_category_id translate="label">
316
+ <label>Category ID</label>
317
+ <frontend_type>text</frontend_type>
318
+ <sort_order>105</sort_order>
319
+ <source_model>adminhtml/system_config_source_yesno</source_model>
320
+ <show_in_default>1</show_in_default>
321
+ <show_in_website>1</show_in_website>
322
+ <show_in_store>1</show_in_store>
323
+ <depends>
324
+ <noti_price_enable>1</noti_price_enable>
325
+ <noti_price_type>2</noti_price_type>
326
+ </depends>
327
+ <comment></comment>
328
+ </noti_price_category_id>
329
+ <noti_price_url translate="label">
330
+ <label>URL</label>
331
+ <frontend_type>text</frontend_type>
332
+ <sort_order>106</sort_order>
333
+ <source_model>adminhtml/system_config_source_yesno</source_model>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>1</show_in_store>
337
+ <depends>
338
+ <noti_price_enable>1</noti_price_enable>
339
+ <noti_price_type>3</noti_price_type>
340
+ </depends>
341
+ <comment>Ex: https://simicart.com</comment>
342
+ </noti_price_url>
343
+ <noti_price_platform translate="label">
344
+ <label>Device</label>
345
+ <frontend_type>select</frontend_type>
346
+ <sort_order>107</sort_order>
347
+ <source_model>simiconnector/platform</source_model>
348
+ <show_in_default>1</show_in_default>
349
+ <show_in_website>1</show_in_website>
350
+ <show_in_store>1</show_in_store>
351
+ <depends>
352
+ <noti_price_enable>1</noti_price_enable>
353
+ </depends>
354
+ <comment></comment>
355
+ </noti_price_platform>
356
+ <noti_new_product_separator translate="label">
357
+ <label>Send Notification when there's a new product</label>
358
+ <sort_order>199</sort_order>
359
+ <show_in_default>1</show_in_default>
360
+ <show_in_website>1</show_in_website>
361
+ <show_in_store>1</show_in_store>
362
+ <frontend_model>simiconnector/adminhtml_system_config_form_field_separator</frontend_model>
363
+ <comment></comment>
364
+ </noti_new_product_separator>
365
+ <new_product_enable translate="label">
366
+ <label>Send notification to all users when there's a new product</label>
367
+ <frontend_type>select</frontend_type>
368
+ <sort_order>200</sort_order>
369
+ <source_model>adminhtml/system_config_source_yesno</source_model>
370
+ <show_in_default>1</show_in_default>
371
+ <show_in_website>1</show_in_website>
372
+ <show_in_store>1</show_in_store>
373
+ <comment></comment>
374
+ </new_product_enable>
375
+ <new_product_showpopup translate="label">
376
+ <label>Show Popup</label>
377
+ <frontend_type>select</frontend_type>
378
+ <sort_order>201</sort_order>
379
+ <source_model>adminhtml/system_config_source_yesno</source_model>
380
+ <show_in_default>1</show_in_default>
381
+ <show_in_website>1</show_in_website>
382
+ <show_in_store>1</show_in_store>
383
+ <depends>
384
+ <new_product_enable>1</new_product_enable>
385
+ </depends>
386
+ <comment></comment>
387
+ </new_product_showpopup>
388
+ <new_product_title translate="label">
389
+ <label>Title</label>
390
+ <frontend_type>text</frontend_type>
391
+ <sort_order>202</sort_order>
392
+ <source_model>adminhtml/system_config_source_yesno</source_model>
393
+ <show_in_default>1</show_in_default>
394
+ <show_in_website>1</show_in_website>
395
+ <show_in_store>1</show_in_store>
396
+ <depends>
397
+ <new_product_enable>1</new_product_enable>
398
+ </depends>
399
+ <comment></comment>
400
+ </new_product_title>
401
+ <new_product_message translate="label">
402
+ <label>Message</label>
403
+ <frontend_type>textarea</frontend_type>
404
+ <sort_order>203</sort_order>
405
+ <source_model>adminhtml/system_config_source_yesno</source_model>
406
+ <show_in_default>1</show_in_default>
407
+ <show_in_website>1</show_in_website>
408
+ <show_in_store>1</show_in_store>
409
+ <depends>
410
+ <new_product_enable>1</new_product_enable>
411
+ </depends>
412
+ <comment><![CDATA[Characters recommended: < 250]]></comment>
413
+ </new_product_message>
414
+ <new_product_type translate="label">
415
+ <label>Direct Viewers to</label>
416
+ <frontend_type>select</frontend_type>
417
+ <sort_order>204</sort_order>
418
+ <source_model>simiconnector/siminotification</source_model>
419
+ <show_in_default>1</show_in_default>
420
+ <show_in_website>1</show_in_website>
421
+ <show_in_store>1</show_in_store>
422
+ <depends>
423
+ <new_product_enable>1</new_product_enable>
424
+ </depends>
425
+ <comment></comment>
426
+ </new_product_type>
427
+ <new_product_category_id translate="label">
428
+ <label>Category ID</label>
429
+ <frontend_type>text</frontend_type>
430
+ <sort_order>205</sort_order>
431
+ <source_model>adminhtml/system_config_source_yesno</source_model>
432
+ <show_in_default>1</show_in_default>
433
+ <show_in_website>1</show_in_website>
434
+ <show_in_store>1</show_in_store>
435
+ <depends>
436
+ <new_product_enable>1</new_product_enable>
437
+ <new_product_type>2</new_product_type>
438
+ </depends>
439
+ <comment></comment>
440
+ </new_product_category_id>
441
+ <new_product_url translate="label">
442
+ <label>URL</label>
443
+ <frontend_type>text</frontend_type>
444
+ <sort_order>206</sort_order>
445
+ <source_model>adminhtml/system_config_source_yesno</source_model>
446
+ <show_in_default>1</show_in_default>
447
+ <show_in_website>1</show_in_website>
448
+ <show_in_store>1</show_in_store>
449
+ <depends>
450
+ <new_product_enable>1</new_product_enable>
451
+ <new_product_type>3</new_product_type>
452
+ </depends>
453
+ <comment>Ex: https://simicart.com</comment>
454
+ </new_product_url>
455
+ <new_product_platform translate="label">
456
+ <label>Device</label>
457
+ <frontend_type>select</frontend_type>
458
+ <sort_order>207</sort_order>
459
+ <source_model>simiconnector/platform</source_model>
460
+ <show_in_default>1</show_in_default>
461
+ <show_in_website>1</show_in_website>
462
+ <show_in_store>1</show_in_store>
463
+ <depends>
464
+ <new_product_enable>1</new_product_enable>
465
+ </depends>
466
+ <comment></comment>
467
+ </new_product_platform>
468
+ <noti_new_order_separator translate="label">
469
+ <label>Send Notification after customer purchase</label>
470
+ <sort_order>299</sort_order>
471
+ <show_in_default>1</show_in_default>
472
+ <show_in_website>1</show_in_website>
473
+ <show_in_store>1</show_in_store>
474
+ <frontend_model>simiconnector/adminhtml_system_config_form_field_separator</frontend_model>
475
+ <comment></comment>
476
+ </noti_new_order_separator>
477
+ <noti_purchase_enable translate="label">
478
+ <label>Send notification to a customer when he/she finish purchasing</label>
479
+ <frontend_type>select</frontend_type>
480
+ <sort_order>300</sort_order>
481
+ <source_model>adminhtml/system_config_source_yesno</source_model>
482
+ <show_in_default>1</show_in_default>
483
+ <show_in_website>1</show_in_website>
484
+ <show_in_store>1</show_in_store>
485
+ <comment></comment>
486
+ </noti_purchase_enable>
487
+ <noti_purchase_title translate="label">
488
+ <label>Title</label>
489
+ <frontend_type>text</frontend_type>
490
+ <sort_order>301</sort_order>
491
+ <source_model>adminhtml/system_config_source_yesno</source_model>
492
+ <show_in_default>1</show_in_default>
493
+ <show_in_website>1</show_in_website>
494
+ <show_in_store>1</show_in_store>
495
+ <depends>
496
+ <noti_purchase_enable>1</noti_purchase_enable>
497
+ </depends>
498
+ <comment></comment>
499
+ </noti_purchase_title>
500
+ <noti_purchase_message translate="label">
501
+ <label>Message</label>
502
+ <frontend_type>textarea</frontend_type>
503
+ <sort_order>302</sort_order>
504
+ <source_model>adminhtml/system_config_source_yesno</source_model>
505
+ <show_in_default>1</show_in_default>
506
+ <show_in_website>1</show_in_website>
507
+ <show_in_store>1</show_in_store>
508
+ <depends>
509
+ <noti_purchase_enable>1</noti_purchase_enable>
510
+ </depends>
511
+ <comment><![CDATA[Characters recommended: < 250]]></comment>
512
+ </noti_purchase_message>
513
+ <noti_purchase_type translate="label">
514
+ <label>Direct Viewers to</label>
515
+ <frontend_type>select</frontend_type>
516
+ <sort_order>303</sort_order>
517
+ <source_model>simiconnector/siminotification</source_model>
518
+ <show_in_default>1</show_in_default>
519
+ <show_in_website>1</show_in_website>
520
+ <show_in_store>1</show_in_store>
521
+ <depends>
522
+ <noti_purchase_enable>1</noti_purchase_enable>
523
+ </depends>
524
+ <comment></comment>
525
+ </noti_purchase_type>
526
+ <noti_purchase_product_id translate="label">
527
+ <label>Product ID</label>
528
+ <frontend_type>text</frontend_type>
529
+ <sort_order>304</sort_order>
530
+ <source_model>adminhtml/system_config_source_yesno</source_model>
531
+ <show_in_default>1</show_in_default>
532
+ <show_in_website>1</show_in_website>
533
+ <show_in_store>1</show_in_store>
534
+ <depends>
535
+ <noti_purchase_enable>1</noti_purchase_enable>
536
+ <noti_purchase_type>1</noti_purchase_type>
537
+ </depends>
538
+ <comment></comment>
539
+ </noti_purchase_product_id>
540
+ <noti_purchase_category_id translate="label">
541
+ <label>Category ID</label>
542
+ <frontend_type>text</frontend_type>
543
+ <sort_order>305</sort_order>
544
+ <source_model>adminhtml/system_config_source_yesno</source_model>
545
+ <show_in_default>1</show_in_default>
546
+ <show_in_website>1</show_in_website>
547
+ <show_in_store>1</show_in_store>
548
+ <depends>
549
+ <noti_purchase_enable>1</noti_purchase_enable>
550
+ <noti_purchase_type>2</noti_purchase_type>
551
+ </depends>
552
+ <comment></comment>
553
+ </noti_purchase_category_id>
554
+ <noti_purchase_url translate="label">
555
+ <label>URL</label>
556
+ <frontend_type>text</frontend_type>
557
+ <sort_order>306</sort_order>
558
+ <source_model>adminhtml/system_config_source_yesno</source_model>
559
+ <show_in_default>1</show_in_default>
560
+ <show_in_website>1</show_in_website>
561
+ <show_in_store>1</show_in_store>
562
+ <depends>
563
+ <noti_purchase_enable>1</noti_purchase_enable>
564
+ <noti_purchase_type>3</noti_purchase_type>
565
+ </depends>
566
+ <comment>Ex: https://simicart.com</comment>
567
+ </noti_purchase_url>
568
+ </fields>
569
+ </notification>
570
+ <hideaddress translate="label">
571
+ <label>Checkout Information Management</label>
572
+ <frontend_type>text</frontend_type>
573
+ <sort_order>299</sort_order>
574
+ <show_in_default>1</show_in_default>
575
+ <show_in_website>1</show_in_website>
576
+ <show_in_store>1</show_in_store>
577
+ <fields>
578
+ <hideaddress_enable translate="label">
579
+ <label>Enable</label>
580
+ <frontend_type>select</frontend_type>
581
+ <sort_order>1</sort_order>
582
+ <source_model>adminhtml/system_config_source_yesno</source_model>
583
+ <show_in_default>1</show_in_default>
584
+ <show_in_website>1</show_in_website>
585
+ <show_in_store>1</show_in_store>
586
+ <comment></comment>
587
+ </hideaddress_enable>
588
+ <company translate="label">
589
+ <label>Company</label>
590
+ <frontend_type>select</frontend_type>
591
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
592
+ <sort_order>4</sort_order>
593
+ <show_in_default>1</show_in_default>
594
+ <show_in_website>1</show_in_website>
595
+ <show_in_store>1</show_in_store>
596
+ <depends>
597
+ <hideaddress_enable>1</hideaddress_enable>
598
+ </depends>
599
+ </company>
600
+ <street translate="label">
601
+ <label>Address</label>
602
+ <frontend_type>select</frontend_type>
603
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
604
+ <sort_order>5</sort_order>
605
+ <show_in_default>1</show_in_default>
606
+ <show_in_website>1</show_in_website>
607
+ <show_in_store>1</show_in_store>
608
+ <depends>
609
+ <hideaddress_enable>1</hideaddress_enable>
610
+ </depends>
611
+ </street>
612
+ <street_default translate="label">
613
+ <label>Default Address Value</label>
614
+ <frontend_type>text</frontend_type>
615
+ <sort_order>6</sort_order>
616
+ <show_in_default>1</show_in_default>
617
+ <show_in_website>1</show_in_website>
618
+ <show_in_store>1</show_in_store>
619
+ <depends>
620
+ <hideaddress_enable>1</hideaddress_enable>
621
+ <street separator=",">2,3</street>
622
+ </depends>
623
+ <comment>Applied when Customers leave Address field blank</comment>
624
+ </street_default>
625
+ <country_id translate="label">
626
+ <label>Country</label>
627
+ <frontend_type>select</frontend_type>
628
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
629
+ <sort_order>7</sort_order>
630
+ <show_in_default>1</show_in_default>
631
+ <show_in_website>1</show_in_website>
632
+ <show_in_store>1</show_in_store>
633
+ <depends>
634
+ <hideaddress_enable>1</hideaddress_enable>
635
+ </depends>
636
+ </country_id>
637
+ <country_id_default translate="label">
638
+ <label>Default Country Value</label>
639
+ <frontend_type>text</frontend_type>
640
+ <sort_order>8</sort_order>
641
+ <show_in_default>1</show_in_default>
642
+ <show_in_website>1</show_in_website>
643
+ <show_in_store>1</show_in_store>
644
+ <depends>
645
+ <hideaddress_enable>1</hideaddress_enable>
646
+ <country_id separator=",">2,3</country_id>
647
+ </depends>
648
+ <comment>Applied when Customers leave Country field blank, use country ID, eg. US</comment>
649
+ </country_id_default>
650
+ <region_id translate="label">
651
+ <label>State/Province</label>
652
+ <frontend_type>select</frontend_type>
653
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
654
+ <sort_order>9</sort_order>
655
+ <show_in_default>1</show_in_default>
656
+ <show_in_website>1</show_in_website>
657
+ <show_in_store>1</show_in_store>
658
+ <depends>
659
+ <hideaddress_enable>1</hideaddress_enable>
660
+ </depends>
661
+ </region_id>
662
+ <region_id_default translate="label">
663
+ <label>Default State/Province Value</label>
664
+ <frontend_type>text</frontend_type>
665
+ <sort_order>10</sort_order>
666
+ <show_in_default>1</show_in_default>
667
+ <show_in_website>1</show_in_website>
668
+ <show_in_store>1</show_in_store>
669
+ <depends>
670
+ <hideaddress_enable>1</hideaddress_enable>
671
+ <region_id separator=",">2,3</region_id>
672
+ </depends>
673
+ <comment>Applied when Customers leave State/Province field blank, use region_id if State/Province is a option field. Eg. 1 for Alabama</comment>
674
+ </region_id_default>
675
+ <city translate="label">
676
+ <label>City</label>
677
+ <frontend_type>select</frontend_type>
678
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
679
+ <sort_order>11</sort_order>
680
+ <show_in_default>1</show_in_default>
681
+ <show_in_website>1</show_in_website>
682
+ <show_in_store>1</show_in_store>
683
+ <depends>
684
+ <hideaddress_enable>1</hideaddress_enable>
685
+ </depends>
686
+ </city>
687
+ <city_default translate="label">
688
+ <label>Default City Value</label>
689
+ <frontend_type>text</frontend_type>
690
+ <sort_order>12</sort_order>
691
+ <show_in_default>1</show_in_default>
692
+ <show_in_website>1</show_in_website>
693
+ <show_in_store>1</show_in_store>
694
+ <depends>
695
+ <hideaddress_enable>1</hideaddress_enable>
696
+ <city separator=",">2,3</city>
697
+ </depends>
698
+ <comment>Applied when Customers leave City field blank</comment>
699
+ </city_default>
700
+ <zipcode translate="label">
701
+ <label>Zip/Postal Code</label>
702
+ <frontend_type>select</frontend_type>
703
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
704
+ <sort_order>13</sort_order>
705
+ <show_in_default>1</show_in_default>
706
+ <show_in_website>1</show_in_website>
707
+ <show_in_store>1</show_in_store>
708
+ <depends>
709
+ <hideaddress_enable>1</hideaddress_enable>
710
+ </depends>
711
+ </zipcode>
712
+ <zipcode_default translate="label">
713
+ <label>Default Zip/Postal Code Value</label>
714
+ <frontend_type>text</frontend_type>
715
+ <sort_order>14</sort_order>
716
+ <show_in_default>1</show_in_default>
717
+ <show_in_website>1</show_in_website>
718
+ <show_in_store>1</show_in_store>
719
+ <depends>
720
+ <hideaddress_enable>1</hideaddress_enable>
721
+ <zipcode separator=",">2,3</zipcode>
722
+ </depends>
723
+ <comment>Applied when Customers leave Zip/Postal Code field blank</comment>
724
+ </zipcode_default>
725
+ <telephone translate="label">
726
+ <label>Telephone</label>
727
+ <frontend_type>select</frontend_type>
728
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
729
+ <sort_order>15</sort_order>
730
+ <show_in_default>1</show_in_default>
731
+ <show_in_website>1</show_in_website>
732
+ <show_in_store>1</show_in_store>
733
+ <depends>
734
+ <hideaddress_enable>1</hideaddress_enable>
735
+ </depends>
736
+ </telephone>
737
+ <telephone_default translate="label">
738
+ <label>Default Telephone Value</label>
739
+ <frontend_type>text</frontend_type>
740
+ <sort_order>16</sort_order>
741
+ <show_in_default>1</show_in_default>
742
+ <show_in_website>1</show_in_website>
743
+ <show_in_store>1</show_in_store>
744
+ <depends>
745
+ <hideaddress_enable>1</hideaddress_enable>
746
+ <telephone separator=",">2,3</telephone>
747
+ </depends>
748
+ <comment>Applied when Customers leave Telephone field blank</comment>
749
+ </telephone_default>
750
+ <fax translate="label">
751
+ <label>Fax</label>
752
+ <frontend_type>select</frontend_type>
753
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
754
+ <sort_order>17</sort_order>
755
+ <show_in_default>1</show_in_default>
756
+ <show_in_website>1</show_in_website>
757
+ <show_in_store>1</show_in_store>
758
+ <depends>
759
+ <hideaddress_enable>1</hideaddress_enable>
760
+ </depends>
761
+ </fax>
762
+ <prefix translate="label">
763
+ <label>Prefix Name</label>
764
+ <frontend_type>select</frontend_type>
765
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
766
+ <sort_order>18</sort_order>
767
+ <show_in_default>1</show_in_default>
768
+ <show_in_website>1</show_in_website>
769
+ <show_in_store>1</show_in_store>
770
+ <depends>
771
+ <hideaddress_enable>1</hideaddress_enable>
772
+ </depends>
773
+ </prefix>
774
+ <suffix translate="label">
775
+ <label>Suffix Name</label>
776
+ <frontend_type>select</frontend_type>
777
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
778
+ <sort_order>19</sort_order>
779
+ <show_in_default>1</show_in_default>
780
+ <show_in_website>1</show_in_website>
781
+ <show_in_store>1</show_in_store>
782
+ <depends>
783
+ <hideaddress_enable>1</hideaddress_enable>
784
+ </depends>
785
+ </suffix>
786
+ <dob translate="label">
787
+ <label>Date of Birth</label>
788
+ <frontend_type>select</frontend_type>
789
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
790
+ <sort_order>20</sort_order>
791
+ <show_in_default>1</show_in_default>
792
+ <show_in_website>1</show_in_website>
793
+ <show_in_store>1</show_in_store>
794
+ <depends>
795
+ <hideaddress_enable>1</hideaddress_enable>
796
+ </depends>
797
+ </dob>
798
+ <gender translate="label">
799
+ <label>Gender</label>
800
+ <frontend_type>select</frontend_type>
801
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
802
+ <sort_order>21</sort_order>
803
+ <show_in_default>1</show_in_default>
804
+ <show_in_website>1</show_in_website>
805
+ <show_in_store>1</show_in_store>
806
+ <depends>
807
+ <hideaddress_enable>1</hideaddress_enable>
808
+ </depends>
809
+ </gender>
810
+ <taxvat translate="label">
811
+ <label>Tax/VAT number</label>
812
+ <frontend_type>select</frontend_type>
813
+ <source_model>simiconnector/config_source_addressrequiretype</source_model>
814
+ <sort_order>22</sort_order>
815
+ <show_in_default>1</show_in_default>
816
+ <show_in_website>1</show_in_website>
817
+ <show_in_store>1</show_in_store>
818
+ <depends>
819
+ <hideaddress_enable>1</hideaddress_enable>
820
+ </depends>
821
+ </taxvat>
822
+ </fields>
823
+ </hideaddress>
824
+ <terms_conditions translate="label">
825
+ <label>Terms and Conditions</label>
826
+ <frontend_type>text</frontend_type>
827
+ <sort_order>399</sort_order>
828
+ <show_in_default>1</show_in_default>
829
+ <show_in_website>1</show_in_website>
830
+ <show_in_store>1</show_in_store>
831
+ <fields>
832
+ <enable_terms translate="label">
833
+ <label>Show Terms and Conditions</label>
834
+ <frontend_type>select</frontend_type>
835
+ <source_model>adminhtml/system_config_source_yesno</source_model>
836
+ <sort_order>10</sort_order>
837
+ <show_in_default>1</show_in_default>
838
+ <show_in_website>1</show_in_website>
839
+ <show_in_store>1</show_in_store>
840
+ </enable_terms>
841
+ <term_title translate="label">
842
+ <label>Terms and Conditions Title</label>
843
+ <frontend_type>text</frontend_type>
844
+ <sort_order>20</sort_order>
845
+ <show_in_default>1</show_in_default>
846
+ <show_in_website>1</show_in_website>
847
+ <show_in_store>1</show_in_store>
848
+ <depends>
849
+ <enable_terms>1</enable_terms>
850
+ </depends>
851
+ </term_title>
852
+ <term_html translate="label">
853
+ <label>Terms and Conditions Content (HTML)</label>
854
+ <frontend_type>textarea</frontend_type>
855
+ <sort_order>30</sort_order>
856
+ <show_in_default>1</show_in_default>
857
+ <show_in_website>1</show_in_website>
858
+ <show_in_store>1</show_in_store>
859
+ <depends>
860
+ <enable_terms>1</enable_terms>
861
+ </depends>
862
+ </term_html>
863
+ </fields>
864
+ </terms_conditions>
865
+ <instant_contact translate="label">
866
+ <label>Instant Contact Configuration</label>
867
+ <frontend_type>text</frontend_type>
868
+ <sort_order>499</sort_order>
869
+ <show_in_default>1</show_in_default>
870
+ <show_in_website>1</show_in_website>
871
+ <show_in_store>1</show_in_store>
872
+ <fields>
873
+ <enable translate="label">
874
+ <label>Enable</label>
875
+ <frontend_type>select</frontend_type>
876
+ <sort_order>1</sort_order>
877
+ <source_model>adminhtml/system_config_source_yesno</source_model>
878
+ <show_in_default>1</show_in_default>
879
+ <show_in_website>1</show_in_website>
880
+ <show_in_store>1</show_in_store>
881
+ <comment></comment>
882
+ </enable>
883
+ <email translate="label">
884
+ <label>Email</label>
885
+ <frontend_type>text</frontend_type>
886
+ <sort_order>5</sort_order>
887
+ <show_in_default>1</show_in_default>
888
+ <show_in_website>1</show_in_website>
889
+ <show_in_store>1</show_in_store>
890
+ <comment>Used to send email. Seperate emails with comma.</comment>
891
+ </email>
892
+ <phone translate="label">
893
+ <label>Phone Number</label>
894
+ <frontend_type>text</frontend_type>
895
+ <sort_order>10</sort_order>
896
+ <show_in_default>1</show_in_default>
897
+ <show_in_website>1</show_in_website>
898
+ <show_in_store>1</show_in_store>
899
+ <comment>Used to call. Seperate phone numbers with comma</comment>
900
+ </phone>
901
+ <message translate="label">
902
+ <label>Message Number</label>
903
+ <frontend_type>text</frontend_type>
904
+ <sort_order>15</sort_order>
905
+ <show_in_default>1</show_in_default>
906
+ <show_in_website>1</show_in_website>
907
+ <show_in_store>1</show_in_store>
908
+ <comment>Used to send message. Seperate phone numbers with comma</comment>
909
+ </message>
910
+ <website translate="label">
911
+ <label>Website Url</label>
912
+ <frontend_type>text</frontend_type>
913
+ <sort_order>20</sort_order>
914
+ <show_in_default>1</show_in_default>
915
+ <show_in_website>1</show_in_website>
916
+ <show_in_store>1</show_in_store>
917
+ <comment>Please enter the URL with http or https. For example: http://yourwebsite.com or https://yourwebsite.com</comment>
918
+ </website>
919
+ <style translate="label">
920
+ <label>Style</label>
921
+ <frontend_type>select</frontend_type>
922
+ <sort_order>25</sort_order>
923
+ <show_in_default>1</show_in_default>
924
+ <show_in_website>1</show_in_website>
925
+ <show_in_store>1</show_in_store>
926
+ <source_model>simiconnector/config_source_productsviewtype</source_model>
927
+ <comment></comment>
928
+ </style>
929
+ <icon_color>
930
+ <label>Icon Color</label>
931
+ <frontend_type>text</frontend_type>
932
+ <validate>color</validate> <!-- This is important -->
933
+ <sort_order>30</sort_order>
934
+ <show_in_default>1</show_in_default>
935
+ <show_in_website>1</show_in_website>
936
+ <show_in_store>1</show_in_store>
937
+ <comment>Select the color of contact icons displayed in Contact page of your app.</comment>
938
+ </icon_color>
939
+ </fields>
940
+ </instant_contact>
941
+ <barcode translate="label" module="simiconnector">
942
+ <label>Barcode Configuration</label>
943
+ <frontend_type>text</frontend_type>
944
+ <sort_order>599</sort_order>
945
+ <show_in_default>1</show_in_default>
946
+ <show_in_website>1</show_in_website>
947
+ <show_in_store>1</show_in_store>
948
+ <fields>
949
+ <pattern translate="label" module="simiconnector">
950
+ <label>Barcode pattern</label>
951
+ <frontend_type>text</frontend_type>
952
+ <sort_order>0</sort_order>
953
+ <show_in_default>1</show_in_default>
954
+ <show_in_website>1</show_in_website>
955
+ <show_in_store>1</show_in_store>
956
+ <comment><![CDATA[Enter the pattern you want to generate barcodes. For Example:<br/><strong>[A.8] : 8 alpha<br/>[N.4] : 4 numeric<br/>[AN.6] : 6 alphanumeric<br/>BAR[A.4][AN.6] : BARADFA12NF0O</strong>]]></comment>
957
+ </pattern>
958
+ <qrcode_pattern translate="label" module="simiconnector">
959
+ <label>QR code pattern</label>
960
+ <frontend_type>text</frontend_type>
961
+ <sort_order>99</sort_order>
962
+ <show_in_default>1</show_in_default>
963
+ <show_in_website>1</show_in_website>
964
+ <show_in_store>1</show_in_store>
965
+ <comment><![CDATA[Enter the pattern you want to generate QR codes. For Example:<br/><strong>[A.8] : 8 alpha<br/>[N.4] : 4 numeric<br/>[AN.6] : 6 alphanumeric<br/>QR[A.4][AN.6] : QRADFA12NF0O</strong>]]></comment>
966
+ </qrcode_pattern>
967
+ </fields>
968
+ </barcode>
969
+ <productlabel translate="label" module="simiconnector">
970
+ <label>Product Label Configuration</label>
971
+ <frontend_type>text</frontend_type>
972
+ <sort_order>699</sort_order>
973
+ <show_in_default>1</show_in_default>
974
+ <show_in_website>1</show_in_website>
975
+ <show_in_store>1</show_in_store>
976
+ <fields>
977
+ <enable translate="label">
978
+ <label>Enable</label>
979
+ <frontend_type>select</frontend_type>
980
+ <sort_order>1</sort_order>
981
+ <source_model>adminhtml/system_config_source_yesno</source_model>
982
+ <show_in_default>1</show_in_default>
983
+ <show_in_website>1</show_in_website>
984
+ <show_in_store>1</show_in_store>
985
+ <comment></comment>
986
+ </enable>
987
+ </fields>
988
+ </productlabel>
989
+ <wishlist translate="label">
990
+ <label>Wishlist Configuration</label>
991
+ <frontend_type>text</frontend_type>
992
+ <sort_order>799</sort_order>
993
+ <show_in_default>1</show_in_default>
994
+ <show_in_website>1</show_in_website>
995
+ <show_in_store>1</show_in_store>
996
+ <fields>
997
+ <sharing_message translate="label">
998
+ <label>Message For Sharing Wishlist</label>
999
+ <frontend_type>Textarea</frontend_type>
1000
+ <sort_order>2</sort_order>
1001
+ <show_in_default>1</show_in_default>
1002
+ <show_in_website>1</show_in_website>
1003
+ <show_in_store>1</show_in_store>
1004
+ <comment>The message is used when customers share their wishlist on Facebook, Twitter, Emails... It appears before Wishlist URL.</comment>
1005
+ </sharing_message>
1006
+ <product_sharing_message translate="label">
1007
+ <label>Message For Sharing Product</label>
1008
+ <frontend_type>Textarea</frontend_type>
1009
+ <sort_order>3</sort_order>
1010
+ <show_in_default>1</show_in_default>
1011
+ <show_in_website>1</show_in_website>
1012
+ <show_in_store>1</show_in_store>
1013
+ <comment>The message is used when customers share a product in their wishlist on Facebook, Twitter, Emails... It appears before the product URL.</comment>
1014
+ </product_sharing_message>
1015
+ </fields>
1016
+ </wishlist>
1017
+ <zopim translate="label">
1018
+ <label>Zopim Configuration</label>
1019
+ <frontend_type>text</frontend_type>
1020
+ <sort_order>899</sort_order>
1021
+ <show_in_default>1</show_in_default>
1022
+ <show_in_website>1</show_in_website>
1023
+ <show_in_store>1</show_in_store>
1024
+ <fields>
1025
+ <enable translate="label">
1026
+ <label>Enable</label>
1027
+ <frontend_type>select</frontend_type>
1028
+ <sort_order>1</sort_order>
1029
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1030
+ <show_in_default>1</show_in_default>
1031
+ <show_in_website>1</show_in_website>
1032
+ <show_in_store>1</show_in_store>
1033
+ <comment></comment>
1034
+ </enable>
1035
+ <account_key translate="label">
1036
+ <label>Account Key</label>
1037
+ <frontend_type>text</frontend_type>
1038
+ <sort_order>2</sort_order>
1039
+ <comment>Key get from zopim dashboard</comment>
1040
+ <show_in_default>1</show_in_default>
1041
+ <show_in_website>1</show_in_website>
1042
+ <show_in_store>1</show_in_store>
1043
+ </account_key>
1044
+ <show_profile translate="label">
1045
+ <label>Allow show profile</label>
1046
+ <frontend_type>select</frontend_type>
1047
+ <sort_order>4</sort_order>
1048
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1049
+ <show_in_default>1</show_in_default>
1050
+ <show_in_website>1</show_in_website>
1051
+ <show_in_store>1</show_in_store>
1052
+ <comment></comment>
1053
+ </show_profile>
1054
+ <name translate="label">
1055
+ <label>Name</label>
1056
+ <frontend_type>select</frontend_type>
1057
+ <source_model>simiconnector/config_source_showandhideoption</source_model>
1058
+ <sort_order>6</sort_order>
1059
+ <show_in_default>1</show_in_default>
1060
+ <show_in_website>1</show_in_website>
1061
+ <show_in_store>1</show_in_store>
1062
+ <depends>
1063
+ <show_profile>1</show_profile>
1064
+ </depends>
1065
+ </name>
1066
+ <email translate="label">
1067
+ <label>Email</label>
1068
+ <frontend_type>select</frontend_type>
1069
+ <source_model>simiconnector/config_source_showandhideoption</source_model>
1070
+ <sort_order>8</sort_order>
1071
+ <show_in_default>1</show_in_default>
1072
+ <show_in_website>1</show_in_website>
1073
+ <show_in_store>1</show_in_store>
1074
+ <depends>
1075
+ <show_profile>1</show_profile>
1076
+ </depends>
1077
+ </email>
1078
+ <phone translate="label">
1079
+ <label>Phone</label>
1080
+ <frontend_type>select</frontend_type>
1081
+ <source_model>simiconnector/config_source_showandhideoption</source_model>
1082
+ <sort_order>10</sort_order>
1083
+ <show_in_default>1</show_in_default>
1084
+ <show_in_website>1</show_in_website>
1085
+ <show_in_store>1</show_in_store>
1086
+ <depends>
1087
+ <show_profile>1</show_profile>
1088
+ </depends>
1089
+ </phone>
1090
+ </fields>
1091
+ </zopim>
1092
+ <mixpanel translate="label">
1093
+ <label>Mixpanel Configuration</label>
1094
+ <frontend_type>text</frontend_type>
1095
+ <sort_order>999</sort_order>
1096
+ <show_in_default>1</show_in_default>
1097
+ <show_in_website>1</show_in_website>
1098
+ <show_in_store>1</show_in_store>
1099
+ <fields>
1100
+ <token translate="label">
1101
+ <label>Mixpanel Token</label>
1102
+ <frontend_type>text</frontend_type>
1103
+ <sort_order>1</sort_order>
1104
+ <show_in_default>1</show_in_default>
1105
+ <show_in_website>1</show_in_website>
1106
+ <show_in_store>1</show_in_store>
1107
+ <comment>Leave this field blank to disable Mixpanel on Application</comment>
1108
+ </token>
1109
+ </fields>
1110
+ </mixpanel>
1111
+ </groups>
1112
+ </simiconnector>
1113
+ </sections>
1114
+ </config>
app/code/local/Simi/Simiconnector/sql/.DS_Store ADDED
Binary file
app/code/local/Simi/Simiconnector/sql/simiconnector_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_simicategory')};
8
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_banner')};
9
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_cms')};
10
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_device')};
11
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_notice')};
12
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_notice_history')};
13
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_product_list')};
14
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_visibility')};
15
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_simibarcode')};
16
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_videos')};
17
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_transactions')};
18
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_productlabels')};
19
+ DROP TABLE IF EXISTS {$installer->getTable('simiconnector_taskbar')};
20
+
21
+
22
+ CREATE TABLE {$installer->getTable('simiconnector_simicategory')} (
23
+ `simicategory_id` int(11) unsigned NOT NULL auto_increment,
24
+ `simicategory_name` varchar(255),
25
+ `simicategory_filename` varchar(255),
26
+ `simicategory_filename_tablet` varchar(255),
27
+ `category_id` int(8),
28
+ `status` smallint(6) NOT NULL default '0',
29
+ `website_id` int(6) default 0,
30
+ `storeview_id` varchar(255) NULL default '',
31
+ `sort_order` int(6) NULL default '0',
32
+ `matrix_width_percent` varchar(255) NULL default '100',
33
+ `matrix_height_percent` varchar(255) NULL default '30',
34
+ `matrix_width_percent_tablet` varchar(255) NULL default '100',
35
+ `matrix_height_percent_tablet` varchar(255) NULL default '30',
36
+ `matrix_row` varchar(255) NULL default '1',
37
+ PRIMARY KEY (`simicategory_id`)
38
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39
+
40
+ CREATE TABLE {$installer->getTable('simiconnector_banner')} (
41
+ `banner_id` int(11) unsigned NOT NULL auto_increment,
42
+ `banner_name` varchar(255) NULL,
43
+ `banner_url` varchar(255) NULL default '',
44
+ `banner_name_tablet` varchar(255) NULL default '',
45
+ `banner_title` varchar(255) NULL,
46
+ `status` int(11) NULL,
47
+ `website_id` smallint(5) NULL default 0,
48
+ `type` smallint(5) unsigned default 3,
49
+ `category_id` int(10) unsigned NOT NULL,
50
+ `product_id` int(10) unsigned NOT NULL,
51
+ `sort_order` int(6) NULL default '0',
52
+ PRIMARY KEY (`banner_id`)
53
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
54
+
55
+ CREATE TABLE {$installer->getTable('simiconnector_cms')} (
56
+ `cms_id` int(11) unsigned NOT NULL auto_increment,
57
+ `cms_title` varchar(255) NULL,
58
+ `cms_image` varchar(255) NULL default '',
59
+ `cms_content` text NULL default '',
60
+ `cms_status` tinyint(4) NOT NULL default '1',
61
+ `website_id` smallint(5) NULL default 0,
62
+ `type` smallint(5) unsigned default 3,
63
+ `category_id` int(10) unsigned NOT NULL,
64
+ `sort_order` int(6) NULL default '0',
65
+ PRIMARY KEY (`cms_id`)
66
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
67
+
68
+ CREATE TABLE {$installer->getTable('simiconnector_product_list')} (
69
+ `productlist_id` int(11) unsigned NOT NULL auto_increment,
70
+ `list_title` varchar(255) NULL,
71
+ `list_image` varchar(255) NULL default '',
72
+ `list_image_tablet` varchar(255) NULL default '',
73
+ `list_type` tinyint(4) NOT NULL default '1',
74
+ `list_products` text NULL default '',
75
+ `list_status` tinyint(4) NOT NULL default '1',
76
+ `sort_order` int(6) NULL default '0',
77
+ `matrix_width_percent` varchar(255) NULL default '100',
78
+ `matrix_height_percent` varchar(255) NULL default '30',
79
+ `matrix_width_percent_tablet` varchar(255) NULL default '100',
80
+ `matrix_height_percent_tablet` varchar(255) NULL default '30',
81
+ `matrix_row` varchar(255) NULL default '1',
82
+ PRIMARY KEY (`productlist_id`)
83
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
84
+
85
+ CREATE TABLE {$installer->getTable('simiconnector_visibility')} (
86
+ `entity_id` int(11) unsigned NOT NULL auto_increment,
87
+ `content_type` tinyint(4) NOT NULL default '0',
88
+ `item_id` int(10) NOT NULL default '0',
89
+ `store_view_id` varchar(255) NULL default '0',
90
+ PRIMARY KEY (`entity_id`)
91
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
92
+
93
+ CREATE TABLE {$installer->getTable('simiconnector_device')} (
94
+ `device_id` int(11) unsigned NOT NULL auto_increment,
95
+ `device_token` varchar(255) NOT NULL default '',
96
+ `plaform_id` int (11),
97
+ `storeview_id` int (11),
98
+ `latitude` varchar(30) NOT NULL default '',
99
+ `longitude` varchar(30) NOT NULL default '',
100
+ `address` varchar(255) NOT NULL default '',
101
+ `city` varchar(255) NOT NULL default '',
102
+ `country` varchar(255) NOT NULL default '',
103
+ `zipcode` varchar(25) NOT NULL default '',
104
+ `state` varchar(255) NOT NULL default '',
105
+ `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
106
+ `is_demo` tinyint(1) NULL default '3',
107
+ `user_email` varchar(255) NOT NULL default '',
108
+ `app_id` varchar(255) NOT NULL default '',
109
+ `build_version` varchar(255) NOT NULL default '',
110
+ `device_ip` varchar(255) NOT NULL default '',
111
+ `device_user_agent` varchar(255) NOT NULL default '',
112
+ `unseen_count` int (11),
113
+ PRIMARY KEY (`device_id`)
114
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
115
+
116
+ CREATE TABLE {$installer->getTable('simiconnector_notice')} (
117
+ `notice_id` int(11) unsigned NOT NULL auto_increment,
118
+ `notice_title` varchar(255) NULL default '',
119
+ `notice_url` varchar(255) NULL default '',
120
+ `notice_content` text NULL default '',
121
+ `notice_sanbox` tinyint(1) NULL default '0',
122
+ `storeview_id` int (11),
123
+ `device_id` int (11),
124
+ `type` smallint(5) unsigned,
125
+ `category_id` int(10) unsigned NOT NULL,
126
+ `product_id` int(10) unsigned NOT NULL,
127
+ `image_url` varchar(255) NOT NULL default'',
128
+ `location` varchar(255) NOT NULL default '',
129
+ `distance` varchar(255) NOT NULL default '',
130
+ `address` varchar(255) NOT NULL default '',
131
+ `city` varchar(255) NOT NULL default '',
132
+ `country` varchar(255) NOT NULL default '',
133
+ `zipcode` varchar(25) NOT NULL default '',
134
+ `state` varchar(255) NOT NULL default '',
135
+ `show_popup` smallint(5) unsigned NULL default 0,
136
+ `devices_pushed` text NULL default '',
137
+ `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
138
+ PRIMARY KEY (`notice_id`)
139
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
140
+
141
+ CREATE TABLE {$installer->getTable('simiconnector_notice_history')} (
142
+ `history_id` int(11) unsigned NOT NULL auto_increment,
143
+ `notice_title` varchar(255) NULL default '',
144
+ `notice_url` varchar(255) NULL default '',
145
+ `notice_content` text NULL default '',
146
+ `notice_sanbox` tinyint(1) NULL default '0',
147
+ `storeview_id` int (11),
148
+ `device_id` int (11),
149
+ `type` smallint(5) unsigned,
150
+ `category_id` int(10) unsigned NOT NULL,
151
+ `product_id` int(10) unsigned NOT NULL,
152
+ `image_url` varchar(255) NOT NULL default '',
153
+ `location` varchar(255) NOT NULL default '',
154
+ `distance` varchar(255) NOT NULL default '',
155
+ `address` varchar(255) NOT NULL default '',
156
+ `city` varchar(255) NOT NULL default '',
157
+ `country` varchar(255) NOT NULL default '',
158
+ `zipcode` varchar(25) NOT NULL default '',
159
+ `state` varchar(255) NOT NULL default '',
160
+ `show_popup` smallint(5) unsigned,
161
+ `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
162
+ `notice_type` smallint(5) unsigned,
163
+ `status` smallint(5) unsigned,
164
+ `devices_pushed` text NULL default '',
165
+ `notice_id` int NULL,
166
+ PRIMARY KEY (`history_id`)
167
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
168
+
169
+
170
+ CREATE TABLE {$installer->getTable('simiconnector_simibarcode')} (
171
+ `barcode_id` int(11) unsigned NOT NULL auto_increment,
172
+ `barcode` varchar(255) default '',
173
+ `qrcode` varchar(255) default '',
174
+ `barcode_status` tinyint(3) NOT NULL default '1',
175
+ `product_entity_id` int(11),
176
+ `product_name` varchar(255) default '',
177
+ `product_sku` varchar(255) default '',
178
+ `created_date` datetime,
179
+ UNIQUE (`barcode`),
180
+ UNIQUE (`qrcode`),
181
+ PRIMARY KEY (`barcode_id`)
182
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
183
+
184
+ CREATE TABLE {$installer->getTable('simiconnector_videos')} (
185
+ `video_id` int(11) unsigned NOT NULL auto_increment,
186
+ `video_url` varchar(255) NULL default '',
187
+ `video_key` varchar(255) NULL default '',
188
+ `video_title` varchar(255) NULL default '',
189
+ `product_ids` text NULL default '',
190
+ `storeview_id` int(6) default 0,
191
+ `status` int(11) NULL,
192
+ PRIMARY KEY (`video_id`)
193
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
194
+
195
+ CREATE TABLE {$installer->getTable('simiconnector_transactions')} (
196
+ `transaction_id` int(11) unsigned NOT NULL auto_increment,
197
+ `order_id` int(30),
198
+ PRIMARY KEY (`transaction_id`)
199
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
200
+
201
+ CREATE TABLE {$installer->getTable('simiconnector_productlabels')} (
202
+ `label_id` int(11) unsigned NOT NULL auto_increment,
203
+ `storeview_id` int(6) default 0,
204
+ `name` varchar(255) default '',
205
+ `description` text default '',
206
+ `status` smallint(6) NOT NULL default '2',
207
+ `product_ids` text NULL default '',
208
+ `from_date` datetime default NULL,
209
+ `to_date` datetime default NULL,
210
+ `priority` int(11) unsigned default '0',
211
+ `conditions_serialized` mediumtext default NULL,
212
+ `text` varchar(255) NOT NULL default '',
213
+ `image` varchar(255) NOT NULL default '',
214
+ `position` smallint(6) NOT NULL default '1',
215
+ `display` smallint(6) NOT NULL default '0',
216
+ `category_text` varchar(255) NOT NULL default '',
217
+ `category_image` varchar(255) NOT NULL default '',
218
+ `category_position` smallint(6) NOT NULL default '1',
219
+ `category_display` smallint(6) NOT NULL default '0',
220
+ `is_auto_fill` smallint(6) NOT NULL default '1',
221
+ `created_time` datetime NULL,
222
+ `update_time` datetime NULL,
223
+ `condition_selected` varchar(50) NOT NULL,
224
+ `threshold` int(11) unsigned default NULL,
225
+ PRIMARY KEY (`label_id`)
226
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
227
+
228
+ CREATE TABLE {$installer->getTable('simiconnector_taskbar')} (
229
+ `taskbar_id` int(11) unsigned NOT NULL auto_increment,
230
+ `storeview_id` int(6) default 0,
231
+ `taskbar_color` varchar(255) default '',
232
+ `icon_color` varchar(255) default '',
233
+ `item1_text` varchar(255) default '',
234
+ `item1_image` varchar(255) default '',
235
+ `item1_type` varchar(255) default '',
236
+ `item2_text` varchar(255) default '',
237
+ `item2_image` varchar(255) default '',
238
+ `item2_type` varchar(255) default '',
239
+ `item3_text` varchar(255) default '',
240
+ `item3_image` varchar(255) default '',
241
+ `item3_type` varchar(255) default '',
242
+ `item4_text` varchar(255) default '',
243
+ `item4_image` varchar(255) default '',
244
+ `item4_type` varchar(255) default '',
245
+ `item5_text` varchar(255) default '',
246
+ `item5_image` varchar(255) default '',
247
+ `item5_type` varchar(255) default '',
248
+ `item6_text` varchar(255) default '',
249
+ `item6_image` varchar(255) default '',
250
+ `item6_type` varchar(255) default '',
251
+
252
+ PRIMARY KEY (`taskbar_id`)
253
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
254
+ ");
255
+
256
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/simiconnector.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_simiconnector_appreport_index>
4
+ <reference name="content">
5
+ <block type="simiconnector/adminhtml_appreport" name="appreport" />
6
+ </reference>
7
+ </adminhtml_simiconnector_appreport_index>
8
+ <adminhtml_simiconnector_appreport_grid>
9
+ <block type="core/text_list" name="root" output="toHtml">
10
+ <block type="simiconnector/adminhtml_appreport_grid" name="appreport" />
11
+ </block>
12
+ </adminhtml_simiconnector_appreport_grid>
13
+ <adminhtml_simiconnector_simicategory_index>
14
+ <reference name="content">
15
+ <block type="simiconnector/adminhtml_simicategory" name="simicategory" />
16
+ <block type="simiconnector/adminhtml_simicategory" name="simicategory_more" template="simiconnector/render/category.phtml" />
17
+ </reference>
18
+ </adminhtml_simiconnector_simicategory_index>
19
+ <adminhtml_simiconnector_banner_index>
20
+ <reference name="content">
21
+ <block type="simiconnector/adminhtml_banner" name="simiconnector_banner"/>
22
+ <block type="simiconnector/adminhtml_banner" name="simiconnector_banner_more" template="simiconnector/render/category.phtml" />
23
+ </reference>
24
+ </adminhtml_simiconnector_banner_index>
25
+ <adminhtml_simiconnector_cms_index>
26
+ <reference name="content">
27
+ <block type="simiconnector/adminhtml_cms" name="simiconnector_cms"/>
28
+ </reference>
29
+ </adminhtml_simiconnector_cms_index>
30
+ <adminhtml_simiconnector_productlist_index>
31
+ <reference name="content">
32
+ <block type="simiconnector/adminhtml_productlist" name="simiconnector_productlist"/>
33
+ <block type="simiconnector/adminhtml_productlist" name="simiconnector_productlist_more" template="simiconnector/render/category.phtml" />
34
+ </reference>
35
+ </adminhtml_simiconnector_productlist_index>
36
+ <adminhtml_simiconnector_cms_edit>
37
+ <reference name="head">
38
+ <action method="setCanLoadTinyMce">
39
+ <flag>1</flag>
40
+ </action>
41
+ <action method="addJs">
42
+ <script>mage/adminhtml/variables.js</script>
43
+ </action>
44
+ <action method="addJs">
45
+ <script>mage/adminhtml/wysiwyg/widget.js</script>
46
+ </action>
47
+ <action method="addJs">
48
+ <script>lib/flex.js</script>
49
+ </action>
50
+ <action method="addJs">
51
+ <script>lib/FABridge.js</script>
52
+ </action>
53
+ <action method="addJs">
54
+ <script>mage/adminhtml/flexuploader.js</script>
55
+ </action>
56
+ <action method="addJs">
57
+ <script>mage/adminhtml/browser.js</script>
58
+ </action>
59
+ <action method="addJs">
60
+ <script>prototype/window.js</script>
61
+ </action>
62
+ <action method="addItem">
63
+ <type>js_css</type>
64
+ <name>prototype/windows/themes/default.css</name>
65
+ </action>
66
+ <action method="addItem">
67
+ <type>skin_css</type>
68
+ <name>lib/prototype/windows/themes/magento.css</name>
69
+ </action>
70
+ <action method="addItem">
71
+ <type>js</type>
72
+ <name>mage/adminhtml/wysiwyg/tiny_mce/setup.js</name>
73
+ <params/>
74
+ </action>
75
+ <action method="addItem">
76
+ <type>js</type>
77
+ <name>tiny_mce/tiny_mce.js</name>
78
+ <params/>
79
+ </action>
80
+ </reference>
81
+ </adminhtml_simiconnector_cms_edit>
82
+ <adminhtml_simiconnector_siminotification_index>
83
+ <reference name="content">
84
+ <block type="simiconnector/adminhtml_siminotification" name="siminotification" />
85
+ </reference>
86
+ </adminhtml_simiconnector_siminotification_index>
87
+
88
+ <adminhtml_simiconnector_device_index>
89
+ <reference name="content">
90
+ <block type="simiconnector/adminhtml_device" name="device" />
91
+ </reference>
92
+ </adminhtml_simiconnector_device_index>
93
+
94
+ <adminhtml_simiconnector_history_index>
95
+ <reference name="content">
96
+ <block type="simiconnector/adminhtml_history" name="history" />
97
+ </reference>
98
+ </adminhtml_simiconnector_history_index>
99
+
100
+ <adminhtml_simiconnector_siminotification_guide>
101
+ <reference name="content">
102
+ <block type="simiconnector/adminhtml_siminotification" name="siminotification_guide" as="siminotification_guide" template="simiconnector/siminotification/guide.phtml" />
103
+ </reference>
104
+ </adminhtml_simiconnector_siminotification_guide>
105
+
106
+ <adminhtml_simiconnector_simibarcode_index>
107
+ <reference name="content">
108
+ <block type="simiconnector/adminhtml_simibarcode" name="simibarcode" />
109
+ </reference>
110
+ </adminhtml_simiconnector_simibarcode_index>
111
+ <adminhtml_simiconnector_simibarcode_products>
112
+ <block type="core/text_list" name="root">
113
+ <block type="simiconnector/adminhtml_simibarcode_edit_tab_products" name="barcode.edit.tab.products"/>
114
+ <block type="adminhtml/widget_grid_serializer" name="related_grid_serializer">
115
+ <action method="initSerializerBlock">
116
+ <grid_block_name>barcode.edit.tab.products</grid_block_name>
117
+ <data_callback>getSelectedProducts</data_callback>
118
+ <hidden_input_name>barcode_products</hidden_input_name>
119
+ <reload_param_name>barcode_products</reload_param_name>
120
+ </action>
121
+ </block>
122
+ </block>
123
+ </adminhtml_simiconnector_simibarcode_products>
124
+ <adminhtml_simiconnector_simibarcode_productsgrid>
125
+ <block type="core/text_list" name="root">
126
+ <block type="simiconnector/adminhtml_simibarcode_edit_tab_products" name="barcode.edit.tab.products"/>
127
+ </block>
128
+ </adminhtml_simiconnector_simibarcode_productsgrid>
129
+ <adminhtml_simiconnector_simivideo_index>
130
+ <reference name="content">
131
+ <block type="simiconnector/adminhtml_simivideo" name="simivideo" />
132
+ </reference>
133
+ </adminhtml_simiconnector_simivideo_index>
134
+
135
+ <adminhtml_simiconnector_simiproductlabel_index>
136
+ <reference name="content">
137
+ <block type="simiconnector/adminhtml_simiproductlabel" name="simiproductlabel" />
138
+ </reference>
139
+ </adminhtml_simiconnector_simiproductlabel_index>
140
+
141
+ <adminhtml_system_config_edit>
142
+ <reference name="head">
143
+ <action method="setCanLoadExtJs">
144
+ <flag>1</flag>
145
+ <file>jscolorsimi/jscolor.js</file>
146
+ </action>
147
+ </reference>
148
+ </adminhtml_system_config_edit>
149
+
150
+ <adminhtml_system_config_edit>
151
+ <reference name="head">
152
+ <action method="addJs">
153
+ <file>jscolorsimi/jscolor.js</file>
154
+ </action>
155
+ </reference>
156
+ </adminhtml_system_config_edit>
157
+ </layout>
app/design/adminhtml/default/default/template/simiconnector/banner/categories.phtml ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+
16
+ <?php $_divId = 'main_tree-div_' . time() ?>
17
+ <div id="<?php echo $_divId ?>" class="tree"></div>
18
+ <script type="text/javascript">
19
+ //<![CDATA[
20
+
21
+ // TODO: cleanup this script. It was copypasted from catalog/category/tree
22
+
23
+ var tree;
24
+
25
+ /**
26
+ * Fix ext compatibility with prototype 1.6
27
+ */
28
+ Ext.lib.Event.getTarget = function(e) {
29
+ var ee = e.browserEvent || e;
30
+ return ee.target ? Event.element(ee) : null;
31
+ };
32
+
33
+ Ext.tree.TreePanel.Enhanced = function(el, config)
34
+ {
35
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
36
+ };
37
+
38
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
39
+
40
+ loadTree : function(config, firstLoad)
41
+ {
42
+ var parameters = config['parameters'];
43
+ var data = config['data'];
44
+
45
+ if ((typeof parameters['root_visible']) != 'undefined') {
46
+ this.rootVisible = parameters['root_visible']*1;
47
+ }
48
+
49
+ var root = new Ext.tree.TreeNode(parameters);
50
+
51
+ this.nodeHash = {};
52
+ this.setRootNode(root);
53
+
54
+ if (firstLoad) {
55
+ this.addListener('click', this.categoryClick.createDelegate(this));
56
+ }
57
+
58
+ this.loader.buildCategoryTree(root, data);
59
+ this.el.dom.innerHTML = '';
60
+ // render the tree
61
+ this.render();
62
+ },
63
+
64
+ categoryClick : function(node, e)
65
+ {
66
+ node.getUI().check(!node.getUI().checked());
67
+ }
68
+ });
69
+
70
+ Ext.onReady(function()
71
+ {
72
+ var categoryLoader = new Ext.tree.TreeLoader({
73
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
74
+ });
75
+
76
+ categoryLoader.createNode = function(config) {
77
+ config.uiProvider = Ext.tree.CheckboxNodeUI;
78
+ var node;
79
+ var _node = Object.clone(config);
80
+ if (config.children && !config.children.length) {
81
+ delete(config.children);
82
+ node = new Ext.tree.AsyncTreeNode(config);
83
+ } else {
84
+ node = new Ext.tree.TreeNode(config);
85
+ }
86
+
87
+ return node;
88
+ };
89
+
90
+ categoryLoader.buildCategoryTree = function(parent, config)
91
+ {
92
+ if (!config) return null;
93
+
94
+ if (parent && config && config.length){
95
+ for (var i = 0; i < config.length; i++) {
96
+ config[i].uiProvider = Ext.tree.CheckboxNodeUI;
97
+ var node;
98
+ var _node = Object.clone(config[i]);
99
+ if (_node.children && !_node.children.length) {
100
+ delete(_node.children);
101
+ node = new Ext.tree.AsyncTreeNode(_node);
102
+ } else {
103
+ node = new Ext.tree.TreeNode(config[i]);
104
+ }
105
+ parent.appendChild(node);
106
+ node.loader = node.getOwnerTree().loader;
107
+ if (_node.children) {
108
+ this.buildCategoryTree(node, _node.children);
109
+ }
110
+ }
111
+ }
112
+ };
113
+
114
+ categoryLoader.buildHash = function(node)
115
+ {
116
+ var hash = {};
117
+
118
+ hash = this.toArray(node.attributes);
119
+
120
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
121
+ hash['children'] = new Array;
122
+
123
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
124
+ if (!hash['children']) {
125
+ hash['children'] = new Array;
126
+ }
127
+ hash['children'].push(this.buildHash(node.childNodes[i]));
128
+ }
129
+ }
130
+
131
+ return hash;
132
+ };
133
+
134
+ categoryLoader.toArray = function(attributes) {
135
+ var data = {};
136
+ for (var key in attributes) {
137
+ var value = attributes[key];
138
+ data[key] = value;
139
+ }
140
+
141
+ return data;
142
+ };
143
+
144
+ categoryLoader.on("beforeload", function(treeLoader, node) {
145
+ treeLoader.baseParams.id = node.attributes.id;
146
+ });
147
+
148
+ categoryLoader.on("load", function(treeLoader, node, config) {
149
+ varienWindowOnload();
150
+ });
151
+
152
+ tree = new Ext.tree.TreePanel.Enhanced('<?php echo $_divId ?>', {
153
+ animate: false,
154
+ loader: categoryLoader,
155
+ enableDD: false,
156
+ containerScroll: true,
157
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
158
+ rootVisible: '<?php echo $this->getRoot()->getIsVisible() ?>',
159
+ useAjax: <?php echo $this->getUseAjax() ?>,
160
+ currentNodeId: <?php echo (int) $this->getCategoryId() ?>,
161
+ addNodeTo: false,
162
+ rootUIProvider: Ext.tree.CheckboxNodeUI
163
+ });
164
+
165
+ tree.on('check', function(node, checked) {
166
+ if(checked){
167
+ var checkValue = String(node);
168
+ checkValue = checkValue.substring(6, checkValue.length-1);
169
+ $('category_id').value = checkValue;
170
+ varienElementMethods.setHasChanges(node.getUI().checkbox);
171
+ var categorylist = document.getElementsByClassName("l-tcb");
172
+ var i;
173
+ for (i = 0; i < categorylist.length; i++) {
174
+ var categoryId = String(categorylist[i].getAttribute("id"));
175
+ if(categoryId != node.getUI().checkbox.getAttribute("id")){
176
+ categorylist[i].checked = false;
177
+ }
178
+ }
179
+ }
180
+ }, tree);
181
+
182
+ // set the root node
183
+ var parameters = {
184
+ text: '<?php echo htmlentities($this->getRoot()->getName()) ?>',
185
+ draggable: false,
186
+ checked:'<?php echo $this->getRoot()->getChecked() ?>',
187
+ uiProvider: Ext.tree.CheckboxNodeUI,
188
+ allowDrop: <?php if ($this->getRoot()->getIsVisible()): ?>true<?php else : ?>false<?php endif; ?>,
189
+ id: <?php echo (int) $this->getRoot()->getId() ?>,
190
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
191
+ category_id: <?php echo (int) $this->getCategoryId() ?>
192
+ };
193
+
194
+ tree.loadTree({parameters:parameters, data:<?php echo $this->getTreeJson() ?>},true);
195
+
196
+ });
197
+ //]]>
198
+ </script>
app/design/adminhtml/default/default/template/simiconnector/banner/grid.phtml ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+ <?php
16
+ /**
17
+ * Template for Mage_Adminhtml_Block_Widget_Grid
18
+ *
19
+ * getId()
20
+ * getCollection()
21
+ * getColumns()
22
+ * getPagerVisibility()
23
+ * getVarNamePage()
24
+ */
25
+ $numColumns = sizeof($this->getColumns());
26
+ ?>
27
+ <?php if ($this->getCollection()): ?>
28
+ <?php if ($this->canDisplayContainer()): ?>
29
+ <?php if ($this->getGridHeader()): ?>
30
+ <div class="content-header">
31
+ <table cellspacing="0">
32
+ <tr>
33
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
34
+ </tr>
35
+ </table>
36
+ </div>
37
+ <?php endif ?>
38
+
39
+ <div id="<?php echo $this->getId() ?>">
40
+ <?php else: ?>
41
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
42
+ <?php endif; ?>
43
+ <?php if ($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
44
+ <table cellspacing="0" class="actions">
45
+ <tr>
46
+ <?php if ($this->getPagerVisibility()): ?>
47
+ <td class="pager">
48
+ <?php echo $this->__('Page') ?>
49
+
50
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
51
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
52
+ <?php if ($_curPage > 1): ?>
53
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage - 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
54
+ <?php else: ?>
55
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
56
+ <?php endif; ?>
57
+
58
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
59
+
60
+ <?php if ($_curPage < $_lastPage): ?>
61
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage + 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
62
+ <?php else: ?>
63
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
64
+ <?php endif; ?>
65
+
66
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
67
+ <span class="separator">|</span>
68
+ <?php echo $this->__('View') ?>
69
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
70
+ <option value="20"<?php if ($this->getCollection()->getPageSize() == 20): ?> selected="selected"<?php endif; ?>>20</option>
71
+ <option value="30"<?php if ($this->getCollection()->getPageSize() == 30): ?> selected="selected"<?php endif; ?>>30</option>
72
+ <option value="50"<?php if ($this->getCollection()->getPageSize() == 50): ?> selected="selected"<?php endif; ?>>50</option>
73
+ <option value="100"<?php if ($this->getCollection()->getPageSize() == 100): ?> selected="selected"<?php endif; ?>>100</option>
74
+ <option value="200"<?php if ($this->getCollection()->getPageSize() == 200): ?> selected="selected"<?php endif; ?>>200</option>
75
+ </select>
76
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
77
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
78
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
79
+ <?php if ($this->getRssLists()): ?>
80
+ <?php foreach ($this->getRssLists() as $_rss): ?>
81
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
82
+ <?php endforeach ?>
83
+ <?php endif; ?>
84
+ </td>
85
+ <?php endif ?>
86
+ <?php if ($this->getExportTypes()): ?>
87
+ <td class="export a-right">
88
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
89
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
90
+ <?php foreach ($this->getExportTypes() as $_type): ?>
91
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
92
+ <?php endforeach; ?>
93
+ </select>
94
+ <?php echo $this->getExportButtonHtml() ?>
95
+ </td>
96
+ <?php endif; ?>
97
+ <td class="filter-actions a-right">
98
+ <?php echo $this->getMainButtonsHtml() ?>
99
+ </td>
100
+ </tr>
101
+ </table>
102
+ <?php endif; ?>
103
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
104
+ <?php echo $this->getMassactionBlockHtml() ?>
105
+ <?php endif ?>
106
+ <div class="grid">
107
+ <div class="hor-scroll">
108
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
109
+ <?php foreach ($this->getColumns() as $_column): ?>
110
+ <col <?php echo $_column->getHtmlProperty() ?> />
111
+ <?php endforeach; ?>
112
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
113
+ <thead>
114
+ <?php if ($this->getHeadersVisibility()): ?>
115
+ <tr class="headings">
116
+ <?php foreach ($this->getColumns() as $_column): ?>
117
+ <?php if ($_column->getId() == 'in_products'): ?>
118
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"></span></th>
119
+ <?php else: ?>
120
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
121
+ <?php endif; ?>
122
+ <?php endforeach; ?>
123
+ </tr>
124
+ <?php endif; ?>
125
+ <?php if ($this->getFilterVisibility()): ?>
126
+ <tr class="filter">
127
+ <?php $i = 0;
128
+ foreach ($this->getColumns() as $_column): ?>
129
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
130
+ <?php endforeach; ?>
131
+ </tr>
132
+ <?php endif ?>
133
+ </thead>
134
+ <?php endif; ?>
135
+ <?php if ($this->getCountTotals()): ?>
136
+ <tfoot>
137
+ <tr class="totals">
138
+ <?php foreach ($this->getColumns() as $_column): ?>
139
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
140
+ <?php endforeach; ?>
141
+ </tr>
142
+ </tfoot>
143
+ <?php endif; ?>
144
+
145
+ <tbody>
146
+ <?php if (($this->getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?>
147
+ <?php foreach ($this->getCollection() as $_index => $_item): ?>
148
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)): ?> class="<?php echo $_class; ?>"<?php endif; ?> >
149
+ <?php $i = 0;
150
+ foreach ($this->getColumns() as $_column): ?>
151
+
152
+ <?php if ($this->shouldRenderCell($_item, $_column)): ?>
153
+ <?php $_rowspan = $this->getRowspan($_item, $_column); ?>
154
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
155
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
156
+ </td>
157
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)): ?>
158
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item) ?>" class="last"><?php echo $this->getEmptyCellLabel() ?></td>
159
+ <?php endif; ?>
160
+ <?php endif; ?>
161
+
162
+ <?php endforeach; ?>
163
+ </tr>
164
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)): ?>
165
+ <?php foreach ($_multipleRows as $_i): ?>
166
+ <tr>
167
+ <?php $i = 0;
168
+ foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
169
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns - 1 ? 'last' : '' ?>">
170
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
171
+ </td>
172
+ <?php endforeach; ?>
173
+ </tr>
174
+ <?php endforeach; ?>
175
+ <?php endif; ?>
176
+
177
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
178
+ <tr class="subtotals">
179
+ <?php $i = 0;
180
+ foreach ($this->getSubTotalColumns() as $_column): ?>
181
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
182
+ <?php
183
+ echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
184
+ $_column->getRowField($this->getSubTotalItem($_item))
185
+ );
186
+ ?>
187
+ </td>
188
+ <?php endforeach; ?>
189
+ </tr>
190
+ <?php endif; ?>
191
+ <?php endforeach; ?>
192
+ <?php elseif ($this->getEmptyText()): ?>
193
+ <tr>
194
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
195
+ </tr>
196
+ <?php endif; ?>
197
+ </tbody>
198
+
199
+ </table>
200
+ </div>
201
+ </div>
202
+ <?php if ($this->canDisplayContainer()): ?>
203
+ </div>
204
+ <script type="text/javascript">
205
+ //<![CDATA[
206
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
207
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
208
+ <?php if ($this->getRowClickCallback()): ?>
209
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
210
+ <?php endif; ?>
211
+ <?php if ($this->getCheckboxCheckCallback()): ?>
212
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
213
+ <?php endif; ?>
214
+ <?php if ($this->getRowInitCallback()): ?>
215
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
216
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
217
+ <?php endif; ?>
218
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
219
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
220
+ <?php endif ?>
221
+ <?php echo $this->getAdditionalJavaScript(); ?>
222
+ //]]>
223
+ </script>
224
+ <?php endif; ?>
225
+ <?php
226
+ endif ?>
app/design/adminhtml/default/default/template/simiconnector/categories.phtml ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Connector
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+ <div class="entry-edit">
16
+ <div class="entry-edit-head">
17
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('simiconnector')->__('Categories displayed on App') ?></h4>
18
+ </div>
19
+ <fieldset id="grop_fields">
20
+ <input type="hidden" name="category_ids" id="product_categories" value="<?php echo $this->getIdsString() ?>">
21
+ <div id="product-categories" class="tree"></div>
22
+ </fieldset>
23
+ <input type="hidden" name="groups[general][fields][categories_in_app][value]" value="<?php echo $this->getIdsString() ?>" id="all_id">
24
+ </div>
25
+ <?php if($this->getRootNode() && $this->getRootNode()->hasChildren()): ?>
26
+ <script type="text/javascript">
27
+ Ext.EventManager.onDocumentReady(function() {
28
+ var categoryLoader = new Ext.tree.TreeLoader({
29
+ dataUrl: '<?php echo $this->getLoadTreeUrl()?>'
30
+ });
31
+
32
+ categoryLoader.createNode = function(config) {
33
+ config.uiProvider = Ext.tree.CheckboxNodeUI;
34
+ var node;
35
+ if (config.children && !config.children.length) {
36
+ delete(config.children);
37
+ node = new Ext.tree.AsyncTreeNode(config);
38
+
39
+ } else {
40
+ node = new Ext.tree.TreeNode(config);
41
+ }
42
+ return node;
43
+ };
44
+
45
+ categoryLoader.on("beforeload", function(treeLoader, node) {
46
+ treeLoader.baseParams.category = node.attributes.id;
47
+ });
48
+
49
+ categoryLoader.on("load", function(treeLoader, node, config) {
50
+ varienWindowOnload();
51
+ });
52
+
53
+ var tree = new Ext.tree.TreePanel('product-categories', {
54
+ animate:true,
55
+ loader: categoryLoader,
56
+ enableDD:false,
57
+ containerScroll: true,
58
+ rootUIProvider: Ext.tree.CheckboxNodeUI,
59
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
60
+ rootVisible: '<?php echo $this->getRootNode()->getIsVisible() ?>'
61
+ });
62
+
63
+ tree.on('check', checkHandle, tree);
64
+
65
+ function checkHandle(node){
66
+ setState(node);
67
+ varienElementMethods.setHasChanges(node.getUI().checkbox);
68
+ if (!node.isLeaf() && node.hasChildNodes()){
69
+ processChildren(node, node.attributes.checked);
70
+ }
71
+ }
72
+
73
+ function setState(node){
74
+ if(node.attributes.checked) {
75
+ categoryAdd(node.id);
76
+ } else {
77
+ categoryRemove(node.id);
78
+ }
79
+ }
80
+
81
+ function processChildren(node, state)
82
+ {
83
+ if ( !node.hasChildNodes() ) return false;
84
+ for(var i = 0; i < node.childNodes.length; i++ ) {
85
+ node.childNodes[i].ui.check(state);
86
+ setState(node.childNodes[i]);
87
+ if ( node.childNodes[i].hasChildNodes() ) {
88
+ processChildren(node.childNodes[i], state);
89
+ }
90
+ }
91
+ return true;
92
+ }
93
+
94
+ // set the root node
95
+ var root = new Ext.tree.TreeNode({
96
+ text: '<?php echo $this->jsQuoteEscape($this->getRootNode()->getName()) ?>',
97
+ draggable:false,
98
+ checked:'<?php echo $this->getRootNode()->getChecked() ?>',
99
+ id:'<?php echo $this->getRootNode()->getId() ?>',
100
+ disabled: <?php echo ($this->getRootNode()->getDisabled() ? 'true' : 'false') ?>,
101
+ uiProvider: Ext.tree.CheckboxNodeUI
102
+ });
103
+
104
+ tree.setRootNode(root);
105
+ bildCategoryTree(root, <?php echo $this->getTreeJson() ?>);
106
+ tree.addListener('click', categoryClick.createDelegate(this));
107
+
108
+ // render the tree
109
+ tree.render();
110
+ root.expand();
111
+ //tree.expandAll();
112
+ });
113
+
114
+ function bildCategoryTree(parent, config){
115
+ if (!config) return null;
116
+
117
+ if (parent && config && config.length){
118
+ for (var i = 0; i < config.length; i++){
119
+ config[i].uiProvider = Ext.tree.CheckboxNodeUI;
120
+ var node;
121
+ var _node = Object.clone(config[i]);
122
+ if (_node.children && !_node.children.length) {
123
+ delete(_node.children);
124
+ node = new Ext.tree.AsyncTreeNode(_node);
125
+
126
+ } else {
127
+ node = new Ext.tree.TreeNode(config[i]);
128
+ }
129
+ parent.appendChild(node);
130
+ node.loader = node.getOwnerTree().loader;
131
+ if(config[i].children){
132
+ bildCategoryTree(node, config[i].children);
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ function categoryClick(node, e){
139
+ if (node.disabled) {
140
+ return;
141
+ }
142
+ node.getUI().check(!node.getUI().checked());
143
+ varienElementMethods.setHasChanges(Event.element(e), e);
144
+ };
145
+ function categoryAdd(id) {
146
+ var ids = $('product_categories').value.split(',');
147
+ ids.push(id);
148
+ $('product_categories').value = ids.join(',');
149
+
150
+ var all_ids=$('product_categories').value.split(',');
151
+ var uniqueArray = all_ids.filter(function(item, pos) {
152
+ return all_ids.indexOf(item) == pos;
153
+ });
154
+
155
+ $('all_id').value = uniqueArray.join(',');
156
+ }
157
+ function categoryRemove(id) {
158
+ var ids = $('product_categories').value.split(',');
159
+ // bug #7654 fixed
160
+ while (-1 != ids.indexOf(id)) {
161
+ ids.splice(ids.indexOf(id), 1);
162
+ }
163
+ $('product_categories').value = ids.join(',');
164
+
165
+ //remove duplicate value
166
+ var all_ids=$('product_categories').value.split(',');
167
+ var uniqueArray = all_ids.filter(function(item, pos) {
168
+ return all_ids.indexOf(item) == pos;
169
+ });
170
+
171
+ $('all_id').value = uniqueArray.join(',');
172
+ }
173
+ </script>
174
+ <?php endif; ?>
app/design/adminhtml/default/default/template/simiconnector/productlist/grid.phtml ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ */
5
+ $numColumns = sizeof($this->getColumns());
6
+ ?>
7
+ <?php if ($this->getCollection()): ?>
8
+ <?php if ($this->canDisplayContainer()): ?>
9
+ <?php if ($this->getGridHeader()): ?>
10
+ <div class="content-header">
11
+ <table cellspacing="0">
12
+ <tr>
13
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
14
+ </tr>
15
+ </table>
16
+ </div>
17
+ <?php endif ?>
18
+
19
+ <div id="<?php echo $this->getId() ?>">
20
+ <?php else: ?>
21
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
22
+ <?php endif; ?>
23
+ <?php if ($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
24
+ <table cellspacing="0" class="actions">
25
+ <tr>
26
+ <?php if ($this->getPagerVisibility()): ?>
27
+ <td class="pager">
28
+ <a href="#" onclick="toogleCheckAllProduct(true)"><?php echo $this->__('Select All') ?></a>
29
+ <span class="separator">|</span>
30
+ <a href="#" onclick="toogleCheckAllProduct(false)"><?php echo $this->__('Unselect All') ?></a>
31
+ <span class="separator">|</span>
32
+ <?php echo $this->__('Page') ?>
33
+
34
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
35
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
36
+ <?php if ($_curPage > 1): ?>
37
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage - 1) ?>'); return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
38
+ <?php else: ?>
39
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
40
+ <?php endif; ?>
41
+
42
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
43
+
44
+ <?php if ($_curPage < $_lastPage): ?>
45
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage + 1) ?>'); return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
46
+ <?php else: ?>
47
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
48
+ <?php endif; ?>
49
+
50
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
51
+ <span class="separator">|</span>
52
+ <?php echo $this->__('View') ?>
53
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
54
+ <option value="20"<?php if ($this->getCollection()->getPageSize() == 20): ?> selected="selected"<?php endif; ?>>20</option>
55
+ <option value="30"<?php if ($this->getCollection()->getPageSize() == 30): ?> selected="selected"<?php endif; ?>>30</option>
56
+ <option value="50"<?php if ($this->getCollection()->getPageSize() == 50): ?> selected="selected"<?php endif; ?>>50</option>
57
+ <option value="100"<?php if ($this->getCollection()->getPageSize() == 100): ?> selected="selected"<?php endif; ?>>100</option>
58
+ <option value="200"<?php if ($this->getCollection()->getPageSize() == 200): ?> selected="selected"<?php endif; ?>>200</option>
59
+ </select>
60
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
61
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
62
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
63
+ <?php if ($this->getRssLists()): ?>
64
+ <?php foreach ($this->getRssLists() as $_rss): ?>
65
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
66
+ <?php endforeach ?>
67
+ <?php endif; ?>
68
+ </td>
69
+ <?php endif ?>
70
+ <?php if ($this->getExportTypes()): ?>
71
+ <td class="export a-right">
72
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
73
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
74
+ <?php foreach ($this->getExportTypes() as $_type): ?>
75
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
76
+ <?php endforeach; ?>
77
+ </select>
78
+ <?php echo $this->getExportButtonHtml() ?>
79
+ </td>
80
+ <?php endif; ?>
81
+ <td class="filter-actions a-right">
82
+ <?php echo $this->getMainButtonsHtml() ?>
83
+ </td>
84
+ </tr>
85
+ </table>
86
+ <?php endif; ?>
87
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
88
+ <?php echo $this->getMassactionBlockHtml() ?>
89
+ <?php endif ?>
90
+ <div class="grid">
91
+ <div class="hor-scroll">
92
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
93
+ <?php foreach ($this->getColumns() as $_column): ?>
94
+ <col <?php echo $_column->getHtmlProperty() ?> />
95
+ <?php endforeach; ?>
96
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
97
+ <thead>
98
+ <?php if ($this->getHeadersVisibility()): ?>
99
+ <tr class="headings">
100
+ <?php foreach ($this->getColumns() as $_column): ?>
101
+ <?php if ($_column->getId() == 'in_products'): ?>
102
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"></span></th>
103
+ <?php else: ?>
104
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
105
+ <?php endif; ?>
106
+ <?php endforeach; ?>
107
+ </tr>
108
+ <?php endif; ?>
109
+ <?php if ($this->getFilterVisibility()): ?>
110
+ <tr class="filter">
111
+ <?php $i = 0;
112
+ foreach ($this->getColumns() as $_column):
113
+ ?>
114
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
115
+ <?php endforeach; ?>
116
+ </tr>
117
+ <?php endif ?>
118
+ </thead>
119
+ <?php endif; ?>
120
+ <?php if ($this->getCountTotals()): ?>
121
+ <tfoot>
122
+ <tr class="totals">
123
+ <?php foreach ($this->getColumns() as $_column): ?>
124
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
125
+ <?php endforeach; ?>
126
+ </tr>
127
+ </tfoot>
128
+ <?php endif; ?>
129
+
130
+ <tbody>
131
+ <?php if (($this->getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?>
132
+ <?php foreach ($this->getCollection() as $_index => $_item): ?>
133
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)): ?> class="<?php echo $_class; ?>"<?php endif; ?> >
134
+ <?php $i = 0;
135
+ foreach ($this->getColumns() as $_column):
136
+ ?>
137
+
138
+ <?php if ($this->shouldRenderCell($_item, $_column)): ?>
139
+ <?php $_rowspan = $this->getRowspan($_item, $_column); ?>
140
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
141
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
142
+ </td>
143
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)): ?>
144
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item) ?>" class="last"><?php echo $this->getEmptyCellLabel() ?></td>
145
+ <?php endif; ?>
146
+ <?php endif; ?>
147
+
148
+ <?php endforeach; ?>
149
+ </tr>
150
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)): ?>
151
+ <?php foreach ($_multipleRows as $_i): ?>
152
+ <tr>
153
+ <?php $i = 0;
154
+ foreach ($this->getMultipleRowColumns($_i) as $_column):
155
+ ?>
156
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns - 1 ? 'last' : '' ?>">
157
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
158
+ </td>
159
+ <?php endforeach; ?>
160
+ </tr>
161
+ <?php endforeach; ?>
162
+ <?php endif; ?>
163
+
164
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
165
+ <tr class="subtotals">
166
+ <?php $i = 0;
167
+ foreach ($this->getSubTotalColumns() as $_column):
168
+ ?>
169
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
170
+ <?php
171
+ echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
172
+ $_column->getRowField($this->getSubTotalItem($_item))
173
+ );
174
+ ?>
175
+ </td>
176
+ <?php endforeach; ?>
177
+ </tr>
178
+ <?php endif; ?>
179
+ <?php endforeach; ?>
180
+ <?php elseif ($this->getEmptyText()): ?>
181
+ <tr>
182
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
183
+ </tr>
184
+ <?php endif; ?>
185
+ </tbody>
186
+
187
+ </table>
188
+ </div>
189
+ </div>
190
+ <?php if ($this->canDisplayContainer()): ?>
191
+ </div>
192
+ <script type="text/javascript">
193
+ //<![CDATA[
194
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
195
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
196
+ <?php if ($this->getRowClickCallback()): ?>
197
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
198
+ <?php endif; ?>
199
+ <?php if ($this->getCheckboxCheckCallback()): ?>
200
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
201
+ <?php endif; ?>
202
+ <?php if ($this->getRowInitCallback()): ?>
203
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
204
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
205
+ <?php endif; ?>
206
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
207
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
208
+ <?php endif ?>
209
+ <?php echo $this->getAdditionalJavaScript(); ?>
210
+ //]]>
211
+ </script>
212
+ <?php endif; ?>
213
+ <?php
214
+
215
+ endif ?>
app/design/adminhtml/default/default/template/simiconnector/render/category.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if($this->getTheme() == null):?>
2
+
3
+ <div class="notification-global">
4
+ <strong>Warning the configuration need be to setup</strong>.Click here to go to <a href='<?php echo Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/simiconnector")?>'>the configuration</a> and change your settings.
5
+ </div>
6
+
7
+ <script type="text/javascript">
8
+ //<![CDATA[
9
+ if($('simicategoryGrid')){
10
+ $('simicategoryGrid').hide();
11
+ }
12
+
13
+ if($('noticeGrid')){
14
+ $('noticeGrid').hide();
15
+ }
16
+
17
+ if($('bannerGrid')){
18
+ $('bannerGrid').hide();
19
+ }
20
+
21
+ $('page:main-container'). select('button')[0].hide();
22
+ //]]>
23
+ </script>
24
+
25
+ <?php endif;?>
app/design/adminhtml/default/default/template/simiconnector/siminotification/categories.phtml ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Siminotification
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+
16
+ <?php $_divId = 'main_tree-div_' . time() ?>
17
+ <div id="<?php echo $_divId ?>" class="tree"></div>
18
+ <script type="text/javascript">
19
+ //<![CDATA[
20
+
21
+ // TODO: cleanup this script. It was copypasted from catalog/category/tree
22
+
23
+ var tree;
24
+
25
+ /**
26
+ * Fix ext compatibility with prototype 1.6
27
+ */
28
+ Ext.lib.Event.getTarget = function(e) {
29
+ var ee = e.browserEvent || e;
30
+ return ee.target ? Event.element(ee) : null;
31
+ };
32
+
33
+ Ext.tree.TreePanel.Enhanced = function(el, config)
34
+ {
35
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
36
+ };
37
+
38
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
39
+
40
+ loadTree : function(config, firstLoad)
41
+ {
42
+ var parameters = config['parameters'];
43
+ var data = config['data'];
44
+
45
+ if ((typeof parameters['root_visible']) != 'undefined') {
46
+ this.rootVisible = parameters['root_visible']*1;
47
+ }
48
+
49
+ var root = new Ext.tree.TreeNode(parameters);
50
+
51
+ this.nodeHash = {};
52
+ this.setRootNode(root);
53
+
54
+ if (firstLoad) {
55
+ this.addListener('click', this.categoryClick.createDelegate(this));
56
+ }
57
+
58
+ this.loader.buildCategoryTree(root, data);
59
+ this.el.dom.innerHTML = '';
60
+ // render the tree
61
+ this.render();
62
+ },
63
+
64
+ categoryClick : function(node, e)
65
+ {
66
+ node.getUI().check(!node.getUI().checked());
67
+ }
68
+ });
69
+
70
+ Ext.onReady(function()
71
+ {
72
+ var categoryLoader = new Ext.tree.TreeLoader({
73
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
74
+ });
75
+
76
+ categoryLoader.createNode = function(config) {
77
+ config.uiProvider = Ext.tree.CheckboxNodeUI;
78
+ var node;
79
+ var _node = Object.clone(config);
80
+ if (config.children && !config.children.length) {
81
+ delete(config.children);
82
+ node = new Ext.tree.AsyncTreeNode(config);
83
+ } else {
84
+ node = new Ext.tree.TreeNode(config);
85
+ }
86
+
87
+ return node;
88
+ };
89
+
90
+ categoryLoader.buildCategoryTree = function(parent, config)
91
+ {
92
+ if (!config) return null;
93
+
94
+ if (parent && config && config.length){
95
+ for (var i = 0; i < config.length; i++) {
96
+ config[i].uiProvider = Ext.tree.CheckboxNodeUI;
97
+ var node;
98
+ var _node = Object.clone(config[i]);
99
+ if (_node.children && !_node.children.length) {
100
+ delete(_node.children);
101
+ node = new Ext.tree.AsyncTreeNode(_node);
102
+ } else {
103
+ node = new Ext.tree.TreeNode(config[i]);
104
+ }
105
+ parent.appendChild(node);
106
+ node.loader = node.getOwnerTree().loader;
107
+ if (_node.children) {
108
+ this.buildCategoryTree(node, _node.children);
109
+ }
110
+ }
111
+ }
112
+ };
113
+
114
+ categoryLoader.buildHash = function(node)
115
+ {
116
+ var hash = {};
117
+
118
+ hash = this.toArray(node.attributes);
119
+
120
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
121
+ hash['children'] = new Array;
122
+
123
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
124
+ if (!hash['children']) {
125
+ hash['children'] = new Array;
126
+ }
127
+ hash['children'].push(this.buildHash(node.childNodes[i]));
128
+ }
129
+ }
130
+
131
+ return hash;
132
+ };
133
+
134
+ categoryLoader.toArray = function(attributes) {
135
+ var data = {};
136
+ for (var key in attributes) {
137
+ var value = attributes[key];
138
+ data[key] = value;
139
+ }
140
+
141
+ return data;
142
+ };
143
+
144
+ categoryLoader.on("beforeload", function(treeLoader, node) {
145
+ treeLoader.baseParams.id = node.attributes.id;
146
+ });
147
+
148
+ categoryLoader.on("load", function(treeLoader, node, config) {
149
+ varienWindowOnload();
150
+ });
151
+
152
+ tree = new Ext.tree.TreePanel.Enhanced('<?php echo $_divId ?>', {
153
+ animate: false,
154
+ loader: categoryLoader,
155
+ enableDD: false,
156
+ containerScroll: true,
157
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
158
+ rootVisible: '<?php echo $this->getRoot()->getIsVisible() ?>',
159
+ useAjax: <?php echo $this->getUseAjax() ?>,
160
+ currentNodeId: <?php echo (int) $this->getCategoryId() ?>,
161
+ addNodeTo: false,
162
+ rootUIProvider: Ext.tree.CheckboxNodeUI
163
+ });
164
+
165
+ tree.on('check', function(node, checked) {
166
+ if(checked){
167
+ var checkValue = String(node);
168
+ checkValue = checkValue.substring(6, checkValue.length-1);
169
+ $('category_id').value = checkValue;
170
+ varienElementMethods.setHasChanges(node.getUI().checkbox);
171
+ var categorylist = document.getElementsByClassName("l-tcb");
172
+ var i;
173
+ for (i = 0; i < categorylist.length; i++) {
174
+ var categoryId = String(categorylist[i].getAttribute("id"));
175
+ if(categoryId != node.getUI().checkbox.getAttribute("id")){
176
+ categorylist[i].checked = false;
177
+ }
178
+ }
179
+ }
180
+ }, tree);
181
+
182
+ // set the root node
183
+ var parameters = {
184
+ text: '<?php echo htmlentities($this->getRoot()->getName()) ?>',
185
+ draggable: false,
186
+ checked:'<?php echo $this->getRoot()->getChecked() ?>',
187
+ uiProvider: Ext.tree.CheckboxNodeUI,
188
+ allowDrop: <?php if ($this->getRoot()->getIsVisible()): ?>true<?php else : ?>false<?php endif; ?>,
189
+ id: <?php echo (int) $this->getRoot()->getId() ?>,
190
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
191
+ category_id: <?php echo (int) $this->getCategoryId() ?>
192
+ };
193
+
194
+ tree.loadTree({parameters:parameters, data:<?php echo $this->getTreeJson() ?>},true);
195
+
196
+ });
197
+ //]]>
198
+ </script>
app/design/adminhtml/default/default/template/simiconnector/siminotification/devicegrid.phtml ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Siminotification
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+ <?php
16
+ /**
17
+ * Template for Mage_Adminhtml_Block_Widget_Grid
18
+ *
19
+ * getId()
20
+ * getCollection()
21
+ * getColumns()
22
+ * getPagerVisibility()
23
+ * getVarNamePage()
24
+ */
25
+ $numColumns = sizeof($this->getColumns());
26
+ ?>
27
+ <?php if ($this->getCollection()): ?>
28
+ <?php if ($this->canDisplayContainer()): ?>
29
+ <?php if ($this->getGridHeader()): ?>
30
+ <div class="content-header">
31
+ <table cellspacing="0">
32
+ <tr>
33
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
34
+ </tr>
35
+ </table>
36
+ </div>
37
+ <?php endif ?>
38
+
39
+ <div id="<?php echo $this->getId() ?>">
40
+ <?php else: ?>
41
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
42
+ <?php endif; ?>
43
+ <?php if ($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
44
+ <table cellspacing="0" class="actions">
45
+ <tr>
46
+ <?php if ($this->getPagerVisibility()): ?>
47
+ <td class="pager">
48
+ <a href="#" onclick="toogleCheckAllDevices(true)"><?php echo $this->__('Select All') ?></a>
49
+ <span class="separator">|</span>
50
+ <a href="#" onclick="toogleCheckAllDevices(false)"><?php echo $this->__('Unselect All') ?></a>
51
+ <span class="separator">|</span>
52
+ <?php echo $this->__('Page') ?>
53
+
54
+
55
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
56
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
57
+ <?php if ($_curPage > 1): ?>
58
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage - 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
59
+ <?php else: ?>
60
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
61
+ <?php endif; ?>
62
+
63
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
64
+
65
+ <?php if ($_curPage < $_lastPage): ?>
66
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage + 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
67
+ <?php else: ?>
68
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
69
+ <?php endif; ?>
70
+
71
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
72
+ <span class="separator">|</span>
73
+ <?php echo $this->__('View') ?>
74
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
75
+ <option value="20"<?php if ($this->getCollection()->getPageSize() == 20): ?> selected="selected"<?php endif; ?>>20</option>
76
+ <option value="30"<?php if ($this->getCollection()->getPageSize() == 30): ?> selected="selected"<?php endif; ?>>30</option>
77
+ <option value="50"<?php if ($this->getCollection()->getPageSize() == 50): ?> selected="selected"<?php endif; ?>>50</option>
78
+ <option value="100"<?php if ($this->getCollection()->getPageSize() == 100): ?> selected="selected"<?php endif; ?>>100</option>
79
+ <option value="200"<?php if ($this->getCollection()->getPageSize() == 200): ?> selected="selected"<?php endif; ?>>200</option>
80
+ </select>
81
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
82
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
83
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
84
+ <?php if ($this->getRssLists()): ?>
85
+ <?php foreach ($this->getRssLists() as $_rss): ?>
86
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
87
+ <?php endforeach ?>
88
+ <?php endif; ?>
89
+ </td>
90
+ <?php endif ?>
91
+ <?php if ($this->getExportTypes()): ?>
92
+ <td class="export a-right">
93
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
94
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
95
+ <?php foreach ($this->getExportTypes() as $_type): ?>
96
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
97
+ <?php endforeach; ?>
98
+ </select>
99
+ <?php echo $this->getExportButtonHtml() ?>
100
+ </td>
101
+ <?php endif; ?>
102
+ <td class="filter-actions a-right">
103
+ <?php echo $this->getMainButtonsHtml() ?>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+ <?php endif; ?>
108
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
109
+ <?php echo $this->getMassactionBlockHtml() ?>
110
+ <?php endif ?>
111
+ <div class="grid">
112
+ <div class="hor-scroll">
113
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
114
+ <?php foreach ($this->getColumns() as $_column): ?>
115
+ <col <?php echo $_column->getHtmlProperty() ?> />
116
+ <?php endforeach; ?>
117
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
118
+ <thead>
119
+ <?php if ($this->getHeadersVisibility()): ?>
120
+ <tr class="headings">
121
+ <?php foreach ($this->getColumns() as $_column): ?>
122
+ <?php if ($_column->getId() == 'in_products'): ?>
123
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"></span></th>
124
+ <?php else: ?>
125
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
126
+ <?php endif; ?>
127
+ <?php endforeach; ?>
128
+ </tr>
129
+ <?php endif; ?>
130
+ <?php if ($this->getFilterVisibility()): ?>
131
+ <tr class="filter">
132
+ <?php $i = 0;
133
+ foreach ($this->getColumns() as $_column): ?>
134
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
135
+ <?php endforeach; ?>
136
+ </tr>
137
+ <?php endif ?>
138
+ </thead>
139
+ <?php endif; ?>
140
+ <?php if ($this->getCountTotals()): ?>
141
+ <tfoot>
142
+ <tr class="totals">
143
+ <?php foreach ($this->getColumns() as $_column): ?>
144
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
145
+ <?php endforeach; ?>
146
+ </tr>
147
+ </tfoot>
148
+ <?php endif; ?>
149
+
150
+ <tbody>
151
+ <?php if (($this->getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?>
152
+ <?php foreach ($this->getCollection() as $_index => $_item): ?>
153
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)): ?> class="<?php echo $_class; ?>"<?php endif; ?> >
154
+ <?php $i = 0;
155
+ foreach ($this->getColumns() as $_column): ?>
156
+
157
+ <?php if ($this->shouldRenderCell($_item, $_column)): ?>
158
+ <?php $_rowspan = $this->getRowspan($_item, $_column); ?>
159
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
160
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
161
+ </td>
162
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)): ?>
163
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item) ?>" class="last"><?php echo $this->getEmptyCellLabel() ?></td>
164
+ <?php endif; ?>
165
+ <?php endif; ?>
166
+
167
+ <?php endforeach; ?>
168
+ </tr>
169
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)): ?>
170
+ <?php foreach ($_multipleRows as $_i): ?>
171
+ <tr>
172
+ <?php $i = 0;
173
+ foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
174
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns - 1 ? 'last' : '' ?>">
175
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
176
+ </td>
177
+ <?php endforeach; ?>
178
+ </tr>
179
+ <?php endforeach; ?>
180
+ <?php endif; ?>
181
+
182
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
183
+ <tr class="subtotals">
184
+ <?php $i = 0;
185
+ foreach ($this->getSubTotalColumns() as $_column): ?>
186
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
187
+ <?php
188
+ echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
189
+ $_column->getRowField($this->getSubTotalItem($_item))
190
+ );
191
+ ?>
192
+ </td>
193
+ <?php endforeach; ?>
194
+ </tr>
195
+ <?php endif; ?>
196
+ <?php endforeach; ?>
197
+ <?php elseif ($this->getEmptyText()): ?>
198
+ <tr>
199
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
200
+ </tr>
201
+ <?php endif; ?>
202
+ </tbody>
203
+
204
+ </table>
205
+ </div>
206
+ </div>
207
+ <?php if ($this->canDisplayContainer()): ?>
208
+ </div>
209
+ <script type="text/javascript">
210
+ //<![CDATA[
211
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
212
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
213
+ <?php if ($this->getRowClickCallback()): ?>
214
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
215
+ <?php endif; ?>
216
+ <?php if ($this->getCheckboxCheckCallback()): ?>
217
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
218
+ <?php endif; ?>
219
+ <?php if ($this->getRowInitCallback()): ?>
220
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
221
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
222
+ <?php endif; ?>
223
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
224
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
225
+ <?php endif ?>
226
+ <?php echo $this->getAdditionalJavaScript(); ?>
227
+ //]]>
228
+ </script>
229
+ <?php endif; ?>
230
+ <?php
231
+ endif ?>
app/design/adminhtml/default/default/template/simiconnector/siminotification/grid.phtml ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Siminotification
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+ <?php
16
+ /**
17
+ * Template for Mage_Adminhtml_Block_Widget_Grid
18
+ *
19
+ * getId()
20
+ * getCollection()
21
+ * getColumns()
22
+ * getPagerVisibility()
23
+ * getVarNamePage()
24
+ */
25
+ $numColumns = sizeof($this->getColumns());
26
+ ?>
27
+ <?php if ($this->getCollection()): ?>
28
+ <?php if ($this->canDisplayContainer()): ?>
29
+ <?php if ($this->getGridHeader()): ?>
30
+ <div class="content-header">
31
+ <table cellspacing="0">
32
+ <tr>
33
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
34
+ </tr>
35
+ </table>
36
+ </div>
37
+ <?php endif ?>
38
+
39
+ <div id="<?php echo $this->getId() ?>">
40
+ <?php else: ?>
41
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
42
+ <?php endif; ?>
43
+ <?php if ($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
44
+ <table cellspacing="0" class="actions">
45
+ <tr>
46
+ <?php if ($this->getPagerVisibility()): ?>
47
+ <td class="pager">
48
+ <?php echo $this->__('Page') ?>
49
+
50
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
51
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
52
+ <?php if ($_curPage > 1): ?>
53
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage - 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
54
+ <?php else: ?>
55
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
56
+ <?php endif; ?>
57
+
58
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
59
+
60
+ <?php if ($_curPage < $_lastPage): ?>
61
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage + 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
62
+ <?php else: ?>
63
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
64
+ <?php endif; ?>
65
+
66
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
67
+ <span class="separator">|</span>
68
+ <?php echo $this->__('View') ?>
69
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
70
+ <option value="20"<?php if ($this->getCollection()->getPageSize() == 20): ?> selected="selected"<?php endif; ?>>20</option>
71
+ <option value="30"<?php if ($this->getCollection()->getPageSize() == 30): ?> selected="selected"<?php endif; ?>>30</option>
72
+ <option value="50"<?php if ($this->getCollection()->getPageSize() == 50): ?> selected="selected"<?php endif; ?>>50</option>
73
+ <option value="100"<?php if ($this->getCollection()->getPageSize() == 100): ?> selected="selected"<?php endif; ?>>100</option>
74
+ <option value="200"<?php if ($this->getCollection()->getPageSize() == 200): ?> selected="selected"<?php endif; ?>>200</option>
75
+ </select>
76
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
77
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
78
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
79
+ <?php if ($this->getRssLists()): ?>
80
+ <?php foreach ($this->getRssLists() as $_rss): ?>
81
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
82
+ <?php endforeach ?>
83
+ <?php endif; ?>
84
+ </td>
85
+ <?php endif ?>
86
+ <?php if ($this->getExportTypes()): ?>
87
+ <td class="export a-right">
88
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
89
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
90
+ <?php foreach ($this->getExportTypes() as $_type): ?>
91
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
92
+ <?php endforeach; ?>
93
+ </select>
94
+ <?php echo $this->getExportButtonHtml() ?>
95
+ </td>
96
+ <?php endif; ?>
97
+ <td class="filter-actions a-right">
98
+ <?php echo $this->getMainButtonsHtml() ?>
99
+ </td>
100
+ </tr>
101
+ </table>
102
+ <?php endif; ?>
103
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
104
+ <?php echo $this->getMassactionBlockHtml() ?>
105
+ <?php endif ?>
106
+ <div class="grid">
107
+ <div class="hor-scroll">
108
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
109
+ <?php foreach ($this->getColumns() as $_column): ?>
110
+ <col <?php echo $_column->getHtmlProperty() ?> />
111
+ <?php endforeach; ?>
112
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
113
+ <thead>
114
+ <?php if ($this->getHeadersVisibility()): ?>
115
+ <tr class="headings">
116
+ <?php foreach ($this->getColumns() as $_column): ?>
117
+ <?php if ($_column->getId() == 'in_products'): ?>
118
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"></span></th>
119
+ <?php else: ?>
120
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
121
+ <?php endif; ?>
122
+ <?php endforeach; ?>
123
+ </tr>
124
+ <?php endif; ?>
125
+ <?php if ($this->getFilterVisibility()): ?>
126
+ <tr class="filter">
127
+ <?php $i = 0;
128
+ foreach ($this->getColumns() as $_column): ?>
129
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
130
+ <?php endforeach; ?>
131
+ </tr>
132
+ <?php endif ?>
133
+ </thead>
134
+ <?php endif; ?>
135
+ <?php if ($this->getCountTotals()): ?>
136
+ <tfoot>
137
+ <tr class="totals">
138
+ <?php foreach ($this->getColumns() as $_column): ?>
139
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
140
+ <?php endforeach; ?>
141
+ </tr>
142
+ </tfoot>
143
+ <?php endif; ?>
144
+
145
+ <tbody>
146
+ <?php if (($this->getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?>
147
+ <?php foreach ($this->getCollection() as $_index => $_item): ?>
148
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)): ?> class="<?php echo $_class; ?>"<?php endif; ?> >
149
+ <?php $i = 0;
150
+ foreach ($this->getColumns() as $_column): ?>
151
+
152
+ <?php if ($this->shouldRenderCell($_item, $_column)): ?>
153
+ <?php $_rowspan = $this->getRowspan($_item, $_column); ?>
154
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
155
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
156
+ </td>
157
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)): ?>
158
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item) ?>" class="last"><?php echo $this->getEmptyCellLabel() ?></td>
159
+ <?php endif; ?>
160
+ <?php endif; ?>
161
+
162
+ <?php endforeach; ?>
163
+ </tr>
164
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)): ?>
165
+ <?php foreach ($_multipleRows as $_i): ?>
166
+ <tr>
167
+ <?php $i = 0;
168
+ foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
169
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns - 1 ? 'last' : '' ?>">
170
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
171
+ </td>
172
+ <?php endforeach; ?>
173
+ </tr>
174
+ <?php endforeach; ?>
175
+ <?php endif; ?>
176
+
177
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
178
+ <tr class="subtotals">
179
+ <?php $i = 0;
180
+ foreach ($this->getSubTotalColumns() as $_column): ?>
181
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
182
+ <?php
183
+ echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
184
+ $_column->getRowField($this->getSubTotalItem($_item))
185
+ );
186
+ ?>
187
+ </td>
188
+ <?php endforeach; ?>
189
+ </tr>
190
+ <?php endif; ?>
191
+ <?php endforeach; ?>
192
+ <?php elseif ($this->getEmptyText()): ?>
193
+ <tr>
194
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
195
+ </tr>
196
+ <?php endif; ?>
197
+ </tbody>
198
+
199
+ </table>
200
+ </div>
201
+ </div>
202
+ <?php if ($this->canDisplayContainer()): ?>
203
+ </div>
204
+ <script type="text/javascript">
205
+ //<![CDATA[
206
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
207
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
208
+ <?php if ($this->getRowClickCallback()): ?>
209
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
210
+ <?php endif; ?>
211
+ <?php if ($this->getCheckboxCheckCallback()): ?>
212
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
213
+ <?php endif; ?>
214
+ <?php if ($this->getRowInitCallback()): ?>
215
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
216
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
217
+ <?php endif; ?>
218
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
219
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
220
+ <?php endif ?>
221
+ <?php echo $this->getAdditionalJavaScript(); ?>
222
+ //]]>
223
+ </script>
224
+ <?php endif; ?>
225
+ <?php
226
+ endif ?>
app/design/adminhtml/default/default/template/simiconnector/siminotification/guide.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="entry-edit">
2
+ <div class="entry-edit-head">
3
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('siminotification')->__('Instructions to create Google Map API Key') ?></h4>
4
+ </div>
5
+ <div class="fieldset ">
6
+ <div class="hor-scroll">
7
+ <?php echo '1. Visit the APIs Console at'?> <a href="https://code.google.com/apis/console" target="_blank"><?php echo 'https://code.google.com/apis/console' ?></a><?php echo ' and log in with your Google Account.' ?>
8
+ <br />
9
+ <?php echo '2. Click on the <strong>APIs</strong> link in the left menu.' ?>
10
+ <br />
11
+ <?php echo '3. Activate the <strong>Google Maps JavaScript API v3</strong>, <strong>Distance Matrix API</strong>, <strong>Geocoding API</strong> services.' ?>
12
+ <br />
13
+ <br />
14
+ <img width="80%" src="<?php echo Mage::getBaseUrl('media').'simi/simicart/notification/guide/google-api-active.png' ?>" title="<?php echo $this->__('Google API Active') ?>" />
15
+ <br />
16
+ <br />
17
+ <?php echo '4. Click on the <strong>Credentials</strong> link in the left menu, the "CREATE NEW KEY" in the "Public API access" section to create Google Map API Key for browser apps.' ?>
18
+ <br />
19
+ <br />
20
+ <img width="80%" src="<?php echo Mage::getBaseUrl('media').'simi/simicart/notification/guide/create-key.png' ?>" title="<?php echo $this->__('Google API Active') ?>" />
21
+ </div>
22
+ </div>
23
+ </div>
app/design/adminhtml/default/default/template/simiconnector/simiproductlabel/grid.phtml ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ ?>
4
+ <?php
5
+ /**
6
+ * Template for Mage_Adminhtml_Block_Widget_Grid
7
+ *
8
+ * getId()
9
+ * getCollection()
10
+ * getColumns()
11
+ * getPagerVisibility()
12
+ * getVarNamePage()
13
+ */
14
+ $numColumns = sizeof($this->getColumns());
15
+ ?>
16
+ <?php if ($this->getCollection()): ?>
17
+ <?php if ($this->canDisplayContainer()): ?>
18
+ <?php if ($this->getGridHeader()): ?>
19
+ <div class="content-header">
20
+ <table cellspacing="0">
21
+ <tr>
22
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
23
+ </tr>
24
+ </table>
25
+ </div>
26
+ <?php endif ?>
27
+
28
+ <div id="<?php echo $this->getId() ?>">
29
+ <?php else: ?>
30
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
31
+ <?php endif; ?>
32
+ <?php if ($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
33
+ <table cellspacing="0" class="actions">
34
+ <tr>
35
+ <?php if ($this->getPagerVisibility()): ?>
36
+ <td class="pager">
37
+ <?php echo $this->__('Page') ?>
38
+
39
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
40
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
41
+ <?php if ($_curPage > 1): ?>
42
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage - 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
43
+ <?php else: ?>
44
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
45
+ <?php endif; ?>
46
+
47
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
48
+
49
+ <?php if ($_curPage < $_lastPage): ?>
50
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage + 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
51
+ <?php else: ?>
52
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
53
+ <?php endif; ?>
54
+
55
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
56
+ <span class="separator">|</span>
57
+ <?php echo $this->__('View') ?>
58
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
59
+ <option value="20"<?php if ($this->getCollection()->getPageSize() == 20): ?> selected="selected"<?php endif; ?>>20</option>
60
+ <option value="30"<?php if ($this->getCollection()->getPageSize() == 30): ?> selected="selected"<?php endif; ?>>30</option>
61
+ <option value="50"<?php if ($this->getCollection()->getPageSize() == 50): ?> selected="selected"<?php endif; ?>>50</option>
62
+ <option value="100"<?php if ($this->getCollection()->getPageSize() == 100): ?> selected="selected"<?php endif; ?>>100</option>
63
+ <option value="200"<?php if ($this->getCollection()->getPageSize() == 200): ?> selected="selected"<?php endif; ?>>200</option>
64
+ </select>
65
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
66
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
67
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
68
+ <?php if ($this->getRssLists()): ?>
69
+ <?php foreach ($this->getRssLists() as $_rss): ?>
70
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
71
+ <?php endforeach ?>
72
+ <?php endif; ?>
73
+ </td>
74
+ <?php endif ?>
75
+ <?php if ($this->getExportTypes()): ?>
76
+ <td class="export a-right">
77
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
78
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
79
+ <?php foreach ($this->getExportTypes() as $_type): ?>
80
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
81
+ <?php endforeach; ?>
82
+ </select>
83
+ <?php echo $this->getExportButtonHtml() ?>
84
+ </td>
85
+ <?php endif; ?>
86
+ <td class="filter-actions a-right">
87
+ <?php echo $this->getMainButtonsHtml() ?>
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ <?php endif; ?>
92
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
93
+ <?php echo $this->getMassactionBlockHtml() ?>
94
+ <?php endif ?>
95
+ <div class="grid">
96
+ <div class="hor-scroll">
97
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
98
+ <?php foreach ($this->getColumns() as $_column): ?>
99
+ <col <?php echo $_column->getHtmlProperty() ?> />
100
+ <?php endforeach; ?>
101
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
102
+ <thead>
103
+ <?php if ($this->getHeadersVisibility()): ?>
104
+ <tr class="headings">
105
+ <?php foreach ($this->getColumns() as $_column): ?>
106
+ <?php if ($_column->getId() == 'in_products'): ?>
107
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"></span></th>
108
+ <?php else: ?>
109
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
110
+ <?php endif; ?>
111
+ <?php endforeach; ?>
112
+ </tr>
113
+ <?php endif; ?>
114
+ <?php if ($this->getFilterVisibility()): ?>
115
+ <tr class="filter">
116
+ <?php $i = 0;
117
+ foreach ($this->getColumns() as $_column): ?>
118
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
119
+ <?php endforeach; ?>
120
+ </tr>
121
+ <?php endif ?>
122
+ </thead>
123
+ <?php endif; ?>
124
+ <?php if ($this->getCountTotals()): ?>
125
+ <tfoot>
126
+ <tr class="totals">
127
+ <?php foreach ($this->getColumns() as $_column): ?>
128
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
129
+ <?php endforeach; ?>
130
+ </tr>
131
+ </tfoot>
132
+ <?php endif; ?>
133
+
134
+ <tbody>
135
+ <?php if (($this->getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?>
136
+ <?php foreach ($this->getCollection() as $_index => $_item): ?>
137
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)): ?> class="<?php echo $_class; ?>"<?php endif; ?> >
138
+ <?php $i = 0;
139
+ foreach ($this->getColumns() as $_column): ?>
140
+
141
+ <?php if ($this->shouldRenderCell($_item, $_column)): ?>
142
+ <?php $_rowspan = $this->getRowspan($_item, $_column); ?>
143
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
144
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
145
+ </td>
146
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)): ?>
147
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item) ?>" class="last"><?php echo $this->getEmptyCellLabel() ?></td>
148
+ <?php endif; ?>
149
+ <?php endif; ?>
150
+
151
+ <?php endforeach; ?>
152
+ </tr>
153
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)): ?>
154
+ <?php foreach ($_multipleRows as $_i): ?>
155
+ <tr>
156
+ <?php $i = 0;
157
+ foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
158
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns - 1 ? 'last' : '' ?>">
159
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
160
+ </td>
161
+ <?php endforeach; ?>
162
+ </tr>
163
+ <?php endforeach; ?>
164
+ <?php endif; ?>
165
+
166
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
167
+ <tr class="subtotals">
168
+ <?php $i = 0;
169
+ foreach ($this->getSubTotalColumns() as $_column): ?>
170
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
171
+ <?php
172
+ echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
173
+ $_column->getRowField($this->getSubTotalItem($_item))
174
+ );
175
+ ?>
176
+ </td>
177
+ <?php endforeach; ?>
178
+ </tr>
179
+ <?php endif; ?>
180
+ <?php endforeach; ?>
181
+ <?php elseif ($this->getEmptyText()): ?>
182
+ <tr>
183
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
184
+ </tr>
185
+ <?php endif; ?>
186
+ </tbody>
187
+
188
+ </table>
189
+ </div>
190
+ </div>
191
+ <?php if ($this->canDisplayContainer()): ?>
192
+ </div>
193
+ <script type="text/javascript">
194
+ //<![CDATA[
195
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
196
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
197
+ <?php if ($this->getRowClickCallback()): ?>
198
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
199
+ <?php endif; ?>
200
+ <?php if ($this->getCheckboxCheckCallback()): ?>
201
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
202
+ <?php endif; ?>
203
+ <?php if ($this->getRowInitCallback()): ?>
204
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
205
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
206
+ <?php endif; ?>
207
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
208
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
209
+ <?php endif ?>
210
+ <?php echo $this->getAdditionalJavaScript(); ?>
211
+ //]]>
212
+ </script>
213
+ <?php endif; ?>
214
+ <?php
215
+ endif ?>
app/design/adminhtml/default/default/template/simiconnector/simivideo/grid.phtml ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * DISCLAIMER
5
+ *
6
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
7
+ * version in the future.
8
+ *
9
+ * @category
10
+ * @package Simivideo
11
+ * @copyright Copyright (c) 2012
12
+ * @license
13
+ */
14
+ ?>
15
+ <?php
16
+ /**
17
+ * Template for Mage_Adminhtml_Block_Widget_Grid
18
+ *
19
+ * getId()
20
+ * getCollection()
21
+ * getColumns()
22
+ * getPagerVisibility()
23
+ * getVarNamePage()
24
+ */
25
+ $numColumns = sizeof($this->getColumns());
26
+ ?>
27
+ <?php if ($this->getCollection()): ?>
28
+ <?php if ($this->canDisplayContainer()): ?>
29
+ <?php if ($this->getGridHeader()): ?>
30
+ <div class="content-header">
31
+ <table cellspacing="0">
32
+ <tr>
33
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
34
+ </tr>
35
+ </table>
36
+ </div>
37
+ <?php endif ?>
38
+
39
+ <div id="<?php echo $this->getId() ?>">
40
+ <?php else: ?>
41
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
42
+ <?php endif; ?>
43
+ <?php if ($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
44
+ <table cellspacing="0" class="actions">
45
+ <tr>
46
+ <?php if ($this->getPagerVisibility()): ?>
47
+ <td class="pager">
48
+ <?php echo $this->__('Page') ?>
49
+
50
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
51
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
52
+ <?php if ($_curPage > 1): ?>
53
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage - 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
54
+ <?php else: ?>
55
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
56
+ <?php endif; ?>
57
+
58
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
59
+
60
+ <?php if ($_curPage < $_lastPage): ?>
61
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage + 1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
62
+ <?php else: ?>
63
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
64
+ <?php endif; ?>
65
+
66
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
67
+ <span class="separator">|</span>
68
+ <?php echo $this->__('View') ?>
69
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
70
+ <option value="20"<?php if ($this->getCollection()->getPageSize() == 20): ?> selected="selected"<?php endif; ?>>20</option>
71
+ <option value="30"<?php if ($this->getCollection()->getPageSize() == 30): ?> selected="selected"<?php endif; ?>>30</option>
72
+ <option value="50"<?php if ($this->getCollection()->getPageSize() == 50): ?> selected="selected"<?php endif; ?>>50</option>
73
+ <option value="100"<?php if ($this->getCollection()->getPageSize() == 100): ?> selected="selected"<?php endif; ?>>100</option>
74
+ <option value="200"<?php if ($this->getCollection()->getPageSize() == 200): ?> selected="selected"<?php endif; ?>>200</option>
75
+ </select>
76
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
77
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
78
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
79
+ <?php if ($this->getRssLists()): ?>
80
+ <?php foreach ($this->getRssLists() as $_rss): ?>
81
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
82
+ <?php endforeach ?>
83
+ <?php endif; ?>
84
+ </td>
85
+ <?php endif ?>
86
+ <?php if ($this->getExportTypes()): ?>
87
+ <td class="export a-right">
88
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
89
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
90
+ <?php foreach ($this->getExportTypes() as $_type): ?>
91
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
92
+ <?php endforeach; ?>
93
+ </select>
94
+ <?php echo $this->getExportButtonHtml() ?>
95
+ </td>
96
+ <?php endif; ?>
97
+ <td class="filter-actions a-right">
98
+ <?php echo $this->getMainButtonsHtml() ?>
99
+ </td>
100
+ </tr>
101
+ </table>
102
+ <?php endif; ?>
103
+ <?php if ($this->getMassactionBlock()->isAvailable()): ?>
104
+ <?php echo $this->getMassactionBlockHtml() ?>
105
+ <?php endif ?>
106
+ <div class="grid">
107
+ <div class="hor-scroll">
108
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
109
+ <?php foreach ($this->getColumns() as $_column): ?>
110
+ <col <?php echo $_column->getHtmlProperty() ?> />
111
+ <?php endforeach; ?>
112
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
113
+ <thead>
114
+ <?php if ($this->getHeadersVisibility()): ?>
115
+ <tr class="headings">
116
+ <?php foreach ($this->getColumns() as $_column): ?>
117
+ <?php if ($_column->getId() == 'in_products'): ?>
118
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"></span></th>
119
+ <?php else: ?>
120
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
121
+ <?php endif; ?>
122
+ <?php endforeach; ?>
123
+ </tr>
124
+ <?php endif; ?>
125
+ <?php if ($this->getFilterVisibility()): ?>
126
+ <tr class="filter">
127
+ <?php $i = 0;
128
+ foreach ($this->getColumns() as $_column): ?>
129
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
130
+ <?php endforeach; ?>
131
+ </tr>
132
+ <?php endif ?>
133
+ </thead>
134
+ <?php endif; ?>
135
+ <?php if ($this->getCountTotals()): ?>
136
+ <tfoot>
137
+ <tr class="totals">
138
+ <?php foreach ($this->getColumns() as $_column): ?>
139
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
140
+ <?php endforeach; ?>
141
+ </tr>
142
+ </tfoot>
143
+ <?php endif; ?>
144
+
145
+ <tbody>
146
+ <?php if (($this->getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?>
147
+ <?php foreach ($this->getCollection() as $_index => $_item): ?>
148
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)): ?> class="<?php echo $_class; ?>"<?php endif; ?> >
149
+ <?php $i = 0;
150
+ foreach ($this->getColumns() as $_column): ?>
151
+
152
+ <?php if ($this->shouldRenderCell($_item, $_column)): ?>
153
+ <?php $_rowspan = $this->getRowspan($_item, $_column); ?>
154
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo++$i == $numColumns ? 'last' : '' ?>">
155
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
156
+ </td>
157
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)): ?>
158
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item) ?>" class="last"><?php echo $this->getEmptyCellLabel() ?></td>
159
+ <?php endif; ?>
160
+ <?php endif; ?>
161
+
162
+ <?php endforeach; ?>
163
+