dotmailermagento - Version 6.0.0

Version Notes

New Automation improvements.

Transactional Emails, Custom Customer Attributes, Reports & More

This release includes some great new functionality as well as including a number of fixes.

##IMPORTANT## Dynamic content URL's have been changed so will need updating within your dotMailer account to ensure they continue working correctly. ##IMPORTANT##

Release Highlights:

+ Transactional Emails: Replace the standard emails Magento currently sends to your customers and guests with beautifully created campaigns from dotMailer. Emails include new account, new order, dispatch, cancel and refund emails. **A dotMailer child account is required to enable this functionality**

+ Custom Customer Attributes: Sync your custom created customer attributes to dotMailer

+ Dynamic Content Styling: Apply custom CSS to all dynamic content pages e.g. font size, colour and type.

+ Reporting: Now within the Newsletter section in Magento you can view the import status of contacts and orders, as well as the sending status of transactional and lost basket emails.

Download this release

Release Info

Developer Calin Diacon
Extension dotmailermagento
Version 6.0.0
Comparing to
See all releases


Code changes from version 5.3.0 to 6.0.0

Files changed (215) hide show
  1. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Automation.php +8 -6
  2. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Automation/Grid.php +176 -142
  3. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign.php +8 -6
  4. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Grid.php +160 -118
  5. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Catalog.php +6 -4
  6. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Catalog/Grid.php +71 -44
  7. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Delete.php +14 -3
  8. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Imported.php +16 -8
  9. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Reset.php +14 -3
  10. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Script.php +7 -2
  11. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Status.php +13 -8
  12. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Sync.php +13 -8
  13. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Website.php +4 -1
  14. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Automation/Customdatafields.php +42 -21
  15. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Customdatafields.php +37 -20
  16. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Rules/Customdatafields.php +59 -29
  17. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Select.php +4 -2
  18. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact.php +8 -6
  19. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit.php +29 -14
  20. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit/Form.php +18 -10
  21. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Grid.php +216 -154
  22. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Customer/Tab.php +2 -1
  23. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Customer/Tab/Stats.php +22 -13
  24. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard.php +49 -47
  25. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Switcher.php +91 -80
  26. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs.php +59 -53
  27. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis.php +71 -54
  28. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Abandonedcarts.php +28 -9
  29. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Customer.php +20 -7
  30. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php +46 -28
  31. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Sales.php +26 -9
  32. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php +24 -8
  33. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General.php +94 -91
  34. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General/Data.php +8 -4
  35. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Logs.php +2 -0
  36. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Status.php +2063 -1419
  37. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Importer.php +3 -1
  38. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Importer/Grid.php +134 -93
  39. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order.php +5 -3
  40. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order/Grid.php +106 -76
  41. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Quote.php +6 -4
  42. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Quote/Grid.php +89 -58
  43. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review.php +6 -4
  44. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review/Grid.php +86 -62
  45. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules.php +8 -4
  46. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit.php +11 -8
  47. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Form.php +8 -2
  48. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tab/Conditions.php +38 -22
  49. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tab/Main.php +63 -46
  50. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tabs.php +3 -1
  51. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Grid.php +83 -62
  52. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Sales/Order/Creditmemo/View.php +92 -52
  53. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Deletecontactids.php +8 -3
  54. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Notification.php +18 -7
  55. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportcatalog.php +6 -2
  56. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportorders.php +6 -2
  57. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportquotes.php +6 -2
  58. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportreviews.php +6 -2
  59. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportsubscribers.php +6 -2
  60. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportwishlists.php +6 -2
  61. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reset.php +5 -2
  62. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Resetcustomersimport.php +6 -2
  63. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcatalogsync.php +5 -2
  64. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcontactsync.php +5 -2
  65. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runimportersync.php +5 -2
  66. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runordersync.php +5 -2
  67. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runquotesync.php +5 -2
  68. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runreviewsync.php +5 -2
  69. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runsubscribersync.php +8 -3
  70. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runwishlistsync.php +5 -2
  71. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Setupdatafields.php +21 -16
  72. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Ajaxvalidate.php +5 -2
  73. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Automation/Connect.php +23 -11
  74. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php +15 -9
  75. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Colorpicker.php +21 -8
  76. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php +15 -10
  77. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Enterprisevalidator.php +13 -8
  78. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetcontacts.php +15 -8
  79. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetguests.php +13 -8
  80. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetsubscribers.php +15 -8
  81. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Trial.php +50 -0
  82. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php +17 -13
  83. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php +0 -65
  84. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php +0 -59
  85. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Addressbookbutton.php +7 -3
  86. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Crosssell.php +19 -11
  87. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Related.php +17 -9
  88. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Upsell.php +17 -8
  89. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php +16 -9
  90. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php +13 -7
  91. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php +17 -9
  92. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Crosssell.php +20 -12
  93. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Datafieldbutton.php +8 -3
  94. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackchooser.php +8 -5
  95. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackcontainer.php +5 -3
  96. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Feefo/Reviews.php +11 -4
  97. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Feefo/Score.php +7 -3
  98. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Gridlist.php +15 -11
  99. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Lostbasket.php +20 -12
  100. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualchooser.php +8 -5
  101. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualcontainer.php +5 -3
  102. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php +14 -8
  103. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Nosto.php +0 -22
  104. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php +15 -9
  105. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Recentlyviewed.php +19 -10
  106. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Related.php +22 -14
  107. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Review.php +12 -5
  108. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Upsell.php +20 -11
  109. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist.php +14 -5
  110. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Crosssell.php +14 -5
  111. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Related.php +14 -5
  112. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Upsell.php +15 -5
  113. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Emailapivalidate.php +12 -6
  114. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Installation.php +68 -58
  115. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagefour.php +0 -24
  116. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessageone.php +0 -46
  117. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagethree.php +0 -26
  118. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagetwo.php +0 -25
  119. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdate.php +29 -13
  120. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdateguest.php +29 -13
  121. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmation.php +29 -16
  122. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmed.php +29 -16
  123. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customernew.php +29 -16
  124. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdate.php +28 -14
  125. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdateguest.php +28 -14
  126. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemo.php +30 -16
  127. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemoguest.php +29 -15
  128. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoice.php +29 -15
  129. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoiceguest.php +29 -15
  130. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworder.php +30 -15
  131. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworderguest.php +30 -15
  132. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipment.php +30 -15
  133. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipmentguest.php +30 -15
  134. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdate.php +30 -15
  135. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdateguest.php +30 -15
  136. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdate.php +30 -15
  137. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdateguest.php +30 -15
  138. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Widget/Chooser/Product.php +82 -54
  139. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist.php +6 -4
  140. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist/Grid.php +104 -73
  141. app/code/community/Dotdigitalgroup/Email/Block/Basket.php +104 -90
  142. app/code/community/Dotdigitalgroup/Email/Block/Coupon.php +59 -32
  143. app/code/community/Dotdigitalgroup/Email/Block/Customer/Account/Books.php +87 -58
  144. app/code/community/Dotdigitalgroup/Email/Block/Edc.php +178 -92
  145. app/code/community/Dotdigitalgroup/Email/Block/Feefo.php +43 -31
  146. app/code/community/Dotdigitalgroup/Email/Block/Order.php +57 -47
  147. app/code/community/Dotdigitalgroup/Email/Block/Order/Creditmemo.php +28 -18
  148. app/code/community/Dotdigitalgroup/Email/Block/Order/Invoice.php +23 -13
  149. app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php +22 -13
  150. app/code/community/Dotdigitalgroup/Email/Block/Products.php +24 -19
  151. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Products.php +25 -58
  152. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Wishlistproducts.php +16 -10
  153. app/code/community/Dotdigitalgroup/Email/Block/Wishlist.php +16 -9
  154. app/code/community/Dotdigitalgroup/Email/Helper/Config.php +28 -26
  155. app/code/community/Dotdigitalgroup/Email/Helper/Dashboard.php +200 -165
  156. app/code/community/Dotdigitalgroup/Email/Helper/Data.php +1172 -221
  157. app/code/community/Dotdigitalgroup/Email/Helper/File.php +112 -75
  158. app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php +76 -45
  159. app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php +21 -12
  160. app/code/community/Dotdigitalgroup/Email/Model/Abstract/Rest.php +292 -266
  161. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Content.php +127 -110
  162. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Abandoned.php +30 -19
  163. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Customer.php +24 -14
  164. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Orders.php +41 -24
  165. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php +149 -122
  166. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php +103 -84
  167. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php +135 -164
  168. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php +44 -38
  169. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbookspref.php +71 -60
  170. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Abandonedlimit.php +37 -32
  171. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Attributes.php +6 -2
  172. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Cronexpressionsone.php +7 -3
  173. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Cronexpressionstwo.php +7 -3
  174. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Frequency.php +15 -10
  175. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Quoteattributes.php +5 -2
  176. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Transdata.php +1 -0
  177. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Attributes.php +6 -2
  178. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Automation/Programme.php +39 -37
  179. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php +35 -30
  180. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Imported.php +8 -7
  181. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Modified.php +8 -7
  182. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Customer/Attributes/Select.php +16 -12
  183. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datafields.php +46 -39
  184. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldaccess.php +14 -11
  185. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldtype.php +10 -4
  186. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Displaytype.php +9 -7
  187. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Gridview.php +1 -0
  188. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Fontpicker.php +15 -10
  189. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Fontsize.php +1 -0
  190. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Bulklimit.php +18 -0
  191. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Mode.php +7 -7
  192. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Status.php +13 -4
  193. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Interval.php +15 -11
  194. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Intervalminute.php +16 -7
  195. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Orderstatus.php +5 -2
  196. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Publicdatafields.php +59 -49
  197. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Reviews/Delay.php +4 -1
  198. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Condition.php +29 -10
  199. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Type.php +47 -21
  200. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Value.php +39 -13
  201. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Styling.php +2 -1
  202. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sweettooth/Yesno.php +6 -4
  203. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Attributes.php +8 -3
  204. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Type.php +2 -0
  205. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Values.php +1 -0
  206. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Visibility.php +4 -1
  207. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Yesno.php +0 -62
  208. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Mode.php +8 -7
  209. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Port.php +9 -8
  210. app/code/community/Dotdigitalgroup/Email/Model/Api2/Subscriber/Rest/Admin/V1.php +126 -107
  211. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Client.php +563 -325
  212. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php +302 -160
  213. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php +489 -383
  214. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php +16 -3
  215. app/code/community/Dotdigitalgroup/Email/Model/Automation.php +224 -217
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Automation.php CHANGED
@@ -1,16 +1,18 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Automation extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  /**
6
- * Set the template.
7
- */
8
  public function __construct()
9
  {
10
- $this->_controller = 'adminhtml_automation';
11
- $this->_blockGroup = 'ddg_automation';
12
  parent::__construct();
13
- $this->_headerText = Mage::helper('ddg')->__('Automation Status');
14
  $this->_removeButton('add');
15
 
16
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Automation
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  /**
8
+ * Set the template.
9
+ */
10
  public function __construct()
11
  {
12
+ $this->_controller = 'adminhtml_automation';
13
+ $this->_blockGroup = 'ddg_automation';
14
  parent::__construct();
15
+ $this->_headerText = Mage::helper('ddg')->__('Automation Status');
16
  $this->_removeButton('add');
17
 
18
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Automation/Grid.php CHANGED
@@ -1,147 +1,181 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Automation_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setId('id');
9
- $this->setDefaultSort('entity_id');
10
- $this->setDefaultDir('ASC');
11
- $this->setSaveParametersInSession(true);
12
- $this->setUseAjax(true);
13
-
14
- }
15
-
16
- protected function _prepareCollection()
17
- {
18
- $collection = Mage::getModel('ddg_automation/automation')->getCollection();
19
- $this->setCollection($collection);
20
- $this->setDefaultSort('updated_at');
21
- $this->setDefaultDir('DESC');
22
- return parent::_prepareCollection();
23
- }
24
-
25
- protected function _prepareColumns()
26
- {
27
- $this->addColumn('id', array(
28
- 'header' => Mage::helper('ddg')->__('ID'),
29
- 'index' => 'id',
30
- 'type' => 'number',
31
- 'escape' => true,
32
- ))->addColumn('program_id', array(
33
- 'header' => Mage::helper('ddg')->__('Program ID'),
34
- 'align' => 'center',
35
- 'index' => 'program_id',
36
- 'type' => 'number',
37
- 'escape' => true,
38
- ))->addColumn('automation_type', array(
39
- 'header' => Mage::helper('ddg')->__('Automation Type'),
40
- 'align' => 'right',
41
- 'index' => 'automation_type',
42
- 'type' => 'text',
43
- 'escape' => true
44
- ))->addColumn('enrolment_status', array(
45
- 'header' => Mage::helper('ddg')->__('Enrollment Status'),
46
- 'align' => 'left',
47
- 'index' => 'enrolment_status',
48
- 'type' => 'options',
49
- 'options' => array(
50
- 'pending' => 'Pending',
51
- 'Active' => 'Active',
52
- 'Draft' => 'Draft',
53
- 'Deactivated' => 'Deactivated',
54
- 'ReadOnly' => 'ReadOnly',
55
- 'NotAvailableInThisVersion' => 'NotAvailableInThisVersion',
56
- 'Failed' => 'Failed'
57
- ),
58
- 'escape' => true
59
- ))->addColumn('email', array(
60
- 'header' => Mage::helper('ddg')->__('Email'),
61
- 'align' => 'right',
62
- 'index' => 'email',
63
- 'type' => 'text',
64
- 'escape' => true,
65
- ))->addColumn('type_id', array(
66
- 'header' => Mage::helper('ddg')->__('Type ID'),
67
- 'align' => 'center',
68
- 'index' => 'type_id',
69
- 'type' => 'number',
70
- 'escape' => true,
71
- ))->addColumn('message', array(
72
- 'header' => Mage::helper('ddg')->__('Message'),
73
- 'align' => 'right',
74
- 'index' => 'message',
75
- 'type' => 'text',
76
- 'escape' => true
77
- ))->addColumn('created_at', array(
78
- 'header' => Mage::helper('ddg')->__('Created at'),
79
- 'align' => 'center',
80
- 'index' => 'created_at',
81
- 'escape' => true,
82
- 'type' => 'datetime'
83
-
84
- ))->addColumn('updated_at', array(
85
- 'header' => Mage::helper('ddg')->__('Updated at'),
86
- 'align' => 'center',
87
- 'index' => 'updated_at',
88
- 'escape' => true,
89
- 'type' => 'datetime'
90
- ));
91
- if (!Mage::app()->isSingleStoreMode()) {
92
- $this->addColumn('website_id', array(
93
- 'header' => Mage::helper('customer')->__('Website'),
94
- 'align' => 'center',
95
- 'type' => 'options',
96
- 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
97
- 'index' => 'website_id',
98
- ));
99
- }
100
-
101
- $this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
102
- return parent::_prepareColumns();
103
- }
104
-
105
- /**
106
- * Get the store.
107
- *
108
- * @return Mage_Core_Model_Store
109
- * @throws Exception
110
- */
111
- protected function _getStore()
112
- {
113
- $storeId = (int) $this->getRequest()->getParam('store', 0);
114
- return Mage::app()->getStore($storeId);
115
- }
116
-
117
- /**
118
- * Prepare the grid massaction.
119
- * @return $this|Mage_Adminhtml_Block_Widget_Grid
120
- */
121
- protected function _prepareMassaction()
122
- {
123
- $this->setMassactionIdField('id');
124
- $this->getMassactionBlock()->setFormFieldName('automation');
125
- $this->getMassactionBlock()->addItem('resend', array(
126
- 'label' => Mage::helper('ddg')->__('Resend'),
127
- 'url' => $this->getUrl('*/*/massResend'),
128
-
129
- ));
130
- $this->getMassactionBlock()->addItem('delete', array(
131
- 'label'=> Mage::helper('ddg')->__('Delete'),
132
- 'url' => $this->getUrl('*/*/massDelete'),
133
- 'confirm' => Mage::helper('ddg')->__('Are you sure?')));
134
-
135
- return $this;
136
- }
137
-
138
- /**
139
- * Grid url.
140
- * @return string
141
- */
142
- public function getGridUrl()
143
- {
144
- return $this->getUrl('*/*/grid', array('_current'=>true));
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Automation_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId('id');
11
+ $this->setDefaultSort('entity_id');
12
+ $this->setDefaultDir('ASC');
13
+ $this->setSaveParametersInSession(true);
14
+ $this->setUseAjax(true);
15
+
16
+ }
17
+
18
+ protected function _prepareCollection()
19
+ {
20
+ $collection = Mage::getModel('ddg_automation/automation')
21
+ ->getCollection();
22
+ $this->setCollection($collection);
23
+ $this->setDefaultSort('updated_at');
24
+ $this->setDefaultDir('DESC');
25
+
26
+ return parent::_prepareCollection();
27
+ }
28
+
29
+ protected function _prepareColumns()
30
+ {
31
+ $this->addColumn(
32
+ 'id', array(
33
+ 'header' => Mage::helper('ddg')->__('ID'),
34
+ 'index' => 'id',
35
+ 'type' => 'number',
36
+ 'escape' => true,
37
+ )
38
+ )->addColumn(
39
+ 'program_id', array(
40
+ 'header' => Mage::helper('ddg')->__('Program ID'),
41
+ 'align' => 'center',
42
+ 'index' => 'program_id',
43
+ 'type' => 'number',
44
+ 'escape' => true,
45
+ )
46
+ )->addColumn(
47
+ 'automation_type', array(
48
+ 'header' => Mage::helper('ddg')->__('Automation Type'),
49
+ 'align' => 'right',
50
+ 'index' => 'automation_type',
51
+ 'type' => 'text',
52
+ 'escape' => true
53
+ )
54
+ )->addColumn(
55
+ 'enrolment_status', array(
56
+ 'header' => Mage::helper('ddg')->__('Enrollment Status'),
57
+ 'align' => 'left',
58
+ 'index' => 'enrolment_status',
59
+ 'type' => 'options',
60
+ 'options' => array(
61
+ 'pending' => 'Pending',
62
+ 'suppressed' => 'Suppressed',
63
+ 'Active' => 'Active',
64
+ 'Draft' => 'Draft',
65
+ 'Deactivated' => 'Deactivated',
66
+ 'ReadOnly' => 'ReadOnly',
67
+ 'NotAvailableInThisVersion' => 'NotAvailableInThisVersion',
68
+ 'Failed' => 'Failed'
69
+ ),
70
+ 'escape' => true
71
+ )
72
+ )->addColumn(
73
+ 'email', array(
74
+ 'header' => Mage::helper('ddg')->__('Email'),
75
+ 'align' => 'right',
76
+ 'index' => 'email',
77
+ 'type' => 'text',
78
+ 'escape' => true,
79
+ )
80
+ )->addColumn(
81
+ 'type_id', array(
82
+ 'header' => Mage::helper('ddg')->__('Type ID'),
83
+ 'align' => 'center',
84
+ 'index' => 'type_id',
85
+ 'type' => 'number',
86
+ 'escape' => true,
87
+ )
88
+ )->addColumn(
89
+ 'message', array(
90
+ 'header' => Mage::helper('ddg')->__('Message'),
91
+ 'align' => 'right',
92
+ 'index' => 'message',
93
+ 'type' => 'text',
94
+ 'escape' => true
95
+ )
96
+ )->addColumn(
97
+ 'created_at', array(
98
+ 'header' => Mage::helper('ddg')->__('Created at'),
99
+ 'align' => 'center',
100
+ 'index' => 'created_at',
101
+ 'escape' => true,
102
+ 'type' => 'datetime'
103
+
104
+ )
105
+ )->addColumn(
106
+ 'updated_at', array(
107
+ 'header' => Mage::helper('ddg')->__('Updated at'),
108
+ 'align' => 'center',
109
+ 'index' => 'updated_at',
110
+ 'escape' => true,
111
+ 'type' => 'datetime'
112
+ )
113
+ );
114
+ if ( ! Mage::app()->isSingleStoreMode()) {
115
+ $this->addColumn(
116
+ 'website_id', array(
117
+ 'header' => Mage::helper('customer')->__('Website'),
118
+ 'align' => 'center',
119
+ 'type' => 'options',
120
+ 'options' => Mage::getSingleton('adminhtml/system_store')
121
+ ->getWebsiteOptionHash(true),
122
+ 'index' => 'website_id',
123
+ )
124
+ );
125
+ }
126
+
127
+ $this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
128
+
129
+ return parent::_prepareColumns();
130
+ }
131
+
132
+ /**
133
+ * Get the store.
134
+ *
135
+ * @return Mage_Core_Model_Store
136
+ * @throws Exception
137
+ */
138
+ protected function _getStore()
139
+ {
140
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
141
+
142
+ return Mage::app()->getStore($storeId);
143
+ }
144
+
145
+ /**
146
+ * Prepare the grid massaction.
147
+ *
148
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
149
+ */
150
+ protected function _prepareMassaction()
151
+ {
152
+ $this->setMassactionIdField('id');
153
+ $this->getMassactionBlock()->setFormFieldName('automation');
154
+ $this->getMassactionBlock()->addItem(
155
+ 'resend', array(
156
+ 'label' => Mage::helper('ddg')->__('Resend'),
157
+ 'url' => $this->getUrl('*/*/massResend'),
158
+
159
+ )
160
+ );
161
+ $this->getMassactionBlock()->addItem(
162
+ 'delete', array(
163
+ 'label' => Mage::helper('ddg')->__('Delete'),
164
+ 'url' => $this->getUrl('*/*/massDelete'),
165
+ 'confirm' => Mage::helper('ddg')->__('Are you sure?'))
166
+ );
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Grid url.
173
+ *
174
+ * @return string
175
+ */
176
+ public function getGridUrl()
177
+ {
178
+ return $this->getUrl('*/*/grid', array('_current' => true));
179
+ }
180
 
181
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign.php CHANGED
@@ -1,16 +1,18 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Campaign extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  /**
6
- * Set the template.
7
- */
8
  public function __construct()
9
  {
10
- $this->_controller = 'adminhtml_campaign';
11
- $this->_blockGroup = 'ddg_automation';
12
  parent::__construct();
13
- $this->_headerText = Mage::helper('ddg')->__('Campaigns');
14
  $this->_removeButton('add');
15
 
16
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  /**
8
+ * Set the template.
9
+ */
10
  public function __construct()
11
  {
12
+ $this->_controller = 'adminhtml_campaign';
13
+ $this->_blockGroup = 'ddg_automation';
14
  parent::__construct();
15
+ $this->_headerText = Mage::helper('ddg')->__('Campaigns');
16
  $this->_removeButton('add');
17
 
18
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -13,166 +15,206 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid extends Mage_Adminhtml
13
  }
14
 
15
  /**
16
- * Prepare grid collection object.
17
- * @return Mage_Adminhtml_Block_Widget_Grid
18
- */
 
19
  protected function _prepareCollection()
20
  {
21
- $collection = Mage::getModel('ddg_automation/campaign')->getCollection();
 
22
  $this->setCollection($collection);
23
  $this->setDefaultSort('created_at');
24
  $this->setDefaultDir('DESC');
 
25
  return parent::_prepareCollection();
26
  }
27
 
28
  protected function _prepareColumns()
29
  {
30
- $this->addColumn('id', array(
31
- 'header' => Mage::helper('ddg')->__('Campaign ID'),
32
- 'width' => '20px',
33
- 'index' => 'campaign_id',
34
- 'type' => 'number',
35
- 'truncate' => 50,
36
- 'escape' => true
37
- ))->addColumn('customer_id', array(
38
- 'header' => Mage::helper('ddg')->__('Customer ID'),
39
- 'align' => 'left',
40
- 'width' => '50px',
41
- 'index' => 'customer_id',
42
- 'type' => 'number',
43
- 'escape' => true
44
- ))->addColumn('email', array(
45
- 'header' => Mage::helper('ddg')->__('Email'),
46
- 'align' => 'left',
47
- 'width' => '50px',
48
- 'index' => 'email',
49
- 'type' => 'text',
50
- 'escape' => true
51
- ))->addColumn('is_sent', array(
52
- 'header' => Mage::helper('ddg')->__('Is Sent'),
53
- 'align' => 'center',
54
- 'width' => '20px',
55
- 'index' => 'is_sent',
56
- 'escape' => true,
57
- 'type' => 'options',
58
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
59
- 'options' => array(
60
- '1' => 'Is Send',
61
- 'null' => 'Not Send'
62
- ),
63
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
64
- ))->addColumn('message', array(
65
- 'header' => Mage::helper('ddg')->__('Send Message'),
66
- 'align' => 'left',
67
- 'width' => '300px',
68
- 'index' => 'message',
69
- 'type' => 'text',
70
- 'escape' => true
71
- ))->addColumn('event_name', array(
72
- 'header' => Mage::helper('ddg')->__('Event Name'),
73
- 'align' => 'left',
74
- 'index' => 'event_name',
75
- 'width' => '100px',
76
- 'type' => 'string',
77
- 'escape' => true
78
- ))->addColumn('quote_id', array(
79
- 'header' => Mage::helper('ddg')->__('Quote Id'),
80
- 'align' => 'left',
81
- 'width' => '50px',
82
- 'index' => 'quote_id',
83
- 'type' => 'number',
84
- 'escape' => true
85
- ))->addColumn('sent_at', array(
86
- 'header' => Mage::helper('ddg')->__('Sent At'),
87
- 'align' => 'center',
88
- 'width' => '100px',
89
- 'index' => 'sent_at',
90
- 'type' => 'datetime',
91
- 'escape' => true
92
- ))->addColumn('created_at', array(
93
- 'header' => Mage::helper('ddg')->__('Created At'),
94
- 'align' => 'center',
95
- 'width' => '100px',
96
- 'index' => 'created_at',
97
- 'type' => 'datetime',
98
- 'escape' => true
99
- ))->addColumn('updated_at', array(
100
- 'header' => Mage::helper('ddg')->__('Updated At'),
101
- 'align' => 'center',
102
- 'width' => '100px',
103
- 'index' => 'updated_at',
104
- 'type' => 'datetime',
105
- 'escape' => true
106
- ));
107
- if (!Mage::app()->isSingleStoreMode()) {
108
- $this->addColumn('store_id', array(
109
- 'header' => Mage::helper('customer')->__('Store'),
110
- 'align' => 'center',
111
- 'width' => '80px',
112
- 'type' => 'options',
113
- 'options' => Mage::getSingleton('adminhtml/system_store')->getStoreOptionHash(true),
114
- 'index' => 'store_id'
115
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
  $this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
 
119
  return parent::_prepareColumns();
120
  }
121
 
122
  /**
123
- * Get the store selected.
124
- * @return Mage_Core_Model_Store
125
- * @throws Exception
126
- */
 
127
  protected function _getStore()
128
  {
129
- $storeId = (int) $this->getRequest()->getParam('store', 0);
 
130
  return Mage::app()->getStore($storeId);
131
  }
132
 
133
 
134
  /**
135
- * @return $this|Mage_Adminhtml_Block_Widget_Grid
136
- */
137
  protected function _prepareMassaction()
138
  {
139
  $this->setMassactionIdField('id');
140
  $this->getMassactionBlock()->setFormFieldName('campaign');
141
- $this->getMassactionBlock()->addItem('delete', array (
142
- 'label'=> Mage::helper('ddg')->__('Delete'),
143
- 'url' => $this->getUrl('*/*/massDelete'),
144
- 'confirm' => Mage::helper('ddg')->__('Are you sure?')
145
- )
 
 
 
 
 
 
146
  );
147
 
148
- $this->getMassactionBlock()->addItem('resend', array('label'=>Mage::helper('ddg')->__('Resend'),'url'=>$this->getUrl('*/*/massResend')));
149
  return $this;
150
  }
151
 
152
  /**
153
- * Grid selected url.
154
- * @return string
155
- */
 
156
  public function getGridUrl()
157
  {
158
- return $this->getUrl('*/*/grid', array('_current'=>true));
159
  }
 
160
  /**
161
- * Custom callback action for the campaign.
162
  *
163
- * @param $collection
164
- * @param $column
165
- */
166
  public function filterCallbackContact($collection, $column)
167
- {
168
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
169
- $value = $column->getFilter()->getValue();
 
170
 
171
  if ($value == 'null') {
172
- $collection->addFieldToFilter($field, array('null' => true) );
173
  } else {
174
- $collection->addFieldToFilter($field, array('notnull' => true));
175
  }
176
- }
177
 
178
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
15
  }
16
 
17
  /**
18
+ * Prepare grid collection object.
19
+ *
20
+ * @return Mage_Adminhtml_Block_Widget_Grid
21
+ */
22
  protected function _prepareCollection()
23
  {
24
+ $collection = Mage::getModel('ddg_automation/campaign')->getCollection(
25
+ );
26
  $this->setCollection($collection);
27
  $this->setDefaultSort('created_at');
28
  $this->setDefaultDir('DESC');
29
+
30
  return parent::_prepareCollection();
31
  }
32
 
33
  protected function _prepareColumns()
34
  {
35
+ $this->addColumn(
36
+ 'id', array(
37
+ 'header' => Mage::helper('ddg')->__('Campaign ID'),
38
+ 'width' => '20px',
39
+ 'index' => 'campaign_id',
40
+ 'type' => 'number',
41
+ 'truncate' => 50,
42
+ 'escape' => true
43
+ )
44
+ )->addColumn(
45
+ 'customer_id', array(
46
+ 'header' => Mage::helper('ddg')->__('Customer ID'),
47
+ 'align' => 'left',
48
+ 'width' => '50px',
49
+ 'index' => 'customer_id',
50
+ 'type' => 'number',
51
+ 'escape' => true
52
+ )
53
+ )->addColumn(
54
+ 'email', array(
55
+ 'header' => Mage::helper('ddg')->__('Email'),
56
+ 'align' => 'left',
57
+ 'width' => '50px',
58
+ 'index' => 'email',
59
+ 'type' => 'text',
60
+ 'escape' => true
61
+ )
62
+ )->addColumn(
63
+ 'is_sent', array(
64
+ 'header' => Mage::helper('ddg')->__(
65
+ 'Is Sent'
66
+ ),
67
+ 'align' => 'center',
68
+ 'width' => '20px',
69
+ 'index' => 'is_sent',
70
+ 'escape' => true,
71
+ 'type' => 'options',
72
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
73
+ 'options' => array(
74
+ '1' => 'Is Send',
75
+ 'null' => 'Not Send'
76
+ ),
77
+ 'filter_condition_callback' => array($this,
78
+ 'filterCallbackContact')
79
+ )
80
+ )->addColumn(
81
+ 'message', array(
82
+ 'header' => Mage::helper('ddg')->__('Send Message'),
83
+ 'align' => 'left',
84
+ 'width' => '300px',
85
+ 'index' => 'message',
86
+ 'type' => 'text',
87
+ 'escape' => true
88
+ )
89
+ )->addColumn(
90
+ 'event_name', array(
91
+ 'header' => Mage::helper('ddg')->__('Event Name'),
92
+ 'align' => 'left',
93
+ 'index' => 'event_name',
94
+ 'width' => '100px',
95
+ 'type' => 'string',
96
+ 'escape' => true
97
+ )
98
+ )->addColumn(
99
+ 'quote_id', array(
100
+ 'header' => Mage::helper('ddg')->__('Quote Id'),
101
+ 'align' => 'left',
102
+ 'width' => '50px',
103
+ 'index' => 'quote_id',
104
+ 'type' => 'number',
105
+ 'escape' => true
106
+ )
107
+ )->addColumn(
108
+ 'sent_at', array(
109
+ 'header' => Mage::helper('ddg')->__('Sent At'),
110
+ 'align' => 'center',
111
+ 'width' => '100px',
112
+ 'index' => 'sent_at',
113
+ 'type' => 'datetime',
114
+ 'escape' => true
115
+ )
116
+ )->addColumn(
117
+ 'created_at', array(
118
+ 'header' => Mage::helper('ddg')->__('Created At'),
119
+ 'align' => 'center',
120
+ 'width' => '100px',
121
+ 'index' => 'created_at',
122
+ 'type' => 'datetime',
123
+ 'escape' => true
124
+ )
125
+ )->addColumn(
126
+ 'updated_at', array(
127
+ 'header' => Mage::helper('ddg')->__('Updated At'),
128
+ 'align' => 'center',
129
+ 'width' => '100px',
130
+ 'index' => 'updated_at',
131
+ 'type' => 'datetime',
132
+ 'escape' => true
133
+ )
134
+ );
135
+ if ( ! Mage::app()->isSingleStoreMode()) {
136
+ $this->addColumn(
137
+ 'store_id', array(
138
+ 'header' => Mage::helper('customer')->__('Store'),
139
+ 'align' => 'center',
140
+ 'width' => '80px',
141
+ 'type' => 'options',
142
+ 'options' => Mage::getSingleton('adminhtml/system_store')
143
+ ->getStoreOptionHash(true),
144
+ 'index' => 'store_id'
145
+ )
146
+ );
147
  }
148
 
149
  $this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
150
+
151
  return parent::_prepareColumns();
152
  }
153
 
154
  /**
155
+ * Get the store selected.
156
+ *
157
+ * @return Mage_Core_Model_Store
158
+ * @throws Exception
159
+ */
160
  protected function _getStore()
161
  {
162
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
163
+
164
  return Mage::app()->getStore($storeId);
165
  }
166
 
167
 
168
  /**
169
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
170
+ */
171
  protected function _prepareMassaction()
172
  {
173
  $this->setMassactionIdField('id');
174
  $this->getMassactionBlock()->setFormFieldName('campaign');
175
+ $this->getMassactionBlock()->addItem(
176
+ 'delete', array(
177
+ 'label' => Mage::helper('ddg')->__('Delete'),
178
+ 'url' => $this->getUrl('*/*/massDelete'),
179
+ 'confirm' => Mage::helper('ddg')->__('Are you sure?')
180
+ )
181
+ );
182
+
183
+ $this->getMassactionBlock()->addItem(
184
+ 'resend', array('label' => Mage::helper('ddg')->__('Resend'),
185
+ 'url' => $this->getUrl('*/*/massResend'))
186
  );
187
 
 
188
  return $this;
189
  }
190
 
191
  /**
192
+ * Grid selected url.
193
+ *
194
+ * @return string
195
+ */
196
  public function getGridUrl()
197
  {
198
+ return $this->getUrl('*/*/grid', array('_current' => true));
199
  }
200
+
201
  /**
202
+ * Custom callback action for the campaign.
203
  *
204
+ * @param $collection
205
+ * @param $column
206
+ */
207
  public function filterCallbackContact($collection, $column)
208
+ {
209
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
210
+ : $column->getIndex();
211
+ $value = $column->getFilter()->getValue();
212
 
213
  if ($value == 'null') {
214
+ $collection->addFieldToFilter($field, array('null' => true));
215
  } else {
216
+ $collection->addFieldToFilter($field, array('notnull' => true));
217
  }
218
+ }
219
 
220
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Catalog.php CHANGED
@@ -1,14 +1,16 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Catalog extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
 
9
- $this->_controller = 'adminhtml_catalog';
10
- $this->_blockGroup = 'ddg_automation';
11
- $this->_headerText = Mage::helper('ddg')->__('Email Catalog');
12
 
13
  $this->_removeButton('add');
14
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
 
11
+ $this->_controller = 'adminhtml_catalog';
12
+ $this->_blockGroup = 'ddg_automation';
13
+ $this->_headerText = Mage::helper('ddg')->__('Email Catalog');
14
 
15
  $this->_removeButton('add');
16
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Catalog/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -14,6 +16,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
14
 
15
  /**
16
  * Collection class;
 
17
  * @return string
18
  */
19
  protected function _getCollectionClass()
@@ -24,6 +27,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
24
 
25
  /**
26
  * Prepare the grid collection.
 
27
  * @return Mage_Adminhtml_Block_Widget_Grid
28
  */
29
  protected function _prepareCollection()
@@ -31,58 +35,80 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
31
  // Get and set our collection for the grid
32
  $collection = Mage::getResourceModel($this->_getCollectionClass());
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
  /**
38
  * Prepare the grid collumns.
 
39
  * @return $this
40
  * @throws Exception
41
  */
42
  protected function _prepareColumns()
43
  {
44
- $this->addColumn('product_id', array(
45
- 'header' => Mage::helper('ddg')->__('Product ID'),
46
- 'align' => 'left',
47
- 'width' => '50px',
48
- 'index' => 'product_id',
49
- 'type' => 'number',
50
- 'escape' => true
51
- ))->addColumn('imported', array(
52
- 'header' => Mage::helper('ddg')->__('Imported'),
53
- 'align' => 'center',
54
- 'width' => '50px',
55
- 'index' => 'imported',
56
- 'type' => 'options',
57
- 'escape' => true,
58
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
59
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
60
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
61
- ))->addColumn('modified', array(
62
- 'header' => Mage::helper('ddg')->__('Modified'),
63
- 'align' => 'center',
64
- 'width' => '50px',
65
- 'index' => 'modified',
66
- 'type' => 'options',
67
- 'escape' => true,
68
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
69
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_modified')->getOptions(),
70
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
71
- ))->addColumn('created_at', array(
72
- 'header' => Mage::helper('ddg')->__('Created At'),
73
- 'width' => '50px',
74
- 'align' => 'center',
75
- 'index' => 'created_at',
76
- 'type' => 'datetime',
77
- 'escape' => true,
78
- ))->addColumn('updated_at', array(
79
- 'header' => Mage::helper('ddg')->__('Updated At'),
80
- 'width' => '50px',
81
- 'align' => 'center',
82
- 'index' => 'updated_at',
83
- 'type' => 'datetime',
84
- 'escape' => true,
85
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  return parent::_prepareColumns();
88
  }
@@ -95,7 +121,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
95
  */
96
  public function filterCallbackContact($collection, $column)
97
  {
98
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
 
99
  $value = $column->getFilter()->getValue();
100
  if ($value == 'null') {
101
  $collection->addFieldToFilter($field, array('null' => true));
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
16
 
17
  /**
18
  * Collection class;
19
+ *
20
  * @return string
21
  */
22
  protected function _getCollectionClass()
27
 
28
  /**
29
  * Prepare the grid collection.
30
+ *
31
  * @return Mage_Adminhtml_Block_Widget_Grid
32
  */
33
  protected function _prepareCollection()
35
  // Get and set our collection for the grid
36
  $collection = Mage::getResourceModel($this->_getCollectionClass());
37
  $this->setCollection($collection);
38
+
39
  return parent::_prepareCollection();
40
  }
41
 
42
  /**
43
  * Prepare the grid collumns.
44
+ *
45
  * @return $this
46
  * @throws Exception
47
  */
48
  protected function _prepareColumns()
49
  {
50
+ $this->addColumn(
51
+ 'product_id', array(
52
+ 'header' => Mage::helper('ddg')->__('Product ID'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'product_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ )
59
+ )->addColumn(
60
+ 'imported', array(
61
+ 'header' => Mage::helper('ddg')->__(
62
+ 'Imported'
63
+ ),
64
+ 'align' => 'center',
65
+ 'width' => '50px',
66
+ 'index' => 'imported',
67
+ 'type' => 'options',
68
+ 'escape' => true,
69
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
70
+ 'options' => Mage::getModel(
71
+ 'ddg_automation/adminhtml_source_contact_imported'
72
+ )->getOptions(),
73
+ 'filter_condition_callback' => array($this,
74
+ 'filterCallbackContact')
75
+ )
76
+ )->addColumn(
77
+ 'modified', array(
78
+ 'header' => Mage::helper('ddg')->__(
79
+ 'Modified'
80
+ ),
81
+ 'align' => 'center',
82
+ 'width' => '50px',
83
+ 'index' => 'modified',
84
+ 'type' => 'options',
85
+ 'escape' => true,
86
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
87
+ 'options' => Mage::getModel(
88
+ 'ddg_automation/adminhtml_source_contact_modified'
89
+ )->getOptions(),
90
+ 'filter_condition_callback' => array($this,
91
+ 'filterCallbackContact')
92
+ )
93
+ )->addColumn(
94
+ 'created_at', array(
95
+ 'header' => Mage::helper('ddg')->__('Created At'),
96
+ 'width' => '50px',
97
+ 'align' => 'center',
98
+ 'index' => 'created_at',
99
+ 'type' => 'datetime',
100
+ 'escape' => true,
101
+ )
102
+ )->addColumn(
103
+ 'updated_at', array(
104
+ 'header' => Mage::helper('ddg')->__('Updated At'),
105
+ 'width' => '50px',
106
+ 'align' => 'center',
107
+ 'index' => 'updated_at',
108
+ 'type' => 'datetime',
109
+ 'escape' => true,
110
+ )
111
+ );
112
 
113
  return parent::_prepareColumns();
114
  }
121
  */
122
  public function filterCallbackContact($collection, $column)
123
  {
124
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
125
+ : $column->getIndex();
126
  $value = $column->getFilter()->getValue();
127
  if ($value == 'null') {
128
  $collection->addFieldToFilter($field, array('null' => true));
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Delete.php CHANGED
@@ -1,17 +1,28 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Delete extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
  * Render the grid columns.
7
  *
8
  * @param Varien_Object $row
 
9
  * @return string
10
  */
11
  public function render(Varien_Object $row)
12
  {
13
- $url = HtmlSpecialChars(json_encode(Mage::helper('adminhtml')->getUrl('*/*/delete', array('id' => $row->getId()))));
14
- return '<button title="Delete" onclick="visitPage(' . $url . ')" type="button" style=""><span><span><span>Delete</span></span></span></button>';
 
 
 
 
 
 
 
 
15
  }
16
 
17
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Delete
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
  * Render the grid columns.
9
  *
10
  * @param Varien_Object $row
11
+ *
12
  * @return string
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
+ $url = HtmlSpecialChars(
17
+ json_encode(
18
+ Mage::helper('adminhtml')->getUrl(
19
+ '*/*/delete', array('id' => $row->getId())
20
+ )
21
+ )
22
+ );
23
+
24
+ return '<button title="Delete" onclick="visitPage(' . $url
25
+ . ')" type="button" style=""><span><span><span>Delete</span></span></span></button>';
26
  }
27
 
28
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Imported.php CHANGED
@@ -1,16 +1,24 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Imported extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
- * Render grid columns.
7
- * @param Varien_Object $row
8
- *
9
- * @return string
10
- */
 
11
  public function render(Varien_Object $row)
12
  {
13
- return '<img style="padding-top:2px" '.(($this->_getValue($row)=='1' || $this->_getValue($row)==true) ? 'src="'.$this->getSkinUrl('images/success_msg_icon.gif').'" alt="YES" ' : 'src="'.
14
- $this->getSkinUrl('images/error_msg_icon.gif').'" alt="NO" ').'>';
 
 
 
 
 
15
  }
16
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Imported
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
+ * Render grid columns.
9
+ *
10
+ * @param Varien_Object $row
11
+ *
12
+ * @return string
13
+ */
14
  public function render(Varien_Object $row)
15
  {
16
+ return '<img style="padding-top:2px" ' . (($this->_getValue($row) == '1'
17
+ || $this->_getValue($row) == true)
18
+ ? 'src="' . $this->getSkinUrl('images/success_msg_icon.gif')
19
+ . '" alt="YES" '
20
+ : 'src="' .
21
+ $this->getSkinUrl('images/error_msg_icon.gif') . '" alt="NO" ')
22
+ . '>';
23
  }
24
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Reset.php CHANGED
@@ -1,17 +1,28 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Reset extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
  * Render the grid columns.
7
  *
8
  * @param Varien_Object $row
 
9
  * @return string
10
  */
11
  public function render(Varien_Object $row)
12
  {
13
- $url = HtmlSpecialChars(json_encode(Mage::helper('adminhtml')->getUrl('*/*/reset', array('id' => $row->getId()))));
14
- return '<button title="Reset" onclick="visitPage(' . $url . '); return false" type="button" style=""><span><span><span>Reset</span></span></span></button>';
 
 
 
 
 
 
 
 
15
  }
16
 
17
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Reset
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
  * Render the grid columns.
9
  *
10
  * @param Varien_Object $row
11
+ *
12
  * @return string
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
+ $url = HtmlSpecialChars(
17
+ json_encode(
18
+ Mage::helper('adminhtml')->getUrl(
19
+ '*/*/reset', array('id' => $row->getId())
20
+ )
21
+ )
22
+ );
23
+
24
+ return '<button title="Reset" onclick="visitPage(' . $url
25
+ . '); return false" type="button" style=""><span><span><span>Reset</span></span></span></button>';
26
  }
27
 
28
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Script.php CHANGED
@@ -1,20 +1,25 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Script extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
  * Render the grid columns.
7
  *
8
  * @param Varien_Object $row
 
9
  * @return string
10
  */
11
  public function render(Varien_Object $row)
12
  {
13
- $html = "<script type='application/javascript'>
 
14
  function visitPage(url){
15
  document.location.href = url;
16
  }
17
  </script>";
 
18
  return $html;
19
  }
20
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Script
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
  * Render the grid columns.
9
  *
10
  * @param Varien_Object $row
11
+ *
12
  * @return string
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
+ $html
17
+ = "<script type='application/javascript'>
18
  function visitPage(url){
19
  document.location.href = url;
20
  }
21
  </script>";
22
+
23
  return $html;
24
  }
25
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Status.php CHANGED
@@ -1,17 +1,22 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
- * Render the grid columns.
7
- *
8
- * @param Varien_Object $row
9
- * @return string
10
- */
 
11
  public function render(Varien_Object $row)
12
  {
13
- if($this->getValue($row) == '1')
14
- return $this->__('Subscribed');
 
 
15
  return $this->__('Unsubscribed');
16
  }
17
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Status
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
+ * Render the grid columns.
9
+ *
10
+ * @param Varien_Object $row
11
+ *
12
+ * @return string
13
+ */
14
  public function render(Varien_Object $row)
15
  {
16
+ if ($this->getValue($row) == '1') {
17
+ return $this->__('Subscribed');
18
+ }
19
+
20
  return $this->__('Unsubscribed');
21
  }
22
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Sync.php CHANGED
@@ -1,18 +1,23 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Sync extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
- * Render the grid columns.
7
- *
8
- * @param Varien_Object $row
9
- * @return string
10
- */
 
11
  public function render(Varien_Object $row)
12
  {
13
- $title = '<button title="Connect" type="button" style=""><span><span><span>' . $this->__('Sync Now') . '</span></span></span></button>';
 
 
14
 
15
- return $title;
16
  }
17
 
18
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Sync
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
+ * Render the grid columns.
9
+ *
10
+ * @param Varien_Object $row
11
+ *
12
+ * @return string
13
+ */
14
  public function render(Varien_Object $row)
15
  {
16
+ $title
17
+ = '<button title="Connect" type="button" style=""><span><span><span>'
18
+ . $this->__('Sync Now') . '</span></span></span></button>';
19
 
20
+ return $title;
21
  }
22
 
23
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Website.php CHANGED
@@ -1,9 +1,12 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Website extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 
4
  {
 
5
  /**
6
  * Render grid columns.
 
7
  * @param Varien_Object $row
8
  *
9
  * @return string
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Website
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
5
  {
6
+
7
  /**
8
  * Render grid columns.
9
+ *
10
  * @param Varien_Object $row
11
  *
12
  * @return string
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Automation/Customdatafields.php CHANGED
@@ -1,43 +1,52 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
 
4
  {
 
5
  protected $_getStatusRenderer;
6
  protected $_getAutomationRenderer;
7
 
8
 
9
  /**
10
- * Construct.
11
- */
12
  public function __construct()
13
  {
14
- $this->_addAfter = false;
15
- $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New Enrolment');
 
 
16
  parent::__construct();
17
 
18
  }
19
 
20
  protected function _prepareToRender()
21
  {
22
- $this->_getStatusRenderer = null;
23
  $this->_getAutomationRenderer = null;
24
- $this->addColumn('status',
25
- array(
26
- 'label' => Mage::helper('adminhtml')->__('Order Status'),
 
27
  'style' => 'width:120px',
28
  )
29
  );
30
- $this->addColumn('automation', array(
31
- 'label' => Mage::helper('adminhtml')->__('Automation Programme'),
32
- 'style' => 'width:120px',
33
- )
 
 
 
34
  );
35
  }
36
 
37
  protected function _renderCellTemplate($columnName)
38
  {
39
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
40
- if ($columnName=="status") {
 
41
  return $this->_getStatusRenderer()
42
  ->setName($inputName)
43
  ->setTitle($columnName)
@@ -51,9 +60,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
51
  ->setName($inputName)
52
  ->setTitle($columnName)
53
  ->setExtraParams('style="width:160px"')
54
- ->setOptions(Mage::getModel('ddg_automation/adminhtml_source_automation_programme')->toOptionArray())
 
 
 
 
55
  ->toHtml();
56
  }
 
57
  return parent::_renderCellTemplate($columnName);
58
  }
59
 
@@ -66,38 +80,45 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
66
  {
67
 
68
  $row->setData(
69
- 'option_extra_attr_' . $this->_getStatusRenderer()->calcOptionHash($row->getData('status')),
 
 
70
  'selected="selected"'
71
  );
72
 
73
  $row->setData(
74
- 'option_extra_attr_' . $this->_getAutomationRenderer()->calcOptionHash($row->getData('automation')),
 
75
  'selected="selected"'
76
  );
77
  }
 
78
  protected function _getStatusRenderer()
79
  {
80
- if (!$this->_getStatusRenderer) {
81
  $this->_getStatusRenderer = $this->getLayout()
82
  ->createBlock('ddg_automation/adminhtml_config_select')
83
  ->setIsRenderToJsTemplate(true);
84
  }
 
85
  return $this->_getStatusRenderer;
86
  }
87
 
88
  protected function _getAutomationRenderer()
89
  {
90
- if (!$this->_getAutomationRenderer) {
91
  $this->_getAutomationRenderer = $this->getLayout()
92
  ->createBlock('ddg_automation/adminhtml_config_select')
93
  ->setIsRenderToJsTemplate(true);
94
  }
 
95
  return $this->_getAutomationRenderer;
96
  }
97
 
98
  public function _toHtml()
99
  {
100
- return '<input type="hidden" id="'.$this->getElement()->getHtmlId().'"/>'.parent::_toHtml();
 
101
 
102
  }
103
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
5
  {
6
+
7
  protected $_getStatusRenderer;
8
  protected $_getAutomationRenderer;
9
 
10
 
11
  /**
12
+ * Construct.
13
+ */
14
  public function __construct()
15
  {
16
+ $this->_addAfter = false;
17
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__(
18
+ 'Add New Enrolment'
19
+ );
20
  parent::__construct();
21
 
22
  }
23
 
24
  protected function _prepareToRender()
25
  {
26
+ $this->_getStatusRenderer = null;
27
  $this->_getAutomationRenderer = null;
28
+ $this->addColumn(
29
+ 'status',
30
+ array(
31
+ 'label' => Mage::helper('adminhtml')->__('Order Status'),
32
  'style' => 'width:120px',
33
  )
34
  );
35
+ $this->addColumn(
36
+ 'automation', array(
37
+ 'label' => Mage::helper('adminhtml')->__(
38
+ 'Automation Programme'
39
+ ),
40
+ 'style' => 'width:120px',
41
+ )
42
  );
43
  }
44
 
45
  protected function _renderCellTemplate($columnName)
46
  {
47
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName
48
+ . ']';
49
+ if ($columnName == "status") {
50
  return $this->_getStatusRenderer()
51
  ->setName($inputName)
52
  ->setTitle($columnName)
60
  ->setName($inputName)
61
  ->setTitle($columnName)
62
  ->setExtraParams('style="width:160px"')
63
+ ->setOptions(
64
+ Mage::getModel(
65
+ 'ddg_automation/adminhtml_source_automation_programme'
66
+ )->toOptionArray()
67
+ )
68
  ->toHtml();
69
  }
70
+
71
  return parent::_renderCellTemplate($columnName);
72
  }
73
 
80
  {
81
 
82
  $row->setData(
83
+ 'option_extra_attr_' . $this->_getStatusRenderer()->calcOptionHash(
84
+ $row->getData('status')
85
+ ),
86
  'selected="selected"'
87
  );
88
 
89
  $row->setData(
90
+ 'option_extra_attr_' . $this->_getAutomationRenderer()
91
+ ->calcOptionHash($row->getData('automation')),
92
  'selected="selected"'
93
  );
94
  }
95
+
96
  protected function _getStatusRenderer()
97
  {
98
+ if ( ! $this->_getStatusRenderer) {
99
  $this->_getStatusRenderer = $this->getLayout()
100
  ->createBlock('ddg_automation/adminhtml_config_select')
101
  ->setIsRenderToJsTemplate(true);
102
  }
103
+
104
  return $this->_getStatusRenderer;
105
  }
106
 
107
  protected function _getAutomationRenderer()
108
  {
109
+ if ( ! $this->_getAutomationRenderer) {
110
  $this->_getAutomationRenderer = $this->getLayout()
111
  ->createBlock('ddg_automation/adminhtml_config_select')
112
  ->setIsRenderToJsTemplate(true);
113
  }
114
+
115
  return $this->_getAutomationRenderer;
116
  }
117
 
118
  public function _toHtml()
119
  {
120
+ return '<input type="hidden" id="' . $this->getElement()->getHtmlId()
121
+ . '"/>' . parent::_toHtml();
122
 
123
  }
124
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Customdatafields.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
 
4
  {
 
5
  /**
6
  * Customer attribute
7
  *
@@ -15,12 +17,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
15
 
16
 
17
  /**
18
- * Construct.
19
- */
20
  public function __construct()
21
  {
22
- $this->_addAfter = false;
23
- $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New Attribute');
 
 
24
  parent::__construct();
25
 
26
  }
@@ -29,23 +33,26 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
29
  {
30
  $this->_getDatafieldRenderer = null;
31
  $this->_getAttributeRenderer = null;
32
- $this->addColumn('attribute',
33
- array(
34
- 'label' => Mage::helper('adminhtml')->__('Attribute'),
 
35
  'style' => 'width:120px',
36
  )
37
  );
38
- $this->addColumn('datafield', array(
39
- 'label' => Mage::helper('adminhtml')->__('DataField'),
40
- 'style' => 'width:120px',
41
- )
 
42
  );
43
  }
44
 
45
  protected function _renderCellTemplate($columnName)
46
  {
47
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
48
- if ($columnName=="attribute") {
 
49
  return $this->_getAttributeRenderer()
50
  ->setName($inputName)
51
  ->setTitle($columnName)
@@ -59,9 +66,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
59
  ->setName($inputName)
60
  ->setTitle($columnName)
61
  ->setExtraParams('style="width:160px"')
62
- ->setOptions(Mage::getModel('ddg_automation/adminhtml_source_datafields')->toOptionArray())
 
 
 
63
  ->toHtml();
64
  }
 
65
  return parent::_renderCellTemplate($columnName);
66
  }
67
 
@@ -74,38 +85,44 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
74
  {
75
 
76
  $row->setData(
77
- 'option_extra_attr_' . $this->_getAttributeRenderer()->calcOptionHash($row->getData('attribute')),
 
78
  'selected="selected"'
79
  );
80
 
81
  $row->setData(
82
- 'option_extra_attr_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield')),
 
83
  'selected="selected"'
84
  );
85
  }
 
86
  protected function _getAttributeRenderer()
87
  {
88
- if (!$this->_getAttributeRenderer) {
89
  $this->_getAttributeRenderer = $this->getLayout()
90
  ->createBlock('ddg_automation/adminhtml_config_select')
91
  ->setIsRenderToJsTemplate(true);
92
  }
 
93
  return $this->_getAttributeRenderer;
94
  }
95
 
96
  protected function _getDatafieldRenderer()
97
  {
98
- if (!$this->_getDatafieldRenderer) {
99
  $this->_getDatafieldRenderer = $this->getLayout()
100
  ->createBlock('ddg_automation/adminhtml_config_select')
101
  ->setIsRenderToJsTemplate(true);
102
  }
 
103
  return $this->_getDatafieldRenderer;
104
  }
105
 
106
  public function _toHtml()
107
  {
108
- return '<input type="hidden" id="'.$this->getElement()->getHtmlId().'"/>'.parent::_toHtml();
 
109
 
110
  }
111
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
5
  {
6
+
7
  /**
8
  * Customer attribute
9
  *
17
 
18
 
19
  /**
20
+ * Construct.
21
+ */
22
  public function __construct()
23
  {
24
+ $this->_addAfter = false;
25
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__(
26
+ 'Add New Attribute'
27
+ );
28
  parent::__construct();
29
 
30
  }
33
  {
34
  $this->_getDatafieldRenderer = null;
35
  $this->_getAttributeRenderer = null;
36
+ $this->addColumn(
37
+ 'attribute',
38
+ array(
39
+ 'label' => Mage::helper('adminhtml')->__('Attribute'),
40
  'style' => 'width:120px',
41
  )
42
  );
43
+ $this->addColumn(
44
+ 'datafield', array(
45
+ 'label' => Mage::helper('adminhtml')->__('DataField'),
46
+ 'style' => 'width:120px',
47
+ )
48
  );
49
  }
50
 
51
  protected function _renderCellTemplate($columnName)
52
  {
53
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName
54
+ . ']';
55
+ if ($columnName == "attribute") {
56
  return $this->_getAttributeRenderer()
57
  ->setName($inputName)
58
  ->setTitle($columnName)
66
  ->setName($inputName)
67
  ->setTitle($columnName)
68
  ->setExtraParams('style="width:160px"')
69
+ ->setOptions(
70
+ Mage::getModel('ddg_automation/adminhtml_source_datafields')
71
+ ->toOptionArray()
72
+ )
73
  ->toHtml();
74
  }
75
+
76
  return parent::_renderCellTemplate($columnName);
77
  }
78
 
85
  {
86
 
87
  $row->setData(
88
+ 'option_extra_attr_' . $this->_getAttributeRenderer()
89
+ ->calcOptionHash($row->getData('attribute')),
90
  'selected="selected"'
91
  );
92
 
93
  $row->setData(
94
+ 'option_extra_attr_' . $this->_getDatafieldRenderer()
95
+ ->calcOptionHash($row->getData('datafield')),
96
  'selected="selected"'
97
  );
98
  }
99
+
100
  protected function _getAttributeRenderer()
101
  {
102
+ if ( ! $this->_getAttributeRenderer) {
103
  $this->_getAttributeRenderer = $this->getLayout()
104
  ->createBlock('ddg_automation/adminhtml_config_select')
105
  ->setIsRenderToJsTemplate(true);
106
  }
107
+
108
  return $this->_getAttributeRenderer;
109
  }
110
 
111
  protected function _getDatafieldRenderer()
112
  {
113
+ if ( ! $this->_getDatafieldRenderer) {
114
  $this->_getDatafieldRenderer = $this->getLayout()
115
  ->createBlock('ddg_automation/adminhtml_config_select')
116
  ->setIsRenderToJsTemplate(true);
117
  }
118
+
119
  return $this->_getDatafieldRenderer;
120
  }
121
 
122
  public function _toHtml()
123
  {
124
+ return '<input type="hidden" id="' . $this->getElement()->getHtmlId()
125
+ . '"/>' . parent::_toHtml();
126
 
127
  }
128
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Rules/Customdatafields.php CHANGED
@@ -1,19 +1,23 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
 
4
  {
 
5
  protected $_getAttributeRenderer;
6
  protected $_getConditionsRenderer;
7
  protected $_getValueRenderer;
8
 
9
 
10
  /**
11
- * Construct.
12
- */
13
  public function __construct()
14
  {
15
- $this->_addAfter = false;
16
- $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New Condition');
 
 
17
  parent::__construct();
18
 
19
  }
@@ -24,21 +28,24 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
24
  protected function _prepareToRender()
25
  {
26
  $this->_getConditionsRenderer = null;
27
- $this->_getAttributeRenderer = null;
28
- $this->_getValueRenderer = null;
29
- $this->addColumn('attribute',
30
- array(
31
- 'label' => Mage::helper('adminhtml')->__('Attribute'),
 
32
  'style' => 'width:120px',
33
  )
34
  );
35
- $this->addColumn('conditions',
 
36
  array(
37
  'label' => Mage::helper('adminhtml')->__('Condition'),
38
  'style' => 'width:120px',
39
- )
40
  );
41
- $this->addColumn('cvalue',
 
42
  array(
43
  'label' => Mage::helper('adminhtml')->__('Value'),
44
  'style' => 'width:120px',
@@ -50,13 +57,15 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
50
  * render cell template
51
  *
52
  * @param string $columnName
 
53
  * @return string
54
  * @throws Exception
55
  */
56
  protected function _renderCellTemplate($columnName)
57
  {
58
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
59
- if ($columnName=="attribute") {
 
60
  return $this->_getAttributeRenderer()
61
  ->setName($inputName)
62
  ->setTitle($columnName)
@@ -65,21 +74,30 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
65
  $this->getElement()->getValues()
66
  )
67
  ->toHtml();
68
- }elseif ($columnName == "conditions") {
69
  return $this->_getConditionsRenderer()
70
  ->setName($inputName)
71
  ->setTitle($columnName)
72
  ->setExtraParams('style="width:160px"')
73
- ->setOptions(Mage::getModel('ddg_automation/adminhtml_source_rules_condition')->toOptionArray())
 
 
 
 
74
  ->toHtml();
75
- }elseif ($columnName == "cvalue") {
76
  return $this->_getValueRenderer()
77
  ->setName($inputName)
78
  ->setTitle($columnName)
79
  ->setExtraParams('style="width:160px"')
80
- ->setOptions(Mage::getModel('ddg_automation/adminhtml_source_rules_value')->toOptionArray())
 
 
 
 
81
  ->toHtml();
82
  }
 
83
  return parent::_renderCellTemplate($columnName);
84
  }
85
 
@@ -91,7 +109,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
91
  protected function _prepareArrayRow(Varien_Object $row)
92
  {
93
  $row->setData(
94
- 'option_extra_attr_' . $this->_getAttributeRenderer()->calcOptionHash($row->getData('attribute')),
 
95
  'selected="selected"'
96
  );
97
  }
@@ -103,11 +122,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
103
  */
104
  protected function _getAttributeRenderer()
105
  {
106
- if (!$this->_getAttributeRenderer) {
107
  $this->_getAttributeRenderer = $this->getLayout()
108
  ->createBlock('ddg_automation/adminhtml_config_select')
109
  ->setIsRenderToJsTemplate(true);
110
  }
 
111
  return $this->_getAttributeRenderer;
112
  }
113
 
@@ -118,11 +138,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
118
  */
119
  protected function _getConditionsRenderer()
120
  {
121
- if (!$this->_getConditionsRenderer) {
122
  $this->_getConditionsRenderer = $this->getLayout()
123
  ->createBlock('ddg_automation/adminhtml_config_select')
124
  ->setIsRenderToJsTemplate(true);
125
  }
 
126
  return $this->_getConditionsRenderer;
127
  }
128
 
@@ -133,18 +154,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
133
  */
134
  protected function _getValueRenderer()
135
  {
136
- if (!$this->_getValueRenderer) {
137
  $this->_getValueRenderer = $this->getLayout()
138
  ->createBlock('ddg_automation/adminhtml_config_select')
139
  ->setIsRenderToJsTemplate(true);
140
  }
 
141
  return $this->_getValueRenderer;
142
  }
143
 
144
  public function _toHtml()
145
  {
146
- $script =
147
- "<script type=\"text/javascript\">
148
  document.observe('dom:loaded', function() {
149
  $$('tr#row_rule_condition tr td:first-child select').each(function(item) {
150
  doUpdateWithValues(item);
@@ -174,7 +196,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
174
  });
175
 
176
  function doUpdate(item){
177
- var url = '". Mage::helper('adminhtml')->getUrl('adminhtml/rules/ajax') ."';
 
 
178
  var cond = item.up(1).down().next();
179
  var condName = cond.down().readAttribute('name');
180
  var value = item.up(1).down().next(1);
@@ -204,7 +228,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
204
  }
205
 
206
  function doUpdateWithValues(item){
207
- var url = '". Mage::helper('adminhtml')->getUrl('adminhtml/rules/selected') ."';
 
 
208
  var arrayKey = item.up(1).readAttribute('id');
209
  var cond = item.up(1).down().next();
210
  var condName = cond.down().readAttribute('name');
@@ -238,7 +264,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
238
  }
239
 
240
  function doUpdateForCondition(item){
241
- var url = '". Mage::helper('adminhtml')->getUrl('adminhtml/rules/value') ."';
 
 
242
  var attribute = item.up(1).down();
243
  var attributeValue = attribute.down().value;
244
  var value = item.up().next();
@@ -259,7 +287,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
259
  }
260
  });
261
  </script>";
262
- return '<input type="hidden" id="'.$this->getElement()->getHtmlId().'"/>'.parent::_toHtml().$script;
 
 
263
 
264
  }
265
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
5
  {
6
+
7
  protected $_getAttributeRenderer;
8
  protected $_getConditionsRenderer;
9
  protected $_getValueRenderer;
10
 
11
 
12
  /**
13
+ * Construct.
14
+ */
15
  public function __construct()
16
  {
17
+ $this->_addAfter = false;
18
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__(
19
+ 'Add New Condition'
20
+ );
21
  parent::__construct();
22
 
23
  }
28
  protected function _prepareToRender()
29
  {
30
  $this->_getConditionsRenderer = null;
31
+ $this->_getAttributeRenderer = null;
32
+ $this->_getValueRenderer = null;
33
+ $this->addColumn(
34
+ 'attribute',
35
+ array(
36
+ 'label' => Mage::helper('adminhtml')->__('Attribute'),
37
  'style' => 'width:120px',
38
  )
39
  );
40
+ $this->addColumn(
41
+ 'conditions',
42
  array(
43
  'label' => Mage::helper('adminhtml')->__('Condition'),
44
  'style' => 'width:120px',
45
+ )
46
  );
47
+ $this->addColumn(
48
+ 'cvalue',
49
  array(
50
  'label' => Mage::helper('adminhtml')->__('Value'),
51
  'style' => 'width:120px',
57
  * render cell template
58
  *
59
  * @param string $columnName
60
+ *
61
  * @return string
62
  * @throws Exception
63
  */
64
  protected function _renderCellTemplate($columnName)
65
  {
66
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName
67
+ . ']';
68
+ if ($columnName == "attribute") {
69
  return $this->_getAttributeRenderer()
70
  ->setName($inputName)
71
  ->setTitle($columnName)
74
  $this->getElement()->getValues()
75
  )
76
  ->toHtml();
77
+ } elseif ($columnName == "conditions") {
78
  return $this->_getConditionsRenderer()
79
  ->setName($inputName)
80
  ->setTitle($columnName)
81
  ->setExtraParams('style="width:160px"')
82
+ ->setOptions(
83
+ Mage::getModel(
84
+ 'ddg_automation/adminhtml_source_rules_condition'
85
+ )->toOptionArray()
86
+ )
87
  ->toHtml();
88
+ } elseif ($columnName == "cvalue") {
89
  return $this->_getValueRenderer()
90
  ->setName($inputName)
91
  ->setTitle($columnName)
92
  ->setExtraParams('style="width:160px"')
93
+ ->setOptions(
94
+ Mage::getModel(
95
+ 'ddg_automation/adminhtml_source_rules_value'
96
+ )->toOptionArray()
97
+ )
98
  ->toHtml();
99
  }
100
+
101
  return parent::_renderCellTemplate($columnName);
102
  }
103
 
109
  protected function _prepareArrayRow(Varien_Object $row)
110
  {
111
  $row->setData(
112
+ 'option_extra_attr_' . $this->_getAttributeRenderer()
113
+ ->calcOptionHash($row->getData('attribute')),
114
  'selected="selected"'
115
  );
116
  }
122
  */
123
  protected function _getAttributeRenderer()
124
  {
125
+ if ( ! $this->_getAttributeRenderer) {
126
  $this->_getAttributeRenderer = $this->getLayout()
127
  ->createBlock('ddg_automation/adminhtml_config_select')
128
  ->setIsRenderToJsTemplate(true);
129
  }
130
+
131
  return $this->_getAttributeRenderer;
132
  }
133
 
138
  */
139
  protected function _getConditionsRenderer()
140
  {
141
+ if ( ! $this->_getConditionsRenderer) {
142
  $this->_getConditionsRenderer = $this->getLayout()
143
  ->createBlock('ddg_automation/adminhtml_config_select')
144
  ->setIsRenderToJsTemplate(true);
145
  }
146
+
147
  return $this->_getConditionsRenderer;
148
  }
149
 
154
  */
155
  protected function _getValueRenderer()
156
  {
157
+ if ( ! $this->_getValueRenderer) {
158
  $this->_getValueRenderer = $this->getLayout()
159
  ->createBlock('ddg_automation/adminhtml_config_select')
160
  ->setIsRenderToJsTemplate(true);
161
  }
162
+
163
  return $this->_getValueRenderer;
164
  }
165
 
166
  public function _toHtml()
167
  {
168
+ $script
169
+ = "<script type=\"text/javascript\">
170
  document.observe('dom:loaded', function() {
171
  $$('tr#row_rule_condition tr td:first-child select').each(function(item) {
172
  doUpdateWithValues(item);
196
  });
197
 
198
  function doUpdate(item){
199
+ var url = '" . Mage::helper('adminhtml')->getUrl(
200
+ 'adminhtml/rules/ajax'
201
+ ) . "';
202
  var cond = item.up(1).down().next();
203
  var condName = cond.down().readAttribute('name');
204
  var value = item.up(1).down().next(1);
228
  }
229
 
230
  function doUpdateWithValues(item){
231
+ var url = '" . Mage::helper('adminhtml')->getUrl(
232
+ 'adminhtml/rules/selected'
233
+ ) . "';
234
  var arrayKey = item.up(1).readAttribute('id');
235
  var cond = item.up(1).down().next();
236
  var condName = cond.down().readAttribute('name');
264
  }
265
 
266
  function doUpdateForCondition(item){
267
+ var url = '" . Mage::helper('adminhtml')->getUrl(
268
+ 'adminhtml/rules/value'
269
+ ) . "';
270
  var attribute = item.up(1).down();
271
  var attributeValue = attribute.down().value;
272
  var value = item.up().next();
287
  }
288
  });
289
  </script>";
290
+
291
+ return '<input type="hidden" id="' . $this->getElement()->getHtmlId()
292
+ . '"/>' . parent::_toHtml() . $script;
293
 
294
  }
295
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Select.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select extends Mage_Core_Block_Html_Select
 
4
  {
 
5
  /**
6
  * Return output in one line
7
  *
@@ -9,6 +11,6 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select extends Mage_Core_Bloc
9
  */
10
  public function _toHtml()
11
  {
12
- return trim(preg_replace('/\s+/', ' ',parent::_toHtml()));
13
  }
14
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select
4
+ extends Mage_Core_Block_Html_Select
5
  {
6
+
7
  /**
8
  * Return output in one line
9
  *
11
  */
12
  public function _toHtml()
13
  {
14
+ return trim(preg_replace('/\s+/', ' ', parent::_toHtml()));
15
  }
16
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact.php CHANGED
@@ -1,16 +1,18 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Contact extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  /**
6
- * Set the template.
7
- */
8
  public function __construct()
9
  {
10
- $this->_controller = 'adminhtml_contact';
11
- $this->_blockGroup = 'ddg_automation';
12
  parent::__construct();
13
- $this->_headerText = Mage::helper('ddg')->__('Contacts');
14
  $this->_removeButton('add');
15
 
16
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  /**
8
+ * Set the template.
9
+ */
10
  public function __construct()
11
  {
12
+ $this->_controller = 'adminhtml_contact';
13
+ $this->_blockGroup = 'ddg_automation';
14
  parent::__construct();
15
+ $this->_headerText = Mage::helper('ddg')->__('Contacts');
16
  $this->_removeButton('add');
17
 
18
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit.php CHANGED
@@ -1,20 +1,29 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
  $this->_blockGroup = 'ddg_automation';
9
  $this->_controller = 'adminhtml_contact';
10
- $this->_updateButton('save', 'label', Mage::helper('ddg')->__('Save Contact'));
11
- $this->_updateButton('delete', 'label', Mage::helper('ddg')->__('Delete Contact'));
12
- $this->_addButton('saveandcontinue', array(
13
- 'label' => Mage::helper('ddg')->__('Save And Continue Edit'),
14
- 'onclick' => 'saveAndContinueEdit()',
15
- 'class' => 'save',
16
- ), -100);
17
- $this->_formScripts[] = "
 
 
 
 
 
 
 
18
  function saveAndContinueEdit(){
19
  editForm.submit($('edit_form').action+'back/edit/');
20
  }
@@ -22,13 +31,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit extends Mage_Adminhtml_
22
  }
23
 
24
  /**
25
- * HEader text.
26
- * @return string
27
- */
 
28
  public function getHeaderText()
29
  {
30
- if ( Mage::registry('contact_data') && Mage::registry('contact_data')->getId() ) {
31
- return Mage::helper('ddg')->__("Edit Contact '%s'", $this->htmlEscape(Mage::registry('contact_data')->getContact()));
 
 
 
 
 
32
  } else {
33
  return Mage::helper('ddg')->__('Add Contact');
34
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit
4
+ extends Mage_Adminhtml_Block_Widget_Form_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
  $this->_blockGroup = 'ddg_automation';
11
  $this->_controller = 'adminhtml_contact';
12
+ $this->_updateButton(
13
+ 'save', 'label', Mage::helper('ddg')->__('Save Contact')
14
+ );
15
+ $this->_updateButton(
16
+ 'delete', 'label', Mage::helper('ddg')->__('Delete Contact')
17
+ );
18
+ $this->_addButton(
19
+ 'saveandcontinue', array(
20
+ 'label' => Mage::helper('ddg')->__('Save And Continue Edit'),
21
+ 'onclick' => 'saveAndContinueEdit()',
22
+ 'class' => 'save',
23
+ ), -100
24
+ );
25
+ $this->_formScripts[]
26
+ = "
27
  function saveAndContinueEdit(){
28
  editForm.submit($('edit_form').action+'back/edit/');
29
  }
31
  }
32
 
33
  /**
34
+ * HEader text.
35
+ *
36
+ * @return string
37
+ */
38
  public function getHeaderText()
39
  {
40
+ if (Mage::registry('contact_data')
41
+ && Mage::registry('contact_data')->getId()
42
+ ) {
43
+ return Mage::helper('ddg')->__(
44
+ "Edit Contact '%s'",
45
+ $this->htmlEscape(Mage::registry('contact_data')->getContact())
46
+ );
47
  } else {
48
  return Mage::helper('ddg')->__('Add Contact');
49
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit/Form.php CHANGED
@@ -1,25 +1,33 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
 
4
  {
5
 
6
  /**
7
- * Contact Form.
8
- * @return Mage_Adminhtml_Block_Widget_Form
9
- * @throws Exception
10
- */
 
11
  protected function _prepareForm()
12
  {
13
- $form = new Varien_Data_Form(array(
14
- 'id' => 'edit_form',
15
- 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'store' => $this->getRequest()->getParam('store'))),
16
- 'method' => 'post',
17
- 'enctype' => 'multipart/form-data'
 
 
 
 
 
18
  )
19
  );
20
  $form->setUseContainer(true);
21
 
22
  $this->setForm($form);
 
23
  return parent::_prepareForm();
24
  }
25
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit_Form
4
+ extends Mage_Adminhtml_Block_Widget_Form
5
  {
6
 
7
  /**
8
+ * Contact Form.
9
+ *
10
+ * @return Mage_Adminhtml_Block_Widget_Form
11
+ * @throws Exception
12
+ */
13
  protected function _prepareForm()
14
  {
15
+ $form = new Varien_Data_Form(
16
+ array(
17
+ 'id' => 'edit_form',
18
+ 'action' => $this->getUrl(
19
+ '*/*/save',
20
+ array('id' => $this->getRequest()->getParam('id'),
21
+ 'store' => $this->getRequest()->getParam('store'))
22
+ ),
23
+ 'method' => 'post',
24
+ 'enctype' => 'multipart/form-data'
25
  )
26
  );
27
  $form->setUseContainer(true);
28
 
29
  $this->setForm($form);
30
+
31
  return parent::_prepareForm();
32
  }
33
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -14,203 +16,263 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid extends Mage_Adminhtml_
14
 
15
  protected function _prepareCollection()
16
  {
17
- $collection = Mage::getModel('ddg_automation/contact')->getCollection();
18
  $this->setCollection($collection);
 
19
  return parent::_prepareCollection();
20
  }
21
 
22
  protected function _prepareColumns()
23
  {
24
- $this->addColumn('email_contact_id', array(
25
- 'header' => Mage::helper('ddg')->__('Email Contact ID'),
26
- 'width' => '20px',
27
- 'index' => 'email_contact_id',
28
- 'type' => 'number',
29
- 'escape' => true,
30
- ))->addColumn('email', array(
31
- 'header' => Mage::helper('ddg')->__('Email'),
32
- 'align' => 'left',
33
- 'width' => '50px',
34
- 'index' => 'email',
35
- 'type' => 'text',
36
- 'escape' => true
37
- ))->addColumn('customer_id', array(
38
- 'header' => Mage::helper('ddg')->__('Customer ID'),
39
- 'align' => 'left',
40
- 'index' => 'customer_id',
41
- 'type' => 'number',
42
- 'escape' => true
43
- ))->addColumn('is_guest', array(
44
- 'header' => Mage::helper('ddg')->__('Is Guest'),
45
- 'align' => 'right',
46
- 'width' => '50px',
47
- 'index' => 'is_guest',
48
- 'type' => 'options',
49
- 'options' => array(
50
- '1' => 'Guest',
51
- 'null' => 'Not Guest'
52
- ),
53
- 'escape' => true,
54
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
55
- ))->addColumn('is_subscriber', array(
56
- 'header' => Mage::helper('ddg')->__('Is Subscriber'),
57
- 'width' => '50px',
58
- 'align' => 'right',
59
- 'index' => 'is_subscriber',
60
- 'type' => 'options',
61
- 'options' => array(
62
- '1' => 'Subscriber',
63
- 'null' => 'Not Subscriber'
64
- ),
65
- 'filter_condition_callback' => array($this, 'filterCallbackContact'),
66
- 'escape' => true,
67
- ))->addColumn('subscriber_status', array(
68
- 'header' => Mage::helper('ddg')->__('Subscriber Status'),
69
- 'align' => 'center',
70
- 'width' => '50px',
71
- 'index' => 'subscriber_status',
72
- 'type' => 'options',
73
- 'options' => array(
74
- '1' => 'Subscribed',
75
- '2' => 'Not Active',
76
- '3' => 'Unsubscribed',
77
- '4' => 'Unconfirmed'
78
- ),
79
- 'escape' => true,
80
- ))->addColumn('email_imported', array(
81
- 'header' => Mage::helper('ddg')->__('Email Imported'),
82
- 'width' => '20px',
83
- 'align' => 'center',
84
- 'index' => 'email_imported',
85
- 'escape' => true,
86
- 'type' => 'options',
87
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
88
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
89
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
90
- ))->addColumn('subscriber_imported', array(
91
- 'header' => Mage::helper('ddg')->__('Subscriber Imported'),
92
- 'width' => '20px',
93
- 'align' => 'center',
94
- 'index' => 'subscriber_imported',
95
- 'type' => 'options',
96
- 'escape' => true,
97
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
98
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
99
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
100
- ))->addColumn('suppressed', array(
101
- 'header' => Mage::helper('ddg')->__('Suppressed'),
102
- 'align' => 'right',
103
- 'width' => '50px',
104
- 'index' => 'suppressed',
105
- 'escape' => true,
106
- 'type' => 'options',
107
- 'options' => array(
108
- '1' => 'Suppressed',
109
- 'null' => 'Not Suppressed'
110
- ),
111
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
112
- ));
113
-
114
- //Enterprise customer segments.
115
- if (Mage::helper('ddg')->isEnterprise()) {
116
- $this->addColumn( 'segment_ids', array(
117
- 'header' => Mage::helper( 'ddg' )->__( 'Segment Id\'s' ),
118
- 'align' => 'right',
119
- 'width' => '50px',
120
- 'index' => 'segment_ids',
121
- 'escape' => true,
122
- 'type' => 'text'
123
- ) );
124
- }
125
- if (!Mage::app()->isSingleStoreMode()) {
126
- $this->addColumn('website_id', array(
127
- 'header' => Mage::helper('customer')->__('Website'),
128
- 'align' => 'center',
129
- 'width' => '80px',
130
- 'type' => 'options',
131
- 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
132
- 'index' => 'website_id',
133
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
136
- $this->addColumn('sync', array(
137
- 'header' => Mage::helper('ddg')->__('Sync Contact'),
138
- 'align' => 'center',
139
- 'width' => '80px',
140
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_sync'
 
141
 
142
- ));
 
143
 
144
  $this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
 
145
  return parent::_prepareColumns();
146
  }
147
 
148
  /**
149
- * Get the store.
150
- *
151
- * @return Mage_Core_Model_Store
152
- * @throws Exception
153
- */
154
  protected function _getStore()
155
  {
156
- $storeId = (int) $this->getRequest()->getParam('store', 0);
 
157
  return Mage::app()->getStore($storeId);
158
  }
159
 
160
  /**
161
- * Prepare the grid massaction.
162
- * @return $this|Mage_Adminhtml_Block_Widget_Grid
163
- */
 
164
  protected function _prepareMassaction()
165
  {
166
  $this->setMassactionIdField('email_contact_id');
167
  $this->getMassactionBlock()->setFormFieldName('contact');
168
- $this->getMassactionBlock()->addItem('delete', array(
169
- 'label'=> Mage::helper('ddg')->__('Delete'),
170
- 'url' => $this->getUrl('*/*/massDelete'),
171
- 'confirm' => Mage::helper('ddg')->__('Are you sure?')));
172
- $this->getMassactionBlock()->addItem('resend', array(
173
- 'label' => Mage::helper('ddg')->__('Resend'),
174
- 'url' => $this->getUrl('*/*/massResend'),
175
-
176
- ));
 
 
 
 
 
177
  return $this;
178
  }
179
 
180
  /**
181
- * Custom callback action for the subscribers/contacts.
182
- * @param $collection
183
- * @param $column
184
- */
 
185
  public function filterCallbackContact($collection, $column)
186
  {
187
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
 
188
  $value = $column->getFilter()->getValue();
189
 
190
- if ($value == 'null')
191
- $collection->addFieldToFilter($field, array('null' => true));
192
- else
193
  $collection->addFieldToFilter($field, array('notnull' => true));
 
194
  }
195
 
196
  /**
197
- * Edit the row.
198
- * @param $row
199
- *
200
- * @return string
201
- */
 
202
  public function getRowUrl($row)
203
  {
204
- return $this->getUrl('*/*/edit', array('id' => $row->getEmailContactId()));
 
 
205
  }
206
 
207
  /**
208
- * Grid url.
209
- * @return string
210
- */
 
211
  public function getGridUrl()
212
  {
213
- return $this->getUrl('*/*/grid', array('_current'=>true));
214
  }
215
 
216
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
16
 
17
  protected function _prepareCollection()
18
  {
19
+ $collection = Mage::getModel('ddg_automation/contact')->getCollection();
20
  $this->setCollection($collection);
21
+
22
  return parent::_prepareCollection();
23
  }
24
 
25
  protected function _prepareColumns()
26
  {
27
+ $this->addColumn(
28
+ 'email_contact_id', array(
29
+ 'header' => Mage::helper('ddg')->__('Email Contact ID'),
30
+ 'width' => '20px',
31
+ 'index' => 'email_contact_id',
32
+ 'type' => 'number',
33
+ 'escape' => true,
34
+ )
35
+ )->addColumn(
36
+ 'email', array(
37
+ 'header' => Mage::helper('ddg')->__('Email'),
38
+ 'align' => 'left',
39
+ 'width' => '50px',
40
+ 'index' => 'email',
41
+ 'type' => 'text',
42
+ 'escape' => true
43
+ )
44
+ )->addColumn(
45
+ 'customer_id', array(
46
+ 'header' => Mage::helper('ddg')->__('Customer ID'),
47
+ 'align' => 'left',
48
+ 'index' => 'customer_id',
49
+ 'type' => 'number',
50
+ 'escape' => true
51
+ )
52
+ )->addColumn(
53
+ 'is_guest', array(
54
+ 'header' => Mage::helper('ddg')->__(
55
+ 'Is Guest'
56
+ ),
57
+ 'align' => 'right',
58
+ 'width' => '50px',
59
+ 'index' => 'is_guest',
60
+ 'type' => 'options',
61
+ 'options' => array(
62
+ '1' => 'Guest',
63
+ 'null' => 'Not Guest'
64
+ ),
65
+ 'escape' => true,
66
+ 'filter_condition_callback' => array($this,
67
+ 'filterCallbackContact')
68
+ )
69
+ )->addColumn(
70
+ 'is_subscriber', array(
71
+ 'header' => Mage::helper('ddg')->__(
72
+ 'Is Subscriber'
73
+ ),
74
+ 'width' => '50px',
75
+ 'align' => 'right',
76
+ 'index' => 'is_subscriber',
77
+ 'type' => 'options',
78
+ 'options' => array(
79
+ '1' => 'Subscriber',
80
+ 'null' => 'Not Subscriber'
81
+ ),
82
+ 'filter_condition_callback' => array($this,
83
+ 'filterCallbackContact'),
84
+ 'escape' => true,
85
+ )
86
+ )->addColumn(
87
+ 'subscriber_status', array(
88
+ 'header' => Mage::helper('ddg')->__('Subscriber Status'),
89
+ 'align' => 'center',
90
+ 'width' => '50px',
91
+ 'index' => 'subscriber_status',
92
+ 'type' => 'options',
93
+ 'options' => array(
94
+ '1' => 'Subscribed',
95
+ '2' => 'Not Active',
96
+ '3' => 'Unsubscribed',
97
+ '4' => 'Unconfirmed'
98
+ ),
99
+ 'escape' => true,
100
+ )
101
+ )->addColumn(
102
+ 'email_imported', array(
103
+ 'header' => Mage::helper('ddg')->__(
104
+ 'Email Imported'
105
+ ),
106
+ 'width' => '20px',
107
+ 'align' => 'center',
108
+ 'index' => 'email_imported',
109
+ 'escape' => true,
110
+ 'type' => 'options',
111
+ 'options' => Mage::getModel(
112
+ 'ddg_automation/adminhtml_source_contact_imported'
113
+ )->getOptions(),
114
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
115
+ 'filter_condition_callback' => array($this,
116
+ 'filterCallbackContact')
117
+ )
118
+ )->addColumn(
119
+ 'subscriber_imported', array(
120
+ 'header' => Mage::helper('ddg')->__(
121
+ 'Subscriber Imported'
122
+ ),
123
+ 'width' => '20px',
124
+ 'align' => 'center',
125
+ 'index' => 'subscriber_imported',
126
+ 'type' => 'options',
127
+ 'escape' => true,
128
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
129
+ 'options' => Mage::getModel(
130
+ 'ddg_automation/adminhtml_source_contact_imported'
131
+ )->getOptions(),
132
+ 'filter_condition_callback' => array($this,
133
+ 'filterCallbackContact')
134
+ )
135
+ )->addColumn(
136
+ 'suppressed', array(
137
+ 'header' => Mage::helper('ddg')->__(
138
+ 'Suppressed'
139
+ ),
140
+ 'align' => 'right',
141
+ 'width' => '50px',
142
+ 'index' => 'suppressed',
143
+ 'escape' => true,
144
+ 'type' => 'options',
145
+ 'options' => array(
146
+ '1' => 'Suppressed',
147
+ 'null' => 'Not Suppressed'
148
+ ),
149
+ 'filter_condition_callback' => array($this,
150
+ 'filterCallbackContact')
151
+ )
152
+ );
153
+
154
+ //Enterprise customer segments.
155
+ if (Mage::helper('ddg')->isEnterprise()) {
156
+ $this->addColumn(
157
+ 'segment_ids', array(
158
+ 'header' => Mage::helper('ddg')->__('Segment Id\'s'),
159
+ 'align' => 'right',
160
+ 'width' => '50px',
161
+ 'index' => 'segment_ids',
162
+ 'escape' => true,
163
+ 'type' => 'text'
164
+ )
165
+ );
166
+ }
167
+ if ( ! Mage::app()->isSingleStoreMode()) {
168
+ $this->addColumn(
169
+ 'website_id', array(
170
+ 'header' => Mage::helper('customer')->__('Website'),
171
+ 'align' => 'center',
172
+ 'width' => '80px',
173
+ 'type' => 'options',
174
+ 'options' => Mage::getSingleton('adminhtml/system_store')
175
+ ->getWebsiteOptionHash(true),
176
+ 'index' => 'website_id',
177
+ )
178
+ );
179
  }
180
 
181
+ $this->addColumn(
182
+ 'sync', array(
183
+ 'header' => Mage::helper('ddg')->__('Sync Contact'),
184
+ 'align' => 'center',
185
+ 'width' => '80px',
186
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_sync'
187
 
188
+ )
189
+ );
190
 
191
  $this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
192
+
193
  return parent::_prepareColumns();
194
  }
195
 
196
  /**
197
+ * Get the store.
198
+ *
199
+ * @return Mage_Core_Model_Store
200
+ * @throws Exception
201
+ */
202
  protected function _getStore()
203
  {
204
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
205
+
206
  return Mage::app()->getStore($storeId);
207
  }
208
 
209
  /**
210
+ * Prepare the grid massaction.
211
+ *
212
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
213
+ */
214
  protected function _prepareMassaction()
215
  {
216
  $this->setMassactionIdField('email_contact_id');
217
  $this->getMassactionBlock()->setFormFieldName('contact');
218
+ $this->getMassactionBlock()->addItem(
219
+ 'delete', array(
220
+ 'label' => Mage::helper('ddg')->__('Delete'),
221
+ 'url' => $this->getUrl('*/*/massDelete'),
222
+ 'confirm' => Mage::helper('ddg')->__('Are you sure?'))
223
+ );
224
+ $this->getMassactionBlock()->addItem(
225
+ 'resend', array(
226
+ 'label' => Mage::helper('ddg')->__('Resend'),
227
+ 'url' => $this->getUrl('*/*/massResend'),
228
+
229
+ )
230
+ );
231
+
232
  return $this;
233
  }
234
 
235
  /**
236
+ * Custom callback action for the subscribers/contacts.
237
+ *
238
+ * @param $collection
239
+ * @param $column
240
+ */
241
  public function filterCallbackContact($collection, $column)
242
  {
243
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
244
+ : $column->getIndex();
245
  $value = $column->getFilter()->getValue();
246
 
247
+ if ($value == 'null') {
248
+ $collection->addFieldToFilter($field, array('null' => true));
249
+ } else {
250
  $collection->addFieldToFilter($field, array('notnull' => true));
251
+ }
252
  }
253
 
254
  /**
255
+ * Edit the row.
256
+ *
257
+ * @param $row
258
+ *
259
+ * @return string
260
+ */
261
  public function getRowUrl($row)
262
  {
263
+ return $this->getUrl(
264
+ '*/*/edit', array('id' => $row->getEmailContactId())
265
+ );
266
  }
267
 
268
  /**
269
+ * Grid url.
270
+ *
271
+ * @return string
272
+ */
273
  public function getGridUrl()
274
  {
275
+ return $this->getUrl('*/*/grid', array('_current' => true));
276
  }
277
 
278
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Customer/Tab.php CHANGED
@@ -2,7 +2,8 @@
2
 
3
  class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab
4
  extends Mage_Adminhtml_Block_Widget
5
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
 
6
 
7
  public function getTabLabel()
8
  {
2
 
3
  class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab
4
  extends Mage_Adminhtml_Block_Widget
5
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
+ {
7
 
8
  public function getTabLabel()
9
  {
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Customer/Tab/Stats.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats extends Mage_Adminhtml_Block_Template
 
4
  {
 
5
  protected $_stat = array();
6
 
7
  public function _construct()
@@ -11,21 +13,27 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats extends Mage_Admi
11
 
12
  protected function _getCampaignStatsForCustomer()
13
  {
14
- $id = Mage::app()->getRequest()->getParam('id');
15
  $customer = Mage::getModel('customer/customer')->load($id);
16
- $email = $customer->getEmail();
17
- $website = $customer->getStore()->getWebsite();
18
 
19
- $client = Mage::helper('ddg')->getWebsiteApiClient($website);
20
  $contact = $client->postContacts($email);
21
- if(!isset($contact->message)){
22
- $locale = Mage::app()->getLocale()->getLocale();
23
- $date = Zend_Date::now($locale)->subDay(30);
24
- $response = $client->getCampaignsWithActivitySinceDate($date->toString(Zend_Date::ISO_8601));
25
- if(!isset($response->message) && is_array($response)){
26
- foreach($response as $one){
27
- $result = $client->getCampaignActivityByContactId($one->id, $contact->id);
28
- if(!empty($result) && !isset($result->message) && !is_null($result)){
 
 
 
 
 
 
29
  $this->_stat[$one->name] = $result;
30
  }
31
  }
@@ -36,6 +44,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats extends Mage_Admi
36
  public function getStats()
37
  {
38
  $this->_getCampaignStatsForCustomer();
 
39
  return $this->_stat;
40
  }
41
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats
4
+ extends Mage_Adminhtml_Block_Template
5
  {
6
+
7
  protected $_stat = array();
8
 
9
  public function _construct()
13
 
14
  protected function _getCampaignStatsForCustomer()
15
  {
16
+ $id = Mage::app()->getRequest()->getParam('id');
17
  $customer = Mage::getModel('customer/customer')->load($id);
18
+ $email = $customer->getEmail();
19
+ $website = $customer->getStore()->getWebsite();
20
 
21
+ $client = Mage::helper('ddg')->getWebsiteApiClient($website);
22
  $contact = $client->postContacts($email);
23
+ if ( ! isset($contact->message)) {
24
+ $locale = Mage::app()->getLocale()->getLocale();
25
+ $date = Zend_Date::now($locale)->subDay(30);
26
+ $response = $client->getCampaignsWithActivitySinceDate(
27
+ $date->toString(Zend_Date::ISO_8601)
28
+ );
29
+ if ( ! isset($response->message) && is_array($response)) {
30
+ foreach ($response as $one) {
31
+ $result = $client->getCampaignActivityByContactId(
32
+ $one->id, $contact->id
33
+ );
34
+ if ( ! empty($result) && ! isset($result->message)
35
+ && ! is_null($result)
36
+ ) {
37
  $this->_stat[$one->name] = $result;
38
  }
39
  }
44
  public function getStats()
45
  {
46
  $this->_getCampaignStatsForCustomer();
47
+
48
  return $this->_stat;
49
  }
50
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard.php CHANGED
@@ -1,52 +1,54 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard extends Mage_Adminhtml_Block_Dashboard_Bar
4
-
5
  {
6
- /**
7
- * Set the template.
8
- */
9
- public function _construct()
10
- {
11
- parent::_construct();
12
-
13
- $this->setTemplate('connector/dashboard/accountbar.phtml');
14
- }
15
-
16
- /**
17
- * Prepare the layout.
18
- *
19
- * @return Mage_Core_Block_Abstract|void
20
- * @throws Exception
21
- */
22
- protected function _prepareLayout() {
23
-
24
-
25
- $website = 0;
26
- //request store param
27
- if ($store = $this->getRequest()->getParam('store')) {
28
- $website = Mage::app()->getStore($store)->getWebsite();
29
- //website param
30
- } elseif ($this->getRequest()->getParam('website')) {
31
- $website = $this->getRequest()->getParam('website');
32
- }
33
-
34
- $apiUsername = Mage::helper('ddg')->getApiUsername($website);
35
- $apiPassword = Mage::helper('ddg')->getApiPassword($website);
36
-
37
- //api get account info
38
- $data = Mage::getModel('ddg_automation/apiconnector_client')
39
- ->setApiUsername($apiUsername)
40
- ->setApiPassword($apiPassword)
41
- ->getAccountInfo();
42
-
43
- //check if properties for the data exists
44
- if (isset($data->properties)) {
45
- foreach ( $data->properties as $one ) {
46
- //add total for the api calls
47
- $this->addTotal( $this->__( $one->name ), $one->value, true );
48
- }
49
- }
50
- }
 
 
51
 
52
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard
4
+ extends Mage_Adminhtml_Block_Dashboard_Bar
5
  {
6
+
7
+ /**
8
+ * Set the template.
9
+ */
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+
14
+ $this->setTemplate('connector/dashboard/accountbar.phtml');
15
+ }
16
+
17
+ /**
18
+ * Prepare the layout.
19
+ *
20
+ * @return Mage_Core_Block_Abstract|void
21
+ * @throws Exception
22
+ */
23
+ protected function _prepareLayout()
24
+ {
25
+
26
+
27
+ $website = 0;
28
+ //request store param
29
+ if ($store = $this->getRequest()->getParam('store')) {
30
+ $website = Mage::app()->getStore($store)->getWebsite();
31
+ //website param
32
+ } elseif ($this->getRequest()->getParam('website')) {
33
+ $website = $this->getRequest()->getParam('website');
34
+ }
35
+
36
+ $apiUsername = Mage::helper('ddg')->getApiUsername($website);
37
+ $apiPassword = Mage::helper('ddg')->getApiPassword($website);
38
+
39
+ //api get account info
40
+ $data = Mage::getModel('ddg_automation/apiconnector_client')
41
+ ->setApiUsername($apiUsername)
42
+ ->setApiPassword($apiPassword)
43
+ ->getAccountInfo();
44
+
45
+ //check if properties for the data exists
46
+ if (isset($data->properties)) {
47
+ foreach ($data->properties as $one) {
48
+ //add total for the api calls
49
+ $this->addTotal($this->__($one->name), $one->value, true);
50
+ }
51
+ }
52
+ }
53
 
54
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Switcher.php CHANGED
@@ -1,92 +1,103 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Switcher extends Mage_Adminhtml_Block_Template
 
4
  {
5
- protected function _prepareLayout()
6
- {
7
- $this->setTemplate('system/config/switcher.phtml');
8
- return parent::_prepareLayout();
9
- }
10
 
11
- /**
12
- *
13
- * @return array
14
- */
15
- public function getStoreSelectOptions()
16
- {
17
- $section = $this->getRequest()->getParam('section');
18
 
19
- $curWebsite = $this->getRequest()->getParam('website');
20
- $curStore = $this->getRequest()->getParam('store');
21
 
22
- $storeModel = Mage::getSingleton('adminhtml/system_store');
23
- /* @var $storeModel Mage_Adminhtml_Model_System_Store */
 
 
 
 
 
24
 
25
- $url = Mage::getModel('adminhtml/url');
 
26
 
27
- $options = array();
28
- $options['default'] = array(
29
- 'label' => Mage::helper('adminhtml')->__('Default Config'),
30
- 'url' => $url->getUrl('*/*/*', array('section'=>$section)),
31
- 'selected' => !$curWebsite && !$curStore,
32
- 'style' => 'background:#ccc; font-weight:bold;',
33
- );
34
 
35
- foreach ($storeModel->getWebsiteCollection() as $website) {
36
- $websiteShow = false;
37
- foreach ($storeModel->getGroupCollection() as $group) {
38
- if ($group->getWebsiteId() != $website->getId()) {
39
- continue;
40
- }
41
- $groupShow = false;
42
- foreach ($storeModel->getStoreCollection() as $store) {
43
- if ($store->getGroupId() != $group->getId()) {
44
- continue;
45
- }
46
- if (!$websiteShow) {
47
- $websiteShow = true;
48
- $options['website_' . $website->getId()] = array(
49
- 'label' => $website->getName(),
50
- 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getId())),
51
- 'selected' => !$curStore && $curWebsite == $website->getId(),
52
- 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
53
- );
54
- }
55
- if (!$groupShow) {
56
- $groupShow = true;
57
- $options['group_' . $group->getId() . '_open'] = array(
58
- 'is_group' => true,
59
- 'is_close' => false,
60
- 'label' => $group->getName(),
61
- 'style' => 'padding-left:32px;'
62
- );
63
- }
64
- $options['store_' . $store->getId()] = array(
65
- 'label' => $store->getName(),
66
- 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'store'=>$store->getId())),
67
- 'selected' => $curStore == $store->getId(),
68
- 'style' => '',
69
- );
70
- }
71
- if ($groupShow) {
72
- $options['group_' . $group->getId() . '_close'] = array(
73
- 'is_group' => true,
74
- 'is_close' => true,
75
- );
76
- }
77
- }
78
- }
79
 
80
- return $options;
81
- }
 
 
 
 
 
82
 
83
- /**
84
- * Return store switcher hint html
85
- *
86
- * @return mixed
87
- */
88
- public function getHintHtml()
89
- {
90
- return Mage::getBlockSingleton('adminhtml/store_switcher')->getHintHtml();
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Switcher
4
+ extends Mage_Adminhtml_Block_Template
5
  {
 
 
 
 
 
6
 
7
+ protected function _prepareLayout()
8
+ {
9
+ $this->setTemplate('system/config/switcher.phtml');
 
 
 
 
10
 
11
+ return parent::_prepareLayout();
12
+ }
13
 
14
+ /**
15
+ *
16
+ * @return array
17
+ */
18
+ public function getStoreSelectOptions()
19
+ {
20
+ $section = $this->getRequest()->getParam('section');
21
 
22
+ $curWebsite = $this->getRequest()->getParam('website');
23
+ $curStore = $this->getRequest()->getParam('store');
24
 
25
+ $storeModel = Mage::getSingleton('adminhtml/system_store');
26
+ /* @var $storeModel Mage_Adminhtml_Model_System_Store */
 
 
 
 
 
27
 
28
+ $url = Mage::getModel('adminhtml/url');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ $options = array();
31
+ $options['default'] = array(
32
+ 'label' => Mage::helper('adminhtml')->__('Default Config'),
33
+ 'url' => $url->getUrl('*/*/*', array('section' => $section)),
34
+ 'selected' => ! $curWebsite && ! $curStore,
35
+ 'style' => 'background:#ccc; font-weight:bold;',
36
+ );
37
 
38
+ foreach ($storeModel->getWebsiteCollection() as $website) {
39
+ $websiteShow = false;
40
+ foreach ($storeModel->getGroupCollection() as $group) {
41
+ if ($group->getWebsiteId() != $website->getId()) {
42
+ continue;
43
+ }
44
+ $groupShow = false;
45
+ foreach ($storeModel->getStoreCollection() as $store) {
46
+ if ($store->getGroupId() != $group->getId()) {
47
+ continue;
48
+ }
49
+ if ( ! $websiteShow) {
50
+ $websiteShow = true;
51
+ $options['website_' . $website->getId()] = array(
52
+ 'label' => $website->getName(),
53
+ 'url' => $url->getUrl(
54
+ '*/*/*', array('section' => $section,
55
+ 'website' => $website->getId())
56
+ ),
57
+ 'selected' => ! $curStore
58
+ && $curWebsite == $website->getId(),
59
+ 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
60
+ );
61
+ }
62
+ if ( ! $groupShow) {
63
+ $groupShow = true;
64
+ $options['group_' . $group->getId() . '_open'] = array(
65
+ 'is_group' => true,
66
+ 'is_close' => false,
67
+ 'label' => $group->getName(),
68
+ 'style' => 'padding-left:32px;'
69
+ );
70
+ }
71
+ $options['store_' . $store->getId()] = array(
72
+ 'label' => $store->getName(),
73
+ 'url' => $url->getUrl(
74
+ '*/*/*', array('section' => $section,
75
+ 'store' => $store->getId())
76
+ ),
77
+ 'selected' => $curStore == $store->getId(),
78
+ 'style' => '',
79
+ );
80
+ }
81
+ if ($groupShow) {
82
+ $options['group_' . $group->getId() . '_close'] = array(
83
+ 'is_group' => true,
84
+ 'is_close' => true,
85
+ );
86
+ }
87
+ }
88
+ }
89
+
90
+ return $options;
91
+ }
92
+
93
+ /**
94
+ * Return store switcher hint html
95
+ *
96
+ * @return mixed
97
+ */
98
+ public function getHintHtml()
99
+ {
100
+ return Mage::getBlockSingleton('adminhtml/store_switcher')->getHintHtml(
101
+ );
102
+ }
103
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs.php CHANGED
@@ -1,59 +1,65 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
 
4
  {
5
 
6
- public function __construct()
7
- {
8
- parent::__construct();
9
- $this->setId('connector_dashboard_tabs');
10
- $this->setTitle($this->__('Dashboards' ));
11
- $this->setTemplate('connector/dashboard/tabs.phtml');
12
- }
13
 
14
- /**
15
- * set tabs
16
- *
17
- * @return Mage_Core_Block_Abstract
18
- * @throws Exception
19
- */
20
- protected function _beforeToHtml()
21
- {
22
- $this->addTab(
23
- 'general',
24
- array (
25
- 'label' => $this->__('Account Information'),
26
- 'title' => $this->__('Account Information'),
27
- 'content' => $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_general')->toHtml(),
28
- 'active' => true
29
- )
30
- );
31
- $this->addTab(
32
- 'status',
33
- array (
34
- 'label' => $this->__('Connector Status'),
35
- 'title' => $this->__('Connector Status'),
36
- 'url' => $this->getUrl('*/*/statusGrid'),
37
- 'class' => 'ajax',
38
- )
39
- );
40
- $this->addTab(
41
- 'analysis',
42
- array (
43
- 'label' => $this->__('Data Analysis'),
44
- 'title' => $this->__('Data Analysis'),
45
- 'content' => $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis')->toHtml()
46
- )
47
- );
48
- $this->addTab(
49
- 'logs',
50
- array (
51
- 'label' => $this->__('Connector Logs'),
52
- 'title' => $this->__('Connector Logs'),
53
- 'url' => $this->getUrl('*/*/logs'),
54
- 'class' => 'ajax',
55
- )
56
- );
57
- return parent::_beforeToHtml();
58
- }
 
 
 
 
 
59
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs
4
+ extends Mage_Adminhtml_Block_Widget_Tabs
5
  {
6
 
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId('connector_dashboard_tabs');
11
+ $this->setTitle($this->__('Dashboards'));
12
+ $this->setTemplate('connector/dashboard/tabs.phtml');
13
+ }
14
 
15
+ /**
16
+ * set tabs
17
+ *
18
+ * @return Mage_Core_Block_Abstract
19
+ * @throws Exception
20
+ */
21
+ protected function _beforeToHtml()
22
+ {
23
+ $this->addTab(
24
+ 'general',
25
+ array(
26
+ 'label' => $this->__('Account Information'),
27
+ 'title' => $this->__('Account Information'),
28
+ 'content' => $this->getLayout()->createBlock(
29
+ 'ddg_automation/adminhtml_dashboard_tabs_general'
30
+ )->toHtml(),
31
+ 'active' => true
32
+ )
33
+ );
34
+ $this->addTab(
35
+ 'status',
36
+ array(
37
+ 'label' => $this->__('Connector Status'),
38
+ 'title' => $this->__('Connector Status'),
39
+ 'url' => $this->getUrl('*/*/statusGrid'),
40
+ 'class' => 'ajax',
41
+ )
42
+ );
43
+ $this->addTab(
44
+ 'analysis',
45
+ array(
46
+ 'label' => $this->__('Data Analysis'),
47
+ 'title' => $this->__('Data Analysis'),
48
+ 'content' => $this->getLayout()->createBlock(
49
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis'
50
+ )->toHtml()
51
+ )
52
+ );
53
+ $this->addTab(
54
+ 'logs',
55
+ array(
56
+ 'label' => $this->__('Connector Logs'),
57
+ 'title' => $this->__('Connector Logs'),
58
+ 'url' => $this->getUrl('*/*/logs'),
59
+ 'class' => 'ajax',
60
+ )
61
+ );
62
+
63
+ return parent::_beforeToHtml();
64
+ }
65
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis.php CHANGED
@@ -1,61 +1,78 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis extends Mage_Adminhtml_Block_Dashboard_Bar
 
4
  {
5
- /**
6
- * set template
7
- *
8
- * @throws Exception
9
- */
10
- public function _construct()
11
- {
12
- parent::_construct();
13
- $this->setTemplate('connector/dashboard/tabs/analysis/index.phtml');
14
- }
15
 
16
- /**
17
- * Prepare the layout. set child blocks
18
- *
19
- * @return Mage_Core_Block_Abstract|void
20
- * @throws Exception
21
- */
22
- protected function _prepareLayout()
23
- {
24
- $this->setChild('sales',
25
- $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_sales')
26
- );
27
- $this->setChild('abandoned_cart',
28
- $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_abandonedcarts')
29
- );
30
- $this->setChild('customer',
31
- $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_customer')
32
- );
33
- $this->setChild('subscriber',
34
- $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber')
35
- );
36
- $this->setChild('rfm',
37
- $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_rfm')
38
- );
39
- parent::_prepareLayout();
40
- }
41
 
42
- /**
43
- * get Tab content title
44
- *
45
- * @return string
46
- */
47
- public function getTitle()
48
- {
49
- return Mage::helper('ddg')->__("Marketing Automation Data Analysis");
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- /**
53
- * get column width
54
- *
55
- * @return string
56
- */
57
- public function getColumnWidth()
58
- {
59
- return "290px";
60
- }
 
 
 
 
 
 
 
 
 
 
61
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
4
+ extends Mage_Adminhtml_Block_Dashboard_Bar
5
  {
 
 
 
 
 
 
 
 
 
 
6
 
7
+ /**
8
+ * set template
9
+ *
10
+ * @throws Exception
11
+ */
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->setTemplate('connector/dashboard/tabs/analysis/index.phtml');
16
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ /**
19
+ * Prepare the layout. set child blocks
20
+ *
21
+ * @return Mage_Core_Block_Abstract|void
22
+ * @throws Exception
23
+ */
24
+ protected function _prepareLayout()
25
+ {
26
+ $this->setChild(
27
+ 'sales',
28
+ $this->getLayout()->createBlock(
29
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_sales'
30
+ )
31
+ );
32
+ $this->setChild(
33
+ 'abandoned_cart',
34
+ $this->getLayout()->createBlock(
35
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_abandonedcarts'
36
+ )
37
+ );
38
+ $this->setChild(
39
+ 'customer',
40
+ $this->getLayout()->createBlock(
41
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_customer'
42
+ )
43
+ );
44
+ $this->setChild(
45
+ 'subscriber',
46
+ $this->getLayout()->createBlock(
47
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber'
48
+ )
49
+ );
50
+ $this->setChild(
51
+ 'rfm',
52
+ $this->getLayout()->createBlock(
53
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_rfm'
54
+ )
55
+ );
56
+ parent::_prepareLayout();
57
+ }
58
 
59
+ /**
60
+ * get Tab content title
61
+ *
62
+ * @return string
63
+ */
64
+ public function getTitle()
65
+ {
66
+ return Mage::helper('ddg')->__("Marketing Automation Data Analysis");
67
+ }
68
+
69
+ /**
70
+ * get column width
71
+ *
72
+ * @return string
73
+ */
74
+ public function getColumnWidth()
75
+ {
76
+ return "290px";
77
+ }
78
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Abandonedcarts.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcarts extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
 
4
  {
 
5
  protected $_store = 0;
6
  protected $_group = 0;
7
  protected $_website = 0;
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcar
15
  {
16
  parent::_construct();
17
 
18
- $this->_store = $this->getRequest()->getParam('store');
19
- $this->_group = $this->getRequest()->getParam('group');
20
  $this->_website = $this->getRequest()->getParam('website');
21
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
  }
@@ -30,10 +32,22 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcar
30
  protected function _prepareLayout()
31
  {
32
  $lifetimeAbanodned = $this->getAbandonedCartInformationForTab();
33
- $this->addTotal($this->__('Total Abandoned Cart Lost Revenue'), $lifetimeAbanodned->getLifetime());
34
- $this->addTotal($this->__('Average Abandoned Cart Lost Revenue'), $lifetimeAbanodned->getAverage());
35
- $this->addTotal($this->__('Total Number Of Abandoned Carts'), $lifetimeAbanodned->getTotalCount(), true);
36
- $this->addTotal($this->__('Average Abandoned Carts Created Per Day'), $lifetimeAbanodned->getDayCount(), true);
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
  /**
@@ -43,8 +57,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcar
43
  */
44
  protected function getAbandonedCartInformationForTab()
45
  {
46
- $abandonedAnalysisModel = Mage::getModel('ddg_automation/adminhtml_dashboard_tabs_analysis_abandoned');
47
- return $abandonedAnalysisModel->getLifeTimeAbandoned($this->_store, $this->_website, $this->_group);
 
 
 
 
 
48
  }
49
 
50
  /**
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcarts
4
+ extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
5
  {
6
+
7
  protected $_store = 0;
8
  protected $_group = 0;
9
  protected $_website = 0;
17
  {
18
  parent::_construct();
19
 
20
+ $this->_store = $this->getRequest()->getParam('store');
21
+ $this->_group = $this->getRequest()->getParam('group');
22
  $this->_website = $this->getRequest()->getParam('website');
23
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
24
  }
32
  protected function _prepareLayout()
33
  {
34
  $lifetimeAbanodned = $this->getAbandonedCartInformationForTab();
35
+ $this->addTotal(
36
+ $this->__('Total Abandoned Cart Lost Revenue'),
37
+ $lifetimeAbanodned->getLifetime()
38
+ );
39
+ $this->addTotal(
40
+ $this->__('Average Abandoned Cart Lost Revenue'),
41
+ $lifetimeAbanodned->getAverage()
42
+ );
43
+ $this->addTotal(
44
+ $this->__('Total Number Of Abandoned Carts'),
45
+ $lifetimeAbanodned->getTotalCount(), true
46
+ );
47
+ $this->addTotal(
48
+ $this->__('Average Abandoned Carts Created Per Day'),
49
+ $lifetimeAbanodned->getDayCount(), true
50
+ );
51
  }
52
 
53
  /**
57
  */
58
  protected function getAbandonedCartInformationForTab()
59
  {
60
+ $abandonedAnalysisModel = Mage::getModel(
61
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_abandoned'
62
+ );
63
+
64
+ return $abandonedAnalysisModel->getLifeTimeAbandoned(
65
+ $this->_store, $this->_website, $this->_group
66
+ );
67
  }
68
 
69
  /**
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Customer.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
 
4
  {
 
5
  protected $_store = 0;
6
  protected $_group = 0;
7
  protected $_website = 0;
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
15
  {
16
  parent::_construct();
17
 
18
- $this->_store = $this->getRequest()->getParam('store');
19
- $this->_group = $this->getRequest()->getParam('group');
20
  $this->_website = $this->getRequest()->getParam('website');
21
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
  }
@@ -30,8 +32,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
30
  protected function _prepareLayout()
31
  {
32
  $lifetimeCustomer = $this->getCustomerInformationForTab();
33
- $this->addTotal($this->__('Total Number Of Customers'), $lifetimeCustomer->getTotalCount(), true);
34
- $this->addTotal($this->__('Average Customers Created Per Day'), $lifetimeCustomer->getDayCount(), true);
 
 
 
 
 
 
35
  }
36
 
37
  /**
@@ -41,8 +49,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
41
  */
42
  protected function getCustomerInformationForTab()
43
  {
44
- $customerAnalysisModel = Mage::getModel('ddg_automation/adminhtml_dashboard_tabs_analysis_customer');
45
- return $customerAnalysisModel->getLifeTimeTimeCustomer($this->_store, $this->_website, $this->_group);
 
 
 
 
 
46
  }
47
 
48
  /**
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer
4
+ extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
5
  {
6
+
7
  protected $_store = 0;
8
  protected $_group = 0;
9
  protected $_website = 0;
17
  {
18
  parent::_construct();
19
 
20
+ $this->_store = $this->getRequest()->getParam('store');
21
+ $this->_group = $this->getRequest()->getParam('group');
22
  $this->_website = $this->getRequest()->getParam('website');
23
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
24
  }
32
  protected function _prepareLayout()
33
  {
34
  $lifetimeCustomer = $this->getCustomerInformationForTab();
35
+ $this->addTotal(
36
+ $this->__('Total Number Of Customers'),
37
+ $lifetimeCustomer->getTotalCount(), true
38
+ );
39
+ $this->addTotal(
40
+ $this->__('Average Customers Created Per Day'),
41
+ $lifetimeCustomer->getDayCount(), true
42
+ );
43
  }
44
 
45
  /**
49
  */
50
  protected function getCustomerInformationForTab()
51
  {
52
+ $customerAnalysisModel = Mage::getModel(
53
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_customer'
54
+ );
55
+
56
+ return $customerAnalysisModel->getLifeTimeTimeCustomer(
57
+ $this->_store, $this->_website, $this->_group
58
+ );
59
  }
60
 
61
  /**
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php CHANGED
@@ -1,8 +1,10 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
 
4
  {
5
- protected $rfm = array();
 
6
  protected $_store = 0;
7
  protected $_group = 0;
8
  protected $_website = 0;
@@ -17,8 +19,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
17
  {
18
  parent::_construct();
19
 
20
- $this->_store = $this->getRequest()->getParam('store');
21
- $this->_group = $this->getRequest()->getParam('group');
22
  $this->_website = $this->getRequest()->getParam('website');
23
  $this->setTemplate('connector/dashboard/tabs/analysis/rfm.phtml');
24
  }
@@ -31,10 +33,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
31
  */
32
  protected function _prepareLayout()
33
  {
34
- $rfmAnalysisModel = Mage::getModel('ddg_automation/adminhtml_dashboard_tabs_analysis_rfm');
35
- $this->rfm = $rfmAnalysisModel->getPreparedRfm($this->_store, $this->_website, $this->_group);
36
- foreach($this->rfm['Monetary'] as $key => $value)
37
- {
 
 
 
38
  $this->rfm['Monetary'][$key] = $this->format($value);
39
  }
40
  }
@@ -44,28 +49,31 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
44
  */
45
  protected function getRfm()
46
  {
47
- foreach($this->rfm as $k => $type){
48
- foreach($type as $p => $value){
49
- if($value == '')
50
  $this->rfm[$k][$p] = '0';
 
51
  }
52
  }
 
53
  return $this->rfm;
54
  }
55
 
56
- /**
57
- * @return array
58
- */
59
- protected function getLabels() {
 
60
 
61
- $labels = array(
62
- Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::FREQUENCY => "Frequency (orders)",
63
- Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::RECENCY => "Recency (days)",
64
- Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::MONETARY => "Monetary (value)"
65
- );
66
 
67
- return $labels;
68
- }
69
 
70
  /**
71
  * get currency
@@ -77,14 +85,21 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
77
  public function getCurrency()
78
  {
79
  if ($this->_store) {
80
- $currencyCode = Mage::app()->getStore($this->getRequest()->getParam('store'))->getBaseCurrency();
81
- } else if ($this->_website){
82
- $currencyCode = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getBaseCurrency();
83
- } else if ($this->_group){
84
- $currencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
 
 
 
 
 
 
85
  } else {
86
  $currencyCode = Mage::app()->getStore()->getBaseCurrency();
87
  }
 
88
  return $currencyCode;
89
  }
90
 
@@ -92,6 +107,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
92
  * format price from currency
93
  *
94
  * @param $price
 
95
  * @return string
96
  */
97
  public function format($price)
@@ -101,6 +117,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
101
 
102
  public function getTitle()
103
  {
104
- return $this->__("RFM Matrix") . "(<a href='https://econsultancy.com/blog/64481-finding-your-best-customers-with-the-rfm-matrix' target='_blank'>" . $this->__("Find out more") . "</a>)";
 
 
105
  }
106
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm
4
+ extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
5
  {
6
+
7
+ public $rfm = array();
8
  protected $_store = 0;
9
  protected $_group = 0;
10
  protected $_website = 0;
19
  {
20
  parent::_construct();
21
 
22
+ $this->_store = $this->getRequest()->getParam('store');
23
+ $this->_group = $this->getRequest()->getParam('group');
24
  $this->_website = $this->getRequest()->getParam('website');
25
  $this->setTemplate('connector/dashboard/tabs/analysis/rfm.phtml');
26
  }
33
  */
34
  protected function _prepareLayout()
35
  {
36
+ $rfmAnalysisModel = Mage::getModel(
37
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_rfm'
38
+ );
39
+ $this->rfm = $rfmAnalysisModel->getPreparedRfm(
40
+ $this->_store, $this->_website, $this->_group
41
+ );
42
+ foreach ($this->rfm['Monetary'] as $key => $value) {
43
  $this->rfm['Monetary'][$key] = $this->format($value);
44
  }
45
  }
49
  */
50
  protected function getRfm()
51
  {
52
+ foreach ($this->rfm as $k => $type) {
53
+ foreach ($type as $p => $value) {
54
+ if ($value == '') {
55
  $this->rfm[$k][$p] = '0';
56
+ }
57
  }
58
  }
59
+
60
  return $this->rfm;
61
  }
62
 
63
+ /**
64
+ * @return array
65
+ */
66
+ protected function getLabels()
67
+ {
68
 
69
+ $labels = array(
70
+ Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::FREQUENCY => "Frequency (orders)",
71
+ Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::RECENCY => "Recency (days)",
72
+ Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::MONETARY => "Monetary (value)"
73
+ );
74
 
75
+ return $labels;
76
+ }
77
 
78
  /**
79
  * get currency
85
  public function getCurrency()
86
  {
87
  if ($this->_store) {
88
+ $currencyCode = Mage::app()->getStore(
89
+ $this->getRequest()->getParam('store')
90
+ )->getBaseCurrency();
91
+ } else if ($this->_website) {
92
+ $currencyCode = Mage::app()->getWebsite(
93
+ $this->getRequest()->getParam('website')
94
+ )->getBaseCurrency();
95
+ } else if ($this->_group) {
96
+ $currencyCode = Mage::app()->getGroup(
97
+ $this->getRequest()->getParam('group')
98
+ )->getWebsite()->getBaseCurrency();
99
  } else {
100
  $currencyCode = Mage::app()->getStore()->getBaseCurrency();
101
  }
102
+
103
  return $currencyCode;
104
  }
105
 
107
  * format price from currency
108
  *
109
  * @param $price
110
+ *
111
  * @return string
112
  */
113
  public function format($price)
117
 
118
  public function getTitle()
119
  {
120
+ return $this->__("RFM Matrix")
121
+ . "(<a href='https://econsultancy.com/blog/64481-finding-your-best-customers-with-the-rfm-matrix' target='_blank'>"
122
+ . $this->__("Find out more") . "</a>)";
123
  }
124
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Sales.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
 
4
  {
 
5
  protected $_store = 0;
6
  protected $_group = 0;
7
  protected $_website = 0;
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extend
15
  {
16
  parent::_construct();
17
 
18
- $this->_store = $this->getRequest()->getParam('store');
19
- $this->_group = $this->getRequest()->getParam('group');
20
  $this->_website = $this->getRequest()->getParam('website');
21
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
  }
@@ -30,10 +32,20 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extend
30
  protected function _prepareLayout()
31
  {
32
  $lifetimeSales = $this->getSalesInformationForTab();
33
- $this->addTotal($this->__('Total Sales Revenue'), $lifetimeSales->getLifetime());
34
- $this->addTotal($this->__('Average Order Value'), $lifetimeSales->getAverage());
35
- $this->addTotal($this->__('Total Number Of Orders'), $lifetimeSales->getTotalCount(), true);
36
- $this->addTotal($this->__('Average Orders Created Per Day'), $lifetimeSales->getDayCount(), true);
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
  /**
@@ -43,8 +55,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extend
43
  */
44
  protected function getSalesInformationForTab()
45
  {
46
- $orderAnalysisModel = Mage::getModel('ddg_automation/adminhtml_dashboard_tabs_analysis_orders');
47
- return $orderAnalysisModel->getLifetimeSales($this->_store, $this->_website, $this->_group);
 
 
 
 
 
48
  }
49
 
50
  public function getTitle()
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales
4
+ extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
5
  {
6
+
7
  protected $_store = 0;
8
  protected $_group = 0;
9
  protected $_website = 0;
17
  {
18
  parent::_construct();
19
 
20
+ $this->_store = $this->getRequest()->getParam('store');
21
+ $this->_group = $this->getRequest()->getParam('group');
22
  $this->_website = $this->getRequest()->getParam('website');
23
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
24
  }
32
  protected function _prepareLayout()
33
  {
34
  $lifetimeSales = $this->getSalesInformationForTab();
35
+ $this->addTotal(
36
+ $this->__('Total Sales Revenue'), $lifetimeSales->getLifetime()
37
+ );
38
+ $this->addTotal(
39
+ $this->__('Average Order Value'), $lifetimeSales->getAverage()
40
+ );
41
+ $this->addTotal(
42
+ $this->__('Total Number Of Orders'),
43
+ $lifetimeSales->getTotalCount(), true
44
+ );
45
+ $this->addTotal(
46
+ $this->__('Average Orders Created Per Day'),
47
+ $lifetimeSales->getDayCount(), true
48
+ );
49
  }
50
 
51
  /**
55
  */
56
  protected function getSalesInformationForTab()
57
  {
58
+ $orderAnalysisModel = Mage::getModel(
59
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_orders'
60
+ );
61
+
62
+ return $orderAnalysisModel->getLifetimeSales(
63
+ $this->_store, $this->_website, $this->_group
64
+ );
65
  }
66
 
67
  public function getTitle()
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
 
4
  {
 
5
  protected $_store = 0;
6
  protected $_group = 0;
7
  protected $_website = 0;
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber e
15
  {
16
  parent::_construct();
17
 
18
- $this->_store = $this->getRequest()->getParam('store');
19
- $this->_group = $this->getRequest()->getParam('group');
20
  $this->_website = $this->getRequest()->getParam('website');
21
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
  }
@@ -30,9 +32,18 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber e
30
  protected function _prepareLayout()
31
  {
32
  $lifetimeSubscribers = $this->getSubscriberInformationForTab();
33
- $this->addTotal($this->__('Total Number Of Subscribers'), $lifetimeSubscribers->getTotalSubscriber(), true);
34
- $this->addTotal($this->__('Subscribers Who Are Also Customers'), $lifetimeSubscribers->getTotalSubscriberCustomer(), true);
35
- $this->addTotal($this->__('Average Subscribers Created Per Day'), $lifetimeSubscribers->getSubscribersPerDay(), true);
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  /**
@@ -42,8 +53,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber e
42
  */
43
  protected function getSubscriberInformationForTab()
44
  {
45
- $subscriberAnalysisModel = Mage::getModel('ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber');
46
- return $subscriberAnalysisModel->getLifetimeSubscribers($this->_store, $this->_website, $this->_group);
 
 
 
 
 
47
  }
48
 
49
  /**
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber
4
+ extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
5
  {
6
+
7
  protected $_store = 0;
8
  protected $_group = 0;
9
  protected $_website = 0;
17
  {
18
  parent::_construct();
19
 
20
+ $this->_store = $this->getRequest()->getParam('store');
21
+ $this->_group = $this->getRequest()->getParam('group');
22
  $this->_website = $this->getRequest()->getParam('website');
23
  $this->setTemplate('connector/dashboard/tabs/data.phtml');
24
  }
32
  protected function _prepareLayout()
33
  {
34
  $lifetimeSubscribers = $this->getSubscriberInformationForTab();
35
+ $this->addTotal(
36
+ $this->__('Total Number Of Subscribers'),
37
+ $lifetimeSubscribers->getTotalSubscriber(), true
38
+ );
39
+ $this->addTotal(
40
+ $this->__('Subscribers Who Are Also Customers'),
41
+ $lifetimeSubscribers->getTotalSubscriberCustomer(), true
42
+ );
43
+ $this->addTotal(
44
+ $this->__('Average Subscribers Created Per Day'),
45
+ $lifetimeSubscribers->getSubscribersPerDay(), true
46
+ );
47
  }
48
 
49
  /**
53
  */
54
  protected function getSubscriberInformationForTab()
55
  {
56
+ $subscriberAnalysisModel = Mage::getModel(
57
+ 'ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber'
58
+ );
59
+
60
+ return $subscriberAnalysisModel->getLifetimeSubscribers(
61
+ $this->_store, $this->_website, $this->_group
62
+ );
63
  }
64
 
65
  /**
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General.php CHANGED
@@ -1,106 +1,109 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General extends Mage_Adminhtml_Block_Dashboard_Bar
 
4
  {
5
- protected $group = array();
6
 
7
- /**
8
- * Set the template.
9
- */
10
- public function _construct()
11
- {
12
- $this->initiateGroupArray();
13
- parent::_construct();
14
- $this->setTemplate('connector/dashboard/tabs/general/index.phtml');
15
- }
16
 
17
- /**
18
- * Prepare the layout.
19
- *
20
- * @return Mage_Core_Block_Abstract|void
21
- * @throws Exception
22
- */
23
- protected function _prepareLayout()
24
- {
25
- $website = 0;
26
- if ($store = $this->getRequest()->getParam('store')) {
27
- $website = Mage::app()->getStore($store)->getWebsite();
28
- } elseif ($this->getRequest()->getParam('website')) {
29
- $website = $this->getRequest()->getParam('website');
30
- }
31
- $apiUsername = Mage::helper('ddg')->getApiUsername($website);
32
- $apiPassword = Mage::helper('ddg')->getApiPassword($website);
33
- $data = Mage::getModel('ddg_automation/apiconnector_client')
34
- ->setApiUsername($apiUsername)
35
- ->setApiPassword($apiPassword)
36
- ->getAccountInfo();
37
 
38
- if(isset($data->id))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  $this->prepareGroupArray($data);
 
 
 
40
 
41
- $this->_setChild();
 
42
 
43
- parent::_prepareLayout();
44
- }
 
 
 
 
 
 
 
 
 
 
45
 
46
- protected function _setChild()
47
- {
48
- foreach($this->group as $key => $data){
49
- $this->setChild($key,
50
- $this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_general_data', '', $data)
51
- );
52
- }
53
- }
 
 
54
 
55
- protected function prepareGroupArray($data)
56
- {
57
- foreach ($data->properties as $one) {
58
- foreach($this->group as $key => $type){
59
- if(array_key_exists($one->name, $type)){
60
- $this->group[$key][$one->name] = $one->value;
61
- }
62
- }
63
- }
64
- }
65
 
66
- protected function initiateGroupArray()
67
- {
68
- $this->group['account'] = array(
69
- 'Title' => 'Account',
70
- 'Name' => $this->__('Not Available'),
71
- 'MainMobilePhoneNumber' => $this->__('Not Available'),
72
- 'MainEmail' => $this->__('Not Available'),
73
- 'AvailableEmailSendsCredits' => $this->__('Not Available')
74
- );
75
- $this->group['data'] = array(
76
- 'Title' => 'Data',
77
- 'TransactionalDataAllowanceInMegabytes' => $this->__('Not Available'),
78
- 'TransactionalDataUsageInMegabytes' => $this->__('Not Available')
79
- );
80
- $this->group['api'] = array(
81
- 'Title' => 'Api',
82
- 'APILocale' => $this->__('Not Available'),
83
- 'ApiCallsRemaining' => $this->__('Not Available')
84
- );
85
- }
86
 
87
- /**
88
- * get Tab content title
89
- *
90
- * @return string
91
- */
92
- public function getTitle()
93
- {
94
- return Mage::helper('ddg')->__("Connector Account Information");
95
- }
96
 
97
- /**
98
- * get column width
99
- *
100
- * @return string
101
- */
102
- public function getColumnWidth()
103
- {
104
- return "400px;";
105
- }
106
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
4
+ extends Mage_Adminhtml_Block_Dashboard_Bar
5
  {
 
6
 
7
+ public $group = array();
 
 
 
 
 
 
 
 
8
 
9
+ /**
10
+ * Set the template.
11
+ */
12
+ public function _construct()
13
+ {
14
+ $this->initiateGroupArray();
15
+ parent::_construct();
16
+ $this->setTemplate('connector/dashboard/tabs/general/index.phtml');
17
+ }
 
 
 
 
 
 
 
 
 
 
 
18
 
19
+ /**
20
+ * Prepare the layout.
21
+ *
22
+ * @return Mage_Core_Block_Abstract|void
23
+ * @throws Exception
24
+ */
25
+ protected function _prepareLayout()
26
+ {
27
+ $website = 0;
28
+ if ($store = $this->getRequest()->getParam('store')) {
29
+ $website = Mage::app()->getStore($store)->getWebsite();
30
+ } elseif ($this->getRequest()->getParam('website')) {
31
+ $website = $this->getRequest()->getParam('website');
32
+ }
33
+ $apiUsername = Mage::helper('ddg')->getApiUsername($website);
34
+ $apiPassword = Mage::helper('ddg')->getApiPassword($website);
35
+ $data = Mage::getModel('ddg_automation/apiconnector_client')
36
+ ->setApiUsername($apiUsername)
37
+ ->setApiPassword($apiPassword)
38
+ ->getAccountInfo();
39
+
40
+ if (isset($data->id)) {
41
  $this->prepareGroupArray($data);
42
+ }
43
+
44
+ $this->_setChild();
45
 
46
+ parent::_prepareLayout();
47
+ }
48
 
49
+ protected function _setChild()
50
+ {
51
+ foreach ($this->group as $key => $data) {
52
+ $this->setChild(
53
+ $key,
54
+ $this->getLayout()->createBlock(
55
+ 'ddg_automation/adminhtml_dashboard_tabs_general_data', '',
56
+ $data
57
+ )
58
+ );
59
+ }
60
+ }
61
 
62
+ protected function prepareGroupArray($data)
63
+ {
64
+ foreach ($data->properties as $one) {
65
+ foreach ($this->group as $key => $type) {
66
+ if (array_key_exists($one->name, $type)) {
67
+ $this->group[$key][$one->name] = $one->value;
68
+ }
69
+ }
70
+ }
71
+ }
72
 
73
+ protected function initiateGroupArray()
74
+ {
75
+ $this->group['account'] = array(
76
+ 'Title' => 'Account',
77
+ 'Name' => $this->__('Not Available'),
78
+ 'MainMobilePhoneNumber' => $this->__('Not Available'),
79
+ 'MainEmail' => $this->__('Not Available'),
80
+ 'AvailableEmailSendsCredits' => $this->__('Not Available')
81
+ );
 
82
 
83
+ $this->group['api'] = array(
84
+ 'Title' => 'Api',
85
+ 'APILocale' => $this->__('Not Available'),
86
+ 'ApiCallsRemaining' => $this->__('Not Available')
87
+ );
88
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
+ /**
91
+ * get Tab content title
92
+ *
93
+ * @return string
94
+ */
95
+ public function getTitle()
96
+ {
97
+ return Mage::helper('ddg')->__("Connector Account Information");
98
+ }
99
 
100
+ /**
101
+ * get column width
102
+ *
103
+ * @return string
104
+ */
105
+ public function getColumnWidth()
106
+ {
107
+ return "400px;";
108
+ }
109
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General/Data.php CHANGED
@@ -1,13 +1,17 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
 
4
  {
5
- protected $data = array();
6
- protected $title = "";
 
7
 
8
  /**
9
  * set template
 
10
  * @param $info
 
11
  * @throws Exception
12
  */
13
  public function __construct($info = array())
@@ -28,7 +32,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data extends
28
  */
29
  protected function _prepareLayout()
30
  {
31
- foreach($this->data as $key => $value){
32
  $this->addTotal($this->__($key), $value, true);
33
  }
34
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data
4
+ extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
5
  {
6
+
7
+ public $data = array();
8
+ public $title = "";
9
 
10
  /**
11
  * set template
12
+ *
13
  * @param $info
14
+ *
15
  * @throws Exception
16
  */
17
  public function __construct($info = array())
32
  */
33
  protected function _prepareLayout()
34
  {
35
+ foreach ($this->data as $key => $value) {
36
  $this->addTotal($this->__($key), $value, true);
37
  }
38
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Logs.php CHANGED
@@ -4,6 +4,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Logs
4
  extends Mage_Adminhtml_Block_Widget
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
 
7
  /**
8
  * Set the template.
9
  */
@@ -18,6 +19,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Logs
18
  {
19
  return true;
20
  }
 
21
  public function isHidden()
22
  {
23
  return true;
4
  extends Mage_Adminhtml_Block_Widget
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
7
+
8
  /**
9
  * Set the template.
10
  */
19
  {
20
  return true;
21
  }
22
+
23
  public function isHidden()
24
  {
25
  return true;
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Status.php CHANGED
@@ -1,48 +1,52 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface
 
 
4
  {
5
 
6
- const CONNECTOR_DASHBOARD_PASSED = 'available';
7
- const CONNECTOR_DASHBOARD_WARRNING = 'connector_warning';
8
- const CONNECTOR_DASHBOARD_FAILED = 'error';
9
-
10
- const FAST_FIX_MESSAGE = 'Fast Fix Available, Click To Enable The Mapping And Redirect Back.';
11
-
12
- protected $_checkpoints = array(
13
- 'valid_api_credentials' => 'API Credentials',
14
- 'cron_running' => 'Cron running',
15
- 'conflict_check' => 'Conflict Check',
16
- 'address_book_mapped' => 'Address Book Mapping',
17
- 'file_permission_setttings' => 'File Permission Settings',
18
- 'missing_files' => 'Missing Files',
19
- 'contact_sync_enabled' => 'Contact Sync Enabled',
20
- 'contact_syncing' => 'Contacts Syncing',
21
- 'subscriber_sync_enabled' => 'Subscribers Sync Enabled',
22
- 'subscribers_syncing' => 'Subscribers Syncing',
23
- 'automation_active' => 'Automation Programs Active',
24
- 'abandoned_carts_enabled' => 'Abandoned Carts Enabled',
25
- 'data_field_mapped' => 'Data Field Mapped',
26
- 'order_enabled' => 'Order Sync Enabled',
27
- 'order_syncing' => 'Orders Syncing',
28
- 'custom_order_attributes' => 'Custom Order Attributes',
29
- 'quote_enabled' => 'Quote Sync Enabled',
30
- 'quote_syncing' => 'Quote Syncing',
31
- 'custom_quote_attributes' => 'Custom Quote Attributes',
32
- 'last_abandoned_cart_sent_day' => 'Last Abandoned Cart Sent Day',
33
- 'easy_email_capture_enabled' => 'Easy Email Capture Enabled',
34
- 'disable_newsletter_success_enabled' => 'Disable Newsletter Success Enabled',
35
- 'system_information' => 'System Information'
36
-
37
- );
38
- /**
 
 
39
  * Set the template.
40
  */
41
  public function __construct()
42
  {
43
  parent::__construct();
44
 
45
- $this->setTemplate('connector/dashboard/status.phtml');
46
  }
47
 
48
  /**
@@ -55,273 +59,364 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
55
  {
56
  }
57
 
58
- public function canShowTab()
59
- {
60
- return true;
61
- }
62
- public function isHidden()
63
- {
64
- return true;
65
- }
66
-
67
- public function getTabLabel()
68
- {
69
- return Mage::helper('ddg')->__('Marketing Automation System Status');
70
- }
71
-
72
- public function getTabTitle()
73
- {
74
- return Mage::helper('ddg')->__('Marketing Automation System Status');
75
- }
76
-
77
- /**
78
- * Collapse key for the fieldset state.
79
- * @param $key
80
- *
81
- * @return bool
82
- */
83
- protected function _getCollapseState($key)
84
- {
85
- $extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
86
- if (isset($extra['configState'][$key])) {
87
- return $extra['configState'][$key];
88
- }
89
-
90
- return false;
91
- }
92
-
93
- public function getCheckpoints() {
94
- return $this->_checkpoints;
95
- }
96
-
97
- protected function getDisplayData() {
98
-
99
- $displayData = array();
100
- foreach ( $this->getCheckpoints() as $key => $checkpoint ) {
101
-
102
- $method = $this->getFormatedMethodName( $key );
103
-
104
- if ( is_callable( array( $this, $method ) ) ) {
105
- $data = $this->$method();
106
- $showHowTo = '';
107
- $collapsable = '1';
108
-
109
- if ( $data->getStyle() == 'connector_passed' ) {
110
- $showHowTo = 'no_display';
111
- $collapsable = '0';
112
- }
113
- if ( $this->_getCollapseState( $key ) !== false ) {
114
- $collapsable = $this->_getCollapseState( $key );
115
- }
116
- $displayData[$key] = array(
117
- 'showHowTo' => $showHowTo,
118
- 'collapsable' => $collapsable,
119
- 'data' => $data
120
- );
121
- }
122
- }
123
- return $displayData;
124
- }
125
-
126
-
127
- public function addCheckpoint($checkpoint)
128
- {
129
- $this->_checkpoints[$checkpoint->getName()] = $checkpoint;
130
- }
131
-
132
-
133
-
134
- /**
135
- * Check cron for the customer sync.
136
- * @return array
137
- */
138
- public function cronRunning()
139
- {
140
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
141
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
142
- ->setTitle('Cron Status : ')
143
- ->setMessage('Cron is running.');
144
- $message = 'No cronjob task found. Check if cron is configured correctly.';
145
- $howToSetupCron = 'For more information <a href="http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job">how to setup the Magento cronjob.</a>';
146
- $lastCustomerSync = Mage::getModel('ddg_automation/cron')->getLastCustomerSync();
147
-
148
- if ($lastCustomerSync === false) {
149
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
150
- ->setHowto($howToSetupCron);
151
- } else {
152
- $timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
153
- //last cron was less then 5min
154
- if ($timespan <= 5 * 60) {
155
- $resultContent->setTitle('Cronjob is working : ');
156
- $message = sprintf('(Last execution: %s minute(s) ago) ', round($timespan/60));
157
- } elseif ($timespan > 5 * 60 && $timespan <= 60 * 60 ) {
158
- //last cron execution was between 15min and 60min
159
- $resultContent->setTitle('Last customer sync : ' )
160
- ->setStyle(self::CONNECTOR_DASHBOARD_FAILED);
161
- $message = sprintf(' %s minutes. ', round($timespan/60));
162
- } else {
163
- //last cron was more then an hour
164
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
165
- ->setHowto('Last customer sync is older than one hour.')
166
- ->setHowto($howToSetupCron);
167
- }
168
- }
169
-
170
- $resultContent->setMessage($message);
171
- return $resultContent;
172
- }
173
-
174
- /**
175
- * Address Book Mapping.
176
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
177
- */
178
- public function addressBookMapped()
179
- {
180
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
181
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
182
- ->setTitle('Configuration For Address Book Status : ')
183
- ->setMessage('Looks Great.');
184
-
185
- foreach (Mage::app()->getWebsites() as $website ) {
186
-
187
- $websiteName = $website->getName();
188
- $link = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_sync_settings/website/' . $website->getCode());
189
-
190
- $customerMapped = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID))? true :
191
- 'Not mapped!';
192
- $subscriberMapped = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID))? true :
193
- 'Not mapped!';
194
- $guestMapped = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID))? true :
195
- 'Not mapped!';
196
-
197
- if ($customerMapped !== true || $subscriberMapped !== true || $guestMapped !== true) {
198
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
199
- ->setMessage('')
200
- ->setTable(array(
201
- 'Website' => $websiteName,
202
- 'Customers' => ($customerMapped !== true)? $customerMapped . ' <a href="' . $link . '">configuration</a>' : 'Mapped.',
203
- 'Subscribers' => ($subscriberMapped !== true)? $subscriberMapped . ' <a href="' . $link . '">configuration</a>' : 'Mapped.',
204
- 'Guests' => ($guestMapped !== true)? $guestMapped . ' <a href="' . $link . '">configuration</a>' : 'Mapped.'
205
- ));
206
- }
207
- }
208
-
209
- return $resultContent;
210
- }
211
-
212
- /**
213
- * ROI Tracking.
214
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
215
- */
216
- public function roiTrackingEnabled()
217
- {
218
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
219
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
220
- ->setTitle('ROI Tracking Status : ')
221
- ->setMessage('Looks Great.');
222
-
223
- $valid = true;
224
- foreach ( Mage::app()->getWebsites() as $website ) {
225
- $websiteName = $website->getName();
226
-
227
- $roiConfig = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED))? true : 'Not Mapped! ';
228
- $pageTracking = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED))? true : 'Not Mapped! ';
229
- //not mapped show options
230
- if ($roiConfig !== true || $pageTracking !== true) {
231
-
232
- //links to enable and get redirected back
233
- $roiUrl = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED', 'website' => $website->getId()));
234
- $pageUrl = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED', 'website' => $website->getId()));
235
-
236
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
237
- ->setMessage('')
238
- ->setTable(array(
239
- 'Website' => $websiteName,
240
- 'ROI' => ($roiConfig !== true)? $roiConfig . ' <a href="' . $roiUrl . '">enable</a>' : 'Mapped.',
241
- 'PAGE' => ($pageTracking !== true)? $pageTracking . ' <a href="' . $pageUrl . '">enable</a>' : 'Mapped.'
242
- ));
243
- $valid = false;
244
- }
245
- }
246
- //validation failed
247
- if (! $valid) {
248
- $resultContent->setHowto(self::FAST_FIX_MESSAGE);
249
- }
250
-
251
- return $resultContent;
252
- }
253
-
254
- /**
255
- * File Permissions.
256
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
257
- */
258
- public function filePermissionSetttings()
259
- {
260
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
261
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
262
- ->setTitle('Files/Folders Permission Settings : ')
263
- ->setMessage('Looks Great.');
264
-
265
- /**
266
- * Arhive and email export directories.
267
- */
268
- $emailDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . 'email';
269
- $archiveDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive';
270
-
271
- $checkEmail = Mage::helper('ddg/file')->getPathPermission($emailDir);
272
- $checkArchive = Mage::helper('ddg/file')->getPathPermission($archiveDir);
273
-
274
- //file persmission failed
275
- if ($checkEmail != 755 && $checkEmail != 777 || $checkArchive != 755 && $checkArchive != 777) {
276
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
277
- ->setMessage('Wrong Permission For Directory : 777 or 755');
278
-
279
- //list of directory permission checked
280
- if ($checkEmail != 755 || $checkEmail != 777)
281
- $resultContent->setHowto( $emailDir . ' is set to : ' . $checkEmail);
282
- if ($checkArchive != 755 || $checkArchive != 777)
283
- $resultContent->setHowto( $archiveDir . ' is set to : ' . $checkArchive);
284
- }
285
-
286
- return $resultContent;
287
- }
288
-
289
- /**
290
- * Check for missing files.
291
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
292
- */
293
- public function missingFiles()
294
- {
295
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
296
-
297
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
298
- ->setTitle('Missing Files : ')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  ->setMessage('Looks Great.');
300
 
301
- $filePath = Mage::getModuleDir('etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME).DS.'files.yaml';
302
- $config = Zend_Config_Yaml::decode(file_get_contents($filePath));
303
-
304
- /**
305
- * Code dirs.
306
- */
307
- $etcDir = Mage::getModuleDir('etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
308
- $controllerDir = Mage::getModuleDir('controllers', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
309
- $sqlDir = Mage::getModuleDir('sql', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
310
- $localeDir = Mage::getBaseDir('locale');
311
- $rootDir = Mage::getModuleDir('', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
312
- $blockDir = $rootDir .DS. 'Block';
313
- $helperDir = $rootDir .DS. 'Helper';
314
- $modelDir = $rootDir .DS. 'Model';
315
-
316
- /**
317
- * Design dir.
318
- */
319
- $designDir = Mage::getBaseDir('design');
320
-
321
- /**
322
- * Skin dir.
323
- */
324
- $skinDir = Mage::getBaseDir('skin');
 
 
 
 
 
 
 
 
 
 
325
 
326
  /**
327
  * Js dir
@@ -333,266 +428,373 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
333
  */
334
  $libDir = Mage::getBaseDir('lib');
335
 
336
- $filesToCheck = array($config['etc'], $config['controllers'], $config['sql'], $config['locale'], $config['block'],
337
- $config['helper'], $config['model'], $config['design'], $config['skin'], $config['lib'], $config['js']);
338
- $pathToCheck = array($etcDir, $controllerDir, $sqlDir, $localeDir, $blockDir, $helperDir,
339
- $modelDir, $designDir, $skinDir, $libDir, $jsDir);
340
- foreach ( $filesToCheck as $subdir ) {
341
- foreach ( $subdir as $path ) {
342
- $file = $pathToCheck[0] . DS . str_replace( '#', DS, $path );
343
-
344
- if ( !file_exists( $file ) ) {
345
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED )
346
- ->setMessage('')
347
- ->setHowto('File not found : ' . $file );
348
- }
349
- }
350
- array_shift($pathToCheck);
351
- }
352
-
353
- return $resultContent;
354
- }
355
-
356
- /**
357
- * Contact Sync Status.
358
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
359
- */
360
- public function contactSyncEnabled()
361
- {
362
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
363
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
364
- ->setTitle('Contacts Sync Status : ')
365
- ->setMessage('Looks Great.');
366
-
367
- $valid = true;
368
- foreach ( Mage::app()->getWebsites() as $website ) {
369
- $websiteName = $website->getName();
370
- $contact = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED))? true : 'Disabled!';
371
- //disabled show data table
372
- if ($contact !== true){
373
- //redirection url to enable website config
374
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED', 'website' => $website->getId()));
375
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
376
- ->setMessage('')
377
- ->setTable(array(
378
- 'Website' => $websiteName,
379
- 'Status' => ($contact)? $contact . ' <a href="' . $url . '">enable</a>' : 'Enabled.'
380
- ))
381
- ;
382
- $valid = false;
383
- }
384
- }
385
- //validation failed
386
- if (! $valid) {
387
- $resultContent->setHowto(self::FAST_FIX_MESSAGE);
388
- }
389
-
390
- return $resultContent;
391
- }
392
-
393
- /**
394
- * Check if contact is syncing by counting the number of contacts imported.
395
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
396
- */
397
- public function contactSyncing()
398
- {
399
- //content to render
400
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
401
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
402
- ->setTitle('Contacts Sync : ')
403
- ->setMessage('Looks Great.');
404
- $contactModel = Mage::getModel('ddg_automation/contact');
405
-
406
- //global email duplicates
407
- if (Mage::getResourceModel('customer/customer')->findEmailDuplicates()) {
408
-
409
- //duplicate email customers
410
- $customers = Mage::helper('ddg')->getCustomersWithDuplicateEmails();
411
- $customerEmails = implode(', ', $customers->getColumnValues('email'));
412
- //render the email duplicates
413
- $resultContent->setHowto('Found Duplicate Customers Emails :')
414
- ->setHowto($customerEmails);
415
- }
416
-
417
- foreach ( Mage::app()->getWebsites() as $website ) {
418
-
419
- $websiteId = $website->getId();
420
- //total customers for website
421
- $countCustomers = Mage::getModel('customer/customer')->getCollection()
422
- ->addAttributeToFilter('website_id', $websiteId)
423
- ->getSize();
424
-
425
- //skip if no customers
426
- if (! $countCustomers)
427
- continue;
428
-
429
- //total contacts from customer address book
430
- $customerAddressBook = $this->_getAddressBookContacts($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID), $website);
431
- $countAddressbookContacts = ($customerAddressBook)? $customerAddressBook->contacts : 0;
432
- //total contacts as customers
433
- $countCustomerContacts = $contactModel->getNumberCustomerContacts($websiteId);
434
-
435
- //suppressed contacts
436
- $suppressed = $contactModel->getNumberCustomerSuppressed($websiteId);
437
-
438
- //table data
439
- $tableData = array(
440
- 'Website' => $website->getName(),
441
- 'Total Customers/Contacts' => $countCustomers . '/ ' . $countCustomerContacts,
442
- 'Customer AddressBook Contacts' => ($customerAddressBook)? $customerAddressBook->name . ' : ' . $countAddressbookContacts : 'Not Mapped.',
443
- 'Suppressed' => $suppressed,
444
- 'Synced' => $contactModel->getNumberCustomerSynced($websiteId)
445
- );
446
-
447
- //number of customers not match, try to update
448
- if ($countCustomers != $countCustomerContacts) {
449
-
450
- $url = Mage::helper('adminhtml')->getUrl('*/connector/populatecontacts', array('type' => 'customers', 'website' => $website->getId()));
451
- $link = ' <a href="' . $url . '"> populate</a>';
452
- $tableData['Status'] = 'Customers not matching the contact table. ' . $link;
453
- //customers not synced yet
454
- } elseif ($countCustomers > $countCustomerContacts + $suppressed){
455
- $tableData['Status'] = 'Syncing..';
456
- //all customers syned.
457
- } else {
458
- $tableData['Status'] = 'Synced';
459
- }
460
-
461
- //not valid response remove status
462
- if (!$countAddressbookContacts)
463
- unset($tableData['Status']);
464
-
465
- //no contacts
466
- if (! $countCustomers) {
467
-
468
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
469
- ->setTitle('Contacts Sync (ignore if you have reset contacts for reimport) : ')
470
- ->setMessage('');
471
- $tableData['Status'] = 'No Imported Contacts Found!';
472
- unset($tableData['Imported Contacts']);
473
- }
474
-
475
- $resultContent->setTable($tableData);
476
- }
477
-
478
- return $resultContent;
479
- }
480
-
481
- /**
482
- * Check for subscribers sync status.
483
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
484
- */
485
- public function subscriberSyncEnabled()
486
- {
487
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
488
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
489
- ->setTitle('Subscribers Sync Status : ')
490
- ->setMessage('Looks Great.');
491
-
492
- $passed = true;
493
- foreach ( Mage::app()->getWebsites() as $website ) {
494
- $websiteName = $website->getName();
495
- $contact = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED))? true :
496
- 'Disabled!';
497
- //disabled show data table
498
- if ($contact !== true){
499
- //redirection url to enable website config
500
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED', 'website' => $website->getId()));
501
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
502
- ->setMessage('')
503
- ->setTable(array(
504
- 'Website' => $websiteName,
505
- 'Status' => ($contact)? $contact . ' <a href="' . $url . '">enable</a>' : 'Enabled.'
506
- ));
507
- $passed = false;
508
- }
509
- }
510
- //if validation not passed
511
- if (! $passed)
512
- $resultContent->setHowto(self::FAST_FIX_MESSAGE);
513
-
514
- return $resultContent;
515
- }
516
-
517
- /**
518
- * Subscribers syncing status.
519
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
520
- */
521
- public function subscribersSyncing()
522
- {
523
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
524
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
525
- ->setTitle('Subscribers Sync : ')
526
- ->setMessage('Looks Great.');
527
- $contactModel = Mage::getModel('ddg_automation/contact');
528
-
529
- foreach ( Mage::app()->getWebsites() as $website ) {
530
- $websiteId = $website->getId();
531
- $websiteName = $website->getName();
532
- $storeIds = $website->getStoreIds();
533
- //total subscribers
534
- $countSubscribers = Mage::getModel('newsletter/subscriber')->getCollection()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  ->useOnlySubscribed()
536
  ->addStoreFilter($storeIds)
537
- ->getSize();
538
- //skip if no subscriber
539
- if (! $countSubscribers)
540
- continue;
541
-
542
- //total contacts subscribed
543
- $countSubscribedContacts = $contactModel->getNumberSubscribers($websiteId);
544
- //total contacts subscribed imported
545
- $countSubscribersImported = $contactModel->getNumberSubscribersSynced($websiteId);
546
-
547
- //number of address
548
- $countAddressbookContacts = $this->_getAddressBookContacts($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID), $website);
549
-
550
- $tableData = array(
551
- 'Website' => $websiteName,
552
- 'Total Subscribers/Contacts' => $countSubscribers . '/ ' . $countSubscribedContacts,
553
- 'Subscriber AddressBook Contacts' => ($countAddressbookContacts)? $countAddressbookContacts->name . ' : ' . $countAddressbookContacts->contacts : 'Not Mapped.',
554
- 'Imported' => $countSubscribersImported
555
- );
556
-
557
- $tableData['Status'] = '';
558
-
559
- //no imported contacts
560
- if (! $countSubscribersImported) {
561
-
562
- $tableData['Status'] = 'No Imported Subscribers Found.';
563
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
564
- ->setTitle('Subscriber Sync (ignore if you have reset subscribers for reimport) : ')
565
- ->setMessage('');
566
- }
567
- $resultContent->setTable($tableData);
568
- }
569
-
570
- return $resultContent;
571
- }
572
- //check the mapped programs are active
573
- public function automationActive()
574
- {
575
- $disableCustomer = $disableSubscriber = $disableOrder = $disableGuestOrder = $disableReviews = $disableWishlist = '';
576
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
577
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
578
- ->setTitle('Automation Program Status :')
579
- ->setMessage('');
580
-
581
- foreach ( Mage::app()->getWebsites() as $website ) {
582
- $customerProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER);
583
- $subscriberProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER);
584
- $orderProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER);
585
- $guestOrderProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER);
586
- $reviewsProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW);
587
- $wishlistProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST);
588
-
589
- //programs
590
- $cusProgram = $this->_getWebisteProgram($customerProgram, $website);
591
- $subProgram = $this->_getWebisteProgram($subscriberProgram, $website);
592
- $orderProgram = $this->_getWebisteProgram($orderProgram, $website);
593
- $guestOrderProgram = $this->_getWebisteProgram($guestOrderProgram, $website);
594
- $reviewsProgram = $this->_getWebisteProgram($reviewsProgram, $website);
595
- $wishlistProgram = $this->_getWebisteProgram($wishlistProgram, $website);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
 
597
  //check for wishlist program
598
  if ($wishlistProgram) {
@@ -601,15 +803,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
601
 
602
  //set the status as failed
603
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
604
- ->setMessage(' Consider to disable not active programs');
 
 
605
 
606
- $disableWishlist = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
 
607
  'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST',
608
  'value' => '0',
609
  'website' => $website->getId()
610
  )
611
  );
612
- $disableWishlist = 'Deactivated! <a href="' . $disableWishlist . '">click</a> to disable';
 
613
 
614
  } else {
615
 
@@ -624,529 +830,796 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
624
 
625
  //set the status as failed
626
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
627
- ->setMessage(' Consider to disable not active programs');
 
 
628
 
629
- $disableOrder = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
 
630
  'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER',
631
  'value' => '0',
632
  'website' => $website->getId()
633
  )
634
  );
635
- $disableOrder = 'Deactivated! <a href="' . $disableOrder . '">click</a> to disable';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
 
637
- } else {
 
638
 
639
- $disableOrder = $orderProgram->status;
640
- }
641
- }
642
 
643
- //check for review program
644
- if ($reviewsProgram) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
 
646
- if ($reviewsProgram->status != 'Active') {
 
647
 
648
- //set the status as failed
649
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
650
- ->setMessage(' Consider to disable not active programs');
651
 
652
- $disableReviews = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
653
- 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW',
654
- 'value' => '0',
655
- 'website' => $website->getId()
 
 
 
 
 
 
 
 
 
 
656
  )
657
  );
658
- $disableReviews = 'Deactivated! <a href="' . $disableReviews . '">click</a> to disable';
659
-
660
- } else {
661
-
662
- $disableReviews = $reviewsProgram->status;
663
- }
664
  }
 
665
 
666
- //check for guest order program
667
- if ($guestOrderProgram) {
668
 
669
- if ($guestOrderProgram->status != 'Active') {
 
 
 
 
 
 
 
 
 
 
 
 
670
 
671
- //set the status as failed
672
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
673
- ->setMessage(' Consider to disable not active programs');
 
 
 
 
 
 
674
 
675
- $disableGuestOrder = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
676
- 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER',
677
- 'value' => '0',
678
- 'website' => $website->getId()
 
 
 
 
 
 
 
 
 
 
679
  )
680
  );
681
- $disableGuestOrder = 'Deactivated! <a href="' . $disableGuestOrder . '">click</a> to disable';
682
-
683
- } else {
684
-
685
- $disableGuestOrder = $guestOrderProgram->status;
686
- }
687
- }
688
-
689
- //check for customer program
690
- if ($cusProgram) {
691
-
692
- if ($cusProgram->status != 'Active') {
693
-
694
- //set the status as failed
695
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
696
- ->setMessage(' Consider to disable not active programs');
697
-
698
- $disableCustomer = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
699
- 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER',
700
- 'value' => '0',
701
- 'website' => $website->getId()
702
- )
703
- );
704
- $disableCustomer = 'Deactivated! <a href="' . $disableCustomer . '">click</a> to disable';
705
-
706
- } else {
707
-
708
- $disableCustomer = $cusProgram->status;
709
- }
710
- }
711
-
712
- //check for subscriber program
713
- if ($subProgram) {
714
-
715
- if ($subProgram->status != 'Active') {
716
- // set the status failed
717
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
718
- ->setMessage(' Consider to disable not active programs');
719
-
720
- //link to disbale config
721
- $disableSubscriber = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
722
- 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER',
723
- 'value' => '0',
724
- 'website' => $website->getId()
725
- )
726
- );
727
- $disableSubscriber = 'Deactivated <a href="' . $disableSubscriber . '">click</a> to disable';
728
-
729
- } else {
730
- $disableSubscriber = $subProgram->status;
731
- }
732
- }
733
-
734
- $tableData = array(
735
- 'Website' => $website->getName(),
736
- 'Customer Program' => (isset($cusProgram->name))? $cusProgram->name : 'Disabled',
737
- 'Customer Status' => (isset($cusProgram->status))? $disableCustomer : '',
738
- 'Subscriber Program' => (isset($subProgram->name))? $subProgram->name : 'Disabled',
739
- 'Subscriber Status' => (isset($subProgram->status))? $disableSubscriber : '',
740
- 'Order Program' => (isset($orderProgram->name))? $orderProgram->name : 'Disabled',
741
- 'Order Status' => (isset($orderProgram->status))? $disableOrder : '',
742
- 'Guest Order Program' => (isset($guestOrderProgram->name))? $guestOrderProgram->name : 'Disabled',
743
- 'Guest Order Status' => (isset($guestOrderProgram->status))? $disableGuestOrder : '',
744
- 'Review Program' => (isset($reviewsProgram->name))? $reviewsProgram->name : 'Disabled',
745
- 'Review Status' => (isset($reviewsProgram->status))? $disableReviews : '',
746
- 'Wishlist Program' => (isset($wishlistProgram->name))? $wishlistProgram->name : 'Disabled',
747
- 'Wishlist Status' => (isset($wishlistProgram->status))? $disableWishlist : '',
748
- );
749
-
750
- //set the content with table data
751
- $resultContent->setTable($tableData);
752
-
753
- }
754
-
755
- return $resultContent;
756
- }
757
-
758
- /**
759
- * Abandoned carts status.
760
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
761
- */
762
- public function abandonedCartsEnabled()
763
- {
764
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
765
-
766
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
767
- ->setTitle('Abandoned Carts Status : ')
768
- ->setMessage('Looks Great.');
769
-
770
- foreach ( Mage::app()->getWebsites() as $website ) {
771
- $websiteName = $website->getName();
772
- $abandonedCusomer_1 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1))? true :
773
- 'Disabled!';
774
- $abandonedCusomer_2 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2))? true :
775
- 'Disabled!';
776
- $abandonedCusomer_3 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3))? true :
777
- 'Disabled!';
778
- $abandonedGuest_1 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1))? true :
779
- 'Disabled!';
780
- $abandonedGuest_2 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2))? true :
781
- 'Disabled!';
782
- $abandonedGuest_3 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3))? true :
783
- 'Disabled!';
784
-
785
- if ($abandonedCusomer_1 !== true || $abandonedCusomer_2 !== true || $abandonedCusomer_3 !== true || $abandonedGuest_1 !== true || $abandonedGuest_2 !== true || $abandonedGuest_3 !== true){
786
- //customer abandoned links to enable
787
- $customer1 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1', 'website' => $website->getId()));
788
- $customer2 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2', 'website' => $website->getId()));
789
- $customer3 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3', 'website' => $website->getId()));
790
- //guests abandoned links to enable
791
- $guest1 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1', 'website' => $website->getId()));
792
- $guest2 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2', 'website' => $website->getId()));
793
- $guest3 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3', 'website' => $website->getId()));
794
-
795
-
796
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
797
- ->setMessage('Don\'t forget to map')
798
- ->setTable(array(
799
- 'Website' => $websiteName,
800
- 'Customer Abandoned 1' => ($abandonedCusomer_1 !== true)? $abandonedCusomer_1 . ' <a href="' . $customer1 . '">enable</a>' : 'Enabled',
801
- 'Customer Abandoned 2' => ($abandonedCusomer_2 !== true)? $abandonedCusomer_2 . ' <a href="' . $customer2 . '">enable</a>' : 'Enabled',
802
- 'Customer Abandoned 3' => ($abandonedCusomer_3 !== true)? $abandonedCusomer_3 . ' <a href="' . $customer3 . '">enable</a>' : 'Enabled',
803
- 'Guest Abandoned 1' => ($abandonedGuest_1 !== true)? $abandonedGuest_1 . ' <a href="' . $guest1 . '">enable</a>' : 'Enabled',
804
- 'Guest Abandoned 2' => ($abandonedGuest_2 !== true)? $abandonedGuest_2 . ' <a href="' . $guest2 . '">enable</a>' : 'Enabled',
805
- 'Guest Abandoned 3' => ($abandonedGuest_3 !== true)? $abandonedGuest_3 . ' <a href="' . $guest3 . '">enable</a>' : 'Enabled',
806
- ));
807
- }
808
- }
809
-
810
- return $resultContent;
811
- }
812
-
813
- /**
814
- * Crazy mapping checking.
815
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
816
- */
817
- public function dataFieldMapped()
818
- {
819
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
820
-
821
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
822
- ->setTitle('Default Datafields Mapped Status : ')
823
- ->setMessage('All Datafields Are Mapped.');
824
-
825
- foreach ( Mage::app()->getWebsites() as $website ) {
826
- $passed = true;
827
- $mapped = 0;
828
- $tableData = array();
829
- //website name for table data
830
- $websiteName = $website->getName();
831
- $tableData['Website'] = $websiteName;
832
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID)) {
833
- $passed = false;
834
- $mapped++;
835
- }
836
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME)) {
837
- $passed = false;
838
- $mapped++;
839
- }
840
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LASTNAME)) {
841
- $passed = false;
842
- $mapped++;
843
- }
844
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DOB)) {
845
- $passed = false;
846
- $mapped++;
847
- }
848
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_GENDER)) {
849
- $passed = false;
850
- $mapped++;
851
- }
852
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME)) {
853
- $passed = false;
854
- $mapped++;
855
- }
856
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME)) {
857
- $passed = false;
858
- $mapped++;
859
- }
860
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT)) {
861
- $passed = false;
862
- $mapped++;
863
- }
864
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE)) {
865
- $passed = false;
866
- $mapped++;
867
- }
868
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP)) {
869
- $passed = false;
870
- $mapped++;
871
- }
872
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT)) {
873
- $passed = false;
874
- $mapped++;
875
- }
876
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE)) {
877
- $passed = false;
878
- $mapped++;
879
- }
880
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1)) {
881
- $passed = false;
882
- $mapped++;
883
- }
884
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2)) {
885
- $passed = false;
886
- $mapped++;
887
- }
888
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY)) {
889
- $passed = false;
890
- $mapped++;
891
- }
892
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE)) {
893
- $passed = false;
894
- $mapped++;
895
- }
896
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY)) {
897
- $passed = false;
898
- $mapped++;
899
- }
900
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE)) {
901
- $passed = false;
902
- $mapped++;
903
- }
904
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE)) {
905
- $passed = false;
906
- $mapped++;
907
- }
908
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1)) {
909
- $passed = false;
910
- $mapped++;
911
- }
912
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2)) {
913
- $passed = false;
914
- $mapped++;
915
- }
916
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY)) {
917
- $passed = false;
918
- $mapped++;
919
- }
920
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE)) {
921
- $passed = false;
922
- $mapped++;
923
- }
924
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY)) {
925
- $passed = false;
926
- $mapped++;
927
- }
928
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE)) {
929
- $passed = false;
930
- $mapped++;
931
- }
932
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE)) {
933
- $passed = false;
934
- $mapped++;
935
- }
936
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER)) {
937
- $passed = false;
938
- $mapped++;
939
- }
940
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_AOV)) {
941
- $passed = false;
942
- $mapped++;
943
- }
944
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND)) {
945
- $passed = false;
946
- $mapped++;
947
- }
948
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE)) {
949
- $passed = false;
950
- $mapped++;
951
- }
952
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID)) {
953
- $passed = false;
954
- $mapped++;
955
- }
956
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND)) {
957
- $passed = false;
958
- $mapped++;
959
- }
960
- if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS)) {
961
  $passed = false;
962
- $mapped++;
963
  }
964
- $tableData['Mapped Percentage'] = number_format((1 - $mapped / 32) * 100, 2) . ' %';
965
- //mapping not complete.
966
- if (! $passed ){
967
- $url = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_data_mapping/website/' . $website->getCode());
968
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
969
- ->setMessage('Click <a href="' . $url . '">here</a> to change mapping configuration.')
970
- ;
971
- }
972
- $resultContent->setTable($tableData);
973
- }
974
-
975
- return $resultContent;
976
- }
977
-
978
-
979
- /**
980
- * Validate API Credentials.
981
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
982
- */
983
- public function validApiCredentials()
984
- {
985
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
986
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
987
- ->setTitle('API Credentials Status : ')
988
- ->setMessage('Valid.');
989
- $helper = Mage::helper('ddg');
990
- foreach ( Mage::app()->getWebsites() as $website ) {
991
- $websiteName = $website->getName();
992
- $websiteId = $website->getId();
993
-
994
- $apiUsername = $helper->getApiUsername($websiteId);
995
- $apiPassword = $helper->getApiPassword($websiteId);
996
-
997
- $api = Mage::getModel('ddg_automation/apiconnector_test')->ajaxvalidate($apiUsername, $apiPassword);
998
-
999
- if ($api != 'Credentials Valid.') {
1000
- $url = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_api_credentials/website/' . $website->getCode());
1001
-
1002
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1003
- ->setMessage('')
1004
- ->setTable(array(
1005
- 'Website' => $websiteName,
1006
- 'Status' => $api,
1007
- 'Fast Fix' => 'Click <a href="' . $url . '">here</a> to enter new api credentials.'
1008
- ));
1009
- }
1010
- }
1011
-
1012
- return $resultContent;
1013
- }
1014
-
1015
- /**
1016
- * Order sync enabled.
1017
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1018
- */
1019
- public function orderEnabled()
1020
- {
1021
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
1022
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1023
- ->setTitle('Order Sync : ')
1024
- ->setMessage('Enabled.');
1025
-
1026
- $passed = true;
1027
- foreach ( Mage::app()->getWebsites() as $website ) {
1028
- $websiteName = $website->getName();
1029
- $order = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED))? true :
1030
- 'Disabled!';
1031
-
1032
- if ($order !== true){
1033
-
1034
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED', 'website' => $website->getId()));
1035
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1036
- ->setMessage('')
1037
- ->setTable(array(
1038
- 'Website' => $websiteName,
1039
- 'Status' => $order . ' <a href="' . $url . '">enable</a>'
1040
- ));
1041
- $passed = false;
1042
- }
1043
- }
1044
- //validation failed
1045
- if (! $passed) {
1046
- $resultContent->setHowto(self::FAST_FIX_MESSAGE);
1047
- }
1048
-
1049
- return $resultContent;
1050
- }
1051
 
1052
  /**
1053
  * check if any custom order attribute selected
 
1054
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1055
  */
1056
  public function customOrderAttributes()
1057
  {
1058
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1059
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1060
  ->setTitle('Custom Order Attributes : ')
1061
  ->setMessage('Selected.');
1062
 
1063
- foreach ( Mage::app()->getWebsites() as $website ) {
1064
- $websiteName = $website->getName();
1065
- $customOrderAttibute = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES))? true : false;
 
 
1066
 
1067
- if ($customOrderAttibute !== true){
1068
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1069
- ->setTitle('Custom order attribute not selected (ignore if you do not want to import custom order attributes) :')
 
 
1070
  ->setMessage('')
1071
- ->setTable(array(
1072
- 'Website' => $websiteName,
1073
- 'Status' => 'No Custom Order Attribute Selected'
1074
- ));
 
 
1075
  }
1076
  }
1077
 
1078
  return $resultContent;
1079
  }
1080
 
1081
- /**
1082
- * Check if any orders are imported.
1083
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1084
- */
1085
- public function orderSyncing()
1086
- {
1087
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
1088
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1089
- ->setTitle('Order Syncing : ')
1090
- ->setMessage('Looks Great.');
1091
-
1092
- foreach ( Mage::app()->getWebsites() as $website ) {
1093
- $websiteName = $website->getName();
1094
- $storeIds = $website->getStoreIds();
1095
-
1096
- if(empty($storeIds))
1097
- continue;
1098
-
1099
- //numbser of orders marked as imported
1100
- $numOrders = Mage::getModel('ddg_automation/order')->getCollection()
1101
- ->addFieldToFilter('email_imported', 1)
1102
- ->addFieldToFilter('store_id', array('in', $storeIds))->getSize();
1103
-
1104
- if (! $numOrders) {
1105
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1106
- ->setTitle('Order Syncing (ignore if you have reset orders for reimport) :')
1107
- ->setMessage('')
1108
- ->setTable(array(
1109
- 'Website' => $websiteName,
1110
- 'Status' => 'No Imported Orders Found'
1111
- ));
1112
- }
1113
- }
1114
-
1115
- return $resultContent;
1116
-
1117
- }
 
 
 
 
 
 
 
 
 
1118
 
1119
  /**
1120
  * Quote sync enabled.
 
1121
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1122
  */
1123
  public function quoteEnabled()
1124
  {
1125
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1126
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1127
  ->setTitle('Quote Sync : ')
1128
  ->setMessage('Enabled.');
1129
 
1130
  $passed = true;
1131
- foreach ( Mage::app()->getWebsites() as $website ) {
1132
- $websiteName = $website->getName();
1133
- $quote = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_QUOTE_ENABLED))? true :
 
 
 
 
1134
  'Disabled!';
1135
 
1136
- if ($quote !== true){
1137
 
1138
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_QUOTE_ENABLED', 'website' => $website->getId()));
1139
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
 
 
 
 
1140
  ->setMessage('')
1141
- ->setTable(array(
1142
- 'Website' => $websiteName,
1143
- 'Status' => $quote . ' <a href="' . $url . '">enable</a>'
1144
- ));
 
 
 
1145
  $passed = false;
1146
  }
1147
  }
1148
  //validation failed
1149
- if (! $passed) {
1150
  $resultContent->setHowto(self::FAST_FIX_MESSAGE);
1151
  }
1152
 
@@ -1155,27 +1628,36 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
1155
 
1156
  /**
1157
  * check if any custom quote attribute selected
 
1158
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1159
  */
1160
  public function customQuoteAttributes()
1161
  {
1162
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1163
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1164
  ->setTitle('Custom Quote Attributes : ')
1165
  ->setMessage('Selected.');
1166
 
1167
- foreach ( Mage::app()->getWebsites() as $website ) {
1168
- $websiteName = $website->getName();
1169
- $customQuoteAttribute = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_QUOTE_ATTRIBUTES))? true : false;
 
 
1170
 
1171
- if ($customQuoteAttribute !== true){
1172
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1173
- ->setTitle('Custom quote attribute not selected (ignore if you do not want to import custom quote attributes) :')
 
 
1174
  ->setMessage('')
1175
- ->setTable(array(
1176
- 'Website' => $websiteName,
1177
- 'Status' => 'No Custom Quote Attribute Selected'
1178
- ));
 
 
1179
  }
1180
  }
1181
 
@@ -1184,35 +1666,44 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
1184
 
1185
  /**
1186
  * Check if any quote are imported.
 
1187
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1188
  */
1189
  public function quoteSyncing()
1190
  {
1191
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1192
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1193
  ->setTitle('Quote Syncing : ')
1194
  ->setMessage('Looks Great.');
1195
 
1196
- foreach ( Mage::app()->getWebsites() as $website ) {
1197
- $websiteName = $website->getName();
1198
- $storeIds = $website->getStoreIds();
1199
 
1200
- if(empty($storeIds))
1201
- continue;
 
1202
 
1203
  //number of quote marked as imported
1204
  $numQuotes = Mage::getModel('ddg_automation/quote')->getCollection()
1205
  ->addFieldToFilter('imported', 1)
1206
- ->addFieldToFilter('store_id', array('in', $storeIds))->getSize();
 
1207
 
1208
- if (! $numQuotes) {
1209
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1210
- ->setTitle('Quote Syncing (ignore if you have reset quote for re-import) :')
 
 
1211
  ->setMessage('')
1212
- ->setTable(array(
1213
- 'Website' => $websiteName,
1214
- 'Status' => 'No Imported Quotes Found'
1215
- ));
 
 
1216
  }
1217
  }
1218
 
@@ -1222,517 +1713,670 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
1222
 
1223
  /**
1224
  * review sync enabled.
 
1225
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1226
  * Display the transactional data for orders to be removed.
1227
  */
1228
  public function reviewEnabled()
1229
  {
1230
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1231
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1232
  ->setTitle('Review Sync : ')
1233
  ->setMessage('Enabled.');
1234
 
1235
- foreach ( Mage::app()->getWebsites() as $website ) {
1236
- $websiteName = $website->getName();
1237
- $review = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED))? true :
 
 
 
 
1238
  'Disabled';
1239
 
1240
- if ($review !== true){
1241
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED', 'website' => $website->getId()));
1242
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1243
- ->setMessage('Don\'t forget to enable if you want to sync reviews.' )
1244
- ->setTable(array(
1245
- 'Website' => $websiteName,
1246
- 'Status' => $review,
1247
- 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1248
- ));
 
 
 
 
 
 
 
 
 
1249
  }
1250
  }
 
1251
  return $resultContent;
1252
  }
1253
 
1254
  /**
1255
  * Check if any reviews are imported.
 
1256
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1257
  */
1258
  public function reviewSyncing()
1259
  {
1260
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1261
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1262
  ->setTitle('Review Syncing : ')
1263
  ->setMessage('Looks Great.');
1264
 
1265
- foreach ( Mage::app()->getWebsites() as $website ) {
1266
- $websiteName = $website->getName();
1267
- $storeIds = $website->getStoreIds();
1268
 
1269
- if(empty($storeIds))
1270
- continue;
 
1271
 
1272
  //number of reviews marked as imported
1273
- $numReview = Mage::getModel('ddg_automation/review')->getCollection()
 
1274
  ->addFieldToFilter('review_imported', 1)
1275
  ->addFieldToFilter('store_id', array('in', $storeIds))
1276
  ->getSize();
1277
 
1278
  //total reviews
1279
- $totalReview = Mage::getModel('ddg_automation/review')->getCollection()
 
1280
  ->addFieldToFilter('store_id', array('in', $storeIds))
1281
  ->getSize();
1282
 
1283
  $tableData = array(
1284
- 'Website' => $websiteName,
1285
  'Total Reviews' => $totalReview,
1286
- 'Imported' => $numReview
1287
  );
1288
 
1289
  $tableData['Status'] = 'Importing';
1290
 
1291
- if (! $numReview) {
1292
  $tableData['Status'] = 'No Imported Review Found.';
1293
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1294
- ->setTitle('Review Sync (ignore if you have reset wishlist) : ')
 
 
1295
  ->setMessage('');
1296
  }
1297
  $resultContent->setTable($tableData);
1298
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1299
  return $resultContent;
1300
  }
1301
 
1302
- /**
1303
- * Get the last date for abandaned carts.
1304
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1305
- */
1306
- public function lastAbandonedCartSentDay()
1307
- {
1308
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
1309
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1310
- ->setTitle('Last Abandoned Summary : ');
1311
-
1312
- foreach ( Mage::app()->getWebsites() as $website ) {
1313
-
1314
- $websiteName = $website->getName();
1315
- $client = Mage::helper('ddg')->getWebsiteApiClient($website);
1316
-
1317
- //customer carts
1318
- $customerCampaign1 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_1);
1319
- $customerCampaign2 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_2);
1320
- $customerCampaign3 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_3);
1321
-
1322
- //guests carts
1323
- $guestCampaign1 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_1);
1324
- $guestCampaign2 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_2);
1325
- $guestCampaign3 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_3);
1326
-
1327
-
1328
- //date customer carts
1329
-
1330
- $cusDateSent1 = ($customerCampaign1)? $client->getCampaignSummary($customerCampaign1) : '';
1331
- $cusDateSent2 = ($customerCampaign2)? $client->getCampaignSummary($customerCampaign2) : '';
1332
- $cusDateSent3 = ($customerCampaign3)? $client->getCampaignSummary($customerCampaign3) : '';
1333
-
1334
- //date guest carts
1335
- $resGuest1 = ($guestCampaign1)? $client->getCampaignSummary($guestCampaign1) : '';
1336
- $resGuest2 = ($guestCampaign2)? $client->getCampaignSummary($guestCampaign2) : '';
1337
- $resGuest3 = ($guestCampaign3)? $client->getCampaignSummary($guestCampaign3) : '';
1338
-
1339
- /**
1340
- * Customers.
1341
- */
1342
- $customerCampaign1 = (isset($cusDateSent1->dateSent)? $cusDateSent1->dateSent : 'Not Sent/Selected');
1343
- $customerCampaign2 = (isset($cusDateSent2->dateSent)? $cusDateSent2->dateSent : 'Not Sent/Selected');
1344
- $customerCampaign3 = (isset($cusDateSent3->dateSent)? $cusDateSent3->dateSent : 'Not Sent/Selected');
1345
-
1346
- /**
1347
- * Guests.
1348
- */
1349
- $guestCampaign1 = (isset($resGuest1->dateSent)? $resGuest1->dateSent : 'Not Sent/Selected');
1350
- $guestCampaign2 = (isset($resGuest2->dateSent)? $resGuest2->dateSent : 'Not Sent/Selected');
1351
- $guestCampaign3 = (isset($resGuest3->dateSent)? $resGuest3->dateSent : 'Not Sent/Selected');
1352
-
1353
-
1354
- $resultContent->setTable(array(
1355
- 'Website' => $websiteName,
1356
- 'Customer Campaign 1' => $customerCampaign1,
1357
- 'Customer Campaign 2' => $customerCampaign2,
1358
- 'Customer Campaign 3' => $customerCampaign3,
1359
- 'Guest Campaign 1' => $guestCampaign1,
1360
- 'Guest Campaign 2' => $guestCampaign2,
1361
- 'Guest Campaign 3' => $guestCampaign3
1362
- ));
1363
- }
1364
-
1365
- return $resultContent;
1366
- }
1367
-
1368
- /**
1369
- * Conflict checker.
1370
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1371
- */
1372
- public function conflictCheck()
1373
- {
1374
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
1375
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1376
- ->setTitle('Conflict Status : ')
1377
- ->setMessage('Looks Great.');
1378
-
1379
- //check the module override and conflict
1380
- $rewrites = Mage::helper('ddg/dashboard')->getRewrites();
1381
-
1382
-
1383
- if ($rewrites === false) {
1384
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1385
- ->setMessage('No Conflict Rewrites Found.');
1386
- } else {
1387
-
1388
- $types = array('blocks', 'models', 'helpers');
1389
- foreach ($types as $t) {
1390
-
1391
- if (!empty($rewrites[$t])) {
1392
-
1393
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1394
- ->setMessage('Conflicting Rewrite Found : ');
1395
-
1396
- foreach ($rewrites[$t] as $node => $rewriteInfo) {
1397
-
1398
- $resultContent->setTable(array(
1399
- 'Type' => $t,
1400
- 'Class' => implode(', ', array_values($rewriteInfo['classes'])),
1401
- 'Rewrites' => '',
1402
- 'Loaded Class' => ''
1403
- ));
1404
- }
1405
- }
1406
- }
1407
-
1408
- $conflictCounter = 0;
1409
- $tableData = array();
1410
- foreach ($rewrites as $type => $data) {
1411
- if (count($data) > 0 && is_array($data)) {
1412
-
1413
- foreach ($data as $class => $rewriteClass) {
1414
-
1415
- if (count($rewriteClass) > 1) {
1416
- if ($this->_isInheritanceConflict($rewriteClass)) {
1417
-
1418
- $resultContent->setTable(array(
1419
- 'Type' => $type,
1420
- 'Class' => $class,
1421
- 'Rewrites' => implode(', ', $rewriteClass['classes']),
1422
- 'Loaded Class' => $this->_getLoadedClass($type, $class),
1423
- ));
1424
-
1425
- $conflictCounter++;
1426
- }
1427
- }
1428
- }
1429
- }
1430
- }
1431
- if (! empty($tableData))
1432
- $resultContent->setTable($tableData);
1433
-
1434
- }
1435
-
1436
- return $resultContent;
1437
- }
1438
-
1439
- /**
1440
- * Returns loaded class by type like models or blocks
1441
- *
1442
- * @param string $type
1443
- * @param string $class
1444
- * @return string
1445
- */
1446
- protected function _getLoadedClass($type, $class)
1447
- {
1448
- switch ($type) {
1449
- case 'blocks':
1450
- return Mage::getConfig()->getBlockClassName($class);
1451
-
1452
- case 'helpers':
1453
- return Mage::getConfig()->getHelperClassName($class);
1454
-
1455
- default:
1456
- case 'models':
1457
- return Mage::getConfig()->getModelClassName($class);
1458
- break;
1459
- }
1460
- }
1461
-
1462
- /**
1463
- * Check if rewritten class has inherited the parent class.
1464
- * If yes we have no conflict. The top class can extend every core class.
1465
- * So we cannot check this.
1466
- *
1467
- * @var array $classes
1468
- * @return bool
1469
- */
1470
- protected function _isInheritanceConflict($classes)
1471
- {
1472
- $classes = array_reverse($classes);
1473
- $numClases = count($classes);
1474
-
1475
- for ($i = 0; $i < $numClases - 1; $i++) {
1476
- try {
1477
- if (class_exists($classes[$i])
1478
- && class_exists($classes[$i + 1])
1479
- ) {
1480
- if (! is_a($classes[$i], $classes[$i + 1], true)) {
1481
- return true;
1482
- }
1483
- }
1484
- } catch (\Exception $e) {
1485
- return true;
1486
- }
1487
- }
1488
-
1489
- return false;
1490
- }
1491
-
1492
- /**
1493
- * System information about the version used and the memory limits.
1494
- *
1495
- * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1496
- */
1497
- public function systemInformation()
1498
- {
1499
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
1500
- $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED);
1501
-
1502
- //compatibility with the old versions
1503
- if (version_compare(Mage::getVersion(), '1.6.2.0', '>')) {
1504
- $version = 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion() . 'V';
1505
- } else {
1506
- $version = 'Magento version : ' . Mage::getVersion() . 'V';
1507
- }
1508
-
1509
- $fh = @fopen('/proc/meminfo', 'r');
1510
- $mem = 0;
1511
- if ($fh) {
1512
- while ($line = fgets($fh)) {
1513
- $pieces = array();
1514
- if (preg_match('^MemTotal:\s+(\d+)\skB$^', $line, $pieces)) {
1515
- $mem = $pieces[1];
1516
- break;
1517
- }
1518
- }
1519
- fclose($fh);
1520
- }
1521
- if ($mem > 0) {
1522
- $mem = $mem / 1024 . 'M';
1523
- } else {
1524
- $mem = 'Not available';
1525
- }
1526
-
1527
- //check for php version
1528
- $resultContent->setHowTo('PHP version : V' . PHP_VERSION)
1529
- ->setHowto('PHP Memory : ' . $mem)
1530
- ->setHowto('PHP Max Execution Time : ' . ini_get('max_execution_time') . ' sec')
1531
- ->setHowto($version)
1532
- ->setHowto('Connector version : V' . Mage::helper('ddg')->getConnectorVersion());
1533
-
1534
- return $resultContent;
1535
- }
1536
-
1537
-
1538
- /**
1539
- * Check if the mapped program is active.
1540
- */
1541
- protected function _getWebisteProgram($program, $website) {
1542
-
1543
- $client = Mage::helper('ddg')->getWebsiteApiClient($website);
1544
-
1545
- if (! $client || !$program){
1546
- return false;
1547
- }
1548
-
1549
- $data = $client->getProgramById($program);
1550
-
1551
- if (isset($data->message))
1552
- return false;
1553
-
1554
-
1555
- return $data;
1556
- }
1557
-
1558
- /**
1559
- * Get the contacts address book.
1560
- * @param $addressBook
1561
- * @param $webiste
1562
- *
1563
- * @return bool|null
1564
- */
1565
- protected function _getAddressBookContacts($addressBook, $webiste) {
1566
- $client = Mage::helper('ddg')->getWebsiteApiClient($webiste);
1567
-
1568
- if (! $client && $addressBook)
1569
- return false;
1570
-
1571
- $response = $client->getAddressBookById($addressBook);
1572
-
1573
- if (isset($response->message))
1574
- return false;
1575
- return $response;
1576
- }
1577
-
1578
- /**
1579
- * Get the method name
1580
- * @param $name
1581
- *
1582
- * @return string
1583
- */
1584
- public function getFormatedMethodName($name)
1585
- {
1586
- //version that not support the lcfirst method
1587
- if(function_exists('lcfirst') === false) {
1588
-
1589
- $method = strtolower(substr(uc_words($name, '') ,0,1)).substr(uc_words($name, ''), 1);
1590
-
1591
- } else {
1592
- $method = lcfirst(uc_words($name, ''));
1593
- }
1594
-
1595
- return $method;
1596
- }
1597
 
1598
  /**
1599
  * easy email capture enabled
 
1600
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1601
  */
1602
  public function easyEmailCaptureEnabled()
1603
  {
1604
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1605
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1606
  ->setTitle('Easy Email Capture : ')
1607
  ->setMessage('Enabled.');
1608
 
1609
- foreach ( Mage::app()->getWebsites() as $website ) {
1610
- $websiteName = $website->getName();
1611
- $enabled = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE))? true :
 
 
 
 
1612
  'Disabled';
1613
 
1614
- if ($enabled !== true){
1615
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_EMAIL_CAPTURE', 'website' => $website->getId()));
1616
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1617
- ->setMessage('Don\'t forget to enable if you want to enable easy email capture.' )
1618
- ->setTable(array(
1619
- 'Website' => $websiteName,
1620
- 'Status' => $enabled,
1621
- 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1622
- ));
 
 
 
 
 
 
 
 
 
1623
  }
1624
  }
 
1625
  return $resultContent;
1626
  }
1627
 
1628
  /**
1629
  * disabled newsletter success enabled
 
1630
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1631
  */
1632
  public function disableNewsletterSuccessEnabled()
1633
  {
1634
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1635
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1636
  ->setTitle('Disable Newsletter Success : ')
1637
  ->setMessage('Enabled.');
1638
 
1639
- foreach ( Mage::app()->getWebsites() as $website ) {
1640
- $websiteName = $website->getName();
1641
- $enabled = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS))? true :
 
 
 
 
1642
  'Disabled';
1643
 
1644
- if ($enabled !== true){
1645
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS', 'website' => $website->getId()));
1646
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1647
- ->setMessage('Don\'t forget to enable if you want to disable Magento newsletter success email.' )
1648
- ->setTable(array(
1649
- 'Website' => $websiteName,
1650
- 'Status' => $enabled,
1651
- 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1652
- ));
 
 
 
 
 
 
 
 
 
1653
  }
1654
  }
 
1655
  return $resultContent;
1656
  }
1657
 
1658
  /**
1659
  * wishlist sync enabled.
 
1660
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1661
  */
1662
  public function wishlistEnabled()
1663
  {
1664
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1665
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1666
  ->setTitle('Wishlist Sync : ')
1667
  ->setMessage('Enabled.');
1668
 
1669
- foreach ( Mage::app()->getWebsites() as $website ) {
1670
- $websiteName = $website->getName();
1671
- $wishlist = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED))? true :
 
 
 
 
1672
  'Disabled';
1673
 
1674
- if ($wishlist !== true){
1675
- $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED', 'website' => $website->getId()));
1676
- $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1677
- ->setMessage('Don\'t forget to enable if you want to sync wishlist.' )
1678
- ->setTable(array(
1679
- 'Website' => $websiteName,
1680
- 'Status' => $wishlist,
1681
- 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1682
- ));
 
 
 
 
 
 
 
 
 
1683
  }
1684
  }
 
1685
  return $resultContent;
1686
  }
1687
 
1688
  /**
1689
  * Check if any wishlist are imported.
 
1690
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1691
  */
1692
  public function wishlistSyncing()
1693
  {
1694
- $resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
 
 
1695
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1696
  ->setTitle('Wishlist Syncing : ')
1697
  ->setMessage('Looks Great.');
1698
 
1699
- foreach ( Mage::app()->getWebsites() as $website ) {
1700
- $websiteName = $website->getName();
1701
- $storeIds = $website->getStoreIds();
1702
 
1703
- if(empty($storeIds))
1704
- continue;
 
1705
 
1706
  //number of wishlist marked as imported
1707
- $numWishlist = Mage::getModel('ddg_automation/wishlist')->getCollection()
 
1708
  ->addFieldToFilter('wishlist_imported', 1)
1709
  ->addFieldToFilter('store_id', array('in', $storeIds))
1710
  ->getSize();
1711
 
1712
  //total wishlist
1713
- $totalWishlist = Mage::getModel('ddg_automation/wishlist')->getCollection()
 
1714
  ->addFieldToFilter('store_id', array('in', $storeIds))
1715
  ->getSize();
1716
 
1717
  $tableData = array(
1718
- 'Website' => $websiteName,
1719
  'Total Wishlist' => $totalWishlist,
1720
- 'Imported' => $numWishlist
1721
  );
1722
 
1723
  $tableData['Status'] = 'Importing';
1724
 
1725
- if (! $numWishlist) {
1726
  $tableData['Status'] = 'No Imported Wishlist Found.';
1727
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1728
- ->setTitle('Wishlist Sync (ignore if you have reset wishlist) : ')
 
 
1729
  ->setMessage('');
1730
  }
1731
  $resultContent->setTable($tableData);
1732
  }
 
1733
  return $resultContent;
1734
  }
1735
 
1736
 
1737
-
1738
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status
4
+ extends Mage_Adminhtml_Block_Widget
5
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
7
 
8
+ const CONNECTOR_DASHBOARD_PASSED = 'available';
9
+ const CONNECTOR_DASHBOARD_WARRNING = 'connector_warning';
10
+ const CONNECTOR_DASHBOARD_FAILED = 'error';
11
+
12
+ const FAST_FIX_MESSAGE = 'Fast Fix Available, Click To Enable The Mapping And Redirect Back.';
13
+
14
+ protected $_checkpoints
15
+ = array(
16
+ 'valid_api_credentials' => 'API Credentials',
17
+ 'cron_running' => 'Cron running',
18
+ 'conflict_check' => 'Conflict Check',
19
+ 'address_book_mapped' => 'Address Book Mapping',
20
+ 'file_permission_setttings' => 'File Permission Settings',
21
+ 'missing_files' => 'Missing Files',
22
+ 'contact_sync_enabled' => 'Contact Sync Enabled',
23
+ 'contact_syncing' => 'Contacts Syncing',
24
+ 'subscriber_sync_enabled' => 'Subscribers Sync Enabled',
25
+ 'subscribers_syncing' => 'Subscribers Syncing',
26
+ 'automation_active' => 'Automation Programs Active',
27
+ 'abandoned_carts_enabled' => 'Abandoned Carts Enabled',
28
+ 'data_field_mapped' => 'Data Field Mapped',
29
+ 'order_enabled' => 'Order Sync Enabled',
30
+ 'order_syncing' => 'Orders Syncing',
31
+ 'custom_order_attributes' => 'Custom Order Attributes',
32
+ 'quote_enabled' => 'Quote Sync Enabled',
33
+ 'quote_syncing' => 'Quote Syncing',
34
+ 'custom_quote_attributes' => 'Custom Quote Attributes',
35
+ 'last_abandoned_cart_sent_day' => 'Last Abandoned Cart Sent Day',
36
+ 'easy_email_capture_enabled' => 'Easy Email Capture Enabled',
37
+ 'disable_newsletter_success_enabled' => 'Disable Newsletter Success Enabled',
38
+ 'system_information' => 'System Information'
39
+
40
+ );
41
+
42
+ /**
43
  * Set the template.
44
  */
45
  public function __construct()
46
  {
47
  parent::__construct();
48
 
49
+ $this->setTemplate('connector/dashboard/status.phtml');
50
  }
51
 
52
  /**
59
  {
60
  }
61
 
62
+ public function canShowTab()
63
+ {
64
+ return true;
65
+ }
66
+
67
+ public function isHidden()
68
+ {
69
+ return true;
70
+ }
71
+
72
+ public function getTabLabel()
73
+ {
74
+ return Mage::helper('ddg')->__('Marketing Automation System Status');
75
+ }
76
+
77
+ public function getTabTitle()
78
+ {
79
+ return Mage::helper('ddg')->__('Marketing Automation System Status');
80
+ }
81
+
82
+ /**
83
+ * Collapse key for the fieldset state.
84
+ *
85
+ * @param $key
86
+ *
87
+ * @return bool
88
+ */
89
+ protected function _getCollapseState($key)
90
+ {
91
+ $extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
92
+ if (isset($extra['configState'][$key])) {
93
+ return $extra['configState'][$key];
94
+ }
95
+
96
+ return false;
97
+ }
98
+
99
+ public function getCheckpoints()
100
+ {
101
+ return $this->_checkpoints;
102
+ }
103
+
104
+ protected function getDisplayData()
105
+ {
106
+
107
+ $displayData = array();
108
+ foreach ($this->getCheckpoints() as $key => $checkpoint) {
109
+
110
+ $method = $this->getFormatedMethodName($key);
111
+
112
+ if (is_callable(array($this, $method))) {
113
+ $data = $this->$method();
114
+ $showHowTo = '';
115
+ $collapsable = '1';
116
+
117
+ if ($data->getStyle() == 'connector_passed') {
118
+ $showHowTo = 'no_display';
119
+ $collapsable = '0';
120
+ }
121
+ if ($this->_getCollapseState($key) !== false) {
122
+ $collapsable = $this->_getCollapseState($key);
123
+ }
124
+ $displayData[$key] = array(
125
+ 'showHowTo' => $showHowTo,
126
+ 'collapsable' => $collapsable,
127
+ 'data' => $data
128
+ );
129
+ }
130
+ }
131
+
132
+ return $displayData;
133
+ }
134
+
135
+
136
+ public function addCheckpoint($checkpoint)
137
+ {
138
+ $this->_checkpoints[$checkpoint->getName()] = $checkpoint;
139
+ }
140
+
141
+
142
+ /**
143
+ * Check cron for the customer sync.
144
+ *
145
+ * @return array
146
+ */
147
+ public function cronRunning()
148
+ {
149
+ $resultContent = Mage::getModel(
150
+ 'ddg_automation/adminhtml_dashboard_content'
151
+ );
152
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
153
+ ->setTitle('Cron Status : ')
154
+ ->setMessage('Cron is running.');
155
+ $message
156
+ = 'No cronjob task found. Check if cron is configured correctly.';
157
+ $howToSetupCron
158
+ = 'For more information <a href="http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job">how to setup the Magento cronjob.</a>';
159
+ $lastCustomerSync = Mage::getModel('ddg_automation/cron')
160
+ ->getLastCustomerSync();
161
+
162
+ if ($lastCustomerSync === false) {
163
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
164
+ ->setHowto($howToSetupCron);
165
+ } else {
166
+ $timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
167
+ //last cron was less then 5min
168
+ if ($timespan <= 5 * 60) {
169
+ $resultContent->setTitle('Cronjob is working : ');
170
+ $message = sprintf(
171
+ '(Last execution: %s minute(s) ago) ', round($timespan / 60)
172
+ );
173
+ } elseif ($timespan > 5 * 60 && $timespan <= 60 * 60) {
174
+ //last cron execution was between 15min and 60min
175
+ $resultContent->setTitle('Last customer sync : ')
176
+ ->setStyle(self::CONNECTOR_DASHBOARD_FAILED);
177
+ $message = sprintf(' %s minutes. ', round($timespan / 60));
178
+ } else {
179
+ //last cron was more then an hour
180
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
181
+ ->setHowto('Last customer sync is older than one hour.')
182
+ ->setHowto($howToSetupCron);
183
+ }
184
+ }
185
+
186
+ $resultContent->setMessage($message);
187
+
188
+ return $resultContent;
189
+ }
190
+
191
+ /**
192
+ * Address Book Mapping.
193
+ *
194
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
195
+ */
196
+ public function addressBookMapped()
197
+ {
198
+ $resultContent = Mage::getModel(
199
+ 'ddg_automation/adminhtml_dashboard_content'
200
+ );
201
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
202
+ ->setTitle('Configuration For Address Book Status : ')
203
+ ->setMessage('Looks Great.');
204
+
205
+ foreach (Mage::app()->getWebsites() as $website) {
206
+
207
+ $websiteName = $website->getName();
208
+ $link = Mage::helper('adminhtml')->getUrl(
209
+ '*/system_config/edit/section/connector_sync_settings/website/'
210
+ . $website->getCode()
211
+ );
212
+
213
+ $customerMapped = ($website->getConfig(
214
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID
215
+ ))
216
+ ? true
217
+ :
218
+ 'Not mapped!';
219
+ $subscriberMapped = ($website->getConfig(
220
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID
221
+ ))
222
+ ? true
223
+ :
224
+ 'Not mapped!';
225
+ $guestMapped = ($website->getConfig(
226
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID
227
+ ))
228
+ ? true
229
+ :
230
+ 'Not mapped!';
231
+
232
+ if ($customerMapped !== true || $subscriberMapped !== true
233
+ || $guestMapped !== true
234
+ ) {
235
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
236
+ ->setMessage('')
237
+ ->setTable(
238
+ array(
239
+ 'Website' => $websiteName,
240
+ 'Customers' => ($customerMapped !== true)
241
+ ? $customerMapped . ' <a href="' . $link
242
+ . '">configuration</a>' : 'Mapped.',
243
+ 'Subscribers' => ($subscriberMapped !== true)
244
+ ? $subscriberMapped . ' <a href="' . $link
245
+ . '">configuration</a>' : 'Mapped.',
246
+ 'Guests' => ($guestMapped !== true)
247
+ ? $guestMapped . ' <a href="' . $link
248
+ . '">configuration</a>' : 'Mapped.'
249
+ )
250
+ );
251
+ }
252
+ }
253
+
254
+ return $resultContent;
255
+ }
256
+
257
+ /**
258
+ * ROI Tracking.
259
+ *
260
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
261
+ */
262
+ public function roiTrackingEnabled()
263
+ {
264
+ $resultContent = Mage::getModel(
265
+ 'ddg_automation/adminhtml_dashboard_content'
266
+ );
267
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
268
+ ->setTitle('ROI Tracking Status : ')
269
+ ->setMessage('Looks Great.');
270
+
271
+ $valid = true;
272
+ foreach (Mage::app()->getWebsites() as $website) {
273
+ $websiteName = $website->getName();
274
+
275
+ $roiConfig = ($website->getConfig(
276
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED
277
+ )) ? true : 'Not Mapped! ';
278
+ $pageTracking = ($website->getConfig(
279
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED
280
+ )) ? true : 'Not Mapped! ';
281
+ //not mapped show options
282
+ if ($roiConfig !== true || $pageTracking !== true) {
283
+
284
+ //links to enable and get redirected back
285
+ $roiUrl = Mage::helper('adminhtml')->getUrl(
286
+ '*/connector/enablewebsiteconfiguration',
287
+ array('path' => 'XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED',
288
+ 'website' => $website->getId())
289
+ );
290
+ $pageUrl = Mage::helper('adminhtml')->getUrl(
291
+ '*/connector/enablewebsiteconfiguration',
292
+ array('path' => 'XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED',
293
+ 'website' => $website->getId())
294
+ );
295
+
296
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
297
+ ->setMessage('')
298
+ ->setTable(
299
+ array(
300
+ 'Website' => $websiteName,
301
+ 'ROI' => ($roiConfig !== true) ? $roiConfig
302
+ . ' <a href="' . $roiUrl . '">enable</a>'
303
+ : 'Mapped.',
304
+ 'PAGE' => ($pageTracking !== true)
305
+ ? $pageTracking . ' <a href="' . $pageUrl
306
+ . '">enable</a>' : 'Mapped.'
307
+ )
308
+ );
309
+ $valid = false;
310
+ }
311
+ }
312
+ //validation failed
313
+ if ( ! $valid) {
314
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
315
+ }
316
+
317
+ return $resultContent;
318
+ }
319
+
320
+ /**
321
+ * File Permissions.
322
+ *
323
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
324
+ */
325
+ public function filePermissionSetttings()
326
+ {
327
+ $resultContent = Mage::getModel(
328
+ 'ddg_automation/adminhtml_dashboard_content'
329
+ );
330
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
331
+ ->setTitle('Files/Folders Permission Settings : ')
332
+ ->setMessage('Looks Great.');
333
+
334
+ /**
335
+ * Arhive and email export directories.
336
+ */
337
+ $emailDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export'
338
+ . DIRECTORY_SEPARATOR . 'email';
339
+ $archiveDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export'
340
+ . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive';
341
+
342
+ $checkEmail = Mage::helper('ddg/file')->getPathPermission($emailDir);
343
+ $checkArchive = Mage::helper('ddg/file')->getPathPermission(
344
+ $archiveDir
345
+ );
346
+
347
+ //file persmission failed
348
+ if ($checkEmail != 755 && $checkEmail != 777
349
+ || $checkArchive != 755
350
+ && $checkArchive != 777
351
+ ) {
352
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
353
+ ->setMessage('Wrong Permission For Directory : 777 or 755');
354
+
355
+ //list of directory permission checked
356
+ if ($checkEmail != 755 || $checkEmail != 777) {
357
+ $resultContent->setHowto(
358
+ $emailDir . ' is set to : ' . $checkEmail
359
+ );
360
+ }
361
+ if ($checkArchive != 755 || $checkArchive != 777) {
362
+ $resultContent->setHowto(
363
+ $archiveDir . ' is set to : ' . $checkArchive
364
+ );
365
+ }
366
+ }
367
+
368
+ return $resultContent;
369
+ }
370
+
371
+ /**
372
+ * Check for missing files.
373
+ *
374
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
375
+ */
376
+ public function missingFiles()
377
+ {
378
+ $resultContent = Mage::getModel(
379
+ 'ddg_automation/adminhtml_dashboard_content'
380
+ );
381
+
382
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
383
+ ->setTitle('Missing Files : ')
384
  ->setMessage('Looks Great.');
385
 
386
+ $filePath = Mage::getModuleDir(
387
+ 'etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
388
+ ) . DS . 'files.yaml';
389
+ $config = Zend_Config_Yaml::decode(file_get_contents($filePath));
390
+
391
+ /**
392
+ * Code dirs.
393
+ */
394
+ $etcDir = Mage::getModuleDir(
395
+ 'etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
396
+ );
397
+ $controllerDir = Mage::getModuleDir(
398
+ 'controllers', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
399
+ );
400
+ $sqlDir = Mage::getModuleDir(
401
+ 'sql', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
402
+ );
403
+ $localeDir = Mage::getBaseDir('locale');
404
+ $rootDir = Mage::getModuleDir(
405
+ '', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
406
+ );
407
+ $blockDir = $rootDir . DS . 'Block';
408
+ $helperDir = $rootDir . DS . 'Helper';
409
+ $modelDir = $rootDir . DS . 'Model';
410
+
411
+ /**
412
+ * Design dir.
413
+ */
414
+ $designDir = Mage::getBaseDir('design');
415
+
416
+ /**
417
+ * Skin dir.
418
+ */
419
+ $skinDir = Mage::getBaseDir('skin');
420
 
421
  /**
422
  * Js dir
428
  */
429
  $libDir = Mage::getBaseDir('lib');
430
 
431
+ $filesToCheck = array($config['etc'], $config['controllers'],
432
+ $config['sql'], $config['locale'],
433
+ $config['block'],
434
+ $config['helper'], $config['model'],
435
+ $config['design'], $config['skin'],
436
+ $config['lib'], $config['js']);
437
+ $pathToCheck = array($etcDir, $controllerDir, $sqlDir, $localeDir,
438
+ $blockDir, $helperDir,
439
+ $modelDir, $designDir, $skinDir, $libDir, $jsDir);
440
+ foreach ($filesToCheck as $subdir) {
441
+ foreach ($subdir as $path) {
442
+ $file = $pathToCheck[0] . DS . str_replace('#', DS, $path);
443
+
444
+ if ( ! file_exists($file)) {
445
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
446
+ ->setMessage('')
447
+ ->setHowto('File not found : ' . $file);
448
+ }
449
+ }
450
+ array_shift($pathToCheck);
451
+ }
452
+
453
+ return $resultContent;
454
+ }
455
+
456
+ /**
457
+ * Contact Sync Status.
458
+ *
459
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
460
+ */
461
+ public function contactSyncEnabled()
462
+ {
463
+ $resultContent = Mage::getModel(
464
+ 'ddg_automation/adminhtml_dashboard_content'
465
+ );
466
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
467
+ ->setTitle('Contacts Sync Status : ')
468
+ ->setMessage('Looks Great.');
469
+
470
+ $valid = true;
471
+ foreach (Mage::app()->getWebsites() as $website) {
472
+ $websiteName = $website->getName();
473
+ $contact = ($website->getConfig(
474
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED
475
+ )) ? true : 'Disabled!';
476
+ //disabled show data table
477
+ if ($contact !== true) {
478
+ //redirection url to enable website config
479
+ $url = Mage::helper('adminhtml')->getUrl(
480
+ '*/connector/enablewebsiteconfiguration',
481
+ array('path' => 'XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED',
482
+ 'website' => $website->getId())
483
+ );
484
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
485
+ ->setMessage('')
486
+ ->setTable(
487
+ array(
488
+ 'Website' => $websiteName,
489
+ 'Status' => ($contact) ? $contact . ' <a href="'
490
+ . $url . '">enable</a>' : 'Enabled.'
491
+ )
492
+ );
493
+ $valid = false;
494
+ }
495
+ }
496
+ //validation failed
497
+ if ( ! $valid) {
498
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
499
+ }
500
+
501
+ return $resultContent;
502
+ }
503
+
504
+ /**
505
+ * Check if contact is syncing by counting the number of contacts imported.
506
+ *
507
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
508
+ */
509
+ public function contactSyncing()
510
+ {
511
+ //content to render
512
+ $resultContent = Mage::getModel(
513
+ 'ddg_automation/adminhtml_dashboard_content'
514
+ );
515
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
516
+ ->setTitle('Contacts Sync : ')
517
+ ->setMessage('Looks Great.');
518
+ $contactModel = Mage::getModel('ddg_automation/contact');
519
+
520
+ //global email duplicates
521
+ if (Mage::getResourceModel('customer/customer')->findEmailDuplicates()
522
+ ) {
523
+
524
+ //duplicate email customers
525
+ $customers = Mage::helper('ddg')
526
+ ->getCustomersWithDuplicateEmails();
527
+ $customerEmails = implode(
528
+ ', ', $customers->getColumnValues('email')
529
+ );
530
+ //render the email duplicates
531
+ $resultContent->setHowto('Found Duplicate Customers Emails :')
532
+ ->setHowto($customerEmails);
533
+ }
534
+
535
+ foreach (Mage::app()->getWebsites() as $website) {
536
+
537
+ $websiteId = $website->getId();
538
+ //total customers for website
539
+ $countCustomers = Mage::getModel('customer/customer')
540
+ ->getCollection()
541
+ ->addAttributeToFilter('website_id', $websiteId)
542
+ ->getSize();
543
+
544
+ //skip if no customers
545
+ if ( ! $countCustomers) {
546
+ continue;
547
+ }
548
+
549
+ //total contacts from customer address book
550
+ $customerAddressBook = $this->_getAddressBookContacts(
551
+ $website->getConfig(
552
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID
553
+ ), $website
554
+ );
555
+ $countAddressbookContacts = ($customerAddressBook)
556
+ ? $customerAddressBook->contacts : 0;
557
+ //total contacts as customers
558
+ $countCustomerContacts = $contactModel->getNumberCustomerContacts(
559
+ $websiteId
560
+ );
561
+
562
+ //suppressed contacts
563
+ $suppressed = $contactModel->getNumberCustomerSuppressed(
564
+ $websiteId
565
+ );
566
+
567
+ //table data
568
+ $tableData = array(
569
+ 'Website' => $website->getName(),
570
+ 'Total Customers/Contacts' => $countCustomers . '/ '
571
+ . $countCustomerContacts,
572
+ 'Customer AddressBook Contacts' => ($customerAddressBook)
573
+ ? $customerAddressBook->name . ' : '
574
+ . $countAddressbookContacts : 'Not Mapped.',
575
+ 'Suppressed' => $suppressed,
576
+ 'Synced' => $contactModel->getNumberCustomerSynced(
577
+ $websiteId
578
+ )
579
+ );
580
+
581
+ //number of customers not match, try to update
582
+ if ($countCustomers != $countCustomerContacts) {
583
+
584
+ $url = Mage::helper('adminhtml')->getUrl(
585
+ '*/connector/populatecontacts',
586
+ array('type' => 'customers', 'website' => $website->getId())
587
+ );
588
+ $link = ' <a href="' . $url . '"> populate</a>';
589
+ $tableData['Status']
590
+ = 'Customers not matching the contact table. ' . $link;
591
+ //customers not synced yet
592
+ } elseif ($countCustomers > $countCustomerContacts + $suppressed) {
593
+ $tableData['Status'] = 'Syncing..';
594
+ //all customers syned.
595
+ } else {
596
+ $tableData['Status'] = 'Synced';
597
+ }
598
+
599
+ //not valid response remove status
600
+ if ( ! $countAddressbookContacts) {
601
+ unset($tableData['Status']);
602
+ }
603
+
604
+ //no contacts
605
+ if ( ! $countCustomers) {
606
+
607
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
608
+ ->setTitle(
609
+ 'Contacts Sync (ignore if you have reset contacts for reimport) : '
610
+ )
611
+ ->setMessage('');
612
+ $tableData['Status'] = 'No Imported Contacts Found!';
613
+ unset($tableData['Imported Contacts']);
614
+ }
615
+
616
+ $resultContent->setTable($tableData);
617
+ }
618
+
619
+ return $resultContent;
620
+ }
621
+
622
+ /**
623
+ * Check for subscribers sync status.
624
+ *
625
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
626
+ */
627
+ public function subscriberSyncEnabled()
628
+ {
629
+ $resultContent = Mage::getModel(
630
+ 'ddg_automation/adminhtml_dashboard_content'
631
+ );
632
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
633
+ ->setTitle('Subscribers Sync Status : ')
634
+ ->setMessage('Looks Great.');
635
+
636
+ $passed = true;
637
+ foreach (Mage::app()->getWebsites() as $website) {
638
+ $websiteName = $website->getName();
639
+ $contact = ($website->getConfig(
640
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED
641
+ ))
642
+ ? true
643
+ :
644
+ 'Disabled!';
645
+ //disabled show data table
646
+ if ($contact !== true) {
647
+ //redirection url to enable website config
648
+ $url = Mage::helper('adminhtml')->getUrl(
649
+ '*/connector/enablewebsiteconfiguration',
650
+ array('path' => 'XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED',
651
+ 'website' => $website->getId())
652
+ );
653
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
654
+ ->setMessage('')
655
+ ->setTable(
656
+ array(
657
+ 'Website' => $websiteName,
658
+ 'Status' => ($contact) ? $contact . ' <a href="'
659
+ . $url . '">enable</a>' : 'Enabled.'
660
+ )
661
+ );
662
+ $passed = false;
663
+ }
664
+ }
665
+ //if validation not passed
666
+ if ( ! $passed) {
667
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
668
+ }
669
+
670
+ return $resultContent;
671
+ }
672
+
673
+ /**
674
+ * Subscribers syncing status.
675
+ *
676
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
677
+ */
678
+ public function subscribersSyncing()
679
+ {
680
+ $resultContent = Mage::getModel(
681
+ 'ddg_automation/adminhtml_dashboard_content'
682
+ );
683
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
684
+ ->setTitle('Subscribers Sync : ')
685
+ ->setMessage('Looks Great.');
686
+ $contactModel = Mage::getModel('ddg_automation/contact');
687
+
688
+ foreach (Mage::app()->getWebsites() as $website) {
689
+ $websiteId = $website->getId();
690
+ $websiteName = $website->getName();
691
+ $storeIds = $website->getStoreIds();
692
+ //total subscribers
693
+ $countSubscribers = Mage::getModel('newsletter/subscriber')
694
+ ->getCollection()
695
  ->useOnlySubscribed()
696
  ->addStoreFilter($storeIds)
697
+ ->getSize();
698
+ //skip if no subscriber
699
+ if ( ! $countSubscribers) {
700
+ continue;
701
+ }
702
+
703
+ //total contacts subscribed
704
+ $countSubscribedContacts = $contactModel->getNumberSubscribers(
705
+ $websiteId
706
+ );
707
+ //total contacts subscribed imported
708
+ $countSubscribersImported
709
+ = $contactModel->getNumberSubscribersSynced($websiteId);
710
+
711
+ //number of address
712
+ $countAddressbookContacts = $this->_getAddressBookContacts(
713
+ $website->getConfig(
714
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID
715
+ ), $website
716
+ );
717
+
718
+ $tableData = array(
719
+ 'Website' => $websiteName,
720
+ 'Total Subscribers/Contacts' => $countSubscribers . '/ '
721
+ . $countSubscribedContacts,
722
+ 'Subscriber AddressBook Contacts' => ($countAddressbookContacts)
723
+ ? $countAddressbookContacts->name . ' : '
724
+ . $countAddressbookContacts->contacts : 'Not Mapped.',
725
+ 'Imported' => $countSubscribersImported
726
+ );
727
+
728
+ $tableData['Status'] = '';
729
+
730
+ //no imported contacts
731
+ if ( ! $countSubscribersImported) {
732
+
733
+ $tableData['Status'] = 'No Imported Subscribers Found.';
734
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
735
+ ->setTitle(
736
+ 'Subscriber Sync (ignore if you have reset subscribers for reimport) : '
737
+ )
738
+ ->setMessage('');
739
+ }
740
+ $resultContent->setTable($tableData);
741
+ }
742
+
743
+ return $resultContent;
744
+ }
745
+
746
+ //check the mapped programs are active
747
+ public function automationActive()
748
+ {
749
+ $disableCustomer
750
+ = $disableSubscriber = $disableOrder
751
+ = $disableGuestOrder = $disableReviews = $disableWishlist = '';
752
+ $resultContent = Mage::getModel(
753
+ 'ddg_automation/adminhtml_dashboard_content'
754
+ );
755
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
756
+ ->setTitle('Automation Program Status :')
757
+ ->setMessage('');
758
+
759
+ foreach (Mage::app()->getWebsites() as $website) {
760
+ $customerProgram = $website->getConfig(
761
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER
762
+ );
763
+ $subscriberProgram = $website->getConfig(
764
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER
765
+ );
766
+ $orderProgram = $website->getConfig(
767
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER
768
+ );
769
+ $guestOrderProgram = $website->getConfig(
770
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER
771
+ );
772
+ $reviewsProgram = $website->getConfig(
773
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW
774
+ );
775
+ $wishlistProgram = $website->getConfig(
776
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST
777
+ );
778
+
779
+ //programs
780
+ $cusProgram = $this->_getWebisteProgram(
781
+ $customerProgram, $website
782
+ );
783
+ $subProgram = $this->_getWebisteProgram(
784
+ $subscriberProgram, $website
785
+ );
786
+ $orderProgram = $this->_getWebisteProgram(
787
+ $orderProgram, $website
788
+ );
789
+ $guestOrderProgram = $this->_getWebisteProgram(
790
+ $guestOrderProgram, $website
791
+ );
792
+ $reviewsProgram = $this->_getWebisteProgram(
793
+ $reviewsProgram, $website
794
+ );
795
+ $wishlistProgram = $this->_getWebisteProgram(
796
+ $wishlistProgram, $website
797
+ );
798
 
799
  //check for wishlist program
800
  if ($wishlistProgram) {
803
 
804
  //set the status as failed
805
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
806
+ ->setMessage(
807
+ ' Consider to disable not active programs'
808
+ );
809
 
810
+ $disableWishlist = Mage::helper('adminhtml')->getUrl(
811
+ '*/connector/enablewebsiteconfiguration', array(
812
  'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST',
813
  'value' => '0',
814
  'website' => $website->getId()
815
  )
816
  );
817
+ $disableWishlist = 'Deactivated! <a href="'
818
+ . $disableWishlist . '">click</a> to disable';
819
 
820
  } else {
821
 
830
 
831
  //set the status as failed
832
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
833
+ ->setMessage(
834
+ ' Consider to disable not active programs'
835
+ );
836
 
837
+ $disableOrder = Mage::helper('adminhtml')->getUrl(
838
+ '*/connector/enablewebsiteconfiguration', array(
839
  'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER',
840
  'value' => '0',
841
  'website' => $website->getId()
842
  )
843
  );
844
+ $disableOrder = 'Deactivated! <a href="' . $disableOrder
845
+ . '">click</a> to disable';
846
+
847
+ } else {
848
+
849
+ $disableOrder = $orderProgram->status;
850
+ }
851
+ }
852
+
853
+ //check for review program
854
+ if ($reviewsProgram) {
855
+
856
+ if ($reviewsProgram->status != 'Active') {
857
+
858
+ //set the status as failed
859
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
860
+ ->setMessage(
861
+ ' Consider to disable not active programs'
862
+ );
863
+
864
+ $disableReviews = Mage::helper('adminhtml')->getUrl(
865
+ '*/connector/enablewebsiteconfiguration', array(
866
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW',
867
+ 'value' => '0',
868
+ 'website' => $website->getId()
869
+ )
870
+ );
871
+ $disableReviews = 'Deactivated! <a href="' . $disableReviews
872
+ . '">click</a> to disable';
873
+
874
+ } else {
875
+
876
+ $disableReviews = $reviewsProgram->status;
877
+ }
878
+ }
879
+
880
+ //check for guest order program
881
+ if ($guestOrderProgram) {
882
+
883
+ if ($guestOrderProgram->status != 'Active') {
884
+
885
+ //set the status as failed
886
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
887
+ ->setMessage(
888
+ ' Consider to disable not active programs'
889
+ );
890
+
891
+ $disableGuestOrder = Mage::helper('adminhtml')->getUrl(
892
+ '*/connector/enablewebsiteconfiguration', array(
893
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER',
894
+ 'value' => '0',
895
+ 'website' => $website->getId()
896
+ )
897
+ );
898
+ $disableGuestOrder = 'Deactivated! <a href="'
899
+ . $disableGuestOrder . '">click</a> to disable';
900
+
901
+ } else {
902
+
903
+ $disableGuestOrder = $guestOrderProgram->status;
904
+ }
905
+ }
906
+
907
+ //check for customer program
908
+ if ($cusProgram) {
909
+
910
+ if ($cusProgram->status != 'Active') {
911
+
912
+ //set the status as failed
913
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
914
+ ->setMessage(
915
+ ' Consider to disable not active programs'
916
+ );
917
+
918
+ $disableCustomer = Mage::helper('adminhtml')->getUrl(
919
+ '*/connector/enablewebsiteconfiguration', array(
920
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER',
921
+ 'value' => '0',
922
+ 'website' => $website->getId()
923
+ )
924
+ );
925
+ $disableCustomer = 'Deactivated! <a href="'
926
+ . $disableCustomer . '">click</a> to disable';
927
+
928
+ } else {
929
+
930
+ $disableCustomer = $cusProgram->status;
931
+ }
932
+ }
933
+
934
+ //check for subscriber program
935
+ if ($subProgram) {
936
+
937
+ if ($subProgram->status != 'Active') {
938
+ // set the status failed
939
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
940
+ ->setMessage(
941
+ ' Consider to disable not active programs'
942
+ );
943
+
944
+ //link to disbale config
945
+ $disableSubscriber = Mage::helper('adminhtml')->getUrl(
946
+ '*/connector/enablewebsiteconfiguration', array(
947
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER',
948
+ 'value' => '0',
949
+ 'website' => $website->getId()
950
+ )
951
+ );
952
+ $disableSubscriber = 'Deactivated <a href="'
953
+ . $disableSubscriber . '">click</a> to disable';
954
+
955
+ } else {
956
+ $disableSubscriber = $subProgram->status;
957
+ }
958
+ }
959
+
960
+ $tableData = array(
961
+ 'Website' => $website->getName(),
962
+ 'Customer Program' => (isset($cusProgram->name))
963
+ ? $cusProgram->name : 'Disabled',
964
+ 'Customer Status' => (isset($cusProgram->status))
965
+ ? $disableCustomer : '',
966
+ 'Subscriber Program' => (isset($subProgram->name))
967
+ ? $subProgram->name : 'Disabled',
968
+ 'Subscriber Status' => (isset($subProgram->status))
969
+ ? $disableSubscriber : '',
970
+ 'Order Program' => (isset($orderProgram->name))
971
+ ? $orderProgram->name : 'Disabled',
972
+ 'Order Status' => (isset($orderProgram->status))
973
+ ? $disableOrder : '',
974
+ 'Guest Order Program' => (isset($guestOrderProgram->name))
975
+ ? $guestOrderProgram->name : 'Disabled',
976
+ 'Guest Order Status' => (isset($guestOrderProgram->status))
977
+ ? $disableGuestOrder : '',
978
+ 'Review Program' => (isset($reviewsProgram->name))
979
+ ? $reviewsProgram->name : 'Disabled',
980
+ 'Review Status' => (isset($reviewsProgram->status))
981
+ ? $disableReviews : '',
982
+ 'Wishlist Program' => (isset($wishlistProgram->name))
983
+ ? $wishlistProgram->name : 'Disabled',
984
+ 'Wishlist Status' => (isset($wishlistProgram->status))
985
+ ? $disableWishlist : '',
986
+ );
987
+
988
+ //set the content with table data
989
+ $resultContent->setTable($tableData);
990
+
991
+ }
992
+
993
+ return $resultContent;
994
+ }
995
+
996
+ /**
997
+ * Abandoned carts status.
998
+ *
999
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1000
+ */
1001
+ public function abandonedCartsEnabled()
1002
+ {
1003
+ $resultContent = Mage::getModel(
1004
+ 'ddg_automation/adminhtml_dashboard_content'
1005
+ );
1006
+
1007
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1008
+ ->setTitle('Abandoned Carts Status : ')
1009
+ ->setMessage('Looks Great.');
1010
+
1011
+ foreach (Mage::app()->getWebsites() as $website) {
1012
+ $websiteName = $website->getName();
1013
+ $abandonedCusomer1 = ($website->getConfig(
1014
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1
1015
+ ))
1016
+ ? true
1017
+ :
1018
+ 'Disabled!';
1019
+ $abandonedCusomer2 = ($website->getConfig(
1020
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2
1021
+ ))
1022
+ ? true
1023
+ :
1024
+ 'Disabled!';
1025
+ $abandonedCusomer3 = ($website->getConfig(
1026
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3
1027
+ ))
1028
+ ? true
1029
+ :
1030
+ 'Disabled!';
1031
+ $abandonedGuest1 = ($website->getConfig(
1032
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1
1033
+ ))
1034
+ ? true
1035
+ :
1036
+ 'Disabled!';
1037
+ $abandonedGuest2 = ($website->getConfig(
1038
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2
1039
+ ))
1040
+ ? true
1041
+ :
1042
+ 'Disabled!';
1043
+ $abandonedGuest3 = ($website->getConfig(
1044
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3
1045
+ ))
1046
+ ? true
1047
+ :
1048
+ 'Disabled!';
1049
+
1050
+ if ($abandonedCusomer1 !== true || $abandonedCusomer2 !== true
1051
+ || $abandonedCusomer3 !== true
1052
+ || $abandonedGuest1 !== true
1053
+ || $abandonedGuest2 !== true
1054
+ || $abandonedGuest3 !== true
1055
+ ) {
1056
+ //customer abandoned links to enable
1057
+ $customer1 = Mage::helper('adminhtml')->getUrl(
1058
+ '*/connector/enablewebsiteconfiguration',
1059
+ array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1',
1060
+ 'website' => $website->getId())
1061
+ );
1062
+ $customer2 = Mage::helper('adminhtml')->getUrl(
1063
+ '*/connector/enablewebsiteconfiguration',
1064
+ array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2',
1065
+ 'website' => $website->getId())
1066
+ );
1067
+ $customer3 = Mage::helper('adminhtml')->getUrl(
1068
+ '*/connector/enablewebsiteconfiguration',
1069
+ array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3',
1070
+ 'website' => $website->getId())
1071
+ );
1072
+ //guests abandoned links to enable
1073
+ $guest1 = Mage::helper('adminhtml')->getUrl(
1074
+ '*/connector/enablewebsiteconfiguration',
1075
+ array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1',
1076
+ 'website' => $website->getId())
1077
+ );
1078
+ $guest2 = Mage::helper('adminhtml')->getUrl(
1079
+ '*/connector/enablewebsiteconfiguration',
1080
+ array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2',
1081
+ 'website' => $website->getId())
1082
+ );
1083
+ $guest3 = Mage::helper('adminhtml')->getUrl(
1084
+ '*/connector/enablewebsiteconfiguration',
1085
+ array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3',
1086
+ 'website' => $website->getId())
1087
+ );
1088
+
1089
+
1090
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1091
+ ->setMessage('Don\'t forget to map')
1092
+ ->setTable(
1093
+ array(
1094
+ 'Website' => $websiteName,
1095
+ 'Customer Abandoned 1' => ($abandonedCusomer1
1096
+ !== true) ? $abandonedCusomer1 . ' <a href="'
1097
+ . $customer1 . '">enable</a>' : 'Enabled',
1098
+ 'Customer Abandoned 2' => ($abandonedCusomer2
1099
+ !== true) ? $abandonedCusomer2 . ' <a href="'
1100
+ . $customer2 . '">enable</a>' : 'Enabled',
1101
+ 'Customer Abandoned 3' => ($abandonedCusomer3
1102
+ !== true) ? $abandonedCusomer3 . ' <a href="'
1103
+ . $customer3 . '">enable</a>' : 'Enabled',
1104
+ 'Guest Abandoned 1' => ($abandonedGuest1
1105
+ !== true) ? $abandonedGuest1 . ' <a href="'
1106
+ . $guest1 . '">enable</a>' : 'Enabled',
1107
+ 'Guest Abandoned 2' => ($abandonedGuest2
1108
+ !== true) ? $abandonedGuest2 . ' <a href="'
1109
+ . $guest2 . '">enable</a>' : 'Enabled',
1110
+ 'Guest Abandoned 3' => ($abandonedGuest3
1111
+ !== true) ? $abandonedGuest3 . ' <a href="'
1112
+ . $guest3 . '">enable</a>' : 'Enabled',
1113
+ )
1114
+ );
1115
+ }
1116
+ }
1117
+
1118
+ return $resultContent;
1119
+ }
1120
+
1121
+ /**
1122
+ * Crazy mapping checking.
1123
+ *
1124
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1125
+ */
1126
+ public function dataFieldMapped()
1127
+ {
1128
+ $resultContent = Mage::getModel(
1129
+ 'ddg_automation/adminhtml_dashboard_content'
1130
+ );
1131
+
1132
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1133
+ ->setTitle('Default Datafields Mapped Status : ')
1134
+ ->setMessage('All Datafields Are Mapped.');
1135
+
1136
+ foreach (Mage::app()->getWebsites() as $website) {
1137
+ $passed = true;
1138
+ $mapped = 0;
1139
+ $tableData = array();
1140
+ //website name for table data
1141
+ $websiteName = $website->getName();
1142
+ $tableData['Website'] = $websiteName;
1143
+ if ( ! $website->getConfig(
1144
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID
1145
+ )
1146
+ ) {
1147
+ $passed = false;
1148
+ $mapped++;
1149
+ }
1150
+ if ( ! $website->getConfig(
1151
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME
1152
+ )
1153
+ ) {
1154
+ $passed = false;
1155
+ $mapped++;
1156
+ }
1157
+ if ( ! $website->getConfig(
1158
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LASTNAME
1159
+ )
1160
+ ) {
1161
+ $passed = false;
1162
+ $mapped++;
1163
+ }
1164
+ if ( ! $website->getConfig(
1165
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DOB
1166
+ )
1167
+ ) {
1168
+ $passed = false;
1169
+ $mapped++;
1170
+ }
1171
+ if ( ! $website->getConfig(
1172
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_GENDER
1173
+ )
1174
+ ) {
1175
+ $passed = false;
1176
+ $mapped++;
1177
+ }
1178
+ if ( ! $website->getConfig(
1179
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
1180
+ )
1181
+ ) {
1182
+ $passed = false;
1183
+ $mapped++;
1184
+ }
1185
+ if ( ! $website->getConfig(
1186
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
1187
+ )
1188
+ ) {
1189
+ $passed = false;
1190
+ $mapped++;
1191
+ }
1192
+ if ( ! $website->getConfig(
1193
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT
1194
+ )
1195
+ ) {
1196
+ $passed = false;
1197
+ $mapped++;
1198
+ }
1199
+ if ( ! $website->getConfig(
1200
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE
1201
+ )
1202
+ ) {
1203
+ $passed = false;
1204
+ $mapped++;
1205
+ }
1206
+ if ( ! $website->getConfig(
1207
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP
1208
+ )
1209
+ ) {
1210
+ $passed = false;
1211
+ $mapped++;
1212
+ }
1213
+ if ( ! $website->getConfig(
1214
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT
1215
+ )
1216
+ ) {
1217
+ $passed = false;
1218
+ $mapped++;
1219
+ }
1220
+ if ( ! $website->getConfig(
1221
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE
1222
+ )
1223
+ ) {
1224
+ $passed = false;
1225
+ $mapped++;
1226
+ }
1227
+ if ( ! $website->getConfig(
1228
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1
1229
+ )
1230
+ ) {
1231
+ $passed = false;
1232
+ $mapped++;
1233
+ }
1234
+ if ( ! $website->getConfig(
1235
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2
1236
+ )
1237
+ ) {
1238
+ $passed = false;
1239
+ $mapped++;
1240
+ }
1241
+ if ( ! $website->getConfig(
1242
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY
1243
+ )
1244
+ ) {
1245
+ $passed = false;
1246
+ $mapped++;
1247
+ }
1248
+ if ( ! $website->getConfig(
1249
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE
1250
+ )
1251
+ ) {
1252
+ $passed = false;
1253
+ $mapped++;
1254
+ }
1255
+ if ( ! $website->getConfig(
1256
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY
1257
+ )
1258
+ ) {
1259
+ $passed = false;
1260
+ $mapped++;
1261
+ }
1262
+ if ( ! $website->getConfig(
1263
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE
1264
+ )
1265
+ ) {
1266
+ $passed = false;
1267
+ $mapped++;
1268
+ }
1269
+ if ( ! $website->getConfig(
1270
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE
1271
+ )
1272
+ ) {
1273
+ $passed = false;
1274
+ $mapped++;
1275
+ }
1276
+ if ( ! $website->getConfig(
1277
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1
1278
+ )
1279
+ ) {
1280
+ $passed = false;
1281
+ $mapped++;
1282
+ }
1283
+ if ( ! $website->getConfig(
1284
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2
1285
+ )
1286
+ ) {
1287
+ $passed = false;
1288
+ $mapped++;
1289
+ }
1290
+ if ( ! $website->getConfig(
1291
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY
1292
+ )
1293
+ ) {
1294
+ $passed = false;
1295
+ $mapped++;
1296
+ }
1297
+ if ( ! $website->getConfig(
1298
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE
1299
+ )
1300
+ ) {
1301
+ $passed = false;
1302
+ $mapped++;
1303
+ }
1304
+ if ( ! $website->getConfig(
1305
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY
1306
+ )
1307
+ ) {
1308
+ $passed = false;
1309
+ $mapped++;
1310
+ }
1311
+ if ( ! $website->getConfig(
1312
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE
1313
+ )
1314
+ ) {
1315
+ $passed = false;
1316
+ $mapped++;
1317
+ }
1318
+ if ( ! $website->getConfig(
1319
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE
1320
+ )
1321
+ ) {
1322
+ $passed = false;
1323
+ $mapped++;
1324
+ }
1325
+ if ( ! $website->getConfig(
1326
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER
1327
+ )
1328
+ ) {
1329
+ $passed = false;
1330
+ $mapped++;
1331
+ }
1332
+ if ( ! $website->getConfig(
1333
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_AOV
1334
+ )
1335
+ ) {
1336
+ $passed = false;
1337
+ $mapped++;
1338
+ }
1339
+ if ( ! $website->getConfig(
1340
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND
1341
+ )
1342
+ ) {
1343
+ $passed = false;
1344
+ $mapped++;
1345
+ }
1346
+ if ( ! $website->getConfig(
1347
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE
1348
+ )
1349
+ ) {
1350
+ $passed = false;
1351
+ $mapped++;
1352
+ }
1353
+ if ( ! $website->getConfig(
1354
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID
1355
+ )
1356
+ ) {
1357
+ $passed = false;
1358
+ $mapped++;
1359
+ }
1360
+ if ( ! $website->getConfig(
1361
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND
1362
+ )
1363
+ ) {
1364
+ $passed = false;
1365
+ $mapped++;
1366
+ }
1367
+ if ( ! $website->getConfig(
1368
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS
1369
+ )
1370
+ ) {
1371
+ $passed = false;
1372
+ $mapped++;
1373
+ }
1374
+ $tableData['Mapped Percentage'] = number_format(
1375
+ (1 - $mapped / 32) * 100, 2
1376
+ ) . ' %';
1377
+ //mapping not complete.
1378
+ if ( ! $passed) {
1379
+ $url = Mage::helper('adminhtml')->getUrl(
1380
+ '*/system_config/edit/section/connector_data_mapping/website/'
1381
+ . $website->getCode()
1382
+ );
1383
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1384
+ ->setMessage(
1385
+ 'Click <a href="' . $url
1386
+ . '">here</a> to change mapping configuration.'
1387
+ );
1388
+ }
1389
+ $resultContent->setTable($tableData);
1390
+ }
1391
 
1392
+ return $resultContent;
1393
+ }
1394
 
 
 
 
1395
 
1396
+ /**
1397
+ * Validate API Credentials.
1398
+ *
1399
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1400
+ */
1401
+ public function validApiCredentials()
1402
+ {
1403
+ $resultContent = Mage::getModel(
1404
+ 'ddg_automation/adminhtml_dashboard_content'
1405
+ );
1406
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1407
+ ->setTitle('API Credentials Status : ')
1408
+ ->setMessage('Valid.');
1409
+ $helper = Mage::helper('ddg');
1410
+ foreach (Mage::app()->getWebsites() as $website) {
1411
+ $websiteName = $website->getName();
1412
+ $websiteId = $website->getId();
1413
 
1414
+ $apiUsername = $helper->getApiUsername($websiteId);
1415
+ $apiPassword = $helper->getApiPassword($websiteId);
1416
 
1417
+ $api = Mage::getModel('ddg_automation/apiconnector_test')
1418
+ ->ajaxvalidate($apiUsername, $apiPassword);
 
1419
 
1420
+ if ($api != 'Credentials Valid.') {
1421
+ $url = Mage::helper('adminhtml')->getUrl(
1422
+ '*/system_config/edit/section/connector_api_credentials/website/'
1423
+ . $website->getCode()
1424
+ );
1425
+
1426
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1427
+ ->setMessage('')
1428
+ ->setTable(
1429
+ array(
1430
+ 'Website' => $websiteName,
1431
+ 'Status' => $api,
1432
+ 'Fast Fix' => 'Click <a href="' . $url
1433
+ . '">here</a> to enter new api credentials.'
1434
  )
1435
  );
 
 
 
 
 
 
1436
  }
1437
+ }
1438
 
1439
+ return $resultContent;
1440
+ }
1441
 
1442
+ /**
1443
+ * Order sync enabled.
1444
+ *
1445
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1446
+ */
1447
+ public function orderEnabled()
1448
+ {
1449
+ $resultContent = Mage::getModel(
1450
+ 'ddg_automation/adminhtml_dashboard_content'
1451
+ );
1452
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1453
+ ->setTitle('Order Sync : ')
1454
+ ->setMessage('Enabled.');
1455
 
1456
+ $passed = true;
1457
+ foreach (Mage::app()->getWebsites() as $website) {
1458
+ $websiteName = $website->getName();
1459
+ $order = ($website->getConfig(
1460
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED
1461
+ ))
1462
+ ? true
1463
+ :
1464
+ 'Disabled!';
1465
 
1466
+ if ($order !== true) {
1467
+
1468
+ $url = Mage::helper('adminhtml')->getUrl(
1469
+ '*/connector/enablewebsiteconfiguration',
1470
+ array('path' => 'XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED',
1471
+ 'website' => $website->getId())
1472
+ );
1473
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1474
+ ->setMessage('')
1475
+ ->setTable(
1476
+ array(
1477
+ 'Website' => $websiteName,
1478
+ 'Status' => $order . ' <a href="' . $url
1479
+ . '">enable</a>'
1480
  )
1481
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1482
  $passed = false;
 
1483
  }
1484
+ }
1485
+ //validation failed
1486
+ if ( ! $passed) {
1487
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
1488
+ }
1489
+
1490
+ return $resultContent;
1491
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1492
 
1493
  /**
1494
  * check if any custom order attribute selected
1495
+ *
1496
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1497
  */
1498
  public function customOrderAttributes()
1499
  {
1500
+ $resultContent = Mage::getModel(
1501
+ 'ddg_automation/adminhtml_dashboard_content'
1502
+ );
1503
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1504
  ->setTitle('Custom Order Attributes : ')
1505
  ->setMessage('Selected.');
1506
 
1507
+ foreach (Mage::app()->getWebsites() as $website) {
1508
+ $websiteName = $website->getName();
1509
+ $customOrderAttibute = ($website->getConfig(
1510
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES
1511
+ )) ? true : false;
1512
 
1513
+ if ($customOrderAttibute !== true) {
1514
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1515
+ ->setTitle(
1516
+ 'Custom order attribute not selected (ignore if you do not want to import custom order attributes) :'
1517
+ )
1518
  ->setMessage('')
1519
+ ->setTable(
1520
+ array(
1521
+ 'Website' => $websiteName,
1522
+ 'Status' => 'No Custom Order Attribute Selected'
1523
+ )
1524
+ );
1525
  }
1526
  }
1527
 
1528
  return $resultContent;
1529
  }
1530
 
1531
+ /**
1532
+ * Check if any orders are imported.
1533
+ *
1534
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1535
+ */
1536
+ public function orderSyncing()
1537
+ {
1538
+ $resultContent = Mage::getModel(
1539
+ 'ddg_automation/adminhtml_dashboard_content'
1540
+ );
1541
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1542
+ ->setTitle('Order Syncing : ')
1543
+ ->setMessage('Looks Great.');
1544
+
1545
+ foreach (Mage::app()->getWebsites() as $website) {
1546
+ $websiteName = $website->getName();
1547
+ $storeIds = $website->getStoreIds();
1548
+
1549
+ if (empty($storeIds)) {
1550
+ continue;
1551
+ }
1552
+
1553
+ //numbser of orders marked as imported
1554
+ $numOrders = Mage::getModel('ddg_automation/order')->getCollection()
1555
+ ->addFieldToFilter('email_imported', 1)
1556
+ ->addFieldToFilter('store_id', array('in', $storeIds))->getSize(
1557
+ );
1558
+
1559
+ if ( ! $numOrders) {
1560
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1561
+ ->setTitle(
1562
+ 'Order Syncing (ignore if you have reset orders for reimport) :'
1563
+ )
1564
+ ->setMessage('')
1565
+ ->setTable(
1566
+ array(
1567
+ 'Website' => $websiteName,
1568
+ 'Status' => 'No Imported Orders Found'
1569
+ )
1570
+ );
1571
+ }
1572
+ }
1573
+
1574
+ return $resultContent;
1575
+
1576
+ }
1577
 
1578
  /**
1579
  * Quote sync enabled.
1580
+ *
1581
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1582
  */
1583
  public function quoteEnabled()
1584
  {
1585
+ $resultContent = Mage::getModel(
1586
+ 'ddg_automation/adminhtml_dashboard_content'
1587
+ );
1588
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1589
  ->setTitle('Quote Sync : ')
1590
  ->setMessage('Enabled.');
1591
 
1592
  $passed = true;
1593
+ foreach (Mage::app()->getWebsites() as $website) {
1594
+ $websiteName = $website->getName();
1595
+ $quote = ($website->getConfig(
1596
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_QUOTE_ENABLED
1597
+ ))
1598
+ ? true
1599
+ :
1600
  'Disabled!';
1601
 
1602
+ if ($quote !== true) {
1603
 
1604
+ $url = Mage::helper('adminhtml')->getUrl(
1605
+ '*/connector/enablewebsiteconfiguration',
1606
+ array('path' => 'XML_PATH_CONNECTOR_SYNC_QUOTE_ENABLED',
1607
+ 'website' => $website->getId())
1608
+ );
1609
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1610
  ->setMessage('')
1611
+ ->setTable(
1612
+ array(
1613
+ 'Website' => $websiteName,
1614
+ 'Status' => $quote . ' <a href="' . $url
1615
+ . '">enable</a>'
1616
+ )
1617
+ );
1618
  $passed = false;
1619
  }
1620
  }
1621
  //validation failed
1622
+ if ( ! $passed) {
1623
  $resultContent->setHowto(self::FAST_FIX_MESSAGE);
1624
  }
1625
 
1628
 
1629
  /**
1630
  * check if any custom quote attribute selected
1631
+ *
1632
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1633
  */
1634
  public function customQuoteAttributes()
1635
  {
1636
+ $resultContent = Mage::getModel(
1637
+ 'ddg_automation/adminhtml_dashboard_content'
1638
+ );
1639
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1640
  ->setTitle('Custom Quote Attributes : ')
1641
  ->setMessage('Selected.');
1642
 
1643
+ foreach (Mage::app()->getWebsites() as $website) {
1644
+ $websiteName = $website->getName();
1645
+ $customQuoteAttribute = ($website->getConfig(
1646
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_QUOTE_ATTRIBUTES
1647
+ )) ? true : false;
1648
 
1649
+ if ($customQuoteAttribute !== true) {
1650
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1651
+ ->setTitle(
1652
+ 'Custom quote attribute not selected (ignore if you do not want to import custom quote attributes) :'
1653
+ )
1654
  ->setMessage('')
1655
+ ->setTable(
1656
+ array(
1657
+ 'Website' => $websiteName,
1658
+ 'Status' => 'No Custom Quote Attribute Selected'
1659
+ )
1660
+ );
1661
  }
1662
  }
1663
 
1666
 
1667
  /**
1668
  * Check if any quote are imported.
1669
+ *
1670
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1671
  */
1672
  public function quoteSyncing()
1673
  {
1674
+ $resultContent = Mage::getModel(
1675
+ 'ddg_automation/adminhtml_dashboard_content'
1676
+ );
1677
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1678
  ->setTitle('Quote Syncing : ')
1679
  ->setMessage('Looks Great.');
1680
 
1681
+ foreach (Mage::app()->getWebsites() as $website) {
1682
+ $websiteName = $website->getName();
1683
+ $storeIds = $website->getStoreIds();
1684
 
1685
+ if (empty($storeIds)) {
1686
+ continue;
1687
+ }
1688
 
1689
  //number of quote marked as imported
1690
  $numQuotes = Mage::getModel('ddg_automation/quote')->getCollection()
1691
  ->addFieldToFilter('imported', 1)
1692
+ ->addFieldToFilter('store_id', array('in', $storeIds))->getSize(
1693
+ );
1694
 
1695
+ if ( ! $numQuotes) {
1696
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1697
+ ->setTitle(
1698
+ 'Quote Syncing (ignore if you have reset quote for re-import) :'
1699
+ )
1700
  ->setMessage('')
1701
+ ->setTable(
1702
+ array(
1703
+ 'Website' => $websiteName,
1704
+ 'Status' => 'No Imported Quotes Found'
1705
+ )
1706
+ );
1707
  }
1708
  }
1709
 
1713
 
1714
  /**
1715
  * review sync enabled.
1716
+ *
1717
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1718
  * Display the transactional data for orders to be removed.
1719
  */
1720
  public function reviewEnabled()
1721
  {
1722
+ $resultContent = Mage::getModel(
1723
+ 'ddg_automation/adminhtml_dashboard_content'
1724
+ );
1725
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1726
  ->setTitle('Review Sync : ')
1727
  ->setMessage('Enabled.');
1728
 
1729
+ foreach (Mage::app()->getWebsites() as $website) {
1730
+ $websiteName = $website->getName();
1731
+ $review = ($website->getConfig(
1732
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED
1733
+ ))
1734
+ ? true
1735
+ :
1736
  'Disabled';
1737
 
1738
+ if ($review !== true) {
1739
+ $url = Mage::helper('adminhtml')->getUrl(
1740
+ '*/connector/enablewebsiteconfiguration',
1741
+ array('path' => 'XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED',
1742
+ 'website' => $website->getId())
1743
+ );
1744
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1745
+ ->setMessage(
1746
+ 'Don\'t forget to enable if you want to sync reviews.'
1747
+ )
1748
+ ->setTable(
1749
+ array(
1750
+ 'Website' => $websiteName,
1751
+ 'Status' => $review,
1752
+ 'Fast Fix' => 'Click <a href="' . $url
1753
+ . '">here </a>to enable.'
1754
+ )
1755
+ );
1756
  }
1757
  }
1758
+
1759
  return $resultContent;
1760
  }
1761
 
1762
  /**
1763
  * Check if any reviews are imported.
1764
+ *
1765
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1766
  */
1767
  public function reviewSyncing()
1768
  {
1769
+ $resultContent = Mage::getModel(
1770
+ 'ddg_automation/adminhtml_dashboard_content'
1771
+ );
1772
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1773
  ->setTitle('Review Syncing : ')
1774
  ->setMessage('Looks Great.');
1775
 
1776
+ foreach (Mage::app()->getWebsites() as $website) {
1777
+ $websiteName = $website->getName();
1778
+ $storeIds = $website->getStoreIds();
1779
 
1780
+ if (empty($storeIds)) {
1781
+ continue;
1782
+ }
1783
 
1784
  //number of reviews marked as imported
1785
+ $numReview = Mage::getModel('ddg_automation/review')->getCollection(
1786
+ )
1787
  ->addFieldToFilter('review_imported', 1)
1788
  ->addFieldToFilter('store_id', array('in', $storeIds))
1789
  ->getSize();
1790
 
1791
  //total reviews
1792
+ $totalReview = Mage::getModel('ddg_automation/review')
1793
+ ->getCollection()
1794
  ->addFieldToFilter('store_id', array('in', $storeIds))
1795
  ->getSize();
1796
 
1797
  $tableData = array(
1798
+ 'Website' => $websiteName,
1799
  'Total Reviews' => $totalReview,
1800
+ 'Imported' => $numReview
1801
  );
1802
 
1803
  $tableData['Status'] = 'Importing';
1804
 
1805
+ if ( ! $numReview) {
1806
  $tableData['Status'] = 'No Imported Review Found.';
1807
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1808
+ ->setTitle(
1809
+ 'Review Sync (ignore if you have reset wishlist) : '
1810
+ )
1811
  ->setMessage('');
1812
  }
1813
  $resultContent->setTable($tableData);
1814
  }
1815
+
1816
+ return $resultContent;
1817
+ }
1818
+
1819
+ /**
1820
+ * Get the last date for abandaned carts.
1821
+ *
1822
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1823
+ */
1824
+ public function lastAbandonedCartSentDay()
1825
+ {
1826
+ $resultContent = Mage::getModel(
1827
+ 'ddg_automation/adminhtml_dashboard_content'
1828
+ );
1829
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1830
+ ->setTitle('Last Abandoned Summary : ');
1831
+
1832
+ foreach (Mage::app()->getWebsites() as $website) {
1833
+
1834
+ $websiteName = $website->getName();
1835
+ $client = Mage::helper('ddg')->getWebsiteApiClient($website);
1836
+
1837
+ //customer carts
1838
+ $customerCampaign1 = $website->getConfig(
1839
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_1
1840
+ );
1841
+ $customerCampaign2 = $website->getConfig(
1842
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_2
1843
+ );
1844
+ $customerCampaign3 = $website->getConfig(
1845
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_3
1846
+ );
1847
+
1848
+ //guests carts
1849
+ $guestCampaign1 = $website->getConfig(
1850
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_1
1851
+ );
1852
+ $guestCampaign2 = $website->getConfig(
1853
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_2
1854
+ );
1855
+ $guestCampaign3 = $website->getConfig(
1856
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_3
1857
+ );
1858
+
1859
+
1860
+ //date customer carts
1861
+
1862
+ $cusDateSent1 = ($customerCampaign1) ? $client->getCampaignSummary(
1863
+ $customerCampaign1
1864
+ ) : '';
1865
+ $cusDateSent2 = ($customerCampaign2) ? $client->getCampaignSummary(
1866
+ $customerCampaign2
1867
+ ) : '';
1868
+ $cusDateSent3 = ($customerCampaign3) ? $client->getCampaignSummary(
1869
+ $customerCampaign3
1870
+ ) : '';
1871
+
1872
+ //date guest carts
1873
+ $resGuest1 = ($guestCampaign1) ? $client->getCampaignSummary(
1874
+ $guestCampaign1
1875
+ ) : '';
1876
+ $resGuest2 = ($guestCampaign2) ? $client->getCampaignSummary(
1877
+ $guestCampaign2
1878
+ ) : '';
1879
+ $resGuest3 = ($guestCampaign3) ? $client->getCampaignSummary(
1880
+ $guestCampaign3
1881
+ ) : '';
1882
+
1883
+ /**
1884
+ * Customers.
1885
+ */
1886
+ $customerCampaign1 = (isset($cusDateSent1->dateSent)
1887
+ ? $cusDateSent1->dateSent : 'Not Sent/Selected');
1888
+ $customerCampaign2 = (isset($cusDateSent2->dateSent)
1889
+ ? $cusDateSent2->dateSent : 'Not Sent/Selected');
1890
+ $customerCampaign3 = (isset($cusDateSent3->dateSent)
1891
+ ? $cusDateSent3->dateSent : 'Not Sent/Selected');
1892
+
1893
+ /**
1894
+ * Guests.
1895
+ */
1896
+ $guestCampaign1 = (isset($resGuest1->dateSent)
1897
+ ? $resGuest1->dateSent : 'Not Sent/Selected');
1898
+ $guestCampaign2 = (isset($resGuest2->dateSent)
1899
+ ? $resGuest2->dateSent : 'Not Sent/Selected');
1900
+ $guestCampaign3 = (isset($resGuest3->dateSent)
1901
+ ? $resGuest3->dateSent : 'Not Sent/Selected');
1902
+
1903
+
1904
+ $resultContent->setTable(
1905
+ array(
1906
+ 'Website' => $websiteName,
1907
+ 'Customer Campaign 1' => $customerCampaign1,
1908
+ 'Customer Campaign 2' => $customerCampaign2,
1909
+ 'Customer Campaign 3' => $customerCampaign3,
1910
+ 'Guest Campaign 1' => $guestCampaign1,
1911
+ 'Guest Campaign 2' => $guestCampaign2,
1912
+ 'Guest Campaign 3' => $guestCampaign3
1913
+ )
1914
+ );
1915
+ }
1916
+
1917
+ return $resultContent;
1918
+ }
1919
+
1920
+ /**
1921
+ * Conflict checker.
1922
+ *
1923
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1924
+ */
1925
+ public function conflictCheck()
1926
+ {
1927
+ $resultContent = Mage::getModel(
1928
+ 'ddg_automation/adminhtml_dashboard_content'
1929
+ );
1930
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1931
+ ->setTitle('Conflict Status : ')
1932
+ ->setMessage('Looks Great.');
1933
+
1934
+ //check the module override and conflict
1935
+ $rewrites = Mage::helper('ddg/dashboard')->getRewrites();
1936
+
1937
+
1938
+ if ($rewrites === false) {
1939
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1940
+ ->setMessage('No Conflict Rewrites Found.');
1941
+ } else {
1942
+
1943
+ $types = array('blocks', 'models', 'helpers');
1944
+ foreach ($types as $t) {
1945
+
1946
+ if ( ! empty($rewrites[$t])) {
1947
+
1948
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1949
+ ->setMessage('Conflicting Rewrite Found : ');
1950
+
1951
+ foreach ($rewrites[$t] as $node => $rewriteInfo) {
1952
+
1953
+ $resultContent->setTable(
1954
+ array(
1955
+ 'Type' => $t,
1956
+ 'Class' => implode(
1957
+ ', ', array_values($rewriteInfo['classes'])
1958
+ ),
1959
+ 'Rewrites' => '',
1960
+ 'Loaded Class' => ''
1961
+ )
1962
+ );
1963
+ }
1964
+ }
1965
+ }
1966
+
1967
+ $conflictCounter = 0;
1968
+ $tableData = array();
1969
+ foreach ($rewrites as $type => $data) {
1970
+ if (count($data) > 0 && is_array($data)) {
1971
+
1972
+ foreach ($data as $class => $rewriteClass) {
1973
+
1974
+ if (count($rewriteClass) > 1) {
1975
+ if ($this->_isInheritanceConflict($rewriteClass)) {
1976
+
1977
+ $resultContent->setTable(
1978
+ array(
1979
+ 'Type' => $type,
1980
+ 'Class' => $class,
1981
+ 'Rewrites' => implode(
1982
+ ', ', $rewriteClass['classes']
1983
+ ),
1984
+ 'Loaded Class' => $this->_getLoadedClass(
1985
+ $type, $class
1986
+ ),
1987
+ )
1988
+ );
1989
+
1990
+ $conflictCounter++;
1991
+ }
1992
+ }
1993
+ }
1994
+ }
1995
+ }
1996
+ if ( ! empty($tableData)) {
1997
+ $resultContent->setTable($tableData);
1998
+ }
1999
+
2000
+ }
2001
+
2002
+ return $resultContent;
2003
+ }
2004
+
2005
+ /**
2006
+ * Returns loaded class by type like models or blocks
2007
+ *
2008
+ * @param string $type
2009
+ * @param string $class
2010
+ *
2011
+ * @return string
2012
+ */
2013
+ protected function _getLoadedClass($type, $class)
2014
+ {
2015
+ switch ($type) {
2016
+ case 'blocks':
2017
+ return Mage::getConfig()->getBlockClassName($class);
2018
+
2019
+ case 'helpers':
2020
+ return Mage::getConfig()->getHelperClassName($class);
2021
+
2022
+ default:
2023
+ case 'models':
2024
+ return Mage::getConfig()->getModelClassName($class);
2025
+ }
2026
+ }
2027
+
2028
+ /**
2029
+ * Check if rewritten class has inherited the parent class.
2030
+ * If yes we have no conflict. The top class can extend every core class.
2031
+ * So we cannot check this.
2032
+ *
2033
+ * @var array $classes
2034
+ * @return bool
2035
+ */
2036
+ protected function _isInheritanceConflict($classes)
2037
+ {
2038
+ $classes = array_reverse($classes);
2039
+ $numClases = count($classes);
2040
+
2041
+ for ($i = 0; $i < $numClases - 1; $i++) {
2042
+ try {
2043
+ if (class_exists($classes[$i])
2044
+ && class_exists($classes[$i + 1])
2045
+ ) {
2046
+ if ( ! is_a($classes[$i], $classes[$i + 1], true)) {
2047
+ return true;
2048
+ }
2049
+ }
2050
+ } catch (\Exception $e) {
2051
+ return true;
2052
+ }
2053
+ }
2054
+
2055
+ return false;
2056
+ }
2057
+
2058
+ /**
2059
+ * System information about the version used and the memory limits.
2060
+ *
2061
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
2062
+ */
2063
+ public function systemInformation()
2064
+ {
2065
+ $resultContent = Mage::getModel(
2066
+ 'ddg_automation/adminhtml_dashboard_content'
2067
+ );
2068
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED);
2069
+
2070
+ //compatibility with the old versions
2071
+ if (version_compare(Mage::getVersion(), '1.6.2.0', '>')) {
2072
+ $version = 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion(
2073
+ ) . 'V';
2074
+ } else {
2075
+ $version = 'Magento version : ' . Mage::getVersion() . 'V';
2076
+ }
2077
+
2078
+ $fh = fopen('/proc/meminfo', 'r');
2079
+ $mem = 0;
2080
+ if ($fh) {
2081
+ while ($line = fgets($fh)) {
2082
+ $pieces = array();
2083
+ if (preg_match('^MemTotal:\s+(\d+)\skB$^', $line, $pieces)) {
2084
+ $mem = $pieces[1];
2085
+ break;
2086
+ }
2087
+ }
2088
+ fclose($fh);
2089
+ }
2090
+ if ($mem > 0) {
2091
+ $mem = $mem / 1024 . 'M';
2092
+ } else {
2093
+ $mem = 'Not available';
2094
+ }
2095
+
2096
+ //check for php version
2097
+ $resultContent->setHowTo('PHP version : V' . PHP_VERSION)
2098
+ ->setHowto('PHP Memory : ' . $mem)
2099
+ ->setHowto(
2100
+ 'PHP Max Execution Time : ' . ini_get('max_execution_time')
2101
+ . ' sec'
2102
+ )
2103
+ ->setHowto($version)
2104
+ ->setHowto(
2105
+ 'Connector version : V' . Mage::helper('ddg')
2106
+ ->getConnectorVersion()
2107
+ );
2108
+
2109
  return $resultContent;
2110
  }
2111
 
2112
+
2113
+ /**
2114
+ * Check if the mapped program is active.
2115
+ */
2116
+ protected function _getWebisteProgram($program, $website)
2117
+ {
2118
+
2119
+ $client = Mage::helper('ddg')->getWebsiteApiClient($website);
2120
+
2121
+ if ( ! $client || ! $program) {
2122
+ return false;
2123
+ }
2124
+
2125
+ $data = $client->getProgramById($program);
2126
+
2127
+ if (isset($data->message)) {
2128
+ return false;
2129
+ }
2130
+
2131
+
2132
+ return $data;
2133
+ }
2134
+
2135
+ /**
2136
+ * Get the contacts address book.
2137
+ *
2138
+ * @param $addressBook
2139
+ * @param $webiste
2140
+ *
2141
+ * @return bool|null
2142
+ */
2143
+ protected function _getAddressBookContacts($addressBook, $webiste)
2144
+ {
2145
+ $client = Mage::helper('ddg')->getWebsiteApiClient($webiste);
2146
+
2147
+ if ( ! $client && $addressBook) {
2148
+ return false;
2149
+ }
2150
+
2151
+ $response = $client->getAddressBookById($addressBook);
2152
+
2153
+ if (isset($response->message)) {
2154
+ return false;
2155
+ }
2156
+
2157
+ return $response;
2158
+ }
2159
+
2160
+ /**
2161
+ * Get the method name
2162
+ *
2163
+ * @param $name
2164
+ *
2165
+ * @return string
2166
+ */
2167
+ public function getFormatedMethodName($name)
2168
+ {
2169
+ //version that not support the lcfirst method
2170
+ if (function_exists('lcfirst') === false) {
2171
+
2172
+ $method = strtolower(substr(uc_words($name, ''), 0, 1)) . substr(
2173
+ uc_words($name, ''), 1
2174
+ );
2175
+
2176
+ } else {
2177
+ $method = lcfirst(uc_words($name, ''));
2178
+ }
2179
+
2180
+ return $method;
2181
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2182
 
2183
  /**
2184
  * easy email capture enabled
2185
+ *
2186
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
2187
  */
2188
  public function easyEmailCaptureEnabled()
2189
  {
2190
+ $resultContent = Mage::getModel(
2191
+ 'ddg_automation/adminhtml_dashboard_content'
2192
+ );
2193
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
2194
  ->setTitle('Easy Email Capture : ')
2195
  ->setMessage('Enabled.');
2196
 
2197
+ foreach (Mage::app()->getWebsites() as $website) {
2198
+ $websiteName = $website->getName();
2199
+ $enabled = ($website->getConfig(
2200
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE
2201
+ ))
2202
+ ? true
2203
+ :
2204
  'Disabled';
2205
 
2206
+ if ($enabled !== true) {
2207
+ $url = Mage::helper('adminhtml')->getUrl(
2208
+ '*/connector/enablewebsiteconfiguration',
2209
+ array('path' => 'XML_PATH_CONNECTOR_EMAIL_CAPTURE',
2210
+ 'website' => $website->getId())
2211
+ );
2212
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
2213
+ ->setMessage(
2214
+ 'Don\'t forget to enable if you want to enable easy email capture.'
2215
+ )
2216
+ ->setTable(
2217
+ array(
2218
+ 'Website' => $websiteName,
2219
+ 'Status' => $enabled,
2220
+ 'Fast Fix' => 'Click <a href="' . $url
2221
+ . '">here </a>to enable.'
2222
+ )
2223
+ );
2224
  }
2225
  }
2226
+
2227
  return $resultContent;
2228
  }
2229
 
2230
  /**
2231
  * disabled newsletter success enabled
2232
+ *
2233
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
2234
  */
2235
  public function disableNewsletterSuccessEnabled()
2236
  {
2237
+ $resultContent = Mage::getModel(
2238
+ 'ddg_automation/adminhtml_dashboard_content'
2239
+ );
2240
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
2241
  ->setTitle('Disable Newsletter Success : ')
2242
  ->setMessage('Enabled.');
2243
 
2244
+ foreach (Mage::app()->getWebsites() as $website) {
2245
+ $websiteName = $website->getName();
2246
+ $enabled = ($website->getConfig(
2247
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS
2248
+ ))
2249
+ ? true
2250
+ :
2251
  'Disabled';
2252
 
2253
+ if ($enabled !== true) {
2254
+ $url = Mage::helper('adminhtml')->getUrl(
2255
+ '*/connector/enablewebsiteconfiguration',
2256
+ array('path' => 'XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS',
2257
+ 'website' => $website->getId())
2258
+ );
2259
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
2260
+ ->setMessage(
2261
+ 'Don\'t forget to enable if you want to disable Magento newsletter success email.'
2262
+ )
2263
+ ->setTable(
2264
+ array(
2265
+ 'Website' => $websiteName,
2266
+ 'Status' => $enabled,
2267
+ 'Fast Fix' => 'Click <a href="' . $url
2268
+ . '">here </a>to enable.'
2269
+ )
2270
+ );
2271
  }
2272
  }
2273
+
2274
  return $resultContent;
2275
  }
2276
 
2277
  /**
2278
  * wishlist sync enabled.
2279
+ *
2280
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
2281
  */
2282
  public function wishlistEnabled()
2283
  {
2284
+ $resultContent = Mage::getModel(
2285
+ 'ddg_automation/adminhtml_dashboard_content'
2286
+ );
2287
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
2288
  ->setTitle('Wishlist Sync : ')
2289
  ->setMessage('Enabled.');
2290
 
2291
+ foreach (Mage::app()->getWebsites() as $website) {
2292
+ $websiteName = $website->getName();
2293
+ $wishlist = ($website->getConfig(
2294
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED
2295
+ ))
2296
+ ? true
2297
+ :
2298
  'Disabled';
2299
 
2300
+ if ($wishlist !== true) {
2301
+ $url = Mage::helper('adminhtml')->getUrl(
2302
+ '*/connector/enablewebsiteconfiguration',
2303
+ array('path' => 'XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED',
2304
+ 'website' => $website->getId())
2305
+ );
2306
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
2307
+ ->setMessage(
2308
+ 'Don\'t forget to enable if you want to sync wishlist.'
2309
+ )
2310
+ ->setTable(
2311
+ array(
2312
+ 'Website' => $websiteName,
2313
+ 'Status' => $wishlist,
2314
+ 'Fast Fix' => 'Click <a href="' . $url
2315
+ . '">here </a>to enable.'
2316
+ )
2317
+ );
2318
  }
2319
  }
2320
+
2321
  return $resultContent;
2322
  }
2323
 
2324
  /**
2325
  * Check if any wishlist are imported.
2326
+ *
2327
  * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
2328
  */
2329
  public function wishlistSyncing()
2330
  {
2331
+ $resultContent = Mage::getModel(
2332
+ 'ddg_automation/adminhtml_dashboard_content'
2333
+ );
2334
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
2335
  ->setTitle('Wishlist Syncing : ')
2336
  ->setMessage('Looks Great.');
2337
 
2338
+ foreach (Mage::app()->getWebsites() as $website) {
2339
+ $websiteName = $website->getName();
2340
+ $storeIds = $website->getStoreIds();
2341
 
2342
+ if (empty($storeIds)) {
2343
+ continue;
2344
+ }
2345
 
2346
  //number of wishlist marked as imported
2347
+ $numWishlist = Mage::getModel('ddg_automation/wishlist')
2348
+ ->getCollection()
2349
  ->addFieldToFilter('wishlist_imported', 1)
2350
  ->addFieldToFilter('store_id', array('in', $storeIds))
2351
  ->getSize();
2352
 
2353
  //total wishlist
2354
+ $totalWishlist = Mage::getModel('ddg_automation/wishlist')
2355
+ ->getCollection()
2356
  ->addFieldToFilter('store_id', array('in', $storeIds))
2357
  ->getSize();
2358
 
2359
  $tableData = array(
2360
+ 'Website' => $websiteName,
2361
  'Total Wishlist' => $totalWishlist,
2362
+ 'Imported' => $numWishlist
2363
  );
2364
 
2365
  $tableData['Status'] = 'Importing';
2366
 
2367
+ if ( ! $numWishlist) {
2368
  $tableData['Status'] = 'No Imported Wishlist Found.';
2369
  $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
2370
+ ->setTitle(
2371
+ 'Wishlist Sync (ignore if you have reset wishlist) : '
2372
+ )
2373
  ->setMessage('');
2374
  }
2375
  $resultContent->setTable($tableData);
2376
  }
2377
+
2378
  return $resultContent;
2379
  }
2380
 
2381
 
 
2382
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Importer.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Importer extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Importer
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Importer/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -14,6 +16,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
14
 
15
  /**
16
  * Collection class;
 
17
  * @return string
18
  */
19
  protected function _getCollectionClass()
@@ -24,6 +27,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
24
 
25
  /**
26
  * Prepare the grid collection.
 
27
  * @return Mage_Adminhtml_Block_Widget_Grid
28
  */
29
  protected function _prepareCollection()
@@ -31,93 +35,124 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
31
  // Get and set our collection for the grid
32
  $collection = Mage::getResourceModel($this->_getCollectionClass());
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
  /**
38
  * Prepare the grid collumns.
 
39
  * @return $this
40
  * @throws Exception
41
  */
42
  protected function _prepareColumns()
43
  {
44
- $this->addColumn('id', array(
45
- 'header' => Mage::helper('ddg')->__('ID'),
46
- 'align' => 'left',
47
- 'index' => 'id',
48
- 'type' => 'number',
49
- 'escape' => true
50
- ))->addColumn('import_type', array(
51
- 'header' => Mage::helper('ddg')->__('Import Type'),
52
- 'index' => 'import_type',
53
- 'type' => 'text',
54
- 'escape' => true
55
- ))->addColumn('import_status', array(
56
- 'header' => Mage::helper('ddg')->__('Import Status'),
57
- 'index' => 'import_status',
58
- 'type' => 'options',
59
- 'escape' => true,
60
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_importer_status')->getOptions(),
61
- ))->addColumn('message', array(
62
- 'header' => Mage::helper('ddg')->__('Error Message'),
63
- 'index' => 'message',
64
- 'type' => 'text',
65
- 'escape' => true
66
- ))->addColumn('import_mode', array(
67
- 'header' => Mage::helper('ddg')->__('Import Mode'),
68
- 'index' => 'import_mode',
69
- 'type' => 'options',
70
- 'escape' => true,
71
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_importer_mode')->getOptions(),
72
- ))->addColumn('import_id', array(
73
- 'header' => Mage::helper('ddg')->__('Import ID'),
74
- 'index' => 'import_id',
75
- 'type' => 'text',
76
- 'escape' => true
77
- ))->addColumn('import_started', array(
78
- 'header' => Mage::helper('ddg')->__('Imported Started At'),
79
- 'width' => '50px',
80
- 'align' => 'center',
81
- 'index' => 'import_started',
82
- 'type' => 'datetime',
83
- 'escape' => true
84
- ))->addColumn('import_finished', array(
85
- 'header' => Mage::helper('ddg')->__('Last Import Check Time'),
86
- 'align' => 'center',
87
- 'index' => 'import_finished',
88
- 'type' => 'datetime',
89
- 'escape' => true
90
- ))->addColumn('script', array(
91
- 'header' => Mage::helper('ddg')->__('Script'),
92
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_script',
93
- 'column_css_class' => 'no-display',
94
- 'header_css_class' => 'no-display'
95
- ))->addColumn('created_at', array(
96
- 'header' => Mage::helper('ddg')->__('Created At'),
97
- 'align' => 'center',
98
- 'index' => 'created_at',
99
- 'type' => 'datetime',
100
- 'escape' => true
101
- ))->addColumn('updated_at', array(
102
- 'header' => Mage::helper('ddg')->__('Updated At'),
103
- 'align' => 'center',
104
- 'index' => 'updated_at',
105
- 'type' => 'datetime',
106
- 'escape' => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- ));
109
- if (!Mage::app()->isSingleStoreMode()) {
110
- $this->addColumn('website_id', array(
111
- 'header' => Mage::helper('customer')->__('Website'),
112
- 'align' => 'center',
113
- 'type' => 'options',
114
- 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
115
- 'index' => 'website_id',
116
- ));
117
- }
 
 
 
 
118
 
119
 
120
- return parent::_prepareColumns();
121
  }
122
 
123
  /**
@@ -129,27 +164,33 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
129
  protected function _getStore()
130
  {
131
  $storeId = (int)$this->getRequest()->getParam('store', 0);
 
132
  return Mage::app()->getStore($storeId);
133
  }
134
 
135
- /**
136
- * Prepare the grid massaction.
137
- * @return $this|Mage_Adminhtml_Block_Widget_Grid
138
- */
139
- protected function _prepareMassaction()
140
- {
141
- $this->setMassactionIdField('id');
142
- $this->getMassactionBlock()->setFormFieldName('importer');
143
- $this->getMassactionBlock()->addItem('resend', array(
144
- 'label' => Mage::helper('ddg')->__('Reset'),
145
- 'url' => $this->getUrl('*/*/massResend'),
 
 
146
 
147
- ));
148
- $this->getMassactionBlock()->addItem('delete', array(
149
- 'label'=> Mage::helper('ddg')->__('Delete'),
150
- 'url' => $this->getUrl('*/*/massDelete'),
151
- 'confirm' => Mage::helper('ddg')->__('Are you sure?')));
 
 
 
152
 
153
- return $this;
154
- }
155
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
16
 
17
  /**
18
  * Collection class;
19
+ *
20
  * @return string
21
  */
22
  protected function _getCollectionClass()
27
 
28
  /**
29
  * Prepare the grid collection.
30
+ *
31
  * @return Mage_Adminhtml_Block_Widget_Grid
32
  */
33
  protected function _prepareCollection()
35
  // Get and set our collection for the grid
36
  $collection = Mage::getResourceModel($this->_getCollectionClass());
37
  $this->setCollection($collection);
38
+
39
  return parent::_prepareCollection();
40
  }
41
 
42
  /**
43
  * Prepare the grid collumns.
44
+ *
45
  * @return $this
46
  * @throws Exception
47
  */
48
  protected function _prepareColumns()
49
  {
50
+ $this->addColumn(
51
+ 'id', array(
52
+ 'header' => Mage::helper('ddg')->__('ID'),
53
+ 'align' => 'left',
54
+ 'index' => 'id',
55
+ 'type' => 'number',
56
+ 'escape' => true
57
+ )
58
+ )->addColumn(
59
+ 'import_type', array(
60
+ 'header' => Mage::helper('ddg')->__('Import Type'),
61
+ 'index' => 'import_type',
62
+ 'type' => 'text',
63
+ 'escape' => true
64
+ )
65
+ )->addColumn(
66
+ 'import_status', array(
67
+ 'header' => Mage::helper('ddg')->__('Import Status'),
68
+ 'index' => 'import_status',
69
+ 'type' => 'options',
70
+ 'escape' => true,
71
+ 'options' => Mage::getModel(
72
+ 'ddg_automation/adminhtml_source_importer_status'
73
+ )->getOptions(),
74
+ )
75
+ )->addColumn(
76
+ 'message', array(
77
+ 'header' => Mage::helper('ddg')->__('Error Message'),
78
+ 'index' => 'message',
79
+ 'type' => 'text',
80
+ 'escape' => true
81
+ )
82
+ )->addColumn(
83
+ 'import_mode', array(
84
+ 'header' => Mage::helper('ddg')->__('Import Mode'),
85
+ 'index' => 'import_mode',
86
+ 'type' => 'options',
87
+ 'escape' => true,
88
+ 'options' => Mage::getModel(
89
+ 'ddg_automation/adminhtml_source_importer_mode'
90
+ )->getOptions(),
91
+ )
92
+ )->addColumn(
93
+ 'import_id', array(
94
+ 'header' => Mage::helper('ddg')->__('Import ID'),
95
+ 'index' => 'import_id',
96
+ 'type' => 'text',
97
+ 'escape' => true
98
+ )
99
+ )->addColumn(
100
+ 'import_started', array(
101
+ 'header' => Mage::helper('ddg')->__('Imported Started At'),
102
+ 'width' => '50px',
103
+ 'align' => 'center',
104
+ 'index' => 'import_started',
105
+ 'type' => 'datetime',
106
+ 'escape' => true
107
+ )
108
+ )->addColumn(
109
+ 'import_finished', array(
110
+ 'header' => Mage::helper('ddg')->__('Last Import Check Time'),
111
+ 'align' => 'center',
112
+ 'index' => 'import_finished',
113
+ 'type' => 'datetime',
114
+ 'escape' => true
115
+ )
116
+ )->addColumn(
117
+ 'script', array(
118
+ 'header' => Mage::helper('ddg')->__('Script'),
119
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_script',
120
+ 'column_css_class' => 'no-display',
121
+ 'header_css_class' => 'no-display'
122
+ )
123
+ )->addColumn(
124
+ 'created_at', array(
125
+ 'header' => Mage::helper('ddg')->__('Created At'),
126
+ 'align' => 'center',
127
+ 'index' => 'created_at',
128
+ 'type' => 'datetime',
129
+ 'escape' => true
130
+ )
131
+ )->addColumn(
132
+ 'updated_at', array(
133
+ 'header' => Mage::helper('ddg')->__('Updated At'),
134
+ 'align' => 'center',
135
+ 'index' => 'updated_at',
136
+ 'type' => 'datetime',
137
+ 'escape' => true
138
 
139
+ )
140
+ );
141
+ if ( ! Mage::app()->isSingleStoreMode()) {
142
+ $this->addColumn(
143
+ 'website_id', array(
144
+ 'header' => Mage::helper('customer')->__('Website'),
145
+ 'align' => 'center',
146
+ 'type' => 'options',
147
+ 'options' => Mage::getSingleton('adminhtml/system_store')
148
+ ->getWebsiteOptionHash(true),
149
+ 'index' => 'website_id',
150
+ )
151
+ );
152
+ }
153
 
154
 
155
+ return parent::_prepareColumns();
156
  }
157
 
158
  /**
164
  protected function _getStore()
165
  {
166
  $storeId = (int)$this->getRequest()->getParam('store', 0);
167
+
168
  return Mage::app()->getStore($storeId);
169
  }
170
 
171
+ /**
172
+ * Prepare the grid massaction.
173
+ *
174
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
175
+ */
176
+ protected function _prepareMassaction()
177
+ {
178
+ $this->setMassactionIdField('id');
179
+ $this->getMassactionBlock()->setFormFieldName('importer');
180
+ $this->getMassactionBlock()->addItem(
181
+ 'resend', array(
182
+ 'label' => Mage::helper('ddg')->__('Reset'),
183
+ 'url' => $this->getUrl('*/*/massResend'),
184
 
185
+ )
186
+ );
187
+ $this->getMassactionBlock()->addItem(
188
+ 'delete', array(
189
+ 'label' => Mage::helper('ddg')->__('Delete'),
190
+ 'url' => $this->getUrl('*/*/massDelete'),
191
+ 'confirm' => Mage::helper('ddg')->__('Are you sure?'))
192
+ );
193
 
194
+ return $this;
195
+ }
196
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order.php CHANGED
@@ -1,13 +1,15 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
 
9
- $this->_controller = 'adminhtml_order';
10
- $this->_blockGroup = 'ddg_automation';
11
  $this->_headerText = Mage::helper('ddg')->__('Email Order(s)');
12
 
13
  $this->_removeButton('add');
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Order
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
 
11
+ $this->_controller = 'adminhtml_order';
12
+ $this->_blockGroup = 'ddg_automation';
13
  $this->_headerText = Mage::helper('ddg')->__('Email Order(s)');
14
 
15
  $this->_removeButton('add');
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -13,9 +15,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Bl
13
  }
14
 
15
  /**
16
- * Collection class;
17
- * @return string
18
- */
 
19
  protected function _getCollectionClass()
20
  {
21
  // This is the model we are using for the grid
@@ -23,96 +26,123 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Bl
23
  }
24
 
25
  /**
26
- * Prepare the grid collection.
27
- * @return Mage_Adminhtml_Block_Widget_Grid
28
- */
 
29
  protected function _prepareCollection()
30
  {
31
  // Get and set our collection for the grid
32
  $collection = Mage::getResourceModel($this->_getCollectionClass());
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
  /**
38
- * Prepare the grid collumns.
39
- * @return $this
40
- * @throws Exception
41
- */
 
42
  protected function _prepareColumns()
43
  {
44
- $this->addColumn('order_id', array(
45
- 'header' => Mage::helper('ddg')->__('Order ID'),
46
- 'align' => 'left',
47
- 'width' => '50px',
48
- 'index' => 'order_id',
49
- 'type' => 'number',
50
- 'escape' => true
51
- ))->addColumn('store_id', array(
52
- 'header' => Mage::helper('ddg')->__('Store ID'),
53
- 'width' => '50px',
54
- 'index' => 'store_id',
55
- 'type' => 'number',
56
- 'escape' => true,
57
- ))->addColumn('order_status', array(
58
- 'header' => Mage::helper('ddg')->__('Order Status'),
59
- 'align' => 'right',
60
- 'width' => '50px',
61
- 'index' => 'order_status',
62
- 'type' => 'options',
63
- 'escape' => true,
64
- 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
65
- ))->addColumn('email_imported', array(
66
- 'header' => Mage::helper('ddg')->__('Imported'),
67
- 'align' => 'center',
68
- 'width' => '50px',
69
- 'index' => 'email_imported',
70
- 'type' => 'options',
71
- 'escape' => true,
72
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
73
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
74
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
75
- ))->addColumn('modified', array(
76
- 'header' => Mage::helper('ddg')->__('Modified'),
77
- 'align' => 'center',
78
- 'width' => '50px',
79
- 'index' => 'modified',
80
- 'type' => 'options',
81
- 'escape' => true,
82
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
83
- 'options' => array(
84
- 1 => 'Modified',
85
- null => 'Not Modified',
86
- ),
87
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
88
- ))->addColumn('created_at', array(
89
- 'header' => Mage::helper('ddg')->__('Created At'),
90
- 'width' => '50px',
91
- 'align' => 'center',
92
- 'index' => 'created_at',
93
- 'type' => 'datetime',
94
- 'escape' => true,
95
- ))->addColumn('updated_at', array(
96
- 'header' => Mage::helper('ddg')->__('Updated At'),
97
- 'width' => '50px',
98
- 'align' => 'center',
99
- 'index' => 'updated_at',
100
- 'type' => 'datetime',
101
- 'escape' => true,
102
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  return parent::_prepareColumns();
105
  }
106
 
107
  /**
108
- * Callback action for the imported subscribers/contacts.
109
- *
110
- * @param $collection
111
- * @param $column
112
- */
113
  public function filterCallbackContact($collection, $column)
114
  {
115
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
 
116
  $value = $column->getFilter()->getValue();
117
  if ($value == 'null') {
118
  $collection->addFieldToFilter($field, array('null' => true));
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
15
  }
16
 
17
  /**
18
+ * Collection class;
19
+ *
20
+ * @return string
21
+ */
22
  protected function _getCollectionClass()
23
  {
24
  // This is the model we are using for the grid
26
  }
27
 
28
  /**
29
+ * Prepare the grid collection.
30
+ *
31
+ * @return Mage_Adminhtml_Block_Widget_Grid
32
+ */
33
  protected function _prepareCollection()
34
  {
35
  // Get and set our collection for the grid
36
  $collection = Mage::getResourceModel($this->_getCollectionClass());
37
  $this->setCollection($collection);
38
+
39
  return parent::_prepareCollection();
40
  }
41
 
42
  /**
43
+ * Prepare the grid collumns.
44
+ *
45
+ * @return $this
46
+ * @throws Exception
47
+ */
48
  protected function _prepareColumns()
49
  {
50
+ $this->addColumn(
51
+ 'order_id', array(
52
+ 'header' => Mage::helper('ddg')->__('Order ID'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'order_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ )
59
+ )->addColumn(
60
+ 'store_id', array(
61
+ 'header' => Mage::helper('ddg')->__('Store ID'),
62
+ 'width' => '50px',
63
+ 'index' => 'store_id',
64
+ 'type' => 'number',
65
+ 'escape' => true,
66
+ )
67
+ )->addColumn(
68
+ 'order_status', array(
69
+ 'header' => Mage::helper('ddg')->__('Order Status'),
70
+ 'align' => 'right',
71
+ 'width' => '50px',
72
+ 'index' => 'order_status',
73
+ 'type' => 'options',
74
+ 'escape' => true,
75
+ 'options' => Mage::getSingleton('sales/order_config')
76
+ ->getStatuses(),
77
+ )
78
+ )->addColumn(
79
+ 'email_imported', array(
80
+ 'header' => Mage::helper('ddg')->__(
81
+ 'Imported'
82
+ ),
83
+ 'align' => 'center',
84
+ 'width' => '50px',
85
+ 'index' => 'email_imported',
86
+ 'type' => 'options',
87
+ 'escape' => true,
88
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
89
+ 'options' => Mage::getModel(
90
+ 'ddg_automation/adminhtml_source_contact_imported'
91
+ )->getOptions(),
92
+ 'filter_condition_callback' => array($this,
93
+ 'filterCallbackContact')
94
+ )
95
+ )->addColumn(
96
+ 'modified', array(
97
+ 'header' => Mage::helper('ddg')->__(
98
+ 'Modified'
99
+ ),
100
+ 'align' => 'center',
101
+ 'width' => '50px',
102
+ 'index' => 'modified',
103
+ 'type' => 'options',
104
+ 'escape' => true,
105
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
106
+ 'options' => array(
107
+ 1 => 'Modified',
108
+ null => 'Not Modified',
109
+ ),
110
+ 'filter_condition_callback' => array($this,
111
+ 'filterCallbackContact')
112
+ )
113
+ )->addColumn(
114
+ 'created_at', array(
115
+ 'header' => Mage::helper('ddg')->__('Created At'),
116
+ 'width' => '50px',
117
+ 'align' => 'center',
118
+ 'index' => 'created_at',
119
+ 'type' => 'datetime',
120
+ 'escape' => true,
121
+ )
122
+ )->addColumn(
123
+ 'updated_at', array(
124
+ 'header' => Mage::helper('ddg')->__('Updated At'),
125
+ 'width' => '50px',
126
+ 'align' => 'center',
127
+ 'index' => 'updated_at',
128
+ 'type' => 'datetime',
129
+ 'escape' => true,
130
+ )
131
+ );
132
 
133
  return parent::_prepareColumns();
134
  }
135
 
136
  /**
137
+ * Callback action for the imported subscribers/contacts.
138
+ *
139
+ * @param $collection
140
+ * @param $column
141
+ */
142
  public function filterCallbackContact($collection, $column)
143
  {
144
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
145
+ : $column->getIndex();
146
  $value = $column->getFilter()->getValue();
147
  if ($value == 'null') {
148
  $collection->addFieldToFilter($field, array('null' => true));
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Quote.php CHANGED
@@ -1,14 +1,16 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Quote extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
 
9
- $this->_controller = 'adminhtml_quote';
10
- $this->_blockGroup = 'ddg_automation';
11
- $this->_headerText = Mage::helper('ddg')->__('Email Quote(s)');
12
 
13
  $this->_removeButton('add');
14
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Quote
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
 
11
+ $this->_controller = 'adminhtml_quote';
12
+ $this->_blockGroup = 'ddg_automation';
13
+ $this->_headerText = Mage::helper('ddg')->__('Email Quote(s)');
14
 
15
  $this->_removeButton('add');
16
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Quote/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -14,6 +16,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
14
 
15
  /**
16
  * Collection class;
 
17
  * @return string
18
  */
19
  protected function _getCollectionClass()
@@ -24,6 +27,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
24
 
25
  /**
26
  * Prepare the grid collection.
 
27
  * @return Mage_Adminhtml_Block_Widget_Grid
28
  */
29
  protected function _prepareCollection()
@@ -31,72 +35,98 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
31
  // Get and set our collection for the grid
32
  $collection = Mage::getResourceModel($this->_getCollectionClass());
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
  /**
38
  * Prepare the grid collumns.
 
39
  * @return $this
40
  * @throws Exception
41
  */
42
  protected function _prepareColumns()
43
  {
44
- $this->addColumn('quote_id', array(
45
- 'header' => Mage::helper('ddg')->__('Quote ID'),
46
- 'align' => 'left',
47
- 'width' => '50px',
48
- 'index' => 'quote_id',
49
- 'type' => 'number',
50
- 'escape' => true
51
- ))->addColumn('customer_id', array(
52
- 'header' => Mage::helper('ddg')->__('Customer ID'),
53
- 'align' => 'left',
54
- 'width' => '50px',
55
- 'index' => 'customer_id',
56
- 'type' => 'number',
57
- 'escape' => true
58
- ))->addColumn('store_id', array(
59
- 'header' => Mage::helper('ddg')->__('Store ID'),
60
- 'align' => 'left',
61
- 'width' => '50px',
62
- 'index' => 'store_id',
63
- 'type' => 'number',
64
- 'escape' => true
65
- ))->addColumn('imported', array(
66
- 'header' => Mage::helper('ddg')->__('Quote Imported'),
67
- 'align' => 'center',
68
- 'width' => '50px',
69
- 'index' => 'imported',
70
- 'type' => 'options',
71
- 'escape' => true,
72
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
73
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
74
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
75
- ))->addColumn('modified', array(
76
- 'header' => Mage::helper('ddg')->__('Quote Modified'),
77
- 'align' => 'center',
78
- 'width' => '50px',
79
- 'index' => 'modified',
80
- 'type' => 'options',
81
- 'escape' => true,
82
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
83
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
84
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
85
- ))->addColumn('created_at', array(
86
- 'header' => Mage::helper('ddg')->__('Created At'),
87
- 'width' => '50px',
88
- 'align' => 'center',
89
- 'index' => 'created_at',
90
- 'type' => 'datetime',
91
- 'escape' => true,
92
- ))->addColumn('updated_at', array(
93
- 'header' => Mage::helper('ddg')->__('Updated At'),
94
- 'width' => '50px',
95
- 'align' => 'center',
96
- 'index' => 'updated_at',
97
- 'type' => 'datetime',
98
- 'escape' => true,
99
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  return parent::_prepareColumns();
102
  }
@@ -109,7 +139,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
109
  */
110
  public function filterCallbackContact($collection, $column)
111
  {
112
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
 
113
  $value = $column->getFilter()->getValue();
114
  if ($value == 'null') {
115
  $collection->addFieldToFilter($field, array('null' => true));
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
16
 
17
  /**
18
  * Collection class;
19
+ *
20
  * @return string
21
  */
22
  protected function _getCollectionClass()
27
 
28
  /**
29
  * Prepare the grid collection.
30
+ *
31
  * @return Mage_Adminhtml_Block_Widget_Grid
32
  */
33
  protected function _prepareCollection()
35
  // Get and set our collection for the grid
36
  $collection = Mage::getResourceModel($this->_getCollectionClass());
37
  $this->setCollection($collection);
38
+
39
  return parent::_prepareCollection();
40
  }
41
 
42
  /**
43
  * Prepare the grid collumns.
44
+ *
45
  * @return $this
46
  * @throws Exception
47
  */
48
  protected function _prepareColumns()
49
  {
50
+ $this->addColumn(
51
+ 'quote_id', array(
52
+ 'header' => Mage::helper('ddg')->__('Quote ID'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'quote_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ )
59
+ )->addColumn(
60
+ 'customer_id', array(
61
+ 'header' => Mage::helper('ddg')->__('Customer ID'),
62
+ 'align' => 'left',
63
+ 'width' => '50px',
64
+ 'index' => 'customer_id',
65
+ 'type' => 'number',
66
+ 'escape' => true
67
+ )
68
+ )->addColumn(
69
+ 'store_id', array(
70
+ 'header' => Mage::helper('ddg')->__('Store ID'),
71
+ 'align' => 'left',
72
+ 'width' => '50px',
73
+ 'index' => 'store_id',
74
+ 'type' => 'number',
75
+ 'escape' => true
76
+ )
77
+ )->addColumn(
78
+ 'imported', array(
79
+ 'header' => Mage::helper('ddg')->__(
80
+ 'Quote Imported'
81
+ ),
82
+ 'align' => 'center',
83
+ 'width' => '50px',
84
+ 'index' => 'imported',
85
+ 'type' => 'options',
86
+ 'escape' => true,
87
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
88
+ 'options' => Mage::getModel(
89
+ 'ddg_automation/adminhtml_source_contact_imported'
90
+ )->getOptions(),
91
+ 'filter_condition_callback' => array($this,
92
+ 'filterCallbackContact')
93
+ )
94
+ )->addColumn(
95
+ 'modified', array(
96
+ 'header' => Mage::helper('ddg')->__(
97
+ 'Quote Modified'
98
+ ),
99
+ 'align' => 'center',
100
+ 'width' => '50px',
101
+ 'index' => 'modified',
102
+ 'type' => 'options',
103
+ 'escape' => true,
104
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
105
+ 'options' => Mage::getModel(
106
+ 'ddg_automation/adminhtml_source_contact_imported'
107
+ )->getOptions(),
108
+ 'filter_condition_callback' => array($this,
109
+ 'filterCallbackContact')
110
+ )
111
+ )->addColumn(
112
+ 'created_at', array(
113
+ 'header' => Mage::helper('ddg')->__('Created At'),
114
+ 'width' => '50px',
115
+ 'align' => 'center',
116
+ 'index' => 'created_at',
117
+ 'type' => 'datetime',
118
+ 'escape' => true,
119
+ )
120
+ )->addColumn(
121
+ 'updated_at', array(
122
+ 'header' => Mage::helper('ddg')->__('Updated At'),
123
+ 'width' => '50px',
124
+ 'align' => 'center',
125
+ 'index' => 'updated_at',
126
+ 'type' => 'datetime',
127
+ 'escape' => true,
128
+ )
129
+ );
130
 
131
  return parent::_prepareColumns();
132
  }
139
  */
140
  public function filterCallbackContact($collection, $column)
141
  {
142
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
143
+ : $column->getIndex();
144
  $value = $column->getFilter()->getValue();
145
  if ($value == 'null') {
146
  $collection->addFieldToFilter($field, array('null' => true));
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review.php CHANGED
@@ -1,14 +1,16 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Review extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
 
9
- $this->_controller = 'adminhtml_review';
10
- $this->_blockGroup = 'ddg_automation';
11
- $this->_headerText = Mage::helper('ddg')->__('Email Review(s)');
12
 
13
  $this->_removeButton('add');
14
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Review
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
 
11
+ $this->_controller = 'adminhtml_review';
12
+ $this->_blockGroup = 'ddg_automation';
13
+ $this->_headerText = Mage::helper('ddg')->__('Email Review(s)');
14
 
15
  $this->_removeButton('add');
16
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -13,9 +15,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid extends Mage_Adminhtml_B
13
  }
14
 
15
  /**
16
- * Collection class;
17
- * @return string
18
- */
 
19
  protected function _getCollectionClass()
20
  {
21
  // This is the model we are using for the grid
@@ -23,82 +26,103 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid extends Mage_Adminhtml_B
23
  }
24
 
25
  /**
26
- * Prepare the grid collection.
27
- * @return Mage_Adminhtml_Block_Widget_Grid
28
- */
 
29
  protected function _prepareCollection()
30
  {
31
  // Get and set our collection for the grid
32
  $collection = Mage::getResourceModel($this->_getCollectionClass());
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
  /**
38
- * Prepare the grid collumns.
39
- * @return $this
40
- * @throws Exception
41
- */
 
42
  protected function _prepareColumns()
43
  {
44
- $this->addColumn('review_id', array(
45
- 'header' => Mage::helper('ddg')->__('Review ID'),
46
- 'align' => 'left',
47
- 'width' => '50px',
48
- 'index' => 'review_id',
49
- 'type' => 'number',
50
- 'escape' => true
51
- ))->addColumn('customer_id', array(
52
- 'header' => Mage::helper('ddg')->__('Customer ID'),
53
- 'align' => 'left',
54
- 'width' => '50px',
55
- 'index' => 'customer_id',
56
- 'type' => 'number',
57
- 'escape' => true
58
- ))->addColumn('store_id', array(
59
- 'header' => Mage::helper('ddg')->__('Store ID'),
60
- 'width' => '50px',
61
- 'index' => 'store_id',
62
- 'type' => 'number',
63
- 'escape' => true,
64
- ))->addColumn('review_imported', array(
65
- 'header' => Mage::helper('ddg')->__('Review Imported'),
66
- 'align' => 'center',
67
- 'width' => '50px',
68
- 'index' => 'review_imported',
69
- 'type' => 'options',
70
- 'escape' => true,
71
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
72
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
73
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
74
- ))->addColumn('created_at', array(
75
- 'header' => Mage::helper('ddg')->__('Created At'),
76
- 'width' => '50px',
77
- 'align' => 'center',
78
- 'index' => 'created_at',
79
- 'type' => 'datetime',
80
- 'escape' => true,
81
- ))->addColumn('updated_at', array(
82
- 'header' => Mage::helper('ddg')->__('Updated At'),
83
- 'width' => '50px',
84
- 'align' => 'center',
85
- 'index' => 'updated_at',
86
- 'type' => 'datetime',
87
- 'escape' => true,
88
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  return parent::_prepareColumns();
91
  }
92
 
93
  /**
94
- * Callback action for the imported subscribers/contacts.
95
- *
96
- * @param $collection
97
- * @param $column
98
- */
99
  public function filterCallbackContact($collection, $column)
100
  {
101
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
 
102
  $value = $column->getFilter()->getValue();
103
  if ($value == 'null') {
104
  $collection->addFieldToFilter($field, array('null' => true));
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
15
  }
16
 
17
  /**
18
+ * Collection class;
19
+ *
20
+ * @return string
21
+ */
22
  protected function _getCollectionClass()
23
  {
24
  // This is the model we are using for the grid
26
  }
27
 
28
  /**
29
+ * Prepare the grid collection.
30
+ *
31
+ * @return Mage_Adminhtml_Block_Widget_Grid
32
+ */
33
  protected function _prepareCollection()
34
  {
35
  // Get and set our collection for the grid
36
  $collection = Mage::getResourceModel($this->_getCollectionClass());
37
  $this->setCollection($collection);
38
+
39
  return parent::_prepareCollection();
40
  }
41
 
42
  /**
43
+ * Prepare the grid collumns.
44
+ *
45
+ * @return $this
46
+ * @throws Exception
47
+ */
48
  protected function _prepareColumns()
49
  {
50
+ $this->addColumn(
51
+ 'review_id', array(
52
+ 'header' => Mage::helper('ddg')->__('Review ID'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'review_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ )
59
+ )->addColumn(
60
+ 'customer_id', array(
61
+ 'header' => Mage::helper('ddg')->__('Customer ID'),
62
+ 'align' => 'left',
63
+ 'width' => '50px',
64
+ 'index' => 'customer_id',
65
+ 'type' => 'number',
66
+ 'escape' => true
67
+ )
68
+ )->addColumn(
69
+ 'store_id', array(
70
+ 'header' => Mage::helper('ddg')->__('Store ID'),
71
+ 'width' => '50px',
72
+ 'index' => 'store_id',
73
+ 'type' => 'number',
74
+ 'escape' => true,
75
+ )
76
+ )->addColumn(
77
+ 'review_imported', array(
78
+ 'header' => Mage::helper('ddg')->__(
79
+ 'Review Imported'
80
+ ),
81
+ 'align' => 'center',
82
+ 'width' => '50px',
83
+ 'index' => 'review_imported',
84
+ 'type' => 'options',
85
+ 'escape' => true,
86
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
87
+ 'options' => Mage::getModel(
88
+ 'ddg_automation/adminhtml_source_contact_imported'
89
+ )->getOptions(),
90
+ 'filter_condition_callback' => array($this,
91
+ 'filterCallbackContact')
92
+ )
93
+ )->addColumn(
94
+ 'created_at', array(
95
+ 'header' => Mage::helper('ddg')->__('Created At'),
96
+ 'width' => '50px',
97
+ 'align' => 'center',
98
+ 'index' => 'created_at',
99
+ 'type' => 'datetime',
100
+ 'escape' => true,
101
+ )
102
+ )->addColumn(
103
+ 'updated_at', array(
104
+ 'header' => Mage::helper('ddg')->__('Updated At'),
105
+ 'width' => '50px',
106
+ 'align' => 'center',
107
+ 'index' => 'updated_at',
108
+ 'type' => 'datetime',
109
+ 'escape' => true,
110
+ )
111
+ );
112
 
113
  return parent::_prepareColumns();
114
  }
115
 
116
  /**
117
+ * Callback action for the imported subscribers/contacts.
118
+ *
119
+ * @param $collection
120
+ * @param $column
121
+ */
122
  public function filterCallbackContact($collection, $column)
123
  {
124
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
125
+ : $column->getIndex();
126
  $value = $column->getFilter()->getValue();
127
  if ($value == 'null') {
128
  $collection->addFieldToFilter($field, array('null' => true));
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules.php CHANGED
@@ -1,13 +1,17 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Rules extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
- $this->_controller = 'adminhtml_rules';
9
- $this->_blockGroup = 'ddg_automation';
10
- $this->_headerText = Mage::helper('ddg')->__('Email Exclusion Rule(s)');
 
 
11
  $this->_addButtonLabel = Mage::helper('ddg')->__('Add New Rule');
12
 
13
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Rules
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
+ $this->_controller = 'adminhtml_rules';
11
+ $this->_blockGroup = 'ddg_automation';
12
+ $this->_headerText = Mage::helper('ddg')->__(
13
+ 'Email Exclusion Rule(s)'
14
+ );
15
  $this->_addButtonLabel = Mage::helper('ddg')->__('Add New Rule');
16
 
17
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit.php CHANGED
@@ -3,8 +3,8 @@
3
  /**
4
  * Shopping cart rule edit form block
5
  */
6
-
7
- class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
8
  {
9
 
10
  /**
@@ -14,17 +14,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit extends Mage_Adminhtml_Bl
14
  */
15
  public function __construct()
16
  {
17
- $this->_objectId = 'id';
18
  $this->_blockGroup = 'ddg_automation';
19
  $this->_controller = 'adminhtml_rules';
20
 
21
  parent::__construct();
22
 
23
- $this->_addButton('save_and_continue_edit', array(
 
24
  'class' => 'save',
25
  'label' => Mage::helper('ddg')->__('Save and Continue Edit'),
26
  'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
27
- ), 10);
 
28
  }
29
 
30
  /**
@@ -36,9 +38,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit extends Mage_Adminhtml_Bl
36
  {
37
  $rule = Mage::registry('current_ddg_rule');
38
  if ($rule->getId()) {
39
- return Mage::helper('ddg')->__("Edit Rule '%s'", $this->escapeHtml($rule->getName()));
40
- }
41
- else {
 
42
  return Mage::helper('ddg')->__('New Rule');
43
  }
44
  }
3
  /**
4
  * Shopping cart rule edit form block
5
  */
6
+ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit
7
+ extends Mage_Adminhtml_Block_Widget_Form_Container
8
  {
9
 
10
  /**
14
  */
15
  public function __construct()
16
  {
17
+ $this->_objectId = 'id';
18
  $this->_blockGroup = 'ddg_automation';
19
  $this->_controller = 'adminhtml_rules';
20
 
21
  parent::__construct();
22
 
23
+ $this->_addButton(
24
+ 'save_and_continue_edit', array(
25
  'class' => 'save',
26
  'label' => Mage::helper('ddg')->__('Save and Continue Edit'),
27
  'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
28
+ ), 10
29
+ );
30
  }
31
 
32
  /**
38
  {
39
  $rule = Mage::registry('current_ddg_rule');
40
  if ($rule->getId()) {
41
+ return Mage::helper('ddg')->__(
42
+ "Edit Rule '%s'", $this->escapeHtml($rule->getName())
43
+ );
44
+ } else {
45
  return Mage::helper('ddg')->__('New Rule');
46
  }
47
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Form.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
 
4
  {
5
 
6
  public function __construct()
@@ -12,9 +13,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Form extends Mage_Adminht
12
 
13
  protected function _prepareForm()
14
  {
15
- $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('adminhtml/email_rules/save'), 'method' => 'post'));
 
 
 
 
16
  $form->setUseContainer(true);
17
  $this->setForm($form);
 
18
  return parent::_prepareForm();
19
  }
20
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Form
4
+ extends Mage_Adminhtml_Block_Widget_Form
5
  {
6
 
7
  public function __construct()
13
 
14
  protected function _prepareForm()
15
  {
16
+ $form = new Varien_Data_Form(
17
+ array('id' => 'edit_form',
18
+ 'action' => $this->getUrl('adminhtml/email_rules/save'),
19
+ 'method' => 'post')
20
+ );
21
  $form->setUseContainer(true);
22
  $this->setForm($form);
23
+
24
  return parent::_prepareForm();
25
  }
26
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tab/Conditions.php CHANGED
@@ -4,6 +4,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Conditions
4
  extends Mage_Adminhtml_Block_Widget_Form
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
 
7
  /**
8
  * Prepare content for tab
9
  *
@@ -47,34 +48,49 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Conditions
47
  protected function _prepareForm()
48
  {
49
  $model = Mage::registry('current_ddg_rule');
50
- $form = new Varien_Data_Form();
51
  $form->setHtmlIdPrefix('rule_');
52
 
53
- $fieldset = $form->addFieldset('base_fieldset',
54
- array('legend' => Mage::helper('ddg')->__('Exclusion Rule Conditions'))
 
 
 
55
  );
56
 
57
- $fieldset->addField('combination', 'select', array(
58
- 'label' => Mage::helper('ddg')->__('Conditions Combination Match'),
59
- 'title' => Mage::helper('ddg')->__('Conditions Combination Match'),
60
- 'name' => 'combination',
61
- 'required' => true,
62
- 'options' => array(
63
- '1' => Mage::helper('ddg')->__('ALL'),
64
- '2' => Mage::helper('ddg')->__('ANY'),
65
- ),
66
- 'after_element_html' => '<small>Choose ANY if using multi line conditions for same attribute.
 
 
 
 
 
67
  If multi line conditions for same attribute is used and ALL is chosen then multiple lines for same attribute will be ignored.</small>',
68
- ));
 
69
 
70
- $field = $fieldset->addField('condition', 'select', array(
71
- 'name' => 'condition',
72
- 'label' => Mage::helper('ddg')->__('Condition'),
73
- 'title' => Mage::helper('ddg')->__('Condition'),
74
- 'required' => true,
75
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_rules_type')->toOptionArray(),
76
- ));
77
- $renderer = $this->getLayout()->createBlock('ddg_automation/adminhtml_config_rules_customdatafields');
 
 
 
 
 
 
78
  $field->setRenderer($renderer);
79
 
80
  $form->setValues($model->getData());
4
  extends Mage_Adminhtml_Block_Widget_Form
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
7
+
8
  /**
9
  * Prepare content for tab
10
  *
48
  protected function _prepareForm()
49
  {
50
  $model = Mage::registry('current_ddg_rule');
51
+ $form = new Varien_Data_Form();
52
  $form->setHtmlIdPrefix('rule_');
53
 
54
+ $fieldset = $form->addFieldset(
55
+ 'base_fieldset',
56
+ array('legend' => Mage::helper('ddg')->__(
57
+ 'Exclusion Rule Conditions'
58
+ ))
59
  );
60
 
61
+ $fieldset->addField(
62
+ 'combination', 'select', array(
63
+ 'label' => Mage::helper('ddg')->__(
64
+ 'Conditions Combination Match'
65
+ ),
66
+ 'title' => Mage::helper('ddg')->__(
67
+ 'Conditions Combination Match'
68
+ ),
69
+ 'name' => 'combination',
70
+ 'required' => true,
71
+ 'options' => array(
72
+ '1' => Mage::helper('ddg')->__('ALL'),
73
+ '2' => Mage::helper('ddg')->__('ANY'),
74
+ ),
75
+ 'after_element_html' => '<small>Choose ANY if using multi line conditions for same attribute.
76
  If multi line conditions for same attribute is used and ALL is chosen then multiple lines for same attribute will be ignored.</small>',
77
+ )
78
+ );
79
 
80
+ $field = $fieldset->addField(
81
+ 'condition', 'select', array(
82
+ 'name' => 'condition',
83
+ 'label' => Mage::helper('ddg')->__('Condition'),
84
+ 'title' => Mage::helper('ddg')->__('Condition'),
85
+ 'required' => true,
86
+ 'options' => Mage::getModel(
87
+ 'ddg_automation/adminhtml_source_rules_type'
88
+ )->toOptionArray(),
89
+ )
90
+ );
91
+ $renderer = $this->getLayout()->createBlock(
92
+ 'ddg_automation/adminhtml_config_rules_customdatafields'
93
+ );
94
  $field->setRenderer($renderer);
95
 
96
  $form->setValues($model->getData());
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tab/Main.php CHANGED
@@ -4,6 +4,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Main
4
  extends Mage_Adminhtml_Block_Widget_Form
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
 
7
  /**
8
  * Prepare content for tab
9
  *
@@ -51,65 +52,81 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Main
51
  $form = new Varien_Data_Form();
52
  $form->setHtmlIdPrefix('rule_');
53
 
54
- $fieldset = $form->addFieldset('base_fieldset',
 
55
  array('legend' => Mage::helper('ddg')->__('Rule Information'))
56
  );
57
 
58
  if ($model->getId()) {
59
- $fieldset->addField('id', 'hidden', array(
60
- 'name' => 'id',
61
- ));
 
 
62
  }
63
 
64
- $fieldset->addField('name', 'text', array(
65
- 'name' => 'name',
66
- 'label' => Mage::helper('ddg')->__('Rule Name'),
67
- 'title' => Mage::helper('ddg')->__('Rule Name'),
68
- 'required' => true,
69
- ));
70
-
71
- $fieldset->addField('type', 'select', array(
72
- 'label' => Mage::helper('ddg')->__('Rule Type'),
73
- 'title' => Mage::helper('ddg')->__('Rule Type'),
74
- 'name' => 'type',
75
- 'required' => true,
76
- 'options' => array(
77
- Dotdigitalgroup_Email_Model_Rules::ABANDONED => 'Abandoned Cart Exclusion Rule',
78
- Dotdigitalgroup_Email_Model_Rules::REVIEW => 'Review Email Exclusion Rule',
79
- ),
80
- ));
81
-
82
- $fieldset->addField('status', 'select', array(
83
- 'label' => Mage::helper('ddg')->__('Status'),
84
- 'title' => Mage::helper('ddg')->__('Status'),
85
- 'name' => 'status',
86
- 'required' => true,
87
- 'options' => array(
88
- '1' => Mage::helper('ddg')->__('Active'),
89
- '0' => Mage::helper('ddg')->__('Inactive'),
90
- ),
91
- ));
92
-
93
- if (!$model->getId()) {
 
 
 
 
 
 
94
  $model->setData('status', '0');
95
  }
96
 
97
  if (Mage::app()->isSingleStoreMode()) {
98
  $websiteId = Mage::app()->getStore(true)->getWebsiteId();
99
- $fieldset->addField('website_ids', 'hidden', array(
100
- 'name' => 'website_ids[]',
101
- 'value' => $websiteId
102
- ));
 
 
103
  $model->setWebsiteIds($websiteId);
104
  } else {
105
- $field = $fieldset->addField('website_ids', 'multiselect', array(
106
- 'name' => 'website_ids[]',
107
- 'label' => Mage::helper('ddg')->__('Websites'),
108
- 'title' => Mage::helper('ddg')->__('Websites'),
109
- 'required' => true,
110
- 'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm()
111
- ));
112
- $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
 
 
 
 
 
113
  $field->setRenderer($renderer);
114
  }
115
 
4
  extends Mage_Adminhtml_Block_Widget_Form
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
7
+
8
  /**
9
  * Prepare content for tab
10
  *
52
  $form = new Varien_Data_Form();
53
  $form->setHtmlIdPrefix('rule_');
54
 
55
+ $fieldset = $form->addFieldset(
56
+ 'base_fieldset',
57
  array('legend' => Mage::helper('ddg')->__('Rule Information'))
58
  );
59
 
60
  if ($model->getId()) {
61
+ $fieldset->addField(
62
+ 'id', 'hidden', array(
63
+ 'name' => 'id',
64
+ )
65
+ );
66
  }
67
 
68
+ $fieldset->addField(
69
+ 'name', 'text', array(
70
+ 'name' => 'name',
71
+ 'label' => Mage::helper('ddg')->__('Rule Name'),
72
+ 'title' => Mage::helper('ddg')->__('Rule Name'),
73
+ 'required' => true,
74
+ )
75
+ );
76
+
77
+ $fieldset->addField(
78
+ 'type', 'select', array(
79
+ 'label' => Mage::helper('ddg')->__('Rule Type'),
80
+ 'title' => Mage::helper('ddg')->__('Rule Type'),
81
+ 'name' => 'type',
82
+ 'required' => true,
83
+ 'options' => array(
84
+ Dotdigitalgroup_Email_Model_Rules::ABANDONED => 'Abandoned Cart Exclusion Rule',
85
+ Dotdigitalgroup_Email_Model_Rules::REVIEW => 'Review Email Exclusion Rule',
86
+ ),
87
+ )
88
+ );
89
+
90
+ $fieldset->addField(
91
+ 'status', 'select', array(
92
+ 'label' => Mage::helper('ddg')->__('Status'),
93
+ 'title' => Mage::helper('ddg')->__('Status'),
94
+ 'name' => 'status',
95
+ 'required' => true,
96
+ 'options' => array(
97
+ '1' => Mage::helper('ddg')->__('Active'),
98
+ '0' => Mage::helper('ddg')->__('Inactive'),
99
+ ),
100
+ )
101
+ );
102
+
103
+ if ( ! $model->getId()) {
104
  $model->setData('status', '0');
105
  }
106
 
107
  if (Mage::app()->isSingleStoreMode()) {
108
  $websiteId = Mage::app()->getStore(true)->getWebsiteId();
109
+ $fieldset->addField(
110
+ 'website_ids', 'hidden', array(
111
+ 'name' => 'website_ids[]',
112
+ 'value' => $websiteId
113
+ )
114
+ );
115
  $model->setWebsiteIds($websiteId);
116
  } else {
117
+ $field = $fieldset->addField(
118
+ 'website_ids', 'multiselect', array(
119
+ 'name' => 'website_ids[]',
120
+ 'label' => Mage::helper('ddg')->__('Websites'),
121
+ 'title' => Mage::helper('ddg')->__('Websites'),
122
+ 'required' => true,
123
+ 'values' => Mage::getSingleton('adminhtml/system_store')
124
+ ->getWebsiteValuesForForm()
125
+ )
126
+ );
127
+ $renderer = $this->getLayout()->createBlock(
128
+ 'adminhtml/store_switcher_form_renderer_fieldset_element'
129
+ );
130
  $field->setRenderer($renderer);
131
  }
132
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tabs.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tabs
4
+ extends Mage_Adminhtml_Block_Widget_Tabs
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -15,13 +17,16 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid extends Mage_Adminhtml_Bl
15
 
16
  /**
17
  * Prepare the grid collection.
 
18
  * @return Mage_Adminhtml_Block_Widget_Grid
19
  */
20
  protected function _prepareCollection()
21
  {
22
- $collection = Mage::getModel('ddg_automation/rules')->getResourceCollection();
 
23
  $this->setCollection($collection);
24
  parent::_prepareCollection();
 
25
  return $this;
26
  }
27
 
@@ -33,72 +38,88 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid extends Mage_Adminhtml_Bl
33
  */
34
  protected function _prepareColumns()
35
  {
36
- $this->addColumn('rule_id', array(
37
- 'header' => Mage::helper('ddg')->__('ID'),
38
- 'align' =>'right',
39
- 'width' => '50px',
40
- 'index' => 'id',
41
- ));
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- $this->addColumn('name', array(
44
- 'header' => Mage::helper('ddg')->__('Rule Name'),
45
- 'align' =>'left',
46
- 'width' => '150px',
47
- 'index' => 'name',
48
- ));
 
 
 
 
 
 
 
49
 
50
- $this->addColumn('type', array(
51
- 'header' => Mage::helper('ddg')->__('Rule Type'),
52
- 'align' => 'left',
53
- 'width' => '150px',
54
- 'index' => 'type',
55
- 'type' => 'options',
56
- 'options' => array(
57
- 1 => 'Abandoned Cart Exclusion Rule',
58
- 2 => 'Review Email Exclusion Rule',
59
- ),
60
- ));
 
 
61
 
62
- $this->addColumn('status', array(
63
- 'header' => Mage::helper('ddg')->__('Status'),
64
- 'align' => 'left',
65
- 'width' => '80px',
66
- 'index' => 'status',
67
- 'type' => 'options',
68
- 'options' => array(
69
- 1 => 'Active',
70
- 0 => 'Inactive',
71
- ),
72
- ));
73
 
74
- $this->addColumn('created_at', array(
75
- 'header' => Mage::helper('ddg')->__('Created At'),
76
- 'align' => 'left',
77
- 'width' => '120px',
78
- 'type' => 'datetime',
79
- 'index' => 'created_at',
80
- ));
 
 
81
 
82
- $this->addColumn('updated_at', array(
83
- 'header' => Mage::helper('ddg')->__('Updated At'),
84
- 'align' => 'left',
85
- 'width' => '120px',
86
- 'type' => 'datetime',
87
- 'index' => 'updated_at',
88
- ));
 
 
 
 
 
 
 
 
89
 
90
- if (!Mage::app()->isSingleStoreMode()) {
91
- $this->addColumn('rule_website', array(
92
- 'header' => Mage::helper('salesrule')->__('Website'),
93
- 'align' =>'left',
94
- 'index' => 'website_ids',
95
- 'type' => 'options',
96
- 'sortable' => false,
97
- 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(),
98
- 'width' => 150,
99
- ));
100
- }
101
- parent::_prepareColumns();
102
  return $this;
103
  }
104
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
17
 
18
  /**
19
  * Prepare the grid collection.
20
+ *
21
  * @return Mage_Adminhtml_Block_Widget_Grid
22
  */
23
  protected function _prepareCollection()
24
  {
25
+ $collection = Mage::getModel('ddg_automation/rules')
26
+ ->getResourceCollection();
27
  $this->setCollection($collection);
28
  parent::_prepareCollection();
29
+
30
  return $this;
31
  }
32
 
38
  */
39
  protected function _prepareColumns()
40
  {
41
+ $this->addColumn(
42
+ 'rule_id', array(
43
+ 'header' => Mage::helper('ddg')->__('ID'),
44
+ 'align' => 'right',
45
+ 'width' => '50px',
46
+ 'index' => 'id',
47
+ )
48
+ );
49
+
50
+ $this->addColumn(
51
+ 'name', array(
52
+ 'header' => Mage::helper('ddg')->__('Rule Name'),
53
+ 'align' => 'left',
54
+ 'width' => '150px',
55
+ 'index' => 'name',
56
+ )
57
+ );
58
 
59
+ $this->addColumn(
60
+ 'type', array(
61
+ 'header' => Mage::helper('ddg')->__('Rule Type'),
62
+ 'align' => 'left',
63
+ 'width' => '150px',
64
+ 'index' => 'type',
65
+ 'type' => 'options',
66
+ 'options' => array(
67
+ 1 => 'Abandoned Cart Exclusion Rule',
68
+ 2 => 'Review Email Exclusion Rule',
69
+ ),
70
+ )
71
+ );
72
 
73
+ $this->addColumn(
74
+ 'status', array(
75
+ 'header' => Mage::helper('ddg')->__('Status'),
76
+ 'align' => 'left',
77
+ 'width' => '80px',
78
+ 'index' => 'status',
79
+ 'type' => 'options',
80
+ 'options' => array(
81
+ 1 => 'Active',
82
+ 0 => 'Inactive',
83
+ ),
84
+ )
85
+ );
86
 
87
+ $this->addColumn(
88
+ 'created_at', array(
89
+ 'header' => Mage::helper('ddg')->__('Created At'),
90
+ 'align' => 'left',
91
+ 'width' => '120px',
92
+ 'type' => 'datetime',
93
+ 'index' => 'created_at',
94
+ )
95
+ );
 
 
96
 
97
+ $this->addColumn(
98
+ 'updated_at', array(
99
+ 'header' => Mage::helper('ddg')->__('Updated At'),
100
+ 'align' => 'left',
101
+ 'width' => '120px',
102
+ 'type' => 'datetime',
103
+ 'index' => 'updated_at',
104
+ )
105
+ );
106
 
107
+ if ( ! Mage::app()->isSingleStoreMode()) {
108
+ $this->addColumn(
109
+ 'rule_website', array(
110
+ 'header' => Mage::helper('salesrule')->__('Website'),
111
+ 'align' => 'left',
112
+ 'index' => 'website_ids',
113
+ 'type' => 'options',
114
+ 'sortable' => false,
115
+ 'options' => Mage::getSingleton('adminhtml/system_store')
116
+ ->getWebsiteOptionHash(),
117
+ 'width' => 150,
118
+ )
119
+ );
120
+ }
121
+ parent::_prepareColumns();
122
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  return $this;
124
  }
125
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Sales/Order/Creditmemo/View.php CHANGED
@@ -1,12 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends Mage_Adminhtml_Block_Widget_Form_Container
 
 
3
  {
4
 
5
  public function __construct()
6
  {
7
- $this->_objectId = 'creditmemo_id';
8
- $this->_controller = 'sales_order_creditmemo';
9
- $this->_mode = 'view';
10
 
11
  parent::__construct();
12
 
@@ -15,46 +17,56 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
15
  $this->_removeButton('delete');
16
 
17
  if ($this->getCreditmemo()->canCancel()) {
18
- $this->_addButton('cancel', array(
19
- 'label' => Mage::helper('sales')->__('Cancel'),
20
- 'class' => 'delete',
21
- 'onclick' => 'setLocation(\''.$this->getCancelUrl().'\')'
 
 
22
  )
23
  );
24
  }
25
 
26
  if ($this->_isAllowedAction('emails')) {
27
- $this->addButton('send_notification', array(
28
- 'label' => Mage::helper('sales')->__('Send Email'),
29
- 'onclick' => 'confirmSetLocation(\''
30
- . Mage::helper('sales')->__('Are you sure you want to send Creditmemo email to customer?')
31
- . '\', \'' . $this->getEmailUrl() . '\')'
32
- ));
 
 
 
 
33
  }
34
 
35
  if ($this->getCreditmemo()->canRefund()) {
36
- $this->_addButton('refund', array(
37
- 'label' => Mage::helper('sales')->__('Refund'),
38
- 'class' => 'save',
39
- 'onclick' => 'setLocation(\''.$this->getRefundUrl().'\')'
 
 
40
  )
41
  );
42
  }
43
 
44
  if ($this->getCreditmemo()->canVoid()) {
45
- $this->_addButton('void', array(
46
- 'label' => Mage::helper('sales')->__('Void'),
47
- 'class' => 'save',
48
- 'onclick' => 'setLocation(\''.$this->getVoidUrl().'\')'
 
49
  )
50
  );
51
  }
52
 
53
  if ($this->getCreditmemo()->getId()) {
54
- $this->_addButton('print', array(
55
- 'label' => Mage::helper('sales')->__('Print'),
56
- 'class' => 'save',
57
- 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
 
58
  )
59
  );
60
  }
@@ -78,12 +90,21 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
78
  public function getHeaderText()
79
  {
80
  if ($this->getCreditmemo()->getEmailSent()) {
81
- $emailSent = Mage::helper('sales')->__('the credit memo email was sent');
82
- }
83
- else {
84
- $emailSent = Mage::helper('sales')->__('the credit memo email is not sent');
 
 
 
85
  }
86
- return Mage::helper('sales')->__('Credit Memo #%1$s | %3$s | %2$s (%4$s)', $this->getCreditmemo()->getIncrementId(), $this->formatDate($this->getCreditmemo()->getCreatedAtDate(), 'medium', true), $this->getCreditmemo()->getStateName(), $emailSent);
 
 
 
 
 
 
87
  }
88
 
89
  /**
@@ -96,9 +117,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
96
  return $this->getUrl(
97
  '*/sales_order/view',
98
  array(
99
- 'order_id' => $this->getCreditmemo()->getOrderId(),
100
- 'active_tab'=> 'order_creditmemos'
101
- ));
 
102
  }
103
 
104
  /**
@@ -108,7 +130,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
108
  */
109
  public function getCaptureUrl()
110
  {
111
- return $this->getUrl('*/*/capture', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
 
 
 
112
  }
113
 
114
  /**
@@ -118,7 +143,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
118
  */
119
  public function getVoidUrl()
120
  {
121
- return $this->getUrl('*/*/void', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
 
 
 
122
  }
123
 
124
  /**
@@ -128,7 +156,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
128
  */
129
  public function getCancelUrl()
130
  {
131
- return $this->getUrl('*/*/cancel', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
 
 
 
132
  }
133
 
134
  /**
@@ -138,10 +169,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
138
  */
139
  public function getEmailUrl()
140
  {
141
- return $this->getUrl('*/*/email', array(
142
- 'creditmemo_id' => $this->getCreditmemo()->getId(),
143
- 'order_id' => $this->getCreditmemo()->getOrderId()
144
- ));
 
 
145
  }
146
 
147
  /**
@@ -151,18 +184,20 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
151
  */
152
  public function getPrintUrl()
153
  {
154
- return $this->getUrl('*/*/print', array(
155
- 'creditmemo_id' => $this->getCreditmemo()->getId()
156
- ));
 
 
157
  }
158
 
159
  /**
160
- * Update 'back' button url.
161
- *
162
- * @param $flag
163
- *
164
- * @return $this|Mage_Adminhtml_Block_Widget_Container
165
- */
166
  public function updateBackButtonUrl($flag)
167
  {
168
  if ($flag) {
@@ -170,7 +205,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
170
  return $this->_updateButton(
171
  'back',
172
  'onclick',
173
- 'setLocation(\'' . $this->getCreditmemo()->getBackUrl() . '\')'
 
174
  );
175
  }
176
 
@@ -180,6 +216,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
180
  'setLocation(\'' . $this->getUrl('*/sales_creditmemo/') . '\')'
181
  );
182
  }
 
183
  return $this;
184
  }
185
 
@@ -187,10 +224,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
187
  * Check whether action is allowed
188
  *
189
  * @param string $action
 
190
  * @return bool
191
  */
192
  public function _isAllowedAction($action)
193
  {
194
- return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/' . $action);
 
 
195
  }
196
  }
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View
4
+ extends Mage_Adminhtml_Block_Widget_Form_Container
5
  {
6
 
7
  public function __construct()
8
  {
9
+ $this->_objectId = 'creditmemo_id';
10
+ $this->_controller = 'sales_order_creditmemo';
11
+ $this->_mode = 'view';
12
 
13
  parent::__construct();
14
 
17
  $this->_removeButton('delete');
18
 
19
  if ($this->getCreditmemo()->canCancel()) {
20
+ $this->_addButton(
21
+ 'cancel', array(
22
+ 'label' => Mage::helper('sales')->__('Cancel'),
23
+ 'class' => 'delete',
24
+ 'onclick' => 'setLocation(\'' . $this->getCancelUrl()
25
+ . '\')'
26
  )
27
  );
28
  }
29
 
30
  if ($this->_isAllowedAction('emails')) {
31
+ $this->addButton(
32
+ 'send_notification', array(
33
+ 'label' => Mage::helper('sales')->__('Send Email'),
34
+ 'onclick' => 'confirmSetLocation(\''
35
+ . Mage::helper('sales')->__(
36
+ 'Are you sure you want to send Creditmemo email to customer?'
37
+ )
38
+ . '\', \'' . $this->getEmailUrl() . '\')'
39
+ )
40
+ );
41
  }
42
 
43
  if ($this->getCreditmemo()->canRefund()) {
44
+ $this->_addButton(
45
+ 'refund', array(
46
+ 'label' => Mage::helper('sales')->__('Refund'),
47
+ 'class' => 'save',
48
+ 'onclick' => 'setLocation(\'' . $this->getRefundUrl()
49
+ . '\')'
50
  )
51
  );
52
  }
53
 
54
  if ($this->getCreditmemo()->canVoid()) {
55
+ $this->_addButton(
56
+ 'void', array(
57
+ 'label' => Mage::helper('sales')->__('Void'),
58
+ 'class' => 'save',
59
+ 'onclick' => 'setLocation(\'' . $this->getVoidUrl() . '\')'
60
  )
61
  );
62
  }
63
 
64
  if ($this->getCreditmemo()->getId()) {
65
+ $this->_addButton(
66
+ 'print', array(
67
+ 'label' => Mage::helper('sales')->__('Print'),
68
+ 'class' => 'save',
69
+ 'onclick' => 'setLocation(\'' . $this->getPrintUrl() . '\')'
70
  )
71
  );
72
  }
90
  public function getHeaderText()
91
  {
92
  if ($this->getCreditmemo()->getEmailSent()) {
93
+ $emailSent = Mage::helper('sales')->__(
94
+ 'the credit memo email was sent'
95
+ );
96
+ } else {
97
+ $emailSent = Mage::helper('sales')->__(
98
+ 'the credit memo email is not sent'
99
+ );
100
  }
101
+
102
+ return Mage::helper('sales')->__(
103
+ 'Credit Memo #%1$s | %3$s | %2$s (%4$s)',
104
+ $this->getCreditmemo()->getIncrementId(), $this->formatDate(
105
+ $this->getCreditmemo()->getCreatedAtDate(), 'medium', true
106
+ ), $this->getCreditmemo()->getStateName(), $emailSent
107
+ );
108
  }
109
 
110
  /**
117
  return $this->getUrl(
118
  '*/sales_order/view',
119
  array(
120
+ 'order_id' => $this->getCreditmemo()->getOrderId(),
121
+ 'active_tab' => 'order_creditmemos'
122
+ )
123
+ );
124
  }
125
 
126
  /**
130
  */
131
  public function getCaptureUrl()
132
  {
133
+ return $this->getUrl(
134
+ '*/*/capture',
135
+ array('creditmemo_id' => $this->getCreditmemo()->getId())
136
+ );
137
  }
138
 
139
  /**
143
  */
144
  public function getVoidUrl()
145
  {
146
+ return $this->getUrl(
147
+ '*/*/void',
148
+ array('creditmemo_id' => $this->getCreditmemo()->getId())
149
+ );
150
  }
151
 
152
  /**
156
  */
157
  public function getCancelUrl()
158
  {
159
+ return $this->getUrl(
160
+ '*/*/cancel',
161
+ array('creditmemo_id' => $this->getCreditmemo()->getId())
162
+ );
163
  }
164
 
165
  /**
169
  */
170
  public function getEmailUrl()
171
  {
172
+ return $this->getUrl(
173
+ '*/*/email', array(
174
+ 'creditmemo_id' => $this->getCreditmemo()->getId(),
175
+ 'order_id' => $this->getCreditmemo()->getOrderId()
176
+ )
177
+ );
178
  }
179
 
180
  /**
184
  */
185
  public function getPrintUrl()
186
  {
187
+ return $this->getUrl(
188
+ '*/*/print', array(
189
+ 'creditmemo_id' => $this->getCreditmemo()->getId()
190
+ )
191
+ );
192
  }
193
 
194
  /**
195
+ * Update 'back' button url.
196
+ *
197
+ * @param $flag
198
+ *
199
+ * @return $this|Mage_Adminhtml_Block_Widget_Container
200
+ */
201
  public function updateBackButtonUrl($flag)
202
  {
203
  if ($flag) {
205
  return $this->_updateButton(
206
  'back',
207
  'onclick',
208
+ 'setLocation(\'' . $this->getCreditmemo()->getBackUrl()
209
+ . '\')'
210
  );
211
  }
212
 
216
  'setLocation(\'' . $this->getUrl('*/sales_creditmemo/') . '\')'
217
  );
218
  }
219
+
220
  return $this;
221
  }
222
 
224
  * Check whether action is allowed
225
  *
226
  * @param string $action
227
+ *
228
  * @return bool
229
  */
230
  public function _isAllowedAction($action)
231
  {
232
+ return Mage::getSingleton('admin/session')->isAllowed(
233
+ 'sales/order/actions/' . $action
234
+ );
235
  }
236
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Deletecontactids.php CHANGED
@@ -1,17 +1,22 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Deletecontactids extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
12
  protected function _getAddRowButtonHtml($title)
13
  {
14
- $url = Mage::helper('adminhtml')->getUrl("*/connector/deletecontactids");
 
 
15
 
16
  return $this->getLayout()->createBlock('adminhtml/widget_button')
17
  ->setType('button')
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Deletecontactids
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
15
  protected function _getAddRowButtonHtml($title)
16
  {
17
+ $url = Mage::helper('adminhtml')->getUrl(
18
+ "*/connector/deletecontactids"
19
+ );
20
 
21
  return $this->getLayout()->createBlock('adminhtml/widget_button')
22
  ->setType('button')
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Notification.php CHANGED
@@ -1,11 +1,22 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Notification extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $element->setValue(Mage::app()->loadCache(Dotdigitalgroup_Email_Helper_Config::CONNECTOR_FEED_LAST_CHECK_TIME));
8
- $format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
9
- return Mage::app()->getLocale()->date(intval($element->getValue()))->toString($format);
10
- }
 
 
 
 
 
 
 
 
 
 
11
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Notification
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
+ {
10
+ $element->setValue(
11
+ Mage::app()->loadCache(
12
+ Dotdigitalgroup_Email_Helper_Config::CONNECTOR_FEED_LAST_CHECK_TIME
13
+ )
14
+ );
15
+ $format = Mage::app()->getLocale()->getDateTimeFormat(
16
+ Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM
17
+ );
18
+
19
+ return Mage::app()->getLocale()->date(intval($element->getValue()))
20
+ ->toString($format);
21
+ }
22
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportcatalog.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportcatalog extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportcatalog
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportorders.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportorders extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportorders
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportquotes.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportquotes extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportquotes
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportreviews.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportreviews extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportreviews
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportsubscribers.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportsubscribers extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportsubscribers
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportwishlists.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportwishlists extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportwishlists
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reset.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reset extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reset
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Resetcustomersimport.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Resetcustomersimport extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
 
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
9
  }
10
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Resetcustomersimport
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcatalogsync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcatalogsync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcatalogsync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcontactsync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcontactsync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcontactsync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runimportersync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runimportersync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runimportersync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runordersync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runordersync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runordersync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runquotesync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runquotesync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runquotesync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runreviewsync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runreviewsync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runreviewsync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runsubscribersync.php CHANGED
@@ -1,17 +1,22 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runsubscribersync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
12
  protected function _getAddRowButtonHtml($title)
13
  {
14
- $url = Mage::helper('adminhtml')->getUrl("*/connector/runsubscribersync");
 
 
15
 
16
  return $this->getLayout()->createBlock('adminhtml/widget_button')
17
  ->setType('button')
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runsubscribersync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
15
  protected function _getAddRowButtonHtml($title)
16
  {
17
+ $url = Mage::helper('adminhtml')->getUrl(
18
+ "*/connector/runsubscribersync"
19
+ );
20
 
21
  return $this->getLayout()->createBlock('adminhtml/widget_button')
22
  ->setType('button')
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runwishlistsync.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runwishlistsync extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
  }
11
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runwishlistsync
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
  }
14
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Setupdatafields.php CHANGED
@@ -1,24 +1,29 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Setupdatafields extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
- {
8
- $this->setElement($element);
9
- return $this->_getAddRowButtonHtml($this->__("Run Now"));
10
- }
11
 
12
- protected function _getAddRowButtonHtml($title)
13
- {
14
- $website = $this->getRequest()->getParam('website', 0);
15
- $url = $this->getUrl("*/connector/setupdatafields/website/" . $website );
16
 
17
- return $this->getLayout()->createBlock('adminhtml/widget_button')
18
- ->setType('button')
19
- ->setLabel($this->__($title))
20
- ->setOnClick("window.location.href='" . $url . "'")
21
- ->toHtml();
22
- }
 
 
 
 
 
 
 
23
 
24
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Setupdatafields
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
+ {
10
+ $this->setElement($element);
 
11
 
12
+ return $this->_getAddRowButtonHtml($this->__("Run Now"));
13
+ }
 
 
14
 
15
+ protected function _getAddRowButtonHtml($title)
16
+ {
17
+ $website = $this->getRequest()->getParam('website', 0);
18
+ $url = $this->getUrl(
19
+ "*/connector/setupdatafields/website/" . $website
20
+ );
21
+
22
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
23
+ ->setType('button')
24
+ ->setLabel($this->__($title))
25
+ ->setOnClick("window.location.href='" . $url . "'")
26
+ ->toHtml();
27
+ }
28
 
29
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Ajaxvalidate.php CHANGED
@@ -1,8 +1,11 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Ajaxvalidate extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
 
 
6
 
7
  $element->setData('onchange', "apiValidation(this.form, this)");
8
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Ajaxvalidate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
9
 
10
  $element->setData('onchange', "apiValidation(this.form, this)");
11
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Automation/Connect.php CHANGED
@@ -1,27 +1,37 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
  $this->setElement($element);
 
8
  return $this->_getAddRowButtonHtml();
9
  }
10
 
11
  protected function _getAddRowButtonHtml()
12
  {
13
- $url = Mage::helper('ddg')->getAuthoriseUrl();
14
- $ssl = $this->_checkForSecureUrl();
15
  $disabled = false;
16
- //disable for ssl missing
17
- if (!$ssl) {
18
  $disabled = true;
19
  }
20
 
21
- $adminUser = Mage::getSingleton('admin/session')->getUser();
22
  $refreshToken = $adminUser->getRefreshToken();
23
- $title = ($refreshToken)? $this->__('Disconnect') : $this->__('Connect');
24
- $url = ($refreshToken)? $this->getUrl('*/email_studio/disconnect') : $url;
 
 
 
 
 
 
25
 
26
  return $this->getLayout()->createBlock('adminhtml/widget_button')
27
  ->setType('button')
@@ -31,12 +41,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect extends Ma
31
  ->toHtml();
32
  }
33
 
34
- protected function _checkForSecureUrl() {
 
35
 
36
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
37
- if (!preg_match('/https/',$baseUrl)) {
38
  return false;
39
  }
 
40
  return $this;
41
  }
42
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml();
13
  }
14
 
15
  protected function _getAddRowButtonHtml()
16
  {
17
+ $url = Mage::helper('ddg')->getAuthoriseUrl();
18
+ $ssl = $this->_checkForSecureUrl();
19
  $disabled = false;
20
+ //disable for ssl missing
21
+ if ( ! $ssl) {
22
  $disabled = true;
23
  }
24
 
25
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
26
  $refreshToken = $adminUser->getRefreshToken();
27
+ $title = ($refreshToken)
28
+ ? $this->__('Disconnect')
29
+ : $this->__(
30
+ 'Connect'
31
+ );
32
+ $url = ($refreshToken) ? $this->getUrl(
33
+ '*/email_studio/disconnect'
34
+ ) : $url;
35
 
36
  return $this->getLayout()->createBlock('adminhtml/widget_button')
37
  ->setType('button')
41
  ->toHtml();
42
  }
43
 
44
+ protected function _checkForSecureUrl()
45
+ {
46
 
47
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
48
+ if ( ! preg_match('/https/', $baseUrl)) {
49
  return false;
50
  }
51
+
52
  return $this;
53
  }
54
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php CHANGED
@@ -1,20 +1,26 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Addressbook extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /**
7
- * Ajax Create the addressbooks.
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
- $url = Mage::helper('adminhtml')->getUrl('*/connector/createnewaddressbook');
 
 
15
  $website = Mage::app()->getRequest()->getParam('website', 0);
16
 
17
- $element->setData('after_element_html',
 
18
  "<script>
19
  function createAddressbook(form, element) {
20
  var name = $('connector_sync_settings_dynamic_addressbook_addressbook_name').value;
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Addressbook
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /**
8
+ * Ajax Create the addressbooks.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ )
16
  {
17
+ $url = Mage::helper('adminhtml')->getUrl(
18
+ '*/connector/createnewaddressbook'
19
+ );
20
  $website = Mage::app()->getRequest()->getParam('website', 0);
21
 
22
+ $element->setData(
23
+ 'after_element_html',
24
  "<script>
25
  function createAddressbook(form, element) {
26
  var name = $('connector_sync_settings_dynamic_addressbook_addressbook_name').value;
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Colorpicker.php CHANGED
@@ -1,17 +1,21 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
  * Generate HTML code for color picker
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return string
10
  */
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
- {
13
  // Include Procolor library JS file
14
- $html = '<script type="text/javascript" src="' . Mage::getBaseUrl('js') . 'connector/procolor-1.0/procolor.compressed.js' .'"></script>';
 
15
 
16
  // Use Varien text element as a basis
17
  $input = new Varien_Data_Form_Element_Text();
@@ -22,8 +26,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Ma
22
  ->setValue($element->getValue())
23
  ->setHtmlId($element->getHtmlId())
24
  ->setName($element->getName())
25
- ->setStyle('width: 60px') // Update style in order to shrink width
26
- ->addClass('validate-hex'); // Add some Prototype validation to make sure color code is correct
 
 
27
 
28
  // Inject updated Varien text element HTML in our current HTML
29
  $html .= $input->getHtml();
@@ -41,12 +47,17 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Ma
41
  * Procolor JS code to display color picker
42
  *
43
  * @see http://procolor.sourceforge.net/examples.php
 
44
  * @param string $htmlId
 
45
  * @return string
46
  */
47
  protected function _getProcolorJs($htmlId)
48
  {
49
- return '<script type="text/javascript">ProColor.prototype.attachButton(\'' . $htmlId . '\', { imgPath:\'' . Mage::getBaseUrl('js') . 'connector/procolor-1.0/' . 'img/procolor_win_\', showInField: true });</script>';
 
 
 
50
  }
51
 
52
  /**
@@ -58,7 +69,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Ma
58
  {
59
  return
60
  '<script type="text/javascript">
61
- Validation.add(\'validate-hex\', \'' . Mage::helper('ddg')->__('Please enter a valid hex color code') . '\', function(v) {
 
 
62
  return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(v);
63
  });
64
  </script>';
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
  * Generate HTML code for color picker
9
  *
10
  * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
  * @return string
13
  */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ ) {
16
  // Include Procolor library JS file
17
+ $html = '<script type="text/javascript" src="' . Mage::getBaseUrl('js')
18
+ . 'connector/procolor-1.0/procolor.compressed.js' . '"></script>';
19
 
20
  // Use Varien text element as a basis
21
  $input = new Varien_Data_Form_Element_Text();
26
  ->setValue($element->getValue())
27
  ->setHtmlId($element->getHtmlId())
28
  ->setName($element->getName())
29
+ ->setStyle('width: 60px')// Update style in order to shrink width
30
+ ->addClass(
31
+ 'validate-hex'
32
+ ); // Add some Prototype validation to make sure color code is correct
33
 
34
  // Inject updated Varien text element HTML in our current HTML
35
  $html .= $input->getHtml();
47
  * Procolor JS code to display color picker
48
  *
49
  * @see http://procolor.sourceforge.net/examples.php
50
+ *
51
  * @param string $htmlId
52
+ *
53
  * @return string
54
  */
55
  protected function _getProcolorJs($htmlId)
56
  {
57
+ return '<script type="text/javascript">ProColor.prototype.attachButton(\''
58
+ . $htmlId . '\', { imgPath:\'' . Mage::getBaseUrl('js')
59
+ . 'connector/procolor-1.0/'
60
+ . 'img/procolor_win_\', showInField: true });</script>';
61
  }
62
 
63
  /**
69
  {
70
  return
71
  '<script type="text/javascript">
72
+ Validation.add(\'validate-hex\', \'' . Mage::helper('ddg')->__(
73
+ 'Please enter a valid hex color code'
74
+ ) . '\', function(v) {
75
  return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(v);
76
  });
77
  </script>';
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php CHANGED
@@ -1,20 +1,25 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Datafield extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /**
7
- * Ajax Create the datafields.
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
- {
14
- $url = Mage::helper('adminhtml')->getUrl('*/connector/createnewdatafield');
 
 
 
15
  $website = Mage::app()->getRequest()->getParam('website', 0);
16
 
17
- $element->setData('after_element_html',
 
18
  "<script>
19
  function createDatafield(form, element) {
20
  var datafield_name = $('connector_data_mapping_dynamic_datafield_datafield_name').value;
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Datafield
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /**
8
+ * Ajax Create the datafields.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ ) {
16
+ $url = Mage::helper('adminhtml')->getUrl(
17
+ '*/connector/createnewdatafield'
18
+ );
19
  $website = Mage::app()->getRequest()->getParam('website', 0);
20
 
21
+ $element->setData(
22
+ 'after_element_html',
23
  "<script>
24
  function createDatafield(form, element) {
25
  var datafield_name = $('connector_data_mapping_dynamic_datafield_datafield_name').value;
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Enterprisevalidator.php CHANGED
@@ -1,30 +1,35 @@
1
  <?php
2
 
3
 
4
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Enterprisevalidator extends Mage_Adminhtml_Block_System_Config_Form_Field
 
5
  {
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
7
  {
8
  // Get the default HTML for this option
9
  $html = parent::_getElementHtml($element);
10
 
11
  // Set up additional JavaScript for our validation using jQuery.
12
 
13
- $jquery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
 
14
 
15
- if (! Mage::helper('ddg')->isEnterprise()) {
16
- $html .=$jquery;
17
- $javaScript = "<script type=\"text/javascript\">
 
18
  jQuery.noConflict();
19
  jQuery(document).ready(function() {
20
  jQuery('#connector_data_mapping_enterprise_data-head').parent().hide();
21
 
22
  });
23
  </script>";
24
- $html .= $javaScript;
25
  }
26
 
27
 
28
- return $html;
29
  }
30
  }
1
  <?php
2
 
3
 
4
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Enterprisevalidator
5
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  {
7
+
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
  {
11
  // Get the default HTML for this option
12
  $html = parent::_getElementHtml($element);
13
 
14
  // Set up additional JavaScript for our validation using jQuery.
15
 
16
+ $jquery
17
+ = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
18
 
19
+ if ( ! Mage::helper('ddg')->isEnterprise()) {
20
+ $html .= $jquery;
21
+ $javaScript
22
+ = "<script type=\"text/javascript\">
23
  jQuery.noConflict();
24
  jQuery(document).ready(function() {
25
  jQuery('#connector_data_mapping_enterprise_data-head').parent().hide();
26
 
27
  });
28
  </script>";
29
+ $html .= $javaScript;
30
  }
31
 
32
 
33
+ return $html;
34
  }
35
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetcontacts.php CHANGED
@@ -1,14 +1,20 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
 
7
- $element->setData('onchange', "resetContacts();");
8
- //url to reset the contacs
9
- $url = Mage::helper('adminhtml')->getUrl('*/connector/resetcontactsajax');
10
 
11
- $element->setData('after_element_html', "
 
 
 
 
 
 
 
12
  <script>
13
  function resetContacts(){
14
  new Ajax.Request('{$url}', {
@@ -19,9 +25,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts extends
19
  return false;
20
  }
21
  </script>
22
- ");
 
23
 
24
- return parent::_getElementHtml($element);
25
 
26
 
27
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
 
6
 
7
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
 
9
 
10
+ $element->setData('onchange', "resetContacts();");
11
+ //url to reset the contacs
12
+ $url = Mage::helper('adminhtml')->getUrl(
13
+ '*/connector/resetcontactsajax'
14
+ );
15
+
16
+ $element->setData(
17
+ 'after_element_html', "
18
  <script>
19
  function resetContacts(){
20
  new Ajax.Request('{$url}', {
25
  return false;
26
  }
27
  </script>
28
+ "
29
+ );
30
 
31
+ return parent::_getElementHtml($element);
32
 
33
 
34
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetguests.php CHANGED
@@ -1,14 +1,18 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
 
7
- $element->setData('onchange', "resetGuests();");
8
- //url to reset the guests
9
- $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetguests');
10
 
11
- $element->setData('after_element_html', "
 
 
 
 
 
12
  <script>
13
  function resetGuests(){
14
  new Ajax.Request('{$url}', {
@@ -19,9 +23,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests extends Ma
19
  return false;
20
  }
21
  </script>
22
- ");
 
23
 
24
- return parent::_getElementHtml($element);
25
 
26
 
27
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
 
6
 
7
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
 
9
 
10
+ $element->setData('onchange', "resetGuests();");
11
+ //url to reset the guests
12
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetguests');
13
+
14
+ $element->setData(
15
+ 'after_element_html', "
16
  <script>
17
  function resetGuests(){
18
  new Ajax.Request('{$url}', {
23
  return false;
24
  }
25
  </script>
26
+ "
27
+ );
28
 
29
+ return parent::_getElementHtml($element);
30
 
31
 
32
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetsubscribers.php CHANGED
@@ -1,14 +1,20 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
 
7
- $element->setData('onchange', "resetSubscribers();");
8
- //url to reset the subscribers
9
- $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetsubscribers');
10
 
11
- $element->setData('after_element_html', "
 
 
 
 
 
 
 
12
  <script>
13
  function resetSubscribers(){
14
  new Ajax.Request('{$url}', {
@@ -19,9 +25,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers exten
19
  return false;
20
  }
21
  </script>
22
- ");
 
23
 
24
- return parent::_getElementHtml($element);
25
 
26
 
27
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
 
6
 
7
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
 
9
 
10
+ $element->setData('onchange', "resetSubscribers();");
11
+ //url to reset the subscribers
12
+ $url = Mage::helper('adminhtml')->getUrl(
13
+ '*/connector/ajaxresetsubscribers'
14
+ );
15
+
16
+ $element->setData(
17
+ 'after_element_html', "
18
  <script>
19
  function resetSubscribers(){
20
  new Ajax.Request('{$url}', {
25
  return false;
26
  }
27
  </script>
28
+ "
29
+ );
30
 
31
+ return parent::_getElementHtml($element);
32
 
33
 
34
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Trial.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Trial extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+ public function render(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $helper = Mage::helper('ddg');
8
+ if (!$helper->isFrontendAdminSecure()) {
9
+ $html = '<a class="various" href=' .
10
+ Mage::getDesign()->getSkinUrl('connector/trialerror.png') . '><img style="margin-bottom:15px;" src=' .
11
+ Mage::getDesign()->getSkinUrl('connector/banner.png') .
12
+ ' alt="Open Trial Account"></a>';
13
+ $script = "
14
+ <script>
15
+ var j = jQuery.noConflict();
16
+ j(document).ready(function() {
17
+ j('.various').fancybox();
18
+ });
19
+ </script>
20
+ ";
21
+ } else {
22
+ $html = '<a class="various fancybox.iframe" data-fancybox-type="iframe" href=' .
23
+ $helper->getIframeFormUrl() . '><img style="margin-bottom:15px;" src=' .
24
+ Mage::getDesign()->getSkinUrl('connector/banner.png') .
25
+ ' alt="Open Trial Account"></a>';
26
+ $script = "
27
+ <script>
28
+ var j = jQuery.noConflict();
29
+ j(document).ready(function() {
30
+ j('.various').fancybox({
31
+ width : 508,
32
+ height : 612,
33
+ scrolling : 'no',
34
+ fitToView : false,
35
+ autoSize : false,
36
+ closeClick : false,
37
+ openEffect : 'none',
38
+ closeEffect : 'none',
39
+ });
40
+
41
+ j(document).on('click', 'a.fancybox-close', function(){
42
+ location.reload();
43
+ });
44
+ });
45
+ </script>
46
+ ";
47
+ }
48
+ return $html . $script;
49
+ }
50
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php CHANGED
@@ -1,33 +1,36 @@
1
  <?php
2
 
3
 
4
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator extends Mage_Adminhtml_Block_System_Config_Form_Field
 
5
  {
6
 
7
  /**
8
- * Ajax Validate the duplicate selection.
9
- * @param Varien_Data_Form_Element_Abstract $element
10
- *
11
- * @return string
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
14
- {
 
15
  // Get the default HTML for this option
16
  $html = parent::_getElementHtml($element);
17
 
18
  // Set up additional JavaScript for our validation using jQuery.
19
 
20
- $jquery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
 
21
 
22
- $html .=$jquery;
23
  $javaScript = "<script type=\"text/javascript\"> var show_warning = 0;";
24
 
25
- if(!Mage::helper('ddg')->isSweetToothEnabled()){
26
  $javaScript .= "show_warning = 1;";
27
  }
28
 
29
- $javaScript .=
30
- "jQuery.noConflict();
31
 
32
  jQuery(document).ready(function() {
33
  // Handler for .ready() called.
@@ -81,6 +84,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator extends Mage
81
  </script>";
82
 
83
  $html .= $javaScript;
 
84
  return $html;
85
  }
86
 
1
  <?php
2
 
3
 
4
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator
5
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  {
7
 
8
  /**
9
+ * Ajax Validate the duplicate selection.
10
+ *
11
+ * @param Varien_Data_Form_Element_Abstract $element
12
+ *
13
+ * @return string
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ ) {
17
  // Get the default HTML for this option
18
  $html = parent::_getElementHtml($element);
19
 
20
  // Set up additional JavaScript for our validation using jQuery.
21
 
22
+ $jquery
23
+ = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
24
 
25
+ $html .= $jquery;
26
  $javaScript = "<script type=\"text/javascript\"> var show_warning = 0;";
27
 
28
+ if ( ! Mage::helper('ddg')->isSweetToothEnabled()) {
29
  $javaScript .= "show_warning = 1;";
30
  }
31
 
32
+ $javaScript
33
+ .= "jQuery.noConflict();
34
 
35
  jQuery(document).ready(function() {
36
  // Handler for .ready() called.
84
  </script>";
85
 
86
  $html .= $javaScript;
87
+
88
  return $html;
89
  }
90
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Waitingfield extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- /**
6
- * Unscope the website level.
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- */
11
- public function render(Varien_Data_Form_Element_Abstract $element)
12
- {
13
-
14
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
15
- return parent::render($element);
16
-
17
- }
18
-
19
- /**
20
- * Loading background on save.
21
- * @param Varien_Data_Form_Element_Abstract $element
22
- *
23
- * @return string
24
- */
25
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
26
- {
27
- // Get the default HTML for this option
28
- $html = parent::_getElementHtml($element);
29
-
30
-
31
- $html .= sprintf('<div id="loadingmask" style="position: fixed;">
32
- <div class="loader" id="loading-mask-loader">
33
- <img src="%sskin/adminhtml/default/default/images/ajax-loader-tr.gif" alt="%s"/>%s', preg_replace('/index.php\//', '', $this->getBaseUrl()), $this->__('Loading...'), $this->__('Loading...'))
34
- . '<div id="loading-mask"></div></div>';
35
-
36
- $jQuery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
37
-
38
- $jQuery .=
39
- '<script type="text/javascript">
40
- jQuery.noConflict();
41
- jQuery(document).ready(function() {
42
- //hide the load image field
43
- jQuery("#row_connector_api_credentials_api_credentials_validator").hide();
44
- jQuery("#row_connector_sync_settings_sync_customer_schedule_validator").hide();
45
- var loadingmask = jQuery("#loadingmask");
46
- loadingmask.hide();
47
- loadingmask.css({top : "50\%", left: "50\%"});
48
- //var thisButton = jQuery("button");
49
- //console.log(thisButton);
50
- //jQuery("button").click(function(){
51
- // jQuery("body").css({"background-color": "black", "opacity": "0.4"});
52
- // jQuery("#row_connector_api_settings_api_credentials_validator").show();
53
- // jQuery("#row_connector_sync_settings_sync_customer_schedule_validator").show();
54
- // loadingmask.show();
55
- // loadingmask.css({"display": "block", "opacity" : "1"});
56
- //})
57
- });
58
- </script>';
59
-
60
- $html .= $jQuery;
61
-
62
- return $html;
63
- }
64
-
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Wrapper extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- /**
7
- * Ajax Validate the api credentials.
8
- *
9
- * @param Varien_Data_Form_Element_Abstract $element
10
- *
11
- * @return string
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
14
- {
15
- $element->setData('onchange', "apiValidation(this.form, this);");
16
-
17
- $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
18
-
19
- $element->setData('after_element_html', "
20
- <script>
21
- document.observe('dom:loaded', function(){
22
- apiValidation();
23
- });
24
- function apiValidation(form, element) {
25
- var api_username = $('connector_api_credentials_api_username');
26
- var api_password = $('connector_api_credentials_api_password');
27
- var reloadurl = '{$url}';
28
- var encoded = btoa(api_password.value);
29
- if(api_username.value && api_password.value){
30
- new Ajax.Request(reloadurl, {
31
- method: 'post',
32
- parameters: {'api_username' : api_username.value, 'api_password' : encoded},
33
- onComplete: function(transport) {
34
- Element.hide('loadingmask');
35
- if(transport.responseText == '\"Credentials Valid.\"'){
36
- api_username.setStyle({
37
- fontWeight: 'bold',
38
- color: 'green' ,
39
- background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'
40
- })
41
- }else{
42
- api_username.setStyle({
43
- fontWeight: 'bold',
44
- color: 'red',
45
- background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'
46
- });
47
- }
48
- }
49
- });
50
- }
51
- return false;
52
- }
53
- </script>
54
- ");
55
-
56
- return parent::_getElementHtml($element);
57
-
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Addressbookbutton.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  protected function _getAddRowButtonHtml($title)
@@ -12,11 +13,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton ext
12
  ->toHtml();
13
  }
14
 
15
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
16
  {
17
  $this->setElement($element);
18
  $originalData = $element->getOriginalData();
19
 
20
- return $this->_getAddRowButtonHtml($this->__($originalData['button_label']));
 
 
21
  }
22
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  protected function _getAddRowButtonHtml($title)
13
  ->toHtml();
14
  }
15
 
16
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
17
+ )
18
  {
19
  $this->setElement($element);
20
  $originalData = $element->getOriginalData();
21
 
22
+ return $this->_getAddRowButtonHtml(
23
+ $this->__($originalData['button_label'])
24
+ );
25
  }
26
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Crosssell.php CHANGED
@@ -1,24 +1,32 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Crosssell extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
  //base url
8
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
9
- //config passcode
10
  $passcode = Mage::helper('ddg')->getPasscode();
11
  //last quote id for dynamic page
12
- $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
13
 
14
- if (!strlen($passcode))
15
- $passcode = '[PLEASE SET UP A PASSCODE]';
16
- //alert message for last order id is not mapped
17
- if (!$lastQuoteId)
 
18
  $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
 
19
 
20
- //full url for dynamic content
21
- $text = sprintf('%sconnector/quoteproducts/crosssell/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId);
 
 
 
22
  $element->setData('value', $text);
23
 
24
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Crosssell
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //base url
11
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
12
+ //config passcode
13
  $passcode = Mage::helper('ddg')->getPasscode();
14
  //last quote id for dynamic page
15
+ $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
16
 
17
+ if ( ! strlen($passcode)) {
18
+ $passcode = '[PLEASE SET UP A PASSCODE]';
19
+ }
20
+ //alert message for last order id is not mapped
21
+ if ( ! $lastQuoteId) {
22
  $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
23
+ }
24
 
25
+ //full url for dynamic content
26
+ $text = sprintf(
27
+ '%sconnector/quoteproducts/crosssell/code/%s/quote_id/@%s@',
28
+ $baseUrl, $passcode, $lastQuoteId
29
+ );
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Related.php CHANGED
@@ -1,25 +1,33 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Related extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
- //passcode to append for url
8
  $passcode = Mage::helper('ddg')->getPasscode();
9
  //last quote id for dynamic page
10
  $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
11
 
12
- if (!strlen($passcode))
13
  $passcode = '[PLEASE SET UP A PASSCODE]';
 
14
  //alert message for last order id is not mapped
15
- if (!$lastQuoteId)
16
  $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
 
17
 
18
- //generate the base url and display for default store id
19
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
20
 
21
- //display the full url
22
- $text = sprintf('%sconnector/quoteproducts/related/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId);
 
 
 
23
  $element->setData('value', $text);
24
 
25
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Related
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
+ //passcode to append for url
11
  $passcode = Mage::helper('ddg')->getPasscode();
12
  //last quote id for dynamic page
13
  $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
14
 
15
+ if ( ! strlen($passcode)) {
16
  $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ }
18
  //alert message for last order id is not mapped
19
+ if ( ! $lastQuoteId) {
20
  $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
21
+ }
22
 
23
+ //generate the base url and display for default store id
24
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
25
 
26
+ //display the full url
27
+ $text = sprintf(
28
+ '%sconnector/quoteproducts/related/code/%s/quote_id/@%s@', $baseUrl,
29
+ $passcode, $lastQuoteId
30
+ );
31
  $element->setData('value', $text);
32
 
33
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Upsell.php CHANGED
@@ -1,23 +1,32 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Upsell extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
5
  {
6
  //passcode to append for url
7
  $passcode = Mage::helper('ddg')->getPasscode();
8
  //last quote id for dynamic page
9
  $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
10
 
11
- if (!strlen($passcode))
12
  $passcode = '[PLEASE SET UP A PASSCODE]';
 
13
  //alert message for last order id is not mapped
14
- if (!$lastQuoteId)
15
  $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
 
 
 
 
16
 
17
- //generate the base url and display for default store id
18
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
19
-
20
- $text = sprintf('%sconnector/quoteproducts/upsell/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId);
21
  $element->setData('value', $text);
22
 
23
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Upsell
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //passcode to append for url
11
  $passcode = Mage::helper('ddg')->getPasscode();
12
  //last quote id for dynamic page
13
  $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
14
 
15
+ if ( ! strlen($passcode)) {
16
  $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ }
18
  //alert message for last order id is not mapped
19
+ if ( ! $lastQuoteId) {
20
  $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
21
+ }
22
+
23
+ //generate the base url and display for default store id
24
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
25
 
26
+ $text = sprintf(
27
+ '%sconnector/quoteproducts/upsell/code/%s/quote_id/@%s@', $baseUrl,
28
+ $passcode, $lastQuoteId
29
+ );
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php CHANGED
@@ -1,21 +1,28 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Bestsellers extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /** label */
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 
 
7
 
8
- //base url
9
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
10
 
11
- //config passcode
12
  $passcode = Mage::helper('ddg')->getPasscode();
13
 
14
- if (!strlen($passcode))
15
- $passcode = '[PLEASE SET UP A PASSCODE]';
 
16
 
17
- //full url
18
- $text = sprintf('%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode);
 
 
19
  $element->setData('value', $text);
20
  $element->setData('disabled', 'disabled');
21
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Bestsellers
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /** label */
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
+ {
11
 
12
+ //base url
13
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
14
 
15
+ //config passcode
16
  $passcode = Mage::helper('ddg')->getPasscode();
17
 
18
+ if ( ! strlen($passcode)) {
19
+ $passcode = '[PLEASE SET UP A PASSCODE]';
20
+ }
21
 
22
+ //full url
23
+ $text = sprintf(
24
+ '%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode
25
+ );
26
  $element->setData('value', $text);
27
  $element->setData('disabled', 'disabled');
28
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php CHANGED
@@ -1,25 +1,31 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Couponinfo extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /** label */
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
- //base url
9
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
10
 
11
 
12
- //config code
13
  $code = Mage::helper('ddg')->getPasscode();
14
 
15
- if (!strlen($code))
16
  $code = '[PLEASE SET UP A PASSCODE]';
 
17
 
18
- //full url
19
- $text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/'. $code . '/@EMAIL@';
 
20
 
21
  $element->setData('value', $text);
22
  $element->setData('disabled', 'disabled');
 
23
  return parent::_getElementHtml($element);
24
  }
25
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Couponinfo
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /** label */
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
  {
11
+ //base url
12
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
13
 
14
 
15
+ //config code
16
  $code = Mage::helper('ddg')->getPasscode();
17
 
18
+ if ( ! strlen($code)) {
19
  $code = '[PLEASE SET UP A PASSCODE]';
20
+ }
21
 
22
+ //full url
23
+ $text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/'
24
+ . $code . '/@EMAIL@';
25
 
26
  $element->setData('value', $text);
27
  $element->setData('disabled', 'disabled');
28
+
29
  return parent::_getElementHtml($element);
30
  }
31
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php CHANGED
@@ -1,21 +1,29 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Creditmemonew extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
 
7
- //base url
8
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
 
9
 
10
- //config code
 
 
 
11
  $code = Mage::helper('ddg')->getPasscode();
12
  $orderId = Mage::helper('ddg')->getMappedOrderId();
13
 
14
- //message to set up the passcode
15
- if (!strlen($code))
16
  $code = '[PLEASE SET UP A PASSCODE]';
17
- //full url for dynamic content
18
- $text = sprintf('%s/connector/creditmemo/new/code/%s/id/@%s@', $baseUrl, $code, $orderId);
 
 
 
 
19
 
20
  $element->setData('value', $text);
21
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Creditmemonew
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
 
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
+ {
10
 
11
+ //base url
12
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
13
+
14
+ //config code
15
  $code = Mage::helper('ddg')->getPasscode();
16
  $orderId = Mage::helper('ddg')->getMappedOrderId();
17
 
18
+ //message to set up the passcode
19
+ if ( ! strlen($code)) {
20
  $code = '[PLEASE SET UP A PASSCODE]';
21
+ }
22
+ //full url for dynamic content
23
+ $text = sprintf(
24
+ '%s/connector/creditmemo/new/code/%s/id/@%s@', $baseUrl, $code,
25
+ $orderId
26
+ );
27
 
28
  $element->setData('value', $text);
29
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Crosssell.php CHANGED
@@ -1,24 +1,32 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Crosssell extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
  //base url
8
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
9
- //config passcode
10
  $passcode = Mage::helper('ddg')->getPasscode();
11
  //last order id for dynamic page
12
- $lastOrderId = Mage::helper('ddg')->getLastOrderId();
13
 
14
- if (!strlen($passcode))
15
- $passcode = '[PLEASE SET UP A PASSCODE]';
16
- //alert message for last order id is not mapped
17
- if (!$lastOrderId)
18
- $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
 
 
19
 
20
- //full url for dynamic content
21
- $text = sprintf('%sconnector/products/crosssell/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId);
 
 
 
22
  $element->setData('value', $text);
23
 
24
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Crosssell
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //base url
11
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
12
+ //config passcode
13
  $passcode = Mage::helper('ddg')->getPasscode();
14
  //last order id for dynamic page
15
+ $lastOrderId = Mage::helper('ddg')->getLastOrderId();
16
 
17
+ if ( ! strlen($passcode)) {
18
+ $passcode = '[PLEASE SET UP A PASSCODE]';
19
+ }
20
+ //alert message for last order id is not mapped
21
+ if ( ! $lastOrderId) {
22
+ $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
23
+ }
24
 
25
+ //full url for dynamic content
26
+ $text = sprintf(
27
+ '%sconnector/products/crosssell/code/%s/order_id/@%s@', $baseUrl,
28
+ $passcode, $lastOrderId
29
+ );
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Datafieldbutton.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  protected function _getAddRowButtonHtml($title)
6
  {
7
  return $this->getLayout()->createBlock('adminhtml/widget_button')
@@ -11,11 +13,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton exten
11
  ->toHtml();
12
  }
13
 
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
15
  {
16
  $this->setElement($element);
17
  $originalData = $element->getOriginalData();
18
 
19
- return $this->_getAddRowButtonHtml($this->__($originalData['button_label']));
 
 
20
  }
21
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  protected function _getAddRowButtonHtml($title)
8
  {
9
  return $this->getLayout()->createBlock('adminhtml/widget_button')
13
  ->toHtml();
14
  }
15
 
16
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
17
+ )
18
  {
19
  $this->setElement($element);
20
  $originalData = $element->getOriginalData();
21
 
22
+ return $this->_getAddRowButtonHtml(
23
+ $this->__($originalData['button_label'])
24
+ );
25
  }
26
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackchooser.php CHANGED
@@ -1,20 +1,23 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackchooser extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Choose Products"));
10
  }
11
 
12
  protected function _getAddRowButtonHtml($title)
13
  {
14
  $action = 'getFallbackProductChooser(\'' . Mage::getUrl(
15
- '*/widget_chooser/product/form/fallback_product_selector',
16
- array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
17
- ) . '?isAjax=true\'); return false;';
18
 
19
  return $this->getLayout()->createBlock('adminhtml/widget_button')
20
  ->setType('button')
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackchooser
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Choose Products"));
13
  }
14
 
15
  protected function _getAddRowButtonHtml($title)
16
  {
17
  $action = 'getFallbackProductChooser(\'' . Mage::getUrl(
18
+ '*/widget_chooser/product/form/fallback_product_selector',
19
+ array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
20
+ ) . '?isAjax=true\'); return false;';
21
 
22
  return $this->getLayout()->createBlock('adminhtml/widget_button')
23
  ->setType('button')
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackcontainer.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackcontainer extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
- {
8
  $this->setElement($element);
 
9
  return
10
  "<script type='text/javascript'>
11
  var fallback_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_fallback_products_product_list');
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackcontainer
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ ) {
9
  $this->setElement($element);
10
+
11
  return
12
  "<script type='text/javascript'>
13
  var fallback_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_fallback_products_product_list');
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Feefo/Reviews.php CHANGED
@@ -1,20 +1,27 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Reviews extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
  //passcode to append for url
8
  $passcode = Mage::helper('ddg')->getPasscode();
9
 
10
- if(!strlen($passcode))
11
  $passcode = '[PLEASE SET UP A PASSCODE]';
 
12
 
13
  //generate the base url and display for default store id
14
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
15
 
16
  //display the full url
17
- $text = sprintf('%sconnector/feefo/reviews/code/%s/quote_id/@QUOTE_ID@', $baseUrl, $passcode);
 
 
 
18
  $element->setData('value', $text);
19
 
20
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Reviews
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //passcode to append for url
11
  $passcode = Mage::helper('ddg')->getPasscode();
12
 
13
+ if ( ! strlen($passcode)) {
14
  $passcode = '[PLEASE SET UP A PASSCODE]';
15
+ }
16
 
17
  //generate the base url and display for default store id
18
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
19
 
20
  //display the full url
21
+ $text = sprintf(
22
+ '%sconnector/feefo/reviews/code/%s/quote_id/@QUOTE_ID@', $baseUrl,
23
+ $passcode
24
+ );
25
  $element->setData('value', $text);
26
 
27
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Feefo/Score.php CHANGED
@@ -1,14 +1,18 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Score extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
  //passcode to append for url
8
  $passcode = Mage::helper('ddg')->getPasscode();
9
 
10
- if(!strlen($passcode))
11
  $passcode = '[PLEASE SET UP A PASSCODE]';
 
12
 
13
  //generate the base url and display for default store id
14
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Score
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //passcode to append for url
11
  $passcode = Mage::helper('ddg')->getPasscode();
12
 
13
+ if ( ! strlen($passcode)) {
14
  $passcode = '[PLEASE SET UP A PASSCODE]';
15
+ }
16
 
17
  //generate the base url and display for default store id
18
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Gridlist.php CHANGED
@@ -1,24 +1,28 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Gridlist extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
- * Dynamic contaent dysplay type.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
13
  {
14
  // Get the default HTML for this option
15
  $html = parent::_getElementHtml($element);
16
 
17
 
18
- $jQuery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
 
19
 
20
- $jQuery .=
21
- '<script type="text/javascript">
22
  jQuery.noConflict();
23
  jQuery(document).ready(function() {
24
  var gridOptions = {
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Gridlist
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
+ * Dynamic contaent dysplay type.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ )
16
  {
17
  // Get the default HTML for this option
18
  $html = parent::_getElementHtml($element);
19
 
20
 
21
+ $jQuery
22
+ = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
23
 
24
+ $jQuery
25
+ .= '<script type="text/javascript">
26
  jQuery.noConflict();
27
  jQuery(document).ready(function() {
28
  var gridOptions = {
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Lostbasket.php CHANGED
@@ -1,30 +1,38 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Lostbasket extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /** label */
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
8
  {
9
- //base url for dynamic content
10
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
11
  $passcode = Mage::helper('ddg')->getPasscode();
12
 
13
- //last quote id for dynamic page
14
- $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
15
 
16
- //config passcode
17
- if(!strlen($passcode))
18
  $passcode = '[PLEASE SET UP A PASSCODE]';
19
- //alert message for last order id is not mapped
20
- if (!$lastQuoteId)
21
- $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
 
 
22
 
23
- // full url
24
 
25
- $text = sprintf("%sconnector/email/basket/code/%s/quote_id/@%s@", $baseUrl, $passcode, $lastQuoteId);
 
 
 
26
 
27
  $element->setData('value', $text);
 
28
  return parent::_getElementHtml($element);
29
  }
30
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Lostbasket
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /** label */
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
  {
11
+ //base url for dynamic content
12
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
13
  $passcode = Mage::helper('ddg')->getPasscode();
14
 
15
+ //last quote id for dynamic page
16
+ $lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
17
 
18
+ //config passcode
19
+ if ( ! strlen($passcode)) {
20
  $passcode = '[PLEASE SET UP A PASSCODE]';
21
+ }
22
+ //alert message for last order id is not mapped
23
+ if ( ! $lastQuoteId) {
24
+ $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
25
+ }
26
 
27
+ // full url
28
 
29
+ $text = sprintf(
30
+ "%sconnector/email/basket/code/%s/quote_id/@%s@", $baseUrl,
31
+ $passcode, $lastQuoteId
32
+ );
33
 
34
  $element->setData('value', $text);
35
+
36
  return parent::_getElementHtml($element);
37
  }
38
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualchooser.php CHANGED
@@ -1,20 +1,23 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualchooser extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $this->setElement($element);
 
9
  return $this->_getAddRowButtonHtml($this->__("Choose Products"));
10
  }
11
 
12
  protected function _getAddRowButtonHtml($title)
13
  {
14
  $action = 'getManualProductChooser(\'' . Mage::getUrl(
15
- '*/widget_chooser/product/form/manual_product_selector',
16
- array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
17
- ) . '?isAjax=true\'); return false;';
18
 
19
  return $this->getLayout()->createBlock('adminhtml/widget_button')
20
  ->setType('button')
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualchooser
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $this->setElement($element);
11
+
12
  return $this->_getAddRowButtonHtml($this->__("Choose Products"));
13
  }
14
 
15
  protected function _getAddRowButtonHtml($title)
16
  {
17
  $action = 'getManualProductChooser(\'' . Mage::getUrl(
18
+ '*/widget_chooser/product/form/manual_product_selector',
19
+ array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
20
+ ) . '?isAjax=true\'); return false;';
21
 
22
  return $this->getLayout()->createBlock('adminhtml/widget_button')
23
  ->setType('button')
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualcontainer.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualcontainer extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
- {
8
  $this->setElement($element);
 
9
  return
10
  "<script type='text/javascript'>
11
  var manual_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_manual_product_search_products_push_items');
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualcontainer
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ ) {
9
  $this->setElement($element);
10
+
11
  return
12
  "<script type='text/javascript'>
13
  var manual_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_manual_product_search_products_push_items');
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php CHANGED
@@ -1,19 +1,25 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Mostviewed extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /** label */
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
- //base url for dynamic content
9
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
10
  $passcode = Mage::helper('ddg')->getPasscode();
11
 
12
- if (!strlen($passcode))
13
- $passcode = '[PLEASE SET UP A PASSCODE]';
 
14
 
15
- //full url for dynamic content
16
- $text = sprintf('%sconnector/report/mostviewed/code/%s', $baseUrl, $passcode);
 
 
17
  $element->setData('value', $text);
18
 
19
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Mostviewed
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /** label */
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
  {
11
+ //base url for dynamic content
12
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
13
  $passcode = Mage::helper('ddg')->getPasscode();
14
 
15
+ if ( ! strlen($passcode)) {
16
+ $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ }
18
 
19
+ //full url for dynamic content
20
+ $text = sprintf(
21
+ '%sconnector/report/mostviewed/code/%s', $baseUrl, $passcode
22
+ );
23
  $element->setData('value', $text);
24
 
25
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Nosto.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Nosto extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- //passcode to append for url
8
- $passcode = Mage::helper('ddg')->getPasscode();
9
-
10
- if(!strlen($passcode))
11
- $passcode = '[PLEASE SET UP A PASSCODE]';
12
-
13
- //generate the base url and display for default store id
14
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
15
-
16
- //display the full url
17
- $text = sprintf('%sconnector/products/nosto/code/%s/slot/@SLOT_NAME@/email/@EMAIL@', $baseUrl, $passcode);
18
- $element->setData('value', $text);
19
-
20
- return parent::_getElementHtml($element);
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php CHANGED
@@ -1,19 +1,25 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Productpush extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /** label */
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
- //generate base url
9
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
10
- $passcode = Mage::helper('ddg')->getPasscode();
11
 
12
- if (!strlen($passcode))
13
- $passcode = '[PLEASE SET UP A PASSCODE]';
 
14
 
15
- //full url for dynamic content
16
- $text = sprintf('%sconnector/products/push/code/%s', $baseUrl, $passcode);
 
 
17
  $element->setData('value', $text);
18
 
19
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Productpush
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /** label */
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
  {
11
+ //generate base url
12
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
13
+ $passcode = Mage::helper('ddg')->getPasscode();
14
 
15
+ if ( ! strlen($passcode)) {
16
+ $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ }
18
 
19
+ //full url for dynamic content
20
+ $text = sprintf(
21
+ '%sconnector/products/push/code/%s', $baseUrl, $passcode
22
+ );
23
  $element->setData('value', $text);
24
 
25
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Recentlyviewed.php CHANGED
@@ -1,21 +1,30 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Recentlyviewed extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
5
  {
6
  //generate base url for dynamic content
7
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
8
 
9
- //config passcode
10
  $passcode = Mage::helper('ddg')->getPasscode();
11
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
12
 
13
- if (!strlen($passcode))
14
- $passcode = '[PLEASE SET UP A PASSCODE]';
15
- if (!$customerId)
16
- $customerId = '[PLEASE MAP THE CUSTOMER ID]';
17
- //dynamic content url
18
- $text = sprintf('%sconnector/report/recentlyviewed/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
 
 
19
  $element->setData('value', $text);
20
 
21
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Recentlyviewed
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //generate base url for dynamic content
11
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
12
 
13
+ //config passcode
14
  $passcode = Mage::helper('ddg')->getPasscode();
15
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
16
 
17
+ if ( ! strlen($passcode)) {
18
+ $passcode = '[PLEASE SET UP A PASSCODE]';
19
+ }
20
+ if ( ! $customerId) {
21
+ $customerId = '[PLEASE MAP THE CUSTOMER ID]';
22
+ }
23
+ //dynamic content url
24
+ $text = sprintf(
25
+ '%sconnector/report/recentlyviewed/code/%s/customer_id/@%s@',
26
+ $baseUrl, $passcode, $customerId
27
+ );
28
  $element->setData('value', $text);
29
 
30
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Related.php CHANGED
@@ -1,24 +1,32 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Related extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
6
  {
7
- //passcode to append for url
8
- $passcode = Mage::helper('ddg')->getPasscode();
9
- //last order id witch information will be generated
10
- $lastOrderId = Mage::helper('ddg')->getLastOrderId();
11
 
12
- if(!strlen($passcode))
13
- $passcode = '[PLEASE SET UP A PASSCODE]';
14
- if(!$lastOrderId)
15
- $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
 
 
16
 
17
- //generate the base url and display for default store id
18
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
19
 
20
- //display the full url
21
- $text = sprintf('%sconnector/products/related/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId);
 
 
 
22
  $element->setData('value', $text);
23
 
24
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Related
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
+ //passcode to append for url
11
+ $passcode = Mage::helper('ddg')->getPasscode();
12
+ //last order id witch information will be generated
13
+ $lastOrderId = Mage::helper('ddg')->getLastOrderId();
14
 
15
+ if ( ! strlen($passcode)) {
16
+ $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ }
18
+ if ( ! $lastOrderId) {
19
+ $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
20
+ }
21
 
22
+ //generate the base url and display for default store id
23
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
24
 
25
+ //display the full url
26
+ $text = sprintf(
27
+ '%sconnector/products/related/code/%s/order_id/@%s@', $baseUrl,
28
+ $passcode, $lastOrderId
29
+ );
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Review.php CHANGED
@@ -1,26 +1,33 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Review extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /** label */
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
8
  {
9
  //passcode to append for url
10
  $passcode = Mage::helper('ddg')->getPasscode();
11
  //last order id witch information will be generated
12
  $lastOrderId = Mage::helper('ddg')->getLastOrderId();
13
 
14
- if(!strlen($passcode))
15
  $passcode = '[PLEASE SET UP A PASSCODE]';
16
- if(!$lastOrderId)
 
17
  $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
 
18
 
19
  //generate the base url and display for default store id
20
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
21
 
22
  //display the full url
23
- $text = sprintf('%sconnector/email/review/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId);
 
 
 
24
  $element->setData('value', $text);
25
 
26
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Review
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /** label */
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
9
+ )
10
  {
11
  //passcode to append for url
12
  $passcode = Mage::helper('ddg')->getPasscode();
13
  //last order id witch information will be generated
14
  $lastOrderId = Mage::helper('ddg')->getLastOrderId();
15
 
16
+ if ( ! strlen($passcode)) {
17
  $passcode = '[PLEASE SET UP A PASSCODE]';
18
+ }
19
+ if ( ! $lastOrderId) {
20
  $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
21
+ }
22
 
23
  //generate the base url and display for default store id
24
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
25
 
26
  //display the full url
27
+ $text = sprintf(
28
+ '%sconnector/email/review/code/%s/order_id/@%s@', $baseUrl,
29
+ $passcode, $lastOrderId
30
+ );
31
  $element->setData('value', $text);
32
 
33
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Upsell.php CHANGED
@@ -1,22 +1,31 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Upsell extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
5
  {
6
  //passcode to append for url
7
  $passcode = Mage::helper('ddg')->getPasscode();
8
- //last order id witch information will be generated
9
  $lastOrderid = Mage::helper('ddg')->getLastOrderId();
10
 
11
- if(!strlen($passcode))
12
- $passcode = '[PLEASE SET UP A PASSCODE]';
13
- if(!$lastOrderid)
14
- $lastOrderid = '[PLEASE MAP THE LAST ORDER ID]';
 
 
 
 
 
15
 
16
- //generate the base url and display for default store id
17
- $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
18
-
19
- $text = sprintf('%sconnector/products/upsell/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderid);
20
  $element->setData('value', $text);
21
 
22
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Upsell
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  //passcode to append for url
11
  $passcode = Mage::helper('ddg')->getPasscode();
12
+ //last order id witch information will be generated
13
  $lastOrderid = Mage::helper('ddg')->getLastOrderId();
14
 
15
+ if ( ! strlen($passcode)) {
16
+ $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ }
18
+ if ( ! $lastOrderid) {
19
+ $lastOrderid = '[PLEASE MAP THE LAST ORDER ID]';
20
+ }
21
+
22
+ //generate the base url and display for default store id
23
+ $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
24
 
25
+ $text = sprintf(
26
+ '%sconnector/products/upsell/code/%s/order_id/@%s@', $baseUrl,
27
+ $passcode, $lastOrderid
28
+ );
29
  $element->setData('value', $text);
30
 
31
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist.php CHANGED
@@ -1,30 +1,39 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
  * label
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return string
10
  */
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
12
  {
13
  //passcode to append for url
14
  $passcode = Mage::helper('ddg')->getPasscode();
15
  //last order id witch information will be generated
16
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
17
 
18
- if(!strlen($passcode))
19
  $passcode = '[PLEASE SET UP A PASSCODE]';
20
- if(!$customerId)
 
21
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
 
22
 
23
  //generate the base url and display for default store id
24
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
25
 
26
  //display the full url
27
- $text = sprintf('%sconnector/email/wishlist/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
28
  $element->setData('value', $text);
29
 
30
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
  * label
9
  *
10
  * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
  * @return string
13
  */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ )
16
  {
17
  //passcode to append for url
18
  $passcode = Mage::helper('ddg')->getPasscode();
19
  //last order id witch information will be generated
20
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
21
 
22
+ if ( ! strlen($passcode)) {
23
  $passcode = '[PLEASE SET UP A PASSCODE]';
24
+ }
25
+ if ( ! $customerId) {
26
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
27
+ }
28
 
29
  //generate the base url and display for default store id
30
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
31
 
32
  //display the full url
33
+ $text = sprintf(
34
+ '%sconnector/email/wishlist/code/%s/customer_id/@%s@', $baseUrl,
35
+ $passcode, $customerId
36
+ );
37
  $element->setData('value', $text);
38
 
39
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Crosssell.php CHANGED
@@ -1,30 +1,39 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Crosssell extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
  * label
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return string
10
  */
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
12
  {
13
  //passcode to append for url
14
  $passcode = Mage::helper('ddg')->getPasscode();
15
  //last order id witch information will be generated
16
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
17
 
18
- if(!strlen($passcode))
19
  $passcode = '[PLEASE SET UP A PASSCODE]';
20
- if(!$customerId)
 
21
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
 
22
 
23
  //generate the base url and display for default store id
24
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
25
 
26
  //display the full url
27
- $text = sprintf('%sconnector/wishlist/crosssell/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
28
  $element->setData('value', $text);
29
 
30
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Crosssell
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
  * label
9
  *
10
  * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
  * @return string
13
  */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ )
16
  {
17
  //passcode to append for url
18
  $passcode = Mage::helper('ddg')->getPasscode();
19
  //last order id witch information will be generated
20
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
21
 
22
+ if ( ! strlen($passcode)) {
23
  $passcode = '[PLEASE SET UP A PASSCODE]';
24
+ }
25
+ if ( ! $customerId) {
26
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
27
+ }
28
 
29
  //generate the base url and display for default store id
30
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
31
 
32
  //display the full url
33
+ $text = sprintf(
34
+ '%sconnector/wishlist/crosssell/code/%s/customer_id/@%s@', $baseUrl,
35
+ $passcode, $customerId
36
+ );
37
  $element->setData('value', $text);
38
 
39
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Related.php CHANGED
@@ -1,30 +1,39 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Related extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
  * label
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return string
10
  */
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
12
  {
13
  //passcode to append for url
14
  $passcode = Mage::helper('ddg')->getPasscode();
15
  //last order id witch information will be generated
16
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
17
 
18
- if(!strlen($passcode))
19
  $passcode = '[PLEASE SET UP A PASSCODE]';
20
- if(!$customerId)
 
21
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
 
22
 
23
  //generate the base url and display for default store id
24
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
25
 
26
  //display the full url
27
- $text = sprintf('%sconnector/wishlist/related/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
28
  $element->setData('value', $text);
29
 
30
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Related
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
  * label
9
  *
10
  * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
  * @return string
13
  */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ )
16
  {
17
  //passcode to append for url
18
  $passcode = Mage::helper('ddg')->getPasscode();
19
  //last order id witch information will be generated
20
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
21
 
22
+ if ( ! strlen($passcode)) {
23
  $passcode = '[PLEASE SET UP A PASSCODE]';
24
+ }
25
+ if ( ! $customerId) {
26
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
27
+ }
28
 
29
  //generate the base url and display for default store id
30
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
31
 
32
  //display the full url
33
+ $text = sprintf(
34
+ '%sconnector/wishlist/related/code/%s/customer_id/@%s@', $baseUrl,
35
+ $passcode, $customerId
36
+ );
37
  $element->setData('value', $text);
38
 
39
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Upsell.php CHANGED
@@ -1,29 +1,39 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Upsell extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
 
4
  /**
5
  * label
6
  *
7
  * @param Varien_Data_Form_Element_Abstract $element
 
8
  * @return string
9
  */
10
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
11
  {
12
  //passcode to append for url
13
  $passcode = Mage::helper('ddg')->getPasscode();
14
  //last order id witch information will be generated
15
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
16
 
17
- if(!strlen($passcode))
18
  $passcode = '[PLEASE SET UP A PASSCODE]';
19
- if(!$customerId)
 
20
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
 
21
 
22
  //generate the base url and display for default store id
23
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
24
 
25
  //display the full url
26
- $text = sprintf('%sconnector/wishlist/upsell/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
27
  $element->setData('value', $text);
28
 
29
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Upsell
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
  * label
9
  *
10
  * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
  * @return string
13
  */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
15
+ )
16
  {
17
  //passcode to append for url
18
  $passcode = Mage::helper('ddg')->getPasscode();
19
  //last order id witch information will be generated
20
  $customerId = Mage::helper('ddg')->getMappedCustomerId();
21
 
22
+ if ( ! strlen($passcode)) {
23
  $passcode = '[PLEASE SET UP A PASSCODE]';
24
+ }
25
+ if ( ! $customerId) {
26
  $customerId = '[PLEASE MAP THE CUSTOMER ID]';
27
+ }
28
 
29
  //generate the base url and display for default store id
30
  $baseUrl = Mage::helper('ddg')->generateDynamicUrl();
31
 
32
  //display the full url
33
+ $text = sprintf(
34
+ '%sconnector/wishlist/upsell/code/%s/customer_id/@%s@', $baseUrl,
35
+ $passcode, $customerId
36
+ );
37
  $element->setData('value', $text);
38
 
39
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Emailapivalidate.php CHANGED
@@ -1,15 +1,18 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
7
  {
8
  $element->setData('onchange', "apiValidation(this.form, this);");
9
 
10
  $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
11
 
12
- $element->setData('after_element_html', "
 
13
  <script>
14
  document.observe('dom:loaded', function(){
15
  apiValidation();
@@ -29,13 +32,15 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate extends Mage
29
  api_user.setStyle({
30
  fontWeight: 'bold',
31
  color: 'green' ,
32
- background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'
 
33
  })
34
  }else{
35
  api_user.setStyle({
36
  fontWeight: 'bold',
37
  color: 'red',
38
- background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'
 
39
  });
40
 
41
  }
@@ -46,7 +51,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate extends Mage
46
  }
47
 
48
  </script>
49
- ");
 
50
 
51
  return parent::_getElementHtml($element);
52
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
8
+ )
9
  {
10
  $element->setData('onchange', "apiValidation(this.form, this);");
11
 
12
  $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
13
 
14
+ $element->setData(
15
+ 'after_element_html', "
16
  <script>
17
  document.observe('dom:loaded', function(){
18
  apiValidation();
32
  api_user.setStyle({
33
  fontWeight: 'bold',
34
  color: 'green' ,
35
+ background: 'transparent url(\""
36
+ . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'
37
  })
38
  }else{
39
  api_user.setStyle({
40
  fontWeight: 'bold',
41
  color: 'red',
42
+ background: 'transparent url(\""
43
+ . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'
44
  });
45
 
46
  }
51
  }
52
 
53
  </script>
54
+ "
55
+ );
56
 
57
  return parent::_getElementHtml($element);
58
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Installation.php CHANGED
@@ -1,19 +1,22 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Core_Block_Template
 
4
  {
5
- public $sections = array(
6
- 'connector_api_credentials',
7
- 'connector_data_mapping',
8
- 'connector_sync_settings',
9
- 'connector_roi_tracking',
10
- 'connector_lost_baskets',
11
- 'connector_reviews',
12
- 'connector_dynamic_content',
13
- 'connector_transactional_emails',
14
- 'connector_configuration',
15
- 'connector_developer_settings'
16
- );
 
 
17
 
18
  /**
19
  * get the website domain.
@@ -27,6 +30,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
27
 
28
  /**
29
  * api username.
 
30
  * @return string
31
  */
32
  public function getApiUsername()
@@ -36,11 +40,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
36
 
37
  /**
38
  * check if the cron is running.
 
39
  * @return bool
40
  */
41
  public function getCronInstalled()
42
  {
43
- return (Mage::helper('ddg')->getCronInstalled())? '1' : '0';
44
  }
45
 
46
  /*
@@ -51,17 +56,18 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
51
  $section = $this->getRequest()->getParam('section');
52
 
53
  // not not track other sections
54
- if (!in_array($section, $this->sections))
55
  return;
 
56
 
57
  $features = array(
58
- 'customer_sync' => $this->getCustomerSync(),
59
- 'guest_sync' => $this->getGuestSync(),
60
  'subscriber_sync' => $this->getSubscriberSync(),
61
- 'order_sync' => $this->getOrderSync(),
62
- 'catalog_sync' => $this->getCatalogSync(),
63
- 'dotmailer_smtp' => $this->getDotmailerSmtp(),
64
- 'roi' => $this->getRoi()
65
  );
66
 
67
  return json_encode($features);
@@ -105,6 +111,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
105
 
106
  /**
107
  * magento version.
 
108
  * @return string
109
  */
110
  public function getMageVersion()
@@ -114,6 +121,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
114
 
115
  /**
116
  * connector version.
 
117
  * @return string
118
  */
119
  public function getConnectorVersion()
@@ -121,41 +129,43 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
121
  return Mage::helper('ddg')->getConnectorVersion();
122
  }
123
 
124
- /**
125
- * Get the api and website names.
126
- * @return mixed|string
127
- */
128
- public function getWebsiteNames()
129
- {
130
-
131
- $data = Mage::helper('ddg')->getStringWebsiteApiAccounts();
132
-
133
- return $data;
134
- }
135
-
136
- /**
137
- * Get the account email.
138
- *
139
- * @return mixed
140
- */
141
- public function getAccountEmail()
142
- {
143
- return Mage::helper('ddg')->getAccountEmail();
144
- }
145
-
146
-
147
- /**
148
- * Use the beacon only on the api connector section.
149
- * @return string
150
- */
151
- protected function _toHtml()
152
- {
153
- $section = $this->getAction()->getRequest()->getParam('section', false);
154
-
155
- if ($section == 'connector_api_credentials') {
156
- return parent::_toHtml();
157
- } else {
158
- return '';
159
- }
160
- }
 
 
161
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation
4
+ extends Mage_Core_Block_Template
5
  {
6
+
7
+ public $sections
8
+ = array(
9
+ 'connector_api_credentials',
10
+ 'connector_data_mapping',
11
+ 'connector_sync_settings',
12
+ 'connector_roi_tracking',
13
+ 'connector_lost_baskets',
14
+ 'connector_reviews',
15
+ 'connector_dynamic_content',
16
+ 'connector_transactional_emails',
17
+ 'connector_configuration',
18
+ 'connector_developer_settings'
19
+ );
20
 
21
  /**
22
  * get the website domain.
30
 
31
  /**
32
  * api username.
33
+ *
34
  * @return string
35
  */
36
  public function getApiUsername()
40
 
41
  /**
42
  * check if the cron is running.
43
+ *
44
  * @return bool
45
  */
46
  public function getCronInstalled()
47
  {
48
+ return (Mage::helper('ddg')->getCronInstalled()) ? '1' : '0';
49
  }
50
 
51
  /*
56
  $section = $this->getRequest()->getParam('section');
57
 
58
  // not not track other sections
59
+ if ( ! in_array($section, $this->sections)) {
60
  return;
61
+ }
62
 
63
  $features = array(
64
+ 'customer_sync' => $this->getCustomerSync(),
65
+ 'guest_sync' => $this->getGuestSync(),
66
  'subscriber_sync' => $this->getSubscriberSync(),
67
+ 'order_sync' => $this->getOrderSync(),
68
+ 'catalog_sync' => $this->getCatalogSync(),
69
+ 'dotmailer_smtp' => $this->getDotmailerSmtp(),
70
+ 'roi' => $this->getRoi()
71
  );
72
 
73
  return json_encode($features);
111
 
112
  /**
113
  * magento version.
114
+ *
115
  * @return string
116
  */
117
  public function getMageVersion()
121
 
122
  /**
123
  * connector version.
124
+ *
125
  * @return string
126
  */
127
  public function getConnectorVersion()
129
  return Mage::helper('ddg')->getConnectorVersion();
130
  }
131
 
132
+ /**
133
+ * Get the api and website names.
134
+ *
135
+ * @return mixed|string
136
+ */
137
+ public function getWebsiteNames()
138
+ {
139
+
140
+ $data = Mage::helper('ddg')->getStringWebsiteApiAccounts();
141
+
142
+ return $data;
143
+ }
144
+
145
+ /**
146
+ * Get the account email.
147
+ *
148
+ * @return mixed
149
+ */
150
+ public function getAccountEmail()
151
+ {
152
+ return Mage::helper('ddg')->getAccountEmail();
153
+ }
154
+
155
+
156
+ /**
157
+ * Use the beacon only on the api connector section.
158
+ *
159
+ * @return string
160
+ */
161
+ protected function _toHtml()
162
+ {
163
+ $section = $this->getAction()->getRequest()->getParam('section', false);
164
+
165
+ if ($section == 'connector_api_credentials') {
166
+ return parent::_toHtml();
167
+ } else {
168
+ return '';
169
+ }
170
+ }
171
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagefour.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessagefour extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- /**
8
- * SMS insert links.
9
- * @param Varien_Data_Form_Element_Abstract $element
10
- *
11
- * @return string
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
14
- {
15
- $element->setData('placeholder', self::DEFAULT_TEXT);
16
- $element->setData('after_element_html',
17
- "<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_four_message', '{{var order_number}}');return false;\">Insert Order Number</a>
18
- <a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_four_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
19
- );
20
- return parent::_getElementHtml($element);
21
- }
22
-
23
-
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessageone.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessageone extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- /**
8
- * SMS insert links.
9
- *
10
- * @param Varien_Data_Form_Element_Abstract $element
11
- *
12
- * @return string
13
- */
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
15
- {
16
- $element->setData('placeholder', self::DEFAULT_TEXT);
17
- $element->setData('after_element_html',
18
-
19
- "<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_one_message', '{{var order_number}}');return false;\">Insert Order Number</a>
20
- <a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_one_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
21
-
22
- <script type='text/javascript'>
23
- function injectText(element,value){
24
- var element_dom=document.getElementById(element);
25
- if(document.selection){
26
- element_dom.focus();
27
- sel=document.selection.createRange();
28
- sel.text=value;
29
- return;
30
- }if(element_dom.selectionStart||element_dom.selectionStart=='0'){
31
- var t_start=element_dom.selectionStart;
32
- var t_end=element_dom.selectionEnd;
33
- var val_start=element_dom.value.substring(0,t_start);
34
- var val_end=element_dom.value.substring(t_end,element_dom.value.length);
35
- element_dom.value=val_start+value+val_end;
36
- }else{
37
- element_dom.value+=value;
38
- }
39
- }
40
- </script>
41
- ");
42
- return parent::_getElementHtml($element);
43
- }
44
-
45
-
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagethree.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessagethree extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- /**
8
- * SMS insert links.
9
- *
10
- * @param Varien_Data_Form_Element_Abstract $element
11
- *
12
- * @return string
13
- */
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
15
- {
16
- $element->setData('placeholder', self::DEFAULT_TEXT);
17
- $element->setData('after_element_html',
18
-
19
- "<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_three_message', '{{var order_number}}');return false;\">Insert Order Number</a>
20
- <a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_three_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
21
- );
22
- return parent::_getElementHtml($element);
23
- }
24
-
25
-
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagetwo.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessagetwo extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- /**
8
- * SMS insert links.
9
- *
10
- * @param Varien_Data_Form_Element_Abstract $element
11
- *
12
- * @return string
13
- */
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
15
- {
16
- $element->setData('placeholder', self::DEFAULT_TEXT);
17
- $element->setData('after_element_html',
18
- "<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_two_message', '{{var order_number}}');return false;\">Insert Order Number</a>
19
- <a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_two_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
20
- );
21
- return parent::_getElementHtml($element);
22
- }
23
-
24
-
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdate.php CHANGED
@@ -1,29 +1,45 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
 
4
  /**
5
- * Generate the urls.
6
- * @param Varien_Data_Form_Element_Abstract $element
7
- *
8
- * @return string
9
- * @throws Mage_Core_Exception
10
- */
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
12
  {
13
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
14
  $website = Mage::app()->getRequest()->getParam('website', false);
15
 
16
  if ($website) {
17
  $website = Mage::app()->getWebsite($website);
18
- $baseUrl = $website->getConfig('web/secure/base_url');
19
  }
20
  $helper = Mage::helper('ddg');
21
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
22
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
23
 
24
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
25
 
26
- $text = sprintf('%sconnector/creditmemo/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
27
 
28
  $element->setData('value', $text);
29
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/creditmemo/update/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
 
44
  $element->setData('value', $text);
45
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdateguest.php CHANGED
@@ -1,28 +1,44 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
 
4
  /**
5
- * Generate the urls.
6
- * @param Varien_Data_Form_Element_Abstract $element
7
- *
8
- * @return string
9
- * @throws Mage_Core_Exception
10
- */
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
12
  {
13
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
14
  $website = Mage::app()->getRequest()->getParam('website', false);
15
 
16
  if ($website) {
17
  $website = Mage::app()->getWebsite($website);
18
- $baseUrl = $website->getConfig('web/secure/base_url');
19
  }
20
  $helper = Mage::helper('ddg');
21
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
22
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
23
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
 
 
 
 
 
 
24
 
25
- $text = sprintf('%sconnector/creditmemo/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
26
  $element->setData('value', $text);
27
 
28
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdateguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
+ if ( ! strlen($passcode)) {
35
+ $passcode = '[PLEASE SET UP A PASSCODE]';
36
+ }
37
 
38
+ $text = sprintf(
39
+ '%sconnector/creditmemo/updateguest/code/%s/order_id/@%s@',
40
+ $baseUrl, $passcode, $orderId
41
+ );
42
  $element->setData('value', $text);
43
 
44
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmation.php CHANGED
@@ -1,32 +1,45 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmation extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /**
7
- * Generate the urls.
8
- *
9
- * @param Varien_Data_Form_Element_Abstract $element
10
- *
11
- * @return string
12
- * @throws Mage_Core_Exception
13
- */
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
15
  {
16
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
17
  $website = Mage::app()->getRequest()->getParam('website', false);
18
 
19
  if ($website) {
20
  $website = Mage::app()->getWebsite($website);
21
- $baseUrl = $website->getConfig('web/secure/base_url');
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
- $helper = Mage::helper('ddg');
24
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
25
- $customerId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID, $website);
26
-
27
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
28
 
29
- $text = sprintf('%sconnector/customer/confirmation/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmation
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
+ }
25
+ $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $customerId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID,
32
+ $website
33
+ );
34
+
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
  }
 
 
 
 
 
38
 
39
+ $text = sprintf(
40
+ '%sconnector/customer/confirmation/code/%s/customer_id/@%s@',
41
+ $baseUrl, $passcode, $customerId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmed.php CHANGED
@@ -1,32 +1,45 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmed extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /**
7
- * Generate the urls.
8
- *
9
- * @param Varien_Data_Form_Element_Abstract $element
10
- *
11
- * @return string
12
- * @throws Mage_Core_Exception
13
- */
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
15
  {
16
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
17
  $website = Mage::app()->getRequest()->getParam('website', false);
18
 
19
  if ($website) {
20
  $website = Mage::app()->getWebsite($website);
21
- $baseUrl = $website->getConfig('web/secure/base_url');
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
- $helper = Mage::helper('ddg');
24
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
25
- $customerId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID, $website);
26
-
27
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
28
 
29
- $text = sprintf('%sconnector/customer/confirmed/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmed
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
+ }
25
+ $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $customerId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID,
32
+ $website
33
+ );
34
+
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
  }
 
 
 
 
 
38
 
39
+ $text = sprintf(
40
+ '%sconnector/customer/confirmed/code/%s/customer_id/@%s@', $baseUrl,
41
+ $passcode, $customerId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customernew.php CHANGED
@@ -1,32 +1,45 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customernew extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
 
6
  /**
7
- * Generate the urls.
8
- *
9
- * @param Varien_Data_Form_Element_Abstract $element
10
- *
11
- * @return string
12
- * @throws Mage_Core_Exception
13
- */
14
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
15
  {
16
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
17
  $website = Mage::app()->getRequest()->getParam('website', false);
18
 
19
  if ($website) {
20
  $website = Mage::app()->getWebsite($website);
21
- $baseUrl = $website->getConfig('web/secure/base_url');
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
- $helper = Mage::helper('ddg');
24
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
25
- $customerId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID, $website);
26
-
27
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
28
 
29
- $text = sprintf('%sconnector/customer/new/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
 
 
 
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customernew
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
 
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
+ }
25
+ $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $customerId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID,
32
+ $website
33
+ );
34
+
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
  }
 
 
 
 
 
38
 
39
+ $text = sprintf(
40
+ '%sconnector/customer/new/code/%s/customer_id/@%s@', $baseUrl,
41
+ $passcode, $customerId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdate.php CHANGED
@@ -1,31 +1,45 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
- * Generate the urls.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- * @throws Mage_Core_Exception
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
14
  {
15
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
16
  $website = Mage::app()->getRequest()->getParam('website', false);
17
 
18
  if ($website) {
19
  $website = Mage::app()->getWebsite($website);
20
- $baseUrl = $website->getConfig('web/secure/base_url');
21
  }
22
  $helper = Mage::helper('ddg');
23
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
25
 
26
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
27
 
28
- $text = sprintf('%sconnector/invoice/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
29
  $element->setData('value', $text);
30
 
31
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/invoice/update/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdateguest.php CHANGED
@@ -1,31 +1,45 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
- * Generate the urls.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- * @throws Mage_Core_Exception
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
14
  {
15
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
16
  $website = Mage::app()->getRequest()->getParam('website', false);
17
 
18
  if ($website) {
19
  $website = Mage::app()->getWebsite($website);
20
- $baseUrl = $website->getConfig('web/secure/base_url');
21
  }
22
  $helper = Mage::helper('ddg');
23
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
25
 
26
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
27
 
28
- $text = sprintf('%sconnector/invoice/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
29
  $element->setData('value', $text);
30
 
31
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdateguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/invoice/updateguest/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemo.php CHANGED
@@ -1,16 +1,19 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
 
5
  /**
6
- * Generate the urls.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- * @throws Mage_Core_Exception
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
14
  {
15
 
16
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
@@ -18,16 +21,27 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo extends Mag
18
 
19
  if ($website) {
20
  $website = Mage::app()->getWebsite($website);
21
- $baseUrl = $website->getConfig('web/secure/base_url');
22
  }
23
  $helper = Mage::helper('ddg');
24
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
25
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
26
-
27
-
28
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
 
 
 
 
 
 
29
 
30
- $text = sprintf('%sconnector/creditmemo/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
31
  $element->setData('value', $text);
32
 
33
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
  /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
 
19
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
21
 
22
  if ($website) {
23
  $website = Mage::app()->getWebsite($website);
24
+ $baseUrl = $website->getConfig('web/secure/base_url');
25
  }
26
  $helper = Mage::helper('ddg');
27
+ $passcode = $helper->getWebsiteConfig(
28
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
29
+ $website
30
+ );
31
+ $orderId = $helper->getWebsiteConfig(
32
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
33
+ $website
34
+ );
35
+
36
+
37
+ if ( ! strlen($passcode)) {
38
+ $passcode = '[PLEASE SET UP A PASSCODE]';
39
+ }
40
 
41
+ $text = sprintf(
42
+ '%sconnector/creditmemo/new/code/%s/order_id/@%s@', $baseUrl,
43
+ $passcode, $orderId
44
+ );
45
  $element->setData('value', $text);
46
 
47
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemoguest.php CHANGED
@@ -1,32 +1,46 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemoguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- /**
6
- * Generate the urls.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- * @throws Mage_Core_Exception
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
14
  {
15
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
16
  $website = Mage::app()->getRequest()->getParam('website', false);
17
 
18
  if ($website) {
19
  $website = Mage::app()->getWebsite($website);
20
- $baseUrl = $website->getConfig('web/secure/base_url');
21
  }
22
  $helper = Mage::helper('ddg');
23
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
25
 
26
 
27
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
28
 
29
- $text = sprintf('%sconnector/creditmemo/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemoguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
 
36
+ if ( ! strlen($passcode)) {
37
+ $passcode = '[PLEASE SET UP A PASSCODE]';
38
+ }
39
 
40
+ $text = sprintf(
41
+ '%sconnector/creditmemo/newguest/code/%s/order_id/@%s@', $baseUrl,
42
+ $passcode, $orderId
43
+ );
44
  $element->setData('value', $text);
45
 
46
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoice.php CHANGED
@@ -1,32 +1,46 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoice extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- /**
6
- * Generate the urls.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- * @throws Mage_Core_Exception
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
14
  {
15
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
16
  $website = Mage::app()->getRequest()->getParam('website', false);
17
 
18
  if ($website) {
19
  $website = Mage::app()->getWebsite($website);
20
- $baseUrl = $website->getConfig('web/secure/base_url');
21
  }
22
  $helper = Mage::helper('ddg');
23
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
25
 
26
 
27
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
28
 
29
- $text = sprintf('%sconnector/invoice/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoice
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
 
36
+ if ( ! strlen($passcode)) {
37
+ $passcode = '[PLEASE SET UP A PASSCODE]';
38
+ }
39
 
40
+ $text = sprintf(
41
+ '%sconnector/invoice/new/code/%s/order_id/@%s@', $baseUrl,
42
+ $passcode, $orderId
43
+ );
44
  $element->setData('value', $text);
45
 
46
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoiceguest.php CHANGED
@@ -1,32 +1,46 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoiceguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
4
  {
5
- /**
6
- * Generate the urls.
7
- *
8
- * @param Varien_Data_Form_Element_Abstract $element
9
- *
10
- * @return string
11
- * @throws Mage_Core_Exception
12
- */
13
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
14
  {
15
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
16
  $website = Mage::app()->getRequest()->getParam('website', false);
17
 
18
  if ($website) {
19
  $website = Mage::app()->getWebsite($website);
20
- $baseUrl = $website->getConfig('web/secure/base_url');
21
  }
22
  $helper = Mage::helper('ddg');
23
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
25
 
26
 
27
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
28
 
29
- $text = sprintf('%sconnector/invoice/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
30
  $element->setData('value', $text);
31
 
32
  return parent::_getElementHtml($element);
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoiceguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
 
36
+ if ( ! strlen($passcode)) {
37
+ $passcode = '[PLEASE SET UP A PASSCODE]';
38
+ }
39
 
40
+ $text = sprintf(
41
+ '%sconnector/invoice/newguest/code/%s/order_id/@%s@', $baseUrl,
42
+ $passcode, $orderId
43
+ );
44
  $element->setData('value', $text);
45
 
46
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworder.php CHANGED
@@ -1,31 +1,46 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworder extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
 
26
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
27
 
28
- $text = sprintf('%sconnector/order/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
29
  $element->setData('value', $text);
30
 
31
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworder
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
 
36
+ if ( ! strlen($passcode)) {
37
+ $passcode = '[PLEASE SET UP A PASSCODE]';
38
+ }
39
 
40
+ $text = sprintf(
41
+ '%sconnector/order/new/code/%s/order_id/@%s@', $baseUrl, $passcode,
42
+ $orderId
43
+ );
44
  $element->setData('value', $text);
45
 
46
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworderguest.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworderguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
26
 
27
- $text = sprintf('%sconnector/order/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
28
  $element->setData('value', $text);
29
 
30
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworderguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/order/newguest/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipment.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipment extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
26
 
27
- $text = sprintf('%sconnector/shipping/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
28
 
29
 
30
  $element->setData('value', $text);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipment
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/shipping/new/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
 
44
 
45
  $element->setData('value', $text);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipmentguest.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipmentguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
26
 
27
- $text = sprintf('%sconnector/shipping/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
28
 
29
  $element->setData('value', $text);
30
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipmentguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/shipping/newguest/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
 
44
  $element->setData('value', $text);
45
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdate.php CHANGED
@@ -1,29 +1,44 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
- $text = sprintf('%sconnector/order/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
 
 
27
  $element->setData('value', $text);
28
 
29
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
+ $text = sprintf(
39
+ '%sconnector/order/update/code/%s/order_id/@%s@', $baseUrl,
40
+ $passcode, $orderId
41
+ );
42
  $element->setData('value', $text);
43
 
44
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdateguest.php CHANGED
@@ -1,29 +1,44 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
- $text = sprintf('%sconnector/order/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
 
 
27
  $element->setData('value', $text);
28
 
29
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdateguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
+ $text = sprintf(
39
+ '%sconnector/order/updateguest/code/%s/order_id/@%s@', $baseUrl,
40
+ $passcode, $orderId
41
+ );
42
  $element->setData('value', $text);
43
 
44
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdate.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
26
 
27
- $text = sprintf('%sconnector/shipping/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
28
 
29
  $element->setData('value', $text);
30
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/shipping/update/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
 
44
  $element->setData('value', $text);
45
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdateguest.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
3
  {
4
- /**
5
- * Generate the urls.
6
- *
7
- * @param Varien_Data_Form_Element_Abstract $element
8
- *
9
- * @return string
10
- * @throws Mage_Core_Exception
11
- */
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 
 
13
  {
14
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
15
  $website = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  if ($website) {
18
  $website = Mage::app()->getWebsite($website);
19
- $baseUrl = $website->getConfig('web/secure/base_url');
20
  }
21
  $helper = Mage::helper('ddg');
22
- $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
- $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
 
 
 
 
 
 
24
 
25
- if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
 
 
26
 
27
- $text = sprintf('%sconnector/shipping/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
 
 
 
28
  $element->setData('value', $text);
29
 
30
  return parent::_getElementHtml($element);
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdateguest
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
+
7
+ /**
8
+ * Generate the urls.
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
16
+ )
17
  {
18
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
19
  $website = Mage::app()->getRequest()->getParam('website', false);
20
 
21
  if ($website) {
22
  $website = Mage::app()->getWebsite($website);
23
+ $baseUrl = $website->getConfig('web/secure/base_url');
24
  }
25
  $helper = Mage::helper('ddg');
26
+ $passcode = $helper->getWebsiteConfig(
27
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
28
+ $website
29
+ );
30
+ $orderId = $helper->getWebsiteConfig(
31
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
32
+ $website
33
+ );
34
 
35
+ if ( ! strlen($passcode)) {
36
+ $passcode = '[PLEASE SET UP A PASSCODE]';
37
+ }
38
 
39
+ $text = sprintf(
40
+ '%sconnector/shipping/updateguest/code/%s/order_id/@%s@', $baseUrl,
41
+ $passcode, $orderId
42
+ );
43
  $element->setData('value', $text);
44
 
45
  return parent::_getElementHtml($element);
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Widget/Chooser/Product.php CHANGED
@@ -1,23 +1,26 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
5
 
6
- public function __construct($arguments=array())
7
  {
8
  parent::__construct($arguments);
9
 
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
 
16
  //change to 10
17
  $this->setDefaultLimit(10);
18
  $form = $this->getJsFormObject();
19
  $this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
20
- $this->setCheckboxCheckCallback("$form.chooserGridCheckboxCheck.bind($form)");
 
 
21
  $this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
22
  $this->setDefaultSort('entity_id');
23
  $this->setUseAjax(true);
@@ -28,6 +31,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
28
 
29
  /**
30
  * Retrieve quote store object
 
31
  * @return Mage_Core_Model_Store
32
  */
33
  public function getStore()
@@ -44,13 +48,18 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
44
  $selected = '';
45
  }
46
  if ($column->getFilter()->getValue()) {
47
- $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$selected));
 
 
48
  } else {
49
- $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$selected));
 
 
50
  }
51
  } else {
52
  parent::_addColumnFilterToCollection($column);
53
  }
 
54
  return $this;
55
  }
56
 
@@ -77,68 +86,85 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
77
  */
78
  protected function _prepareColumns()
79
  {
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
- 'use_index' => true,
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('type',
 
 
 
 
 
98
  array(
99
- 'header'=> Mage::helper('catalog')->__('Type'),
100
- 'width' => '60px',
101
- 'index' => 'type_id',
102
- 'type' => 'options',
103
- 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
104
- ));
 
 
105
 
106
  $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
107
- ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
 
 
108
  ->load()
109
  ->toOptionHash();
110
 
111
- $this->addColumn('set_name',
 
112
  array(
113
- 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
114
- 'width' => '100px',
115
- 'index' => 'attribute_set_id',
116
- 'type' => 'options',
117
  'options' => $sets,
118
- ));
119
-
120
- $this->addColumn('chooser_sku', array(
121
- 'header' => Mage::helper('sales')->__('SKU'),
122
- 'name' => 'chooser_sku',
123
- 'width' => '80px',
124
- 'index' => 'sku'
125
- ));
126
- $this->addColumn('chooser_name', array(
127
- 'header' => Mage::helper('sales')->__('Product Name'),
128
- 'name' => 'chooser_name',
129
- 'index' => 'name'
130
- ));
 
 
 
 
 
131
 
132
  return parent::_prepareColumns();
133
  }
134
 
135
  public function getGridUrl()
136
  {
137
- return $this->getUrl('*/*/product', array(
138
- '_current' => true,
139
- 'current_grid_id' => $this->getId(),
140
- 'collapse' => null
141
- ));
 
 
142
  }
143
 
144
  protected function _getSelectedProducts()
@@ -152,11 +178,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
152
  * set default limit
153
  *
154
  * @param $limit
 
155
  * @return $this
156
  */
157
  public function setDefaultLimit($limit)
158
  {
159
  $this->_defaultLimit = $limit;
 
160
  return $this;
161
  }
162
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
 
7
+ public function __construct($arguments = array())
8
  {
9
  parent::__construct($arguments);
10
 
11
  if ($this->getRequest()->getParam('current_grid_id')) {
12
  $this->setId($this->getRequest()->getParam('current_grid_id'));
13
  } else {
14
+ $this->setId('skuChooserGrid_' . $this->getId());
15
  }
16
 
17
  //change to 10
18
  $this->setDefaultLimit(10);
19
  $form = $this->getJsFormObject();
20
  $this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
21
+ $this->setCheckboxCheckCallback(
22
+ "$form.chooserGridCheckboxCheck.bind($form)"
23
+ );
24
  $this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
25
  $this->setDefaultSort('entity_id');
26
  $this->setUseAjax(true);
31
 
32
  /**
33
  * Retrieve quote store object
34
+ *
35
  * @return Mage_Core_Model_Store
36
  */
37
  public function getStore()
48
  $selected = '';
49
  }
50
  if ($column->getFilter()->getValue()) {
51
+ $this->getCollection()->addFieldToFilter(
52
+ 'entity_id', array('in' => $selected)
53
+ );
54
  } else {
55
+ $this->getCollection()->addFieldToFilter(
56
+ 'entity_id', array('nin' => $selected)
57
+ );
58
  }
59
  } else {
60
  parent::_addColumnFilterToCollection($column);
61
  }
62
+
63
  return $this;
64
  }
65
 
86
  */
87
  protected function _prepareColumns()
88
  {
89
+ $this->addColumn(
90
+ 'in_products', array(
91
+ 'header_css_class' => 'a-center',
92
+ 'type' => 'checkbox',
93
+ 'name' => 'in_products',
94
+ 'values' => $this->_getSelectedProducts(),
95
+ 'align' => 'center',
96
+ 'index' => 'entity_id',
97
+ 'use_index' => true,
98
+ )
99
+ );
100
+
101
+ $this->addColumn(
102
+ 'entity_id', array(
103
+ 'header' => Mage::helper('sales')->__('ID'),
104
+ 'sortable' => true,
105
+ 'width' => '60px',
106
+ 'index' => 'entity_id'
107
+ )
108
+ );
109
+
110
+ $this->addColumn(
111
+ 'type',
112
  array(
113
+ 'header' => Mage::helper('catalog')->__('Type'),
114
+ 'width' => '60px',
115
+ 'index' => 'type_id',
116
+ 'type' => 'options',
117
+ 'options' => Mage::getSingleton('catalog/product_type')
118
+ ->getOptionArray(),
119
+ )
120
+ );
121
 
122
  $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
123
+ ->setEntityTypeFilter(
124
+ Mage::getModel('catalog/product')->getResource()->getTypeId()
125
+ )
126
  ->load()
127
  ->toOptionHash();
128
 
129
+ $this->addColumn(
130
+ 'set_name',
131
  array(
132
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
133
+ 'width' => '100px',
134
+ 'index' => 'attribute_set_id',
135
+ 'type' => 'options',
136
  'options' => $sets,
137
+ )
138
+ );
139
+
140
+ $this->addColumn(
141
+ 'chooser_sku', array(
142
+ 'header' => Mage::helper('sales')->__('SKU'),
143
+ 'name' => 'chooser_sku',
144
+ 'width' => '80px',
145
+ 'index' => 'sku'
146
+ )
147
+ );
148
+ $this->addColumn(
149
+ 'chooser_name', array(
150
+ 'header' => Mage::helper('sales')->__('Product Name'),
151
+ 'name' => 'chooser_name',
152
+ 'index' => 'name'
153
+ )
154
+ );
155
 
156
  return parent::_prepareColumns();
157
  }
158
 
159
  public function getGridUrl()
160
  {
161
+ return $this->getUrl(
162
+ '*/*/product', array(
163
+ '_current' => true,
164
+ 'current_grid_id' => $this->getId(),
165
+ 'collapse' => null
166
+ )
167
+ );
168
  }
169
 
170
  protected function _getSelectedProducts()
178
  * set default limit
179
  *
180
  * @param $limit
181
+ *
182
  * @return $this
183
  */
184
  public function setDefaultLimit($limit)
185
  {
186
  $this->_defaultLimit = $limit;
187
+
188
  return $this;
189
  }
190
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist.php CHANGED
@@ -1,14 +1,16 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist extends Mage_Adminhtml_Block_Widget_Grid_Container
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
8
 
9
- $this->_controller = 'adminhtml_wishlist';
10
- $this->_blockGroup = 'ddg_automation';
11
- $this->_headerText = Mage::helper('ddg')->__('Email Wishlist(s)');
12
 
13
  $this->_removeButton('add');
14
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist
4
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
10
 
11
+ $this->_controller = 'adminhtml_wishlist';
12
+ $this->_blockGroup = 'ddg_automation';
13
+ $this->_headerText = Mage::helper('ddg')->__('Email Wishlist(s)');
14
 
15
  $this->_removeButton('add');
16
  }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist/Grid.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid extends Mage_Adminhtml_Block_Widget_Grid
 
4
  {
 
5
  public function __construct()
6
  {
7
  parent::__construct();
@@ -13,9 +15,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid extends Mage_Adminhtml
13
  }
14
 
15
  /**
16
- * Collection class;
17
- * @return string
18
- */
 
19
  protected function _getCollectionClass()
20
  {
21
  // This is the model we are using for the grid
@@ -23,93 +26,121 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid extends Mage_Adminhtml
23
  }
24
 
25
  /**
26
- * Prepare the grid collection.
27
- * @return Mage_Adminhtml_Block_Widget_Grid
28
- */
 
29
  protected function _prepareCollection()
30
  {
31
  // Get and set our collection for the grid
32
  $collection = Mage::getResourceModel($this->_getCollectionClass());
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
  /**
38
- * Prepare the grid collumns.
39
- * @return $this
40
- * @throws Exception
41
- */
 
42
  protected function _prepareColumns()
43
  {
44
- $this->addColumn('wishlist_id', array(
45
- 'header' => Mage::helper('ddg')->__('Wishlist ID'),
46
- 'align' => 'left',
47
- 'width' => '50px',
48
- 'index' => 'wishlist_id',
49
- 'type' => 'number',
50
- 'escape' => true
51
- ))->addColumn('customer_id', array(
52
- 'header' => Mage::helper('ddg')->__('Customer ID'),
53
- 'align' => 'left',
54
- 'width' => '50px',
55
- 'index' => 'customer_id',
56
- 'type' => 'number',
57
- 'escape' => true
58
- ))->addColumn('item_count', array(
59
- 'header' => Mage::helper('ddg')->__('Item Count'),
60
- 'align' => 'left',
61
- 'width' => '50px',
62
- 'index' => 'item_count',
63
- 'type' => 'number',
64
- 'escape' => true
65
- ))->addColumn('wishlist_imported', array(
66
- 'header' => Mage::helper('ddg')->__('Wishlist Imported'),
67
- 'align' => 'center',
68
- 'width' => '50px',
69
- 'index' => 'wishlist_imported',
70
- 'type' => 'options',
71
- 'escape' => true,
72
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
73
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
74
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
75
- ))->addColumn('wishlist_modified', array(
76
- 'header' => Mage::helper('ddg')->__('Wishlist Modified'),
77
- 'align' => 'center',
78
- 'width' => '50px',
79
- 'index' => 'wishlist_modified',
80
- 'type' => 'options',
81
- 'escape' => true,
82
- 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
83
- 'options' => Mage::getModel('ddg_automation/adminhtml_source_contact_imported')->getOptions(),
84
- 'filter_condition_callback' => array($this, 'filterCallbackContact')
85
- ))->addColumn('created_at', array(
86
- 'header' => Mage::helper('ddg')->__('Created At'),
87
- 'width' => '50px',
88
- 'align' => 'center',
89
- 'index' => 'created_at',
90
- 'type' => 'datetime',
91
- 'escape' => true,
92
- ))->addColumn('updated_at', array(
93
- 'header' => Mage::helper('ddg')->__('Updated At'),
94
- 'width' => '50px',
95
- 'align' => 'center',
96
- 'index' => 'updated_at',
97
- 'type' => 'datetime',
98
- 'escape' => true,
99
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  return parent::_prepareColumns();
102
  }
103
 
104
  /**
105
- * Callback action for the imported subscribers/contacts.
106
- *
107
- * @param $collection
108
- * @param $column
109
- */
110
  public function filterCallbackContact($collection, $column)
111
  {
112
- $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
 
113
  $value = $column->getFilter()->getValue();
114
  if ($value == 'null') {
115
  $collection->addFieldToFilter($field, array('null' => true));
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid
4
+ extends Mage_Adminhtml_Block_Widget_Grid
5
  {
6
+
7
  public function __construct()
8
  {
9
  parent::__construct();
15
  }
16
 
17
  /**
18
+ * Collection class;
19
+ *
20
+ * @return string
21
+ */
22
  protected function _getCollectionClass()
23
  {
24
  // This is the model we are using for the grid
26
  }
27
 
28
  /**
29
+ * Prepare the grid collection.
30
+ *
31
+ * @return Mage_Adminhtml_Block_Widget_Grid
32
+ */
33
  protected function _prepareCollection()
34
  {
35
  // Get and set our collection for the grid
36
  $collection = Mage::getResourceModel($this->_getCollectionClass());
37
  $this->setCollection($collection);
38
+
39
  return parent::_prepareCollection();
40
  }
41
 
42
  /**
43
+ * Prepare the grid collumns.
44
+ *
45
+ * @return $this
46
+ * @throws Exception
47
+ */
48
  protected function _prepareColumns()
49
  {
50
+ $this->addColumn(
51
+ 'wishlist_id', array(
52
+ 'header' => Mage::helper('ddg')->__('Wishlist ID'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'wishlist_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ )
59
+ )->addColumn(
60
+ 'customer_id', array(
61
+ 'header' => Mage::helper('ddg')->__('Customer ID'),
62
+ 'align' => 'left',
63
+ 'width' => '50px',
64
+ 'index' => 'customer_id',
65
+ 'type' => 'number',
66
+ 'escape' => true
67
+ )
68
+ )->addColumn(
69
+ 'item_count', array(
70
+ 'header' => Mage::helper('ddg')->__('Item Count'),
71
+ 'align' => 'left',
72
+ 'width' => '50px',
73
+ 'index' => 'item_count',
74
+ 'type' => 'number',
75
+ 'escape' => true
76
+ )
77
+ )->addColumn(
78
+ 'wishlist_imported', array(
79
+ 'header' => Mage::helper('ddg')->__(
80
+ 'Wishlist Imported'
81
+ ),
82
+ 'align' => 'center',
83
+ 'width' => '50px',
84
+ 'index' => 'wishlist_imported',
85
+ 'type' => 'options',
86
+ 'escape' => true,
87
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
88
+ 'options' => Mage::getModel(
89
+ 'ddg_automation/adminhtml_source_contact_imported'
90
+ )->getOptions(),
91
+ 'filter_condition_callback' => array($this,
92
+ 'filterCallbackContact')
93
+ )
94
+ )->addColumn(
95
+ 'wishlist_modified', array(
96
+ 'header' => Mage::helper('ddg')->__(
97
+ 'Wishlist Modified'
98
+ ),
99
+ 'align' => 'center',
100
+ 'width' => '50px',
101
+ 'index' => 'wishlist_modified',
102
+ 'type' => 'options',
103
+ 'escape' => true,
104
+ 'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
105
+ 'options' => Mage::getModel(
106
+ 'ddg_automation/adminhtml_source_contact_imported'
107
+ )->getOptions(),
108
+ 'filter_condition_callback' => array($this,
109
+ 'filterCallbackContact')
110
+ )
111
+ )->addColumn(
112
+ 'created_at', array(
113
+ 'header' => Mage::helper('ddg')->__('Created At'),
114
+ 'width' => '50px',
115
+ 'align' => 'center',
116
+ 'index' => 'created_at',
117
+ 'type' => 'datetime',
118
+ 'escape' => true,
119
+ )
120
+ )->addColumn(
121
+ 'updated_at', array(
122
+ 'header' => Mage::helper('ddg')->__('Updated At'),
123
+ 'width' => '50px',
124
+ 'align' => 'center',
125
+ 'index' => 'updated_at',
126
+ 'type' => 'datetime',
127
+ 'escape' => true,
128
+ )
129
+ );
130
 
131
  return parent::_prepareColumns();
132
  }
133
 
134
  /**
135
+ * Callback action for the imported subscribers/contacts.
136
+ *
137
+ * @param $collection
138
+ * @param $column
139
+ */
140
  public function filterCallbackContact($collection, $column)
141
  {
142
+ $field = $column->getFilterIndex() ? $column->getFilterIndex()
143
+ : $column->getIndex();
144
  $value = $column->getFilter()->getValue();
145
  if ($value == 'null') {
146
  $collection->addFieldToFilter($field, array('null' => true));
app/code/community/Dotdigitalgroup/Email/Block/Basket.php CHANGED
@@ -2,123 +2,137 @@
2
 
3
  class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
4
  {
 
5
  protected $_quote;
6
 
7
  /**
8
- * Basket itmes.
9
- *
10
- * @return mixed
11
- * @throws Exception
12
- * @throws Mage_Core_Exception
13
- */
14
  public function getBasketItems()
15
  {
16
  $params = $this->getRequest()->getParams();
17
 
18
- if (! isset($params['quote_id']) || !isset($params['code'])){
19
  Mage::helper('ddg')->log('Basket no quote id or code is set');
 
20
  return false;
21
  }
22
 
23
- $quoteId = $params['quote_id'];
24
- $quoteModel = Mage::getModel('sales/quote')->load($quoteId);
 
 
 
 
25
 
26
- //check for any quote for this email, don't want to render further
27
- if (! $quoteModel->getId()) {
28
- Mage::helper('ddg')->log('no quote found for '. $quoteId);
29
  return false;
30
- }
31
- if (! $quoteModel->getIsActive()) {
32
- Mage::helper('ddg')->log('Cart is not active : '. $quoteId);
33
- return false;
34
- }
35
 
36
- $this->_quote = $quoteModel;
 
37
 
38
- //Start environment emulation of the specified store
39
- $storeId = $quoteModel->getStoreId();
40
- $appEmulation = Mage::getSingleton('core/app_emulation');
41
- $appEmulation->startEnvironmentEmulation($storeId);
42
 
43
- $quoteItems = $quoteModel->getAllItems();
44
- $itemsData = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- foreach ( $quoteItems as $quoteItem ) {
47
- if ($quoteItem->getParentItemId() != null)
48
- continue;
49
- $_product = Mage::getModel('catalog/product')->load($quoteItem->getProductId());
50
 
51
- $inStock = ($_product->getStockItem()->getIsInStock())? 'In Stock' : 'Out of stock';
52
- $total = Mage::helper('core')->currency($quoteItem->getBaseRowTotalInclTax());
53
- $productUrl = $_product->getProductUrl();
54
- $grandTotal = Mage::helper('core')->currency($this->getGrandTotal());
55
- $itemsData[] = array(
56
- 'grandTotal' => $grandTotal,
57
- 'total' => $total,
58
- 'inStock' => $inStock,
59
- 'productUrl' => $productUrl,
60
- 'product' => $_product,
61
- 'qty' => $quoteItem->getQty()
62
 
63
- );
64
- }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
- return $itemsData;
 
 
 
 
69
  }
70
 
 
71
  /**
72
- * Grand total.
73
- *
74
- * @return mixed
75
- */
76
- public function getGrandTotal()
77
  {
78
- return $this->_quote->getGrandTotal();
79
 
 
 
 
80
  }
81
- /**
82
- * url for "take me to basket" link
83
- *
84
- * @return string
85
- */
86
- public function getUrlForLink()
87
- {
88
- return $this->_quote->getStore()->getUrl(
89
- 'connector/email/getbasket',
90
- array('quote_id' => $this->_quote->getId())
91
- );
92
- }
93
-
94
- /**
95
- * can show go to basket url
96
- *
97
- * @return bool
98
- */
99
- public function canShowUrl()
100
- {
101
- return (boolean) $this->_quote->getStore()->getWebsite()->getConfig(
102
- Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_ENABLED
103
- );
104
- }
105
-
106
- public function takeMeToCartTextForUrl()
107
- {
108
- return $this->_quote->getStore()->getWebsite()->getConfig(
109
- Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_TEXT
110
- );
111
- }
112
-
113
-
114
- /**
115
- * Get dynamic style configuration.
116
- * @return array
117
- */
118
- protected function getDynamicStyle() {
119
-
120
- $dynamicStyle = Mage::helper('ddg')->getDynamicStyles();
121
- return $dynamicStyle;
122
- }
123
 
124
  }
2
 
3
  class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
4
  {
5
+
6
  protected $_quote;
7
 
8
  /**
9
+ * Basket itmes.
10
+ *
11
+ * @return mixed
12
+ * @throws Exception
13
+ * @throws Mage_Core_Exception
14
+ */
15
  public function getBasketItems()
16
  {
17
  $params = $this->getRequest()->getParams();
18
 
19
+ if ( ! isset($params['quote_id']) || ! isset($params['code'])) {
20
  Mage::helper('ddg')->log('Basket no quote id or code is set');
21
+
22
  return false;
23
  }
24
 
25
+ $quoteId = $params['quote_id'];
26
+ $quoteModel = Mage::getModel('sales/quote')->load($quoteId);
27
+
28
+ //check for any quote for this email, don't want to render further
29
+ if ( ! $quoteModel->getId()) {
30
+ Mage::helper('ddg')->log('no quote found for ' . $quoteId);
31
 
 
 
 
32
  return false;
33
+ }
34
+ if ( ! $quoteModel->getIsActive()) {
35
+ Mage::helper('ddg')->log('Cart is not active : ' . $quoteId);
 
 
36
 
37
+ return false;
38
+ }
39
 
40
+ $this->_quote = $quoteModel;
 
 
 
41
 
42
+ //Start environment emulation of the specified store
43
+ $storeId = $quoteModel->getStoreId();
44
+ $appEmulation = Mage::getSingleton('core/app_emulation');
45
+ $appEmulation->startEnvironmentEmulation($storeId);
46
+
47
+ $quoteItems = $quoteModel->getAllItems();
48
+
49
+ $itemsData = array();
50
+
51
+ foreach ($quoteItems as $quoteItem) {
52
+ if ($quoteItem->getParentItemId() != null) {
53
+ continue;
54
+ }
55
+
56
+ $_product = $quoteItem->getProduct();
57
+ $inStock = ($_product->getStockItem()->getIsInStock())
58
+ ? 'In Stock'
59
+ : 'Out of stock';
60
+ $total = Mage::helper('core')->currency(
61
+ $quoteItem->getBaseRowTotalInclTax()
62
+ );
63
+ $productUrl = $_product->getProductUrl();
64
+ $grandTotal = Mage::helper('core')->currency(
65
+ $this->getGrandTotal()
66
+ );
67
+ $itemsData[] = array(
68
+ 'grandTotal' => $grandTotal,
69
+ 'total' => $total,
70
+ 'inStock' => $inStock,
71
+ 'productUrl' => $productUrl,
72
+ 'product' => $_product,
73
+ 'qty' => $quoteItem->getQty()
74
+
75
+ );
76
+ }
77
 
78
+ return $itemsData;
79
+ }
 
 
80
 
81
+ /**
82
+ * Grand total.
83
+ *
84
+ * @return mixed
85
+ */
86
+ public function getGrandTotal()
87
+ {
88
+ return $this->_quote->getGrandTotal();
 
 
 
89
 
90
+ }
 
91
 
92
+ /**
93
+ * url for "take me to basket" link
94
+ *
95
+ * @return string
96
+ */
97
+ public function getUrlForLink()
98
+ {
99
+ return $this->_quote->getStore()->getUrl(
100
+ 'connector/email/getbasket',
101
+ array('quote_id' => $this->_quote->getId())
102
+ );
103
+ }
104
 
105
+ /**
106
+ * can show go to basket url
107
+ *
108
+ * @return bool
109
+ */
110
+ public function canShowUrl()
111
+ {
112
+ return (boolean)$this->_quote->getStore()->getWebsite()->getConfig(
113
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_ENABLED
114
+ );
115
+ }
116
 
117
+ public function takeMeToCartTextForUrl()
118
+ {
119
+ return $this->_quote->getStore()->getWebsite()->getConfig(
120
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_TEXT
121
+ );
122
  }
123
 
124
+
125
  /**
126
+ * Get dynamic style configuration.
127
+ *
128
+ * @return array
129
+ */
130
+ protected function getDynamicStyle()
131
  {
 
132
 
133
+ $dynamicStyle = Mage::helper('ddg')->getDynamicStyles();
134
+
135
+ return $dynamicStyle;
136
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  }
app/code/community/Dotdigitalgroup/Email/Block/Coupon.php CHANGED
@@ -2,17 +2,19 @@
2
 
3
  class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
4
  {
 
5
  /**
6
- * Generates the coupon code based on the code id.
7
- * @return bool
8
- * @throws Exception
9
- */
 
10
  public function generateCoupon()
11
  {
12
  $params = $this->getRequest()->getParams();
13
- if (!isset($params['id']) || !isset($params['code'])){
14
- //throw new Exception('Coupon no id or code is set');
15
  Mage::helper('ddg')->log('Coupon no id or code is set');
 
16
  return false;
17
  }
18
  //coupon rule id
@@ -21,13 +23,18 @@ class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
21
  if ($couponCodeId) {
22
 
23
  $rule = Mage::getModel('salesrule/rule')->load($couponCodeId);
24
- //coupon code id not found
25
- if (! $rule->getId()) {
26
- Mage::helper('ddg')->log('Rule with couponId model not found : ' . $couponCodeId);
27
- return false;
28
- }
 
 
 
29
  $generator = Mage::getModel('salesrule/coupon_massgenerator');
30
- $generator->setFormat( Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC );
 
 
31
  $generator->setRuleId($couponCodeId);
32
  $generator->setUsesPerCoupon(1);
33
  $generator->setDash(3);
@@ -38,38 +45,58 @@ class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
38
  $rule->setCouponCodeGenerator($generator);
39
  $rule->setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO);
40
  //generate the coupon
41
- $coupon = $rule->acquireCoupon();
42
  $couponCode = $coupon->getCode();
43
  //save the type of coupon
44
- $couponModel = Mage::getModel('salesrule/coupon')->loadByCode($couponCode);
45
- $couponModel->setType(Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON);
 
 
 
 
46
  $couponModel->save();
47
 
48
  return $couponCode;
49
  }
 
50
  return false;
51
  }
52
 
53
 
54
- protected function getStyle() {
55
- return explode(',', Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_STYLE));
56
- }
 
 
 
 
 
57
 
58
- protected function getCouponColor() {
59
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_COLOR);
60
- }
 
 
 
61
 
62
- protected function getFontSize() {
63
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT_SIZE);
64
- }
 
 
 
65
 
66
- protected function getFont()
67
- {
68
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT);
69
- }
 
 
70
 
71
- protected function getBackgroundColor()
72
- {
73
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_BG_COLOR);
74
- }
 
 
75
  }
2
 
3
  class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
4
  {
5
+
6
  /**
7
+ * Generates the coupon code based on the code id.
8
+ *
9
+ * @return bool
10
+ * @throws Exception
11
+ */
12
  public function generateCoupon()
13
  {
14
  $params = $this->getRequest()->getParams();
15
+ if ( ! isset($params['id']) || ! isset($params['code'])) {
 
16
  Mage::helper('ddg')->log('Coupon no id or code is set');
17
+
18
  return false;
19
  }
20
  //coupon rule id
23
  if ($couponCodeId) {
24
 
25
  $rule = Mage::getModel('salesrule/rule')->load($couponCodeId);
26
+ //coupon code id not found
27
+ if ( ! $rule->getId()) {
28
+ Mage::helper('ddg')->log(
29
+ 'Rule with couponId model not found : ' . $couponCodeId
30
+ );
31
+
32
+ return false;
33
+ }
34
  $generator = Mage::getModel('salesrule/coupon_massgenerator');
35
+ $generator->setFormat(
36
+ Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC
37
+ );
38
  $generator->setRuleId($couponCodeId);
39
  $generator->setUsesPerCoupon(1);
40
  $generator->setDash(3);
45
  $rule->setCouponCodeGenerator($generator);
46
  $rule->setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO);
47
  //generate the coupon
48
+ $coupon = $rule->acquireCoupon();
49
  $couponCode = $coupon->getCode();
50
  //save the type of coupon
51
+ $couponModel = Mage::getModel('salesrule/coupon')->loadByCode(
52
+ $couponCode
53
+ );
54
+ $couponModel->setType(
55
+ Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON
56
+ );
57
  $couponModel->save();
58
 
59
  return $couponCode;
60
  }
61
+
62
  return false;
63
  }
64
 
65
 
66
+ protected function getStyle()
67
+ {
68
+ return explode(
69
+ ',', Mage::getStoreConfig(
70
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_STYLE
71
+ )
72
+ );
73
+ }
74
 
75
+ protected function getCouponColor()
76
+ {
77
+ return Mage::getStoreConfig(
78
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_COLOR
79
+ );
80
+ }
81
 
82
+ protected function getFontSize()
83
+ {
84
+ return Mage::getStoreConfig(
85
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT_SIZE
86
+ );
87
+ }
88
 
89
+ protected function getFont()
90
+ {
91
+ return Mage::getStoreConfig(
92
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT
93
+ );
94
+ }
95
 
96
+ protected function getBackgroundColor()
97
+ {
98
+ return Mage::getStoreConfig(
99
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_BG_COLOR
100
+ );
101
+ }
102
  }
app/code/community/Dotdigitalgroup/Email/Block/Customer/Account/Books.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_Block_Account_Dashboard
 
4
  {
 
5
  protected $_client;
6
- protected $contact_id;
7
 
8
  /**
9
  * subscription pref save url
@@ -20,6 +22,7 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
20
  *
21
  * @param $path
22
  * @param $website
 
23
  * @return mixed
24
  */
25
  protected function _getWebsiteConfigFromHelper($path, $website)
@@ -34,13 +37,16 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
34
  */
35
  protected function _getApiClient()
36
  {
37
- if(empty($this->_client)) {
38
  $website = $this->getCustomer()->getStore()->getWebsite();
39
- $client = Mage::getModel('ddg_automation/apiconnector_client');
40
- $client->setApiUsername(Mage::helper('ddg')->getApiUsername($website))
 
 
41
  ->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
42
  $this->_client = $client;
43
  }
 
44
  return $this->_client;
45
  }
46
 
@@ -65,39 +71,45 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
65
  public function getAdditionalBooksToShow()
66
  {
67
  $additionalBooksToShow = array();
68
- $additionalFromConfig = $this->_getWebsiteConfigFromHelper(
69
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_BOOKS,
70
  $this->getCustomer()->getStore()->getWebsite()
71
  );
72
 
73
- if(strlen($additionalFromConfig))
74
- {
75
  $additionalFromConfig = explode(',', $additionalFromConfig);
76
  $this->getConnectorContact();
77
- if($this->contact_id){
78
- $addressBooks = $this->_getApiClient()->getContactAddressBooks($this->contact_id);
 
 
 
79
  $processedAddressBooks = array();
80
- if(is_array($addressBooks)){
81
- foreach($addressBooks as $addressBook){
82
- $processedAddressBooks[$addressBook->id] = $addressBook->name;
 
83
  }
84
  }
85
- foreach($additionalFromConfig as $bookId){
86
- $connectorBook = $this->_getApiClient()->getAddressBookById($bookId);
87
- if(isset($connectorBook->id))
88
- {
 
89
  $subscribed = 0;
90
- if(isset($processedAddressBooks[$bookId]))
91
  $subscribed = 1;
 
92
  $additionalBooksToShow[] = array(
93
- "name" => $connectorBook->name,
94
- "value" => $connectorBook->id,
95
- "subscribed" => $subscribed
96
  );
97
  }
98
  }
99
  }
100
  }
 
101
  return $additionalBooksToShow;
102
  }
103
 
@@ -121,52 +133,59 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
121
  */
122
  public function getDataFieldsToShow()
123
  {
124
- $datafieldsToShow = array();
125
- $dataFieldsFromConfig = $this->_getWebsiteConfigFromHelper(
126
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_FIELDS,
127
  $this->getCustomer()->getStore()->getWebsite()
128
  );
129
- if(strlen($dataFieldsFromConfig))
130
- {
131
  $dataFieldsFromConfig = explode(',', $dataFieldsFromConfig);
132
- $contact = $this->getConnectorContact();
133
- if($this->contact_id)
134
- {
135
- $contactDataFields = $contact->dataFields;
136
  $processedContactDataFields = array();
137
- foreach($contactDataFields as $contactDataField){
138
- $processedContactDataFields[$contactDataField->key] = $contactDataField->value;
 
139
  }
140
 
141
- $connectorDataFields = $this->_getApiClient()->getDataFields();
 
142
  $processedConnectorDataFields = array();
143
- foreach($connectorDataFields as $connectorDataField){
144
- $processedConnectorDataFields[$connectorDataField->name] = $connectorDataField;
 
145
  }
146
- foreach($dataFieldsFromConfig as $dataFieldFromConfig){
147
- if(isset($processedConnectorDataFields[$dataFieldFromConfig])){
148
  $value = "";
149
- $type = "";
150
- if(isset($processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name])){
151
- if($processedConnectorDataFields[$dataFieldFromConfig]->type == "Date"){
152
- $type = "Date";
153
- $value = $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
154
- $value = Mage::app()->getLocale()->date($value)->toString("Y/M/d");
 
 
 
 
 
 
 
155
  }
156
- else
157
- $value = $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
158
  }
159
 
160
  $datafieldsToShow[] = array(
161
- 'name' => $processedConnectorDataFields[$dataFieldFromConfig]->name,
162
- 'type' => $processedConnectorDataFields[$dataFieldFromConfig]->type,
163
- 'value' => $value
164
  );
165
  }
166
  }
167
 
168
  }
169
  }
 
170
  return $datafieldsToShow;
171
  }
172
 
@@ -177,12 +196,15 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
177
  */
178
  public function canShowAnything()
179
  {
180
- if($this->getCanShowDataFields() or $this->getCanShowAdditionalBooks()){
181
- $books = $this->getAdditionalBooksToShow();
 
182
  $fields = $this->getDataFieldsToShow();
183
- if(!empty($books) or !empty($fields))
184
  return true;
 
185
  }
 
186
  return false;
187
  }
188
 
@@ -193,17 +215,24 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
193
  */
194
  public function getConnectorContact()
195
  {
196
- $contact = $this->_getApiClient()->getContactByEmail($this->getCustomer()->getEmail());
197
- if($contact->id){
 
 
198
  $this->_getCustomerSession()->setConnectorContactId($contact->id);
199
- $this->contact_id = $contact->id;
200
- }else{
201
- $contact = $this->_getApiClient()->postContacts($this->getCustomer()->getEmail());
202
- if($contact->id){
203
- $this->_getCustomerSession()->setConnectorContactId($contact->id);
204
- $this->contact_id = $contact->id;
 
 
 
 
205
  }
206
  }
 
207
  return $contact;
208
  }
209
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Customer_Account_Books
4
+ extends Mage_Customer_Block_Account_Dashboard
5
  {
6
+
7
  protected $_client;
8
+ public $contactId;
9
 
10
  /**
11
  * subscription pref save url
22
  *
23
  * @param $path
24
  * @param $website
25
+ *
26
  * @return mixed
27
  */
28
  protected function _getWebsiteConfigFromHelper($path, $website)
37
  */
38
  protected function _getApiClient()
39
  {
40
+ if (empty($this->_client)) {
41
  $website = $this->getCustomer()->getStore()->getWebsite();
42
+ $client = Mage::getModel('ddg_automation/apiconnector_client');
43
+ $client->setApiUsername(
44
+ Mage::helper('ddg')->getApiUsername($website)
45
+ )
46
  ->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
47
  $this->_client = $client;
48
  }
49
+
50
  return $this->_client;
51
  }
52
 
71
  public function getAdditionalBooksToShow()
72
  {
73
  $additionalBooksToShow = array();
74
+ $additionalFromConfig = $this->_getWebsiteConfigFromHelper(
75
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_BOOKS,
76
  $this->getCustomer()->getStore()->getWebsite()
77
  );
78
 
79
+ if (strlen($additionalFromConfig)) {
 
80
  $additionalFromConfig = explode(',', $additionalFromConfig);
81
  $this->getConnectorContact();
82
+ if ($this->contactId) {
83
+ $addressBooks = $this->_getApiClient()
84
+ ->getContactAddressBooks(
85
+ $this->contactId
86
+ );
87
  $processedAddressBooks = array();
88
+ if (is_array($addressBooks)) {
89
+ foreach ($addressBooks as $addressBook) {
90
+ $processedAddressBooks[$addressBook->id]
91
+ = $addressBook->name;
92
  }
93
  }
94
+ foreach ($additionalFromConfig as $bookId) {
95
+ $connectorBook = $this->_getApiClient()->getAddressBookById(
96
+ $bookId
97
+ );
98
+ if (isset($connectorBook->id)) {
99
  $subscribed = 0;
100
+ if (isset($processedAddressBooks[$bookId])) {
101
  $subscribed = 1;
102
+ }
103
  $additionalBooksToShow[] = array(
104
+ "name" => $connectorBook->name,
105
+ "value" => $connectorBook->id,
106
+ "subscribed" => $subscribed
107
  );
108
  }
109
  }
110
  }
111
  }
112
+
113
  return $additionalBooksToShow;
114
  }
115
 
133
  */
134
  public function getDataFieldsToShow()
135
  {
136
+ $datafieldsToShow = array();
137
+ $dataFieldsFromConfig = $this->_getWebsiteConfigFromHelper(
138
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_FIELDS,
139
  $this->getCustomer()->getStore()->getWebsite()
140
  );
141
+ if (strlen($dataFieldsFromConfig)) {
 
142
  $dataFieldsFromConfig = explode(',', $dataFieldsFromConfig);
143
+ $contact = $this->getConnectorContact();
144
+ if ($this->contactId) {
145
+ $contactDataFields = $contact->dataFields;
 
146
  $processedContactDataFields = array();
147
+ foreach ($contactDataFields as $contactDataField) {
148
+ $processedContactDataFields[$contactDataField->key]
149
+ = $contactDataField->value;
150
  }
151
 
152
+ $connectorDataFields = $this->_getApiClient()
153
+ ->getDataFields();
154
  $processedConnectorDataFields = array();
155
+ foreach ($connectorDataFields as $connectorDataField) {
156
+ $processedConnectorDataFields[$connectorDataField->name]
157
+ = $connectorDataField;
158
  }
159
+ foreach ($dataFieldsFromConfig as $dataFieldFromConfig) {
160
+ if (isset($processedConnectorDataFields[$dataFieldFromConfig])) {
161
  $value = "";
162
+ $type = "";
163
+ if (isset($processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name])) {
164
+ if ($processedConnectorDataFields[$dataFieldFromConfig]->type
165
+ == "Date"
166
+ ) {
167
+ $type = "Date";
168
+ $value
169
+ = $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
170
+ $value = Mage::app()->getLocale()->date($value)
171
+ ->toString("Y/M/d");
172
+ } else {
173
+ $value
174
+ = $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
175
  }
 
 
176
  }
177
 
178
  $datafieldsToShow[] = array(
179
+ 'name' => $processedConnectorDataFields[$dataFieldFromConfig]->name,
180
+ 'type' => $processedConnectorDataFields[$dataFieldFromConfig]->type,
181
+ 'value' => $value
182
  );
183
  }
184
  }
185
 
186
  }
187
  }
188
+
189
  return $datafieldsToShow;
190
  }
191
 
196
  */
197
  public function canShowAnything()
198
  {
199
+ if ($this->getCanShowDataFields() or $this->getCanShowAdditionalBooks()
200
+ ) {
201
+ $books = $this->getAdditionalBooksToShow();
202
  $fields = $this->getDataFieldsToShow();
203
+ if ( ! empty($books) or ! empty($fields)) {
204
  return true;
205
+ }
206
  }
207
+
208
  return false;
209
  }
210
 
215
  */
216
  public function getConnectorContact()
217
  {
218
+ $contact = $this->_getApiClient()->getContactByEmail(
219
+ $this->getCustomer()->getEmail()
220
+ );
221
+ if ($contact->id) {
222
  $this->_getCustomerSession()->setConnectorContactId($contact->id);
223
+ $this->contactId = $contact->id;
224
+ } else {
225
+ $contact = $this->_getApiClient()->postContacts(
226
+ $this->getCustomer()->getEmail()
227
+ );
228
+ if ($contact->id) {
229
+ $this->_getCustomerSession()->setConnectorContactId(
230
+ $contact->id
231
+ );
232
+ $this->contactId = $contact->id;
233
  }
234
  }
235
+
236
  return $contact;
237
  }
238
 
app/code/community/Dotdigitalgroup/Email/Block/Edc.php CHANGED
@@ -2,7 +2,8 @@
2
 
3
  class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
4
  {
5
- protected $_edc_type;
 
6
 
7
  protected function _construct()
8
  {
@@ -10,12 +11,13 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
10
  parent::_construct();
11
 
12
  if ($this->getRequest()->getControllerName() == 'quoteproducts') {
13
- $this->_edc_type = 'quote_products';
14
  }
15
  }
16
 
17
  /**
18
  * Prepare layout, set the template.
 
19
  * @return Mage_Core_Block_Abstract|void
20
  */
21
  protected function _prepareLayout()
@@ -29,15 +31,17 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
29
  * Product related items.
30
  *
31
  * @param Mage_Catalog_Model_Product $productModel
32
- * @param $mode
33
  *
34
  * @return array
35
  */
36
- protected function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel, $mode)
 
 
37
  {
38
  //array of products to display
39
  $products = array();
40
- switch($mode){
41
  case 'related':
42
  $products = $productModel->getRelatedProducts();
43
  break;
@@ -50,15 +54,17 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
50
 
51
  }
52
  $productIds = array();
53
- foreach($products as $product){
54
  $productIds[] = $product->getId();
55
  }
 
56
  return $productIds;
57
  }
58
 
59
  public function getTextForUrl($store)
60
  {
61
  $store = Mage::app()->getStore($store);
 
62
  return $store->getConfig(
63
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_LINK_TEXT
64
  );
@@ -77,16 +83,20 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
77
 
78
  /**
79
  * Number of the colums.
 
80
  * @return int|mixed
81
  * @throws Exception
82
  */
83
  public function getColumnCount()
84
  {
85
- return Mage::helper('ddg/recommended')->getDisplayLimitByMode($this->getRequest()->getActionName());
 
 
86
  }
87
 
88
  /**
89
  * Price html.
 
90
  * @param $product
91
  *
92
  * @return string
@@ -95,6 +105,7 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
95
  {
96
  $this->setTemplate('connector/product/price.phtml');
97
  $this->setProduct($product);
 
98
  return $this->toHtml();
99
  }
100
 
@@ -106,65 +117,77 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
106
  */
107
  public function getLoadedProductCollection()
108
  {
109
- $mode = $this->getRequest()->getActionName();
 
110
  $limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
111
- if (! $this->_edc_type)
112
- $this->_edc_type = $mode;
 
 
113
 
114
- switch ($this->_edc_type) {
115
  case 'recentlyviewed':
116
- return $this->_getRecentlyViewedCollection($limit);
117
  break;
118
  case 'push':
119
- return $this->_getProductPushCollection($limit);
120
  break;
121
  case 'bestsellers':
122
- return $this->_getBestSellersCollection($mode, $limit);
123
  break;
124
  case 'mostviewed':
125
- return $this->_getMostViewedCollection($mode, $limit);
126
  break;
127
  case 'quote_products':
128
- return $this->_getQuoteProductCollection($mode, $limit);
129
  break;
130
  }
 
 
131
  }
132
 
133
  /**
134
  * get collection for recently viewed products
135
  *
136
  * @param $limit
 
137
  * @return array
138
  * @throws Exception
139
  */
140
  protected function _getRecentlyViewedCollection($limit)
141
  {
142
  $productsToDisplay = array();
143
- $customerId = $this->getRequest()->getParam('customer_id');
144
 
145
  //login customer to receive the recent products
146
- $session = Mage::getSingleton('customer/session');
147
  $isLoggedIn = $session->loginById($customerId);
148
 
149
  /** @var Mage_Reports_Block_Product_Viewed $collection */
150
- $collection = Mage::getSingleton('Mage_Reports_Block_Product_Viewed');
151
- $productItems = $collection->getItemsCollection()
152
- ->setPageSize($limit);
153
-
154
- Mage::helper('ddg')->log('Recentlyviewed customer : ' . $customerId . ', limit : ' . $limit .
155
- ', items found : ' . count($productItems) . ', is customer logged in : ' . $isLoggedIn . ', products :' . count($productsToDisplay));
156
- //get the product ids from items collection
157
- $productIds = $productItems->getColumnValues('product_id');
158
- //get product collection to check for salable
159
- $productCollection = Mage::getModel('catalog/product')->getCollection()
160
- ->addFieldToFilter('entity_id', array('in' => $productIds))
161
- ;
162
- //show products only if is salable
163
- foreach ($productCollection as $product) {
164
- if($product->isSalable())
165
- $productsToDisplay[$product->getId()] = $product;
166
-
167
- }
 
 
 
 
 
 
168
  $session->logout();
169
 
170
  return $productsToDisplay;
@@ -174,22 +197,29 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
174
  * get collection for push items
175
  *
176
  * @param $limit
 
177
  * @return array
178
  */
179
  protected function _getProductPushCollection($limit)
180
  {
181
  $productsToDisplay = array();
182
- $productIds = Mage::helper('ddg/recommended')->getProductPushIds();
 
183
 
184
- $productCollection = Mage::getResourceModel('catalog/product_collection')
 
 
185
  ->addAttributeToFilter('entity_id', array('in' => $productIds))
186
- ->addAttributeToSelect(array('product_url', 'name', 'store_id', 'small_image', 'price'))
 
 
187
  ->setPageSize($limit);
188
 
189
  foreach ($productCollection as $product) {
190
  //add only salable products
191
- if($product->isSaleable())
192
  $productsToDisplay[] = $product;
 
193
  }
194
 
195
  return $productsToDisplay;
@@ -200,38 +230,50 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
200
  *
201
  * @param $mode
202
  * @param $limit
 
203
  * @return Varien_Data_Collection
204
  */
205
  protected function _getBestSellersCollection($mode, $limit)
206
  {
207
- $from = Mage::helper('ddg/recommended')->getTimeFromConfig($mode);
208
  $locale = Mage::app()->getLocale()->getLocale();
209
- $to = Zend_Date::now($locale)->toString(Zend_Date::ISO_8601);
210
-
211
- $productCollection = Mage::getResourceModel('reports/product_collection')
212
- ->addAttributeToSelect(array('product_url', 'name', 'store_id', 'small_image', 'price'))
 
 
 
 
213
  ->addOrderedQty($from, $to)
214
  ->setOrder('ordered_qty', 'desc')
 
215
  ->setPageSize($limit);
216
 
217
- Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($productCollection);
218
- $productCollection->addAttributeToFilter('is_saleable', TRUE);
 
219
 
220
- $cat_id = Mage::app()->getRequest()->getParam('category_id', false);
221
- $cat_name = Mage::app()->getRequest()->getParam('category_name', false);
222
 
223
- //check for params
224
- if ($cat_id or $cat_name){
225
- $category = Mage::getModel('catalog/category');
226
  //load by category id
227
- if($cat_id)
228
- $category->load($cat_id);
229
- //load by the category name
230
- if($cat_name)
231
- $category->loadByAttribute('name', $cat_name);
 
 
232
 
233
- $productCollection = $this->_joinCategoryOnCollection($productCollection, $category);
 
 
234
  }
 
235
  return $productCollection;
236
  }
237
 
@@ -240,43 +282,59 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
240
  *
241
  * @param $mode
242
  * @param $limit
 
243
  * @return array
244
  */
245
  protected function _getMostViewedCollection($mode, $limit)
246
  {
247
  $productsToDisplay = array();
248
- $from = Mage::helper('ddg/recommended')->getTimeFromConfig($mode);
249
- $locale = Mage::app()->getLocale()->getLocale();
 
 
250
 
251
- $to = Zend_Date::now($locale)->toString(Zend_Date::ISO_8601);
252
- $productCollection = Mage::getResourceModel('reports/product_collection')
 
 
 
 
253
  ->addViewsCount($from, $to)
254
  ->setPageSize($limit);
255
 
256
- $cat_id = Mage::app()->getRequest()->getParam('category_id');
257
- $cat_name = Mage::app()->getRequest()->getParam('category_name');
258
- if($cat_id or $cat_name){
259
- $category = Mage::getModel('catalog/category');
260
 
261
- if($cat_id)
262
- $category->load($cat_id);
 
263
 
264
- if($cat_name)
265
- $category->loadByAttribute('name', $cat_name);
 
266
 
267
- $productCollection = $this->_joinCategoryOnCollection($productCollection, $category);
 
 
268
  }
269
 
270
  $productIds = $productCollection->getColumnValues('entity_id');
271
  $productCollection->clear();
272
- $productCollection = Mage::getResourceModel('catalog/product_collection')
 
 
273
  ->addIdFilter($productIds)
274
- ->addAttributeToSelect(array('product_url', 'name', 'store_id', 'small_image', 'price'));
 
 
275
 
276
  foreach ($productCollection as $_product) {
277
  //add only salable products
278
- if($_product->isSalable())
279
  $productsToDisplay[] = $_product;
 
280
  }
281
 
282
  return $productsToDisplay;
@@ -287,20 +345,23 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
287
  *
288
  * @param $productCollection
289
  * @param $category
 
290
  * @return mixed
291
  */
292
  protected function _joinCategoryOnCollection($productCollection, $category)
293
  {
294
- if ($category->getId()){
295
  $productCollection->getSelect()
296
  ->joinLeft(
297
  array("ccpi" => 'catalog_category_product_index'),
298
  "e.entity_id = ccpi.product_id",
299
  array("category_id")
300
  )
301
- ->where('ccpi.category_id =?', $category->getId());
302
- }else{
303
- Mage::helper('ddg')->log('Most viewed. Category id/name is invalid. It does not exist.');
 
 
304
  }
305
 
306
  return $productCollection;
@@ -311,6 +372,7 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
311
  *
312
  * @param $mode
313
  * @param $limit
 
314
  * @return array
315
  * @throws Exception
316
  */
@@ -318,12 +380,16 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
318
  {
319
  $quoteModel = Mage::registry('current_quote');
320
 
321
- if (! $quoteModel) {
322
- Mage::throwException(Mage::helper('ddg')->__('no current_quote found for EDC'));
 
 
323
  }
324
- $quoteItems = $quoteModel->getAllItems();
325
 
326
- $productsToDisplay = $this->getProductsToDisplay($quoteItems, $limit, $mode, 'QUOTE');
 
 
327
 
328
  return $productsToDisplay;
329
  }
@@ -335,12 +401,13 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
335
  * @param $limit
336
  * @param $mode
337
  * @param $type
 
338
  * @return array
339
  */
340
  protected function getProductsToDisplay($items, $limit, $mode, $type)
341
  {
342
  //products to be display for recommended pages
343
- $productsToDisplay = array();
344
  $productsToDisplayCounter = 0;
345
 
346
  $numItems = count($items);
@@ -348,13 +415,16 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
348
  //no product found to display
349
  if ($numItems == 0 || ! $limit) {
350
  return array();
351
- }elseif (count($items) > $limit) {
352
  $maxPerChild = 1;
353
  } else {
354
  $maxPerChild = number_format($limit / count($items));
355
  }
356
 
357
- Mage::helper('ddg')->log('DYNAMIC ' .$type. ' PRODUCTS : limit ' . $limit . ' products : ' . $numItems . ', max per child : '. $maxPerChild);
 
 
 
358
 
359
  foreach ($items as $item) {
360
  $i = 0;
@@ -363,17 +433,26 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
363
  //check for product exists
364
 
365
  //get single product for current mode
366
- $recommendedProducts = $this->_getRecommendedProduct($product, $mode);
367
- if (! empty($recommendedProducts)) {
 
 
368
 
369
  $recommendedProducts = Mage::getModel('catalog/product')
370
  ->getCollection()
371
  ->addIdFilter($recommendedProducts)
372
- ->addAttributeToSelect(array('product_url', 'name', 'store_id', 'small_image', 'price'));
 
 
 
373
 
374
  foreach ($recommendedProducts as $product) {
375
  //check if still exists
376
- if ($product->getId() && $productsToDisplayCounter < $limit && $i <= $maxPerChild && $product->isSaleable() && !$product->getParentId()) {
 
 
 
 
377
  //we have a product to display
378
  $productsToDisplay[$product->getId()] = $product;
379
  $i++;
@@ -390,21 +469,28 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
390
 
391
  //check for more space to fill up the table with fallback products
392
  if ($productsToDisplayCounter < $limit) {
393
- $fallbackIds = Mage::helper('ddg/recommended')->getFallbackIds();
 
394
  $productCollection = Mage::getModel('catalog/product')
395
  ->getCollection()
396
  ->addIdFilter($fallbackIds)
397
- ->addAttributeToSelect(array('product_url', 'name', 'store_id', 'small_image', 'price'));
 
 
 
398
 
399
  foreach ($productCollection as $product) {
400
- if($product->isSaleable())
401
  $productsToDisplay[$product->getId()] = $product;
 
 
402
  //stop the limit was reached
403
  if (count($productsToDisplay) == $limit) {
404
  break;
405
  }
406
  }
407
  }
 
408
  return $productsToDisplay;
409
  }
410
  }
2
 
3
  class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
4
  {
5
+
6
+ protected $_edcType;
7
 
8
  protected function _construct()
9
  {
11
  parent::_construct();
12
 
13
  if ($this->getRequest()->getControllerName() == 'quoteproducts') {
14
+ $this->_edcType = 'quote_products';
15
  }
16
  }
17
 
18
  /**
19
  * Prepare layout, set the template.
20
+ *
21
  * @return Mage_Core_Block_Abstract|void
22
  */
23
  protected function _prepareLayout()
31
  * Product related items.
32
  *
33
  * @param Mage_Catalog_Model_Product $productModel
34
+ * @param $mode
35
  *
36
  * @return array
37
  */
38
+ protected function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel,
39
+ $mode
40
+ )
41
  {
42
  //array of products to display
43
  $products = array();
44
+ switch ($mode) {
45
  case 'related':
46
  $products = $productModel->getRelatedProducts();
47
  break;
54
 
55
  }
56
  $productIds = array();
57
+ foreach ($products as $product) {
58
  $productIds[] = $product->getId();
59
  }
60
+
61
  return $productIds;
62
  }
63
 
64
  public function getTextForUrl($store)
65
  {
66
  $store = Mage::app()->getStore($store);
67
+
68
  return $store->getConfig(
69
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_LINK_TEXT
70
  );
83
 
84
  /**
85
  * Number of the colums.
86
+ *
87
  * @return int|mixed
88
  * @throws Exception
89
  */
90
  public function getColumnCount()
91
  {
92
+ return Mage::helper('ddg/recommended')->getDisplayLimitByMode(
93
+ $this->getRequest()->getActionName()
94
+ );
95
  }
96
 
97
  /**
98
  * Price html.
99
+ *
100
  * @param $product
101
  *
102
  * @return string
105
  {
106
  $this->setTemplate('connector/product/price.phtml');
107
  $this->setProduct($product);
108
+
109
  return $this->toHtml();
110
  }
111
 
117
  */
118
  public function getLoadedProductCollection()
119
  {
120
+ $mode = $this->getRequest()->getActionName();
121
+ $result = array();
122
  $limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
123
+ if ( ! $this->_edcType) {
124
+ $this->_edcType = $mode;
125
+ }
126
+
127
 
128
+ switch ($this->_edcType) {
129
  case 'recentlyviewed':
130
+ $result = $this->_getRecentlyViewedCollection($limit);
131
  break;
132
  case 'push':
133
+ $result = $this->_getProductPushCollection($limit);
134
  break;
135
  case 'bestsellers':
136
+ $result = $this->_getBestSellersCollection($mode, $limit);
137
  break;
138
  case 'mostviewed':
139
+ $result = $this->_getMostViewedCollection($mode, $limit);
140
  break;
141
  case 'quote_products':
142
+ $result = $this->_getQuoteProductCollection($mode, $limit);
143
  break;
144
  }
145
+
146
+ return $result;
147
  }
148
 
149
  /**
150
  * get collection for recently viewed products
151
  *
152
  * @param $limit
153
+ *
154
  * @return array
155
  * @throws Exception
156
  */
157
  protected function _getRecentlyViewedCollection($limit)
158
  {
159
  $productsToDisplay = array();
160
+ $customerId = $this->getRequest()->getParam('customer_id');
161
 
162
  //login customer to receive the recent products
163
+ $session = Mage::getSingleton('customer/session');
164
  $isLoggedIn = $session->loginById($customerId);
165
 
166
  /** @var Mage_Reports_Block_Product_Viewed $collection */
167
+ $collection = Mage::getSingleton('Mage_Reports_Block_Product_Viewed');
168
+ $productItems = $collection->getItemsCollection()
169
+ ->setPageSize($limit);
170
+
171
+ Mage::helper('ddg')->log(
172
+ 'Recentlyviewed customer : ' . $customerId . ', limit : ' . $limit
173
+ .
174
+ ', items found : ' . count($productItems)
175
+ . ', is customer logged in : ' . $isLoggedIn . ', products :'
176
+ . count($productsToDisplay)
177
+ );
178
+ //get the product ids from items collection
179
+ $productIds = $productItems->getColumnValues('product_id');
180
+ //get product collection to check for salable
181
+ $productCollection = Mage::getModel('catalog/product')->getCollection()
182
+ ->addAttributeToSelect('*')
183
+ ->addFieldToFilter('entity_id', array('in' => $productIds));
184
+ //show products only if is salable
185
+ foreach ($productCollection as $product) {
186
+ if ($product->isSalable()) {
187
+ $productsToDisplay[$product->getId()] = $product;
188
+ }
189
+
190
+ }
191
  $session->logout();
192
 
193
  return $productsToDisplay;
197
  * get collection for push items
198
  *
199
  * @param $limit
200
+ *
201
  * @return array
202
  */
203
  protected function _getProductPushCollection($limit)
204
  {
205
  $productsToDisplay = array();
206
+ $productIds = Mage::helper('ddg/recommended')->getProductPushIds(
207
+ );
208
 
209
+ $productCollection = Mage::getResourceModel(
210
+ 'catalog/product_collection'
211
+ )
212
  ->addAttributeToFilter('entity_id', array('in' => $productIds))
213
+ ->addAttributeToSelect(
214
+ array('product_url', 'name', 'store_id', 'small_image', 'price')
215
+ )
216
  ->setPageSize($limit);
217
 
218
  foreach ($productCollection as $product) {
219
  //add only salable products
220
+ if ($product->isSaleable()) {
221
  $productsToDisplay[] = $product;
222
+ }
223
  }
224
 
225
  return $productsToDisplay;
230
  *
231
  * @param $mode
232
  * @param $limit
233
+ *
234
  * @return Varien_Data_Collection
235
  */
236
  protected function _getBestSellersCollection($mode, $limit)
237
  {
238
+ $from = Mage::helper('ddg/recommended')->getTimeFromConfig($mode);
239
  $locale = Mage::app()->getLocale()->getLocale();
240
+ $to = Zend_Date::now($locale)->toString(Zend_Date::ISO_8601);
241
+
242
+ $productCollection = Mage::getResourceModel(
243
+ 'reports/product_collection'
244
+ )
245
+ ->addAttributeToSelect(
246
+ array('product_url', 'name', 'store_id', 'small_image', 'price')
247
+ )
248
  ->addOrderedQty($from, $to)
249
  ->setOrder('ordered_qty', 'desc')
250
+ ->addWebsiteFilter(Mage::app()->getWebsite()->getId())
251
  ->setPageSize($limit);
252
 
253
+ Mage::getSingleton('cataloginventory/stock')
254
+ ->addInStockFilterToCollection($productCollection);
255
+ $productCollection->addAttributeToFilter('is_saleable', true);
256
 
257
+ $catId = Mage::app()->getRequest()->getParam('category_id', false);
258
+ $catName = Mage::app()->getRequest()->getParam('category_name', false);
259
 
260
+ //check for params
261
+ if ($catId or $catName) {
262
+ $category = Mage::getModel('catalog/category');
263
  //load by category id
264
+ if ($catId) {
265
+ $category->load($catId);
266
+ }
267
+ //load by the category name
268
+ if ($catName) {
269
+ $category->loadByAttribute('name', $catName);
270
+ }
271
 
272
+ $productCollection = $this->_joinCategoryOnCollection(
273
+ $productCollection, $category
274
+ );
275
  }
276
+
277
  return $productCollection;
278
  }
279
 
282
  *
283
  * @param $mode
284
  * @param $limit
285
+ *
286
  * @return array
287
  */
288
  protected function _getMostViewedCollection($mode, $limit)
289
  {
290
  $productsToDisplay = array();
291
+ $from = Mage::helper('ddg/recommended')->getTimeFromConfig(
292
+ $mode
293
+ );
294
+ $locale = Mage::app()->getLocale()->getLocale();
295
 
296
+ $to = Zend_Date::now($locale)->toString(
297
+ Zend_Date::ISO_8601
298
+ );
299
+ $productCollection = Mage::getResourceModel(
300
+ 'reports/product_collection'
301
+ )
302
  ->addViewsCount($from, $to)
303
  ->setPageSize($limit);
304
 
305
+ $catId = Mage::app()->getRequest()->getParam('category_id');
306
+ $catName = Mage::app()->getRequest()->getParam('category_name');
307
+ if ($catId or $catName) {
308
+ $category = Mage::getModel('catalog/category');
309
 
310
+ if ($catId) {
311
+ $category->load($catId);
312
+ }
313
 
314
+ if ($catName) {
315
+ $category->loadByAttribute('name', $catName);
316
+ }
317
 
318
+ $productCollection = $this->_joinCategoryOnCollection(
319
+ $productCollection, $category
320
+ );
321
  }
322
 
323
  $productIds = $productCollection->getColumnValues('entity_id');
324
  $productCollection->clear();
325
+ $productCollection = Mage::getResourceModel(
326
+ 'catalog/product_collection'
327
+ )
328
  ->addIdFilter($productIds)
329
+ ->addAttributeToSelect(
330
+ array('product_url', 'name', 'store_id', 'small_image', 'price')
331
+ );
332
 
333
  foreach ($productCollection as $_product) {
334
  //add only salable products
335
+ if ($_product->isSalable()) {
336
  $productsToDisplay[] = $_product;
337
+ }
338
  }
339
 
340
  return $productsToDisplay;
345
  *
346
  * @param $productCollection
347
  * @param $category
348
+ *
349
  * @return mixed
350
  */
351
  protected function _joinCategoryOnCollection($productCollection, $category)
352
  {
353
+ if ($category->getId()) {
354
  $productCollection->getSelect()
355
  ->joinLeft(
356
  array("ccpi" => 'catalog_category_product_index'),
357
  "e.entity_id = ccpi.product_id",
358
  array("category_id")
359
  )
360
+ ->where('ccpi.category_id =?', $category->getId());
361
+ } else {
362
+ Mage::helper('ddg')->log(
363
+ 'Most viewed. Category id/name is invalid. It does not exist.'
364
+ );
365
  }
366
 
367
  return $productCollection;
372
  *
373
  * @param $mode
374
  * @param $limit
375
+ *
376
  * @return array
377
  * @throws Exception
378
  */
380
  {
381
  $quoteModel = Mage::registry('current_quote');
382
 
383
+ if ( ! $quoteModel) {
384
+ Mage::throwException(
385
+ Mage::helper('ddg')->__('no current_quote found for EDC')
386
+ );
387
  }
388
+ $quoteItems = $quoteModel->getAllItems();
389
 
390
+ $productsToDisplay = $this->getProductsToDisplay(
391
+ $quoteItems, $limit, $mode, 'QUOTE'
392
+ );
393
 
394
  return $productsToDisplay;
395
  }
401
  * @param $limit
402
  * @param $mode
403
  * @param $type
404
+ *
405
  * @return array
406
  */
407
  protected function getProductsToDisplay($items, $limit, $mode, $type)
408
  {
409
  //products to be display for recommended pages
410
+ $productsToDisplay = array();
411
  $productsToDisplayCounter = 0;
412
 
413
  $numItems = count($items);
415
  //no product found to display
416
  if ($numItems == 0 || ! $limit) {
417
  return array();
418
+ } elseif (count($items) > $limit) {
419
  $maxPerChild = 1;
420
  } else {
421
  $maxPerChild = number_format($limit / count($items));
422
  }
423
 
424
+ Mage::helper('ddg')->log(
425
+ 'DYNAMIC ' . $type . ' PRODUCTS : limit ' . $limit . ' products : '
426
+ . $numItems . ', max per child : ' . $maxPerChild
427
+ );
428
 
429
  foreach ($items as $item) {
430
  $i = 0;
433
  //check for product exists
434
 
435
  //get single product for current mode
436
+ $recommendedProducts = $this->_getRecommendedProduct(
437
+ $product, $mode
438
+ );
439
+ if ( ! empty($recommendedProducts)) {
440
 
441
  $recommendedProducts = Mage::getModel('catalog/product')
442
  ->getCollection()
443
  ->addIdFilter($recommendedProducts)
444
+ ->addAttributeToSelect(
445
+ array('product_url', 'name', 'store_id', 'small_image',
446
+ 'price')
447
+ );
448
 
449
  foreach ($recommendedProducts as $product) {
450
  //check if still exists
451
+ if ($product->getId() && $productsToDisplayCounter < $limit
452
+ && $i <= $maxPerChild
453
+ && $product->isSaleable()
454
+ && ! $product->getParentId()
455
+ ) {
456
  //we have a product to display
457
  $productsToDisplay[$product->getId()] = $product;
458
  $i++;
469
 
470
  //check for more space to fill up the table with fallback products
471
  if ($productsToDisplayCounter < $limit) {
472
+ $fallbackIds = Mage::helper('ddg/recommended')
473
+ ->getFallbackIds();
474
  $productCollection = Mage::getModel('catalog/product')
475
  ->getCollection()
476
  ->addIdFilter($fallbackIds)
477
+ ->addAttributeToSelect(
478
+ array('product_url', 'name', 'store_id', 'small_image',
479
+ 'price')
480
+ );
481
 
482
  foreach ($productCollection as $product) {
483
+ if ($product->isSaleable()) {
484
  $productsToDisplay[$product->getId()] = $product;
485
+ }
486
+
487
  //stop the limit was reached
488
  if (count($productsToDisplay) == $limit) {
489
  break;
490
  }
491
  }
492
  }
493
+
494
  return $productsToDisplay;
495
  }
496
  }
app/code/community/Dotdigitalgroup/Email/Block/Feefo.php CHANGED
@@ -3,8 +3,10 @@
3
 
4
  class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
5
  {
 
6
  /**
7
  * Prepare layout, set the template.
 
8
  * @return Mage_Core_Block_Abstract|void
9
  */
10
  protected function _prepareLayout()
@@ -21,15 +23,17 @@ class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
21
  */
22
  public function getServiceScoreLogo()
23
  {
24
- $helper = Mage::helper('ddg');
25
- $url = 'http://www.feefo.com/feefo/feefologo.jsp?logon=';
26
- $logon = $helper->getFeefoLogon();
27
  $template = '';
28
 
29
- if( $helper->getFeefoLogoTemplate())
30
  $template = '&template=' . $helper->getFeefoLogoTemplate();
31
- $fullUrl = $url . $logon . $template;
32
- $vendorUrl = 'http://www.feefo.com/feefo/viewvendor.jsp?logon=' . $logon;
 
 
33
 
34
  return
35
  "<a href=$vendorUrl target='_blank'>
@@ -44,24 +48,28 @@ class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
44
  */
45
  public function getQuoteProducts()
46
  {
47
- $products = array();
48
- $quoteId = Mage::app()->getRequest()->getParam('quote_id');
49
  $quoteModel = Mage::getModel('sales/quote')->load($quoteId);
50
  //quote id param
51
- if (! $quoteModel->getId())
52
- Mage::throwException(Mage::helper('ddg')->__('cannot continue, missing quote data'));
 
 
 
53
 
54
  $quoteItems = $quoteModel->getAllItems();
55
 
56
- if(count($quoteItems) == 0)
57
  return array();
 
58
 
59
  /** @var Mage_Sales_Model_Quote_Item $item */
60
- foreach($quoteItems as $item)
61
- {
62
  $productModel = $item->getProduct();
63
- if ($productModel->getId())
64
  $products[$productModel->getSku()] = $productModel->getName();
 
65
  }
66
 
67
  return $products;
@@ -74,33 +82,37 @@ class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
74
  */
75
  public function getProductsReview()
76
  {
77
- $check = true;
78
- $reviews = array();
79
- $helper = Mage::helper('ddg');
80
- $feefo_dir = Mage::getModel('core/config_options')
81
- ->getLibDir() . DS . 'connector' . DS . 'feefo';
82
- $logon = $helper->getFeefoLogon();
83
- $limit = $helper->getFeefoReviewsPerProduct();
84
- $products = $this->getQuoteProducts();
85
-
86
- foreach($products as $sku => $name)
87
- {
88
- $url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon . "&limit=".$limit . "&vendorref=" . $sku . "&mode=productonly" ;
 
89
  $doc = new DOMDocument();
90
  $xsl = new XSLTProcessor();
91
- if ($check)
92
- $doc->load($feefo_dir. DS ."feedback.xsl");
93
- else
94
- $doc->load($feefo_dir. DS ."feedback-no-th.xsl");
 
95
 
96
  $xsl->importStyleSheet($doc);
97
  $doc->load($url);
98
  $productReview = $xsl->transformToXML($doc);
99
 
100
- if (strpos($productReview, '<td') !== false)
101
  $reviews[$name] = $xsl->transformToXML($doc);
 
102
  $check = false;
103
  }
 
104
  return $reviews;
105
  }
106
  }
3
 
4
  class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
5
  {
6
+
7
  /**
8
  * Prepare layout, set the template.
9
+ *
10
  * @return Mage_Core_Block_Abstract|void
11
  */
12
  protected function _prepareLayout()
23
  */
24
  public function getServiceScoreLogo()
25
  {
26
+ $helper = Mage::helper('ddg');
27
+ $url = 'http://www.feefo.com/feefo/feefologo.jsp?logon=';
28
+ $logon = $helper->getFeefoLogon();
29
  $template = '';
30
 
31
+ if ($helper->getFeefoLogoTemplate()) {
32
  $template = '&template=' . $helper->getFeefoLogoTemplate();
33
+ }
34
+ $fullUrl = $url . $logon . $template;
35
+ $vendorUrl = 'http://www.feefo.com/feefo/viewvendor.jsp?logon='
36
+ . $logon;
37
 
38
  return
39
  "<a href=$vendorUrl target='_blank'>
48
  */
49
  public function getQuoteProducts()
50
  {
51
+ $products = array();
52
+ $quoteId = Mage::app()->getRequest()->getParam('quote_id');
53
  $quoteModel = Mage::getModel('sales/quote')->load($quoteId);
54
  //quote id param
55
+ if ( ! $quoteModel->getId()) {
56
+ Mage::throwException(
57
+ Mage::helper('ddg')->__('cannot continue, missing quote data')
58
+ );
59
+ }
60
 
61
  $quoteItems = $quoteModel->getAllItems();
62
 
63
+ if (count($quoteItems) == 0) {
64
  return array();
65
+ }
66
 
67
  /** @var Mage_Sales_Model_Quote_Item $item */
68
+ foreach ($quoteItems as $item) {
 
69
  $productModel = $item->getProduct();
70
+ if ($productModel->getId()) {
71
  $products[$productModel->getSku()] = $productModel->getName();
72
+ }
73
  }
74
 
75
  return $products;
82
  */
83
  public function getProductsReview()
84
  {
85
+ $check = true;
86
+ $reviews = array();
87
+ $helper = Mage::helper('ddg');
88
+ $feeforDir = Mage::getModel('core/config_options')
89
+ ->getLibDir() . DS . 'connector' . DS . 'feefo';
90
+ $logon = $helper->getFeefoLogon();
91
+ $limit = $helper->getFeefoReviewsPerProduct();
92
+ $products = $this->getQuoteProducts();
93
+
94
+ foreach ($products as $sku => $name) {
95
+ $url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon
96
+ . "&limit=" . $limit . "&vendorref=" . $sku
97
+ . "&mode=productonly";
98
  $doc = new DOMDocument();
99
  $xsl = new XSLTProcessor();
100
+ if ($check) {
101
+ $doc->load($feeforDir . DS . "feedback.xsl");
102
+ } else {
103
+ $doc->load($feeforDir . DS . "feedback-no-th.xsl");
104
+ }
105
 
106
  $xsl->importStyleSheet($doc);
107
  $doc->load($url);
108
  $productReview = $xsl->transformToXML($doc);
109
 
110
+ if (strpos($productReview, '<td') !== false) {
111
  $reviews[$name] = $xsl->transformToXML($doc);
112
+ }
113
  $check = false;
114
  }
115
+
116
  return $reviews;
117
  }
118
  }
app/code/community/Dotdigitalgroup/Email/Block/Order.php CHANGED
@@ -4,72 +4,82 @@ class Dotdigitalgroup_Email_Block_Order extends Dotdigitalgroup_Email_Block_Edc
4
  {
5
 
6
  /**
7
- * Prepare layout, set template and title.
8
- *
9
- * @return Mage_Core_Block_Abstract|void
10
- */
11
  protected function _prepareLayout()
12
  {
13
  if ($root = $this->getLayout()->getBlock('root')) {
14
  $root->setTemplate('page/blank.phtml');
15
  }
16
  if ($headBlock = $this->getLayout()->getBlock('head')) {
17
- $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId()));
 
 
18
  }
19
  }
20
 
21
  /**
22
- * Current Order.
23
- *
24
- * @return Mage_Core_Model_Abstract|mixed
25
- */
26
  public function getOrder()
27
  {
28
  $order = Mage::registry('current_order');
29
- if (! $order) {
30
- Mage::throwException(Mage::helper('ddg')->__('no current_order found for EDC'));
 
 
31
  }
32
 
33
  return $order;
34
  }
35
 
36
- /**
37
- * Dysplay mode.
38
- * @return string
39
- */
40
- public function getMode()
41
- {
42
- $website = Mage::app()->getStore($this->getOrder()->getStoreId())->getWebsite();
43
- $mode = Mage::helper('ddg')->getReviewDisplayType($website);
 
 
44
 
45
- return $mode;
46
- }
47
 
48
- /**
49
- * Order website.
50
- * @return Mage_Core_Model_Website
51
- */
52
- public function getWebsite()
53
- {
54
- return Mage::app()->getStore($this->getOrder()->getStoreId())->getWebsite();
55
- }
56
- /**
57
- * Product items to display.
58
- * @return Mage_Catalog_Model_Resource_Product_Collection
59
- */
60
- public function getItems()
61
- {
62
- $order = $this->getOrder();
63
- $items = $order->getAllVisibleItems();
64
- $productIds = array();
65
- //get the product ids for the collection
66
- foreach ( $items as $item ) {
67
- $productIds[] = $item->getProductId();
68
- }
69
- $items = Mage::getModel('catalog/product')->getCollection()
70
- ->addAttributeToSelect('*')
71
- ->addFieldToFilter('entity_id', array('in' => $productIds));
72
 
73
- return $items;
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
4
  {
5
 
6
  /**
7
+ * Prepare layout, set template and title.
8
+ *
9
+ * @return Mage_Core_Block_Abstract|void
10
+ */
11
  protected function _prepareLayout()
12
  {
13
  if ($root = $this->getLayout()->getBlock('root')) {
14
  $root->setTemplate('page/blank.phtml');
15
  }
16
  if ($headBlock = $this->getLayout()->getBlock('head')) {
17
+ $headBlock->setTitle(
18
+ $this->__('Order # %s', $this->getOrder()->getRealOrderId())
19
+ );
20
  }
21
  }
22
 
23
  /**
24
+ * Current Order.
25
+ *
26
+ * @return Mage_Core_Model_Abstract|mixed
27
+ */
28
  public function getOrder()
29
  {
30
  $order = Mage::registry('current_order');
31
+ if ( ! $order) {
32
+ Mage::throwException(
33
+ Mage::helper('ddg')->__('no current_order found for EDC')
34
+ );
35
  }
36
 
37
  return $order;
38
  }
39
 
40
+ /**
41
+ * Dysplay mode.
42
+ *
43
+ * @return string
44
+ */
45
+ public function getMode()
46
+ {
47
+ $website = Mage::app()->getStore($this->getOrder()->getStoreId())
48
+ ->getWebsite();
49
+ $mode = Mage::helper('ddg')->getReviewDisplayType($website);
50
 
51
+ return $mode;
52
+ }
53
 
54
+ /**
55
+ * Order website.
56
+ *
57
+ * @return Mage_Core_Model_Website
58
+ */
59
+ public function getWebsite()
60
+ {
61
+ return Mage::app()->getStore($this->getOrder()->getStoreId())
62
+ ->getWebsite();
63
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ /**
66
+ * Product items to display.
67
+ *
68
+ * @return Mage_Catalog_Model_Resource_Product_Collection
69
+ */
70
+ public function getItems()
71
+ {
72
+ $order = $this->getOrder();
73
+ $items = $order->getAllVisibleItems();
74
+ $productIds = array();
75
+ //get the product ids for the collection
76
+ foreach ($items as $item) {
77
+ $productIds[] = $item->getProductId();
78
+ }
79
+ $items = Mage::getModel('catalog/product')->getCollection()
80
+ ->addAttributeToSelect('*')
81
+ ->addFieldToFilter('entity_id', array('in' => $productIds));
82
+
83
+ return $items;
84
+ }
85
  }
app/code/community/Dotdigitalgroup/Email/Block/Order/Creditmemo.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Order_Creditmemo extends Mage_Sales_Block_Order_Creditmemo_Items
 
 
3
  {
 
4
  /**
5
- * Prepare layout.
6
- *
7
- * @return Mage_Core_Block_Abstract|void
8
- */
9
  protected function _prepareLayout()
10
  {
11
  if ($root = $this->getLayout()->getBlock('root')) {
@@ -13,21 +16,27 @@ class Dotdigitalgroup_Email_Block_Order_Creditmemo extends Mage_Sales_Block_Ord
13
  }
14
  }
15
 
16
- /**
17
- * Get current Order.
18
- * @return Mage_Sales_Model_Order
19
- * @throws Exception
20
- */
 
21
  public function getOrder()
22
  {
23
  $order = Mage::registry('current_order');
24
- if (! $order) {
25
- Mage::throwException(Mage::helper('ddg')->__('no current_order found for EDC'));
 
 
26
  }
27
 
28
- if (! $order->hasCreditmemos()) {
29
- //throw new Exception('TE - no creditmemo for order : '. $orderId);
30
- Mage::helper('ddg')->log('TE - no creditmemo for order : '. $order->getId());
 
 
 
31
  return false;
32
  }
33
 
@@ -35,9 +44,10 @@ class Dotdigitalgroup_Email_Block_Order_Creditmemo extends Mage_Sales_Block_Ord
35
  }
36
 
37
  /**
38
- * Order items.
39
- * @return mixed
40
- */
 
41
  public function getCreditmemoItems()
42
  {
43
  return Mage::registry('current_order')->getItemsCollection();
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Order_Creditmemo
4
+ extends Mage_Sales_Block_Order_Creditmemo_Items
5
  {
6
+
7
  /**
8
+ * Prepare layout.
9
+ *
10
+ * @return Mage_Core_Block_Abstract|void
11
+ */
12
  protected function _prepareLayout()
13
  {
14
  if ($root = $this->getLayout()->getBlock('root')) {
16
  }
17
  }
18
 
19
+ /**
20
+ * Get current Order.
21
+ *
22
+ * @return Mage_Sales_Model_Order
23
+ * @throws Exception
24
+ */
25
  public function getOrder()
26
  {
27
  $order = Mage::registry('current_order');
28
+ if ( ! $order) {
29
+ Mage::throwException(
30
+ Mage::helper('ddg')->__('no current_order found for EDC')
31
+ );
32
  }
33
 
34
+ if ( ! $order->hasCreditmemos()) {
35
+
36
+ Mage::helper('ddg')->log(
37
+ 'TE - no creditmemo for order : ' . $order->getId()
38
+ );
39
+
40
  return false;
41
  }
42
 
44
  }
45
 
46
  /**
47
+ * Order items.
48
+ *
49
+ * @return mixed
50
+ */
51
  public function getCreditmemoItems()
52
  {
53
  return Mage::registry('current_order')->getItemsCollection();
app/code/community/Dotdigitalgroup/Email/Block/Order/Invoice.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Order_Invoice extends Mage_Sales_Block_Order_Invoice_Items
 
 
3
  {
 
4
  /**
5
- * Prepare layout.
6
- * @return Mage_Core_Block_Abstract|void
7
- */
 
8
  protected function _prepareLayout()
9
  {
10
  if ($root = $this->getLayout()->getBlock('root')) {
@@ -12,21 +16,27 @@ class Dotdigitalgroup_Email_Block_Order_Invoice extends Mage_Sales_Block_Order_I
12
  }
13
  }
14
 
15
- /**
16
- * Get current order.
17
- * @return Mage_Sales_Model_Order
18
- * @throws Exception
19
- */
 
20
  public function getOrder()
21
  {
22
  $order = Mage::registry('current_order');
23
- if (! $order) {
24
- Mage::throwException(Mage::helper('ddg')->__('no current_order found for EDC'));
 
 
25
  }
26
 
27
- if (! $order->hasInvoices()) {
28
  //throw new Exception('TE - no invoice for order : '. $orderId);
29
- Mage::helper('ddg')->log('TE - no invoice for order : '. $order->getId());
 
 
 
30
  return false;
31
  }
32
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Order_Invoice
4
+ extends Mage_Sales_Block_Order_Invoice_Items
5
  {
6
+
7
  /**
8
+ * Prepare layout.
9
+ *
10
+ * @return Mage_Core_Block_Abstract|void
11
+ */
12
  protected function _prepareLayout()
13
  {
14
  if ($root = $this->getLayout()->getBlock('root')) {
16
  }
17
  }
18
 
19
+ /**
20
+ * Get current order.
21
+ *
22
+ * @return Mage_Sales_Model_Order
23
+ * @throws Exception
24
+ */
25
  public function getOrder()
26
  {
27
  $order = Mage::registry('current_order');
28
+ if ( ! $order) {
29
+ Mage::throwException(
30
+ Mage::helper('ddg')->__('no current_order found for EDC')
31
+ );
32
  }
33
 
34
+ if ( ! $order->hasInvoices()) {
35
  //throw new Exception('TE - no invoice for order : '. $orderId);
36
+ Mage::helper('ddg')->log(
37
+ 'TE - no invoice for order : ' . $order->getId()
38
+ );
39
+
40
  return false;
41
  }
42
 
app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Block_Order_Shipping extends Mage_Sales_Block_Order_Creditmemo_Items
 
 
3
  {
 
4
  /**
5
- * Prepare layout.
6
- * @return Mage_Core_Block_Abstract|void
7
- */
 
8
  protected function _prepareLayout()
9
  {
10
  if ($root = $this->getLayout()->getBlock('root')) {
@@ -12,20 +16,25 @@ class Dotdigitalgroup_Email_Block_Order_Shipping extends Mage_Sales_Block_Order
12
  }
13
  }
14
 
15
- /**
16
- * @return Mage_Sales_Model_Order
17
- * @throws Exception
18
- */
19
  public function getOrder()
20
  {
21
  $order = Mage::registry('current_order');
22
- if (! $order) {
23
- Mage::throwException(Mage::helper('ddg')->__('no current_order found for EDC'));
 
 
24
  }
25
 
26
- if (! $order->hasShipments()) {
27
- //throw new Exception('TE - no shipments for order : '. $orderId);
28
- Mage::helper('ddg')->log('TE - no shipments for order : '. $order->getId());
 
 
 
29
  return false;
30
  }
31
 
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Order_Shipping
4
+ extends Mage_Sales_Block_Order_Creditmemo_Items
5
  {
6
+
7
  /**
8
+ * Prepare layout.
9
+ *
10
+ * @return Mage_Core_Block_Abstract|void
11
+ */
12
  protected function _prepareLayout()
13
  {
14
  if ($root = $this->getLayout()->getBlock('root')) {
16
  }
17
  }
18
 
19
+ /**
20
+ * @return Mage_Sales_Model_Order
21
+ * @throws Exception
22
+ */
23
  public function getOrder()
24
  {
25
  $order = Mage::registry('current_order');
26
+ if ( ! $order) {
27
+ Mage::throwException(
28
+ Mage::helper('ddg')->__('no current_order found for EDC')
29
+ );
30
  }
31
 
32
+ if ( ! $order->hasShipments()) {
33
+
34
+ Mage::helper('ddg')->log(
35
+ 'TE - no shipments for order : ' . $order->getId()
36
+ );
37
+
38
  return false;
39
  }
40
 
app/code/community/Dotdigitalgroup/Email/Block/Products.php CHANGED
@@ -2,11 +2,12 @@
2
 
3
  class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
4
  {
 
5
  /**
6
- * Prepare layout, set template.
7
- *
8
- * @return Mage_Core_Block_Abstract|void
9
- */
10
  protected function _prepareLayout()
11
  {
12
  if ($root = $this->getLayout()->getBlock('root')) {
@@ -20,16 +21,18 @@ class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
20
  public function getRecommendedProducts()
21
  {
22
  $productsToDisplay = array();
23
- $orderId = $this->getRequest()->getParam('order', false);
24
- $mode = $this->getRequest()->getParam('mode', false);
25
  if ($orderId && $mode) {
26
  $orderModel = Mage::getModel('sales/order')->load($orderId);
27
  if ($orderModel->getId()) {
28
- $storeId = $orderModel->getStoreId();
29
- $appEmulation = Mage::getSingleton('core/app_emulation');
30
- $appEmulation->startEnvironmentEmulation($storeId);
31
  //order products
32
- $productRecommended = Mage::getModel('ddg_automation/dynamic_recommended', $orderModel);
 
 
33
  $productRecommended->setMode($mode);
34
 
35
  //get the order items recommendations
@@ -42,23 +45,25 @@ class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
42
 
43
 
44
  /**
45
- * Price html block.
46
- *
47
- * @param $product
48
- *
49
- * @return string
50
- */
51
  public function getPriceHtml($product)
52
  {
53
  $this->setTemplate('connector/price.phtml');
54
  $this->setProduct($product);
 
55
  return $this->toHtml();
56
  }
57
 
58
  /**
59
- * Display type mode.
60
- * @return mixed|string
61
- */
 
62
  public function getDisplayType()
63
  {
64
  return Mage::helper('ddg/recommended')->getDisplayType();
2
 
3
  class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
4
  {
5
+
6
  /**
7
+ * Prepare layout, set template.
8
+ *
9
+ * @return Mage_Core_Block_Abstract|void
10
+ */
11
  protected function _prepareLayout()
12
  {
13
  if ($root = $this->getLayout()->getBlock('root')) {
21
  public function getRecommendedProducts()
22
  {
23
  $productsToDisplay = array();
24
+ $orderId = $this->getRequest()->getParam('order', false);
25
+ $mode = $this->getRequest()->getParam('mode', false);
26
  if ($orderId && $mode) {
27
  $orderModel = Mage::getModel('sales/order')->load($orderId);
28
  if ($orderModel->getId()) {
29
+ $storeId = $orderModel->getStoreId();
30
+ $appEmulation = Mage::getSingleton('core/app_emulation');
31
+ $appEmulation->startEnvironmentEmulation($storeId);
32
  //order products
33
+ $productRecommended = Mage::getModel(
34
+ 'ddg_automation/dynamic_recommended', $orderModel
35
+ );
36
  $productRecommended->setMode($mode);
37
 
38
  //get the order items recommendations
45
 
46
 
47
  /**
48
+ * Price html block.
49
+ *
50
+ * @param $product
51
+ *
52
+ * @return string
53
+ */
54
  public function getPriceHtml($product)
55
  {
56
  $this->setTemplate('connector/price.phtml');
57
  $this->setProduct($product);
58
+
59
  return $this->toHtml();
60
  }
61
 
62
  /**
63
+ * Display type mode.
64
+ *
65
+ * @return mixed|string
66
+ */
67
  public function getDisplayType()
68
  {
69
  return Mage::helper('ddg/recommended')->getDisplayType();
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Products.php CHANGED
@@ -1,69 +1,36 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Recommended_Products extends Dotdigitalgroup_Email_Block_Edc
 
4
  {
5
- /**
6
- * Slot div name.
7
- * @var string
8
- */
9
- public $slot;
10
 
11
  /**
12
- * get the products to display for table
 
 
 
13
  */
14
  public function getLoadedProductCollection()
15
  {
16
  $orderModel = Mage::registry('current_order');
17
- if (! $orderModel) {
18
- Mage::log('no current_order found for EDC');
19
- return array();
20
- }
21
-
22
- //display mode based on the action name
23
- $mode = $this->getRequest()->getActionName();
24
- //number of product items to be displayed
25
- $limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
26
- $orderItems = $orderModel->getAllItems();
27
- $productsToDisplay = $this->getProductsToDisplay($orderItems, $limit, $mode, 'PRODUCT');
28
-
29
- return $productsToDisplay;
 
 
 
 
 
 
30
  }
31
-
32
- /**
33
- * Nosto products data.
34
- * @return object
35
- */
36
- public function getNostoProducts()
37
- {
38
- $client = Mage::getModel('ddg_automation/apiconnector_client');
39
- //slot name, div id
40
- $slot = Mage::app()->getRequest()->getParam('slot', false);
41
-
42
- //email recommendation
43
- $email = Mage::app()->getRequest()->getParam('email', false);
44
-
45
- //no valid data for nosto recommendation
46
- if (!$slot || ! $email)
47
- return false;
48
- else
49
- $this->slot = $slot;
50
-
51
- //html data from nosto
52
- $data = $client->getNostoProducts($slot, $email);
53
-
54
- //check for valid response
55
- if (! isset($data->$email) && !isset($data->$email->$slot))
56
- return false;
57
- return $data->$email->$slot;
58
- }
59
-
60
- /**
61
- * Slot name.
62
- * Should be called after getNostoProducts.
63
- * @return string
64
- */
65
- public function getSlotName()
66
- {
67
- return $this->slot;
68
- }
69
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Recommended_Products
4
+ extends Dotdigitalgroup_Email_Block_Edc
5
  {
 
 
 
 
 
6
 
7
  /**
8
+ * Get the products to display for table.
9
+ *
10
+ * @return array
11
+ * @throws Exception
12
  */
13
  public function getLoadedProductCollection()
14
  {
15
  $orderModel = Mage::registry('current_order');
16
+ if (! $orderModel) {
17
+ Mage::log('no current_order found for EDC');
18
+
19
+ return array();
20
+ }
21
+
22
+ //display mode based on the action name
23
+ $mode = $this->getRequest()->getActionName();
24
+ //number of product items to be displayed
25
+ $limit = Mage::helper('ddg/recommended')
26
+ ->getDisplayLimitByMode(
27
+ $mode
28
+ );
29
+ $orderItems = $orderModel->getAllItems();
30
+ $productsToDisplay = $this->getProductsToDisplay(
31
+ $orderItems, $limit, $mode, 'PRODUCT'
32
+ );
33
+
34
+ return $productsToDisplay;
35
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Wishlistproducts.php CHANGED
@@ -1,30 +1,34 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Recommended_Wishlistproducts extends Dotdigitalgroup_Email_Block_Edc
 
4
  {
5
 
6
  protected function _getWishlistItems()
7
  {
8
  $wishlist = $this->_getWishlist();
9
- if($wishlist && count($wishlist->getItemCollection()))
10
  return $wishlist->getItemCollection();
11
- else
12
  return array();
 
13
  }
14
 
15
- protected function _getWishlist() {
 
16
 
17
  //customer id param
18
- $customerId = Mage::app()->getRequest()->getParam('customer_id');
19
 
20
- if (! $customerId)
21
  return array();
 
22
 
23
  //load customer wishlist collection
24
  $wishlistModel = Mage::getModel('wishlist/wishlist')
25
- ->loadByCustomer($customerId);
26
 
27
- return $wishlistModel;
28
  }
29
 
30
  /**
@@ -33,12 +37,14 @@ class Dotdigitalgroup_Email_Block_Recommended_Wishlistproducts extends Dotdigita
33
  public function getLoadedProductCollection()
34
  {
35
  //display mode based on the action name
36
- $mode = $this->getRequest()->getActionName();
37
  //number of product items to be displayed
38
  $limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
39
 
40
  $items = $this->_getWishlistItems();
41
- $productsToDisplay = $this->getProductsToDisplay($items, $limit, $mode, 'WISHLIST');
 
 
42
 
43
  return $productsToDisplay;
44
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Recommended_Wishlistproducts
4
+ extends Dotdigitalgroup_Email_Block_Edc
5
  {
6
 
7
  protected function _getWishlistItems()
8
  {
9
  $wishlist = $this->_getWishlist();
10
+ if ($wishlist && count($wishlist->getItemCollection())) {
11
  return $wishlist->getItemCollection();
12
+ } else {
13
  return array();
14
+ }
15
  }
16
 
17
+ protected function _getWishlist()
18
+ {
19
 
20
  //customer id param
21
+ $customerId = Mage::app()->getRequest()->getParam('customer_id');
22
 
23
+ if ( ! $customerId) {
24
  return array();
25
+ }
26
 
27
  //load customer wishlist collection
28
  $wishlistModel = Mage::getModel('wishlist/wishlist')
29
+ ->loadByCustomer($customerId);
30
 
31
+ return $wishlistModel;
32
  }
33
 
34
  /**
37
  public function getLoadedProductCollection()
38
  {
39
  //display mode based on the action name
40
+ $mode = $this->getRequest()->getActionName();
41
  //number of product items to be displayed
42
  $limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
43
 
44
  $items = $this->_getWishlistItems();
45
+ $productsToDisplay = $this->getProductsToDisplay(
46
+ $items, $limit, $mode, 'WISHLIST'
47
+ );
48
 
49
  return $productsToDisplay;
50
  }
app/code/community/Dotdigitalgroup/Email/Block/Wishlist.php CHANGED
@@ -1,29 +1,36 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Wishlist extends Dotdigitalgroup_Email_Block_Edc
 
4
  {
 
5
  protected $_website;
6
 
7
  public function getWishlistItems()
8
  {
9
  $wishlist = $this->_getWishlist();
10
- if($wishlist && count($wishlist->getItemCollection()))
11
  return $wishlist->getItemCollection();
12
- else
13
  return false;
 
14
  }
15
 
16
- protected function _getWishlist() {
 
17
 
18
- //customer id param
19
- $customerId = Mage::app()->getRequest()->getParam('customer_id', false);
20
 
21
- if (! $customerId)
22
  return false;
 
23
 
24
- $wishlistModel = Mage::getModel('wishlist/wishlist')->loadByCustomer($customerId);
 
 
25
 
26
- return $wishlistModel;
27
  }
28
 
29
  public function getMode()
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Wishlist
4
+ extends Dotdigitalgroup_Email_Block_Edc
5
  {
6
+
7
  protected $_website;
8
 
9
  public function getWishlistItems()
10
  {
11
  $wishlist = $this->_getWishlist();
12
+ if ($wishlist && count($wishlist->getItemCollection())) {
13
  return $wishlist->getItemCollection();
14
+ } else {
15
  return false;
16
+ }
17
  }
18
 
19
+ protected function _getWishlist()
20
+ {
21
 
22
+ //customer id param
23
+ $customerId = Mage::app()->getRequest()->getParam('customer_id', false);
24
 
25
+ if ( ! $customerId) {
26
  return false;
27
+ }
28
 
29
+ $wishlistModel = Mage::getModel('wishlist/wishlist')->loadByCustomer(
30
+ $customerId
31
+ );
32
 
33
+ return $wishlistModel;
34
  }
35
 
36
  public function getMode()
app/code/community/Dotdigitalgroup/Email/Helper/Config.php CHANGED
@@ -11,25 +11,6 @@ class Dotdigitalgroup_Email_Helper_Config
11
  const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_credentials/api/username';
12
  const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_credentials/api/password';
13
 
14
- /**
15
- * SMS SECTION.
16
- */
17
- //enabled
18
- const XML_PATH_CONNECTOR_SMS_ENABLED_1 = 'connector_automation_studio/sms/sms_one_enabled';
19
- const XML_PATH_CONNECTOR_SMS_ENABLED_2 = 'connector_automation_studio/sms/sms_two_enabled';
20
- const XML_PATH_CONNECTOR_SMS_ENABLED_3 = 'connector_automation_studio/sms/sms_three_enabled';
21
- const XML_PATH_CONNECTOR_SMS_ENABLED_4 = 'connector_automation_studio/sms/sms_four_enabled';
22
- //status
23
- const XML_PATH_CONNECTOR_SMS_STATUS_1 = 'connector_automation_studio/sms/sms_one_status';
24
- const XML_PATH_CONNECTOR_SMS_STATUS_2 = 'connector_automation_studio/sms/sms_two_status';
25
- const XML_PATH_CONNECTOR_SMS_STATUS_3 = 'connector_automation_studio/sms/sms_three_status';
26
- const XML_PATH_CONNECTOR_SMS_STATUS_4 = 'connector_automation_studio/sms/sms_four_status';
27
- //message
28
- const XML_PATH_CONNECTOR_SMS_MESSAGE_1 = 'connector_automation_studio/sms/sms_one_message';
29
- const XML_PATH_CONNECTOR_SMS_MESSAGE_2 = 'connector_automation_studio/sms/sms_two_message';
30
- const XML_PATH_CONNECTOR_SMS_MESSAGE_3 = 'connector_automation_studio/sms/sms_three_message';
31
- const XML_PATH_CONNECTOR_SMS_MESSAGE_4 = 'connector_automation_studio/sms/sms_four_message';
32
-
33
  /**
34
  * SYNC SECTION.
35
  */
@@ -116,6 +97,8 @@ class Dotdigitalgroup_Email_Helper_Config
116
  const XML_PATH_CONNECTOR_CUSTOMER_LAST_BRAND_PURCHASED = 'connector_data_mapping/customer_data/last_brand_pur';
117
  const XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS = 'connector_data_mapping/customer_data/subscriber_status';
118
  const XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME = 'connector_data_mapping/customer_data/abandoned_prod_name';
 
 
119
 
120
  const XML_PATH_CONNECTOR_ENTERPRISE_CURRENT_BALANCE = 'connector_data_mapping/enterprise_data/reward_points';
121
  const XML_PATH_CONNECTOR_ENTERPRISE_REWARD_AMOUNT = 'connector_data_mapping/enterprise_data/reward_amount';
@@ -129,7 +112,6 @@ class Dotdigitalgroup_Email_Helper_Config
129
  * Dynamic Content
130
  */
131
  const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE = 'connector_dynamic_content/external_dynamic_content_urls/passcode';
132
- const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_NOSTO = 'connector_dynamic_content/nosto_recommendation/api';
133
  const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_WIHSLIST_DISPLAY = 'connector_dynamic_content/products/wishlist_display_type';
134
  const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE = 'connector_dynamic_content/products/review_display_type';
135
 
@@ -219,7 +201,6 @@ class Dotdigitalgroup_Email_Helper_Config
219
  /**
220
  * OAUTH
221
  */
222
- const API_CONNECTOR_OAUTH_URL = 'https://my.dotmailer.com/';
223
  const API_CONNECTOR_OAUTH_URL_AUTHORISE = 'OAuth2/authorise.aspx?';
224
  const API_CONNECTOR_OAUTH_URL_TOKEN = 'OAuth2/Tokens.ashx';
225
  const API_CONNECTOR_OAUTH_URL_LOG_USER = '?oauthtoken=';
@@ -269,6 +250,12 @@ class Dotdigitalgroup_Email_Helper_Config
269
  */
270
  const PATH_FOR_API_ENDPOINT = 'connector/api/endpoint';
271
 
 
 
 
 
 
 
272
  /**
273
  * @param int $website
274
  *
@@ -296,15 +283,30 @@ class Dotdigitalgroup_Email_Helper_Config
296
  if ($this->getAuthorizeLinkFlag($website)){
297
  $website = Mage::app()->getWebsite($website);
298
 
299
- $baseUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
300
-
301
  } else {
302
- $baseUrl = self::API_CONNECTOR_OAUTH_URL . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
 
303
  }
304
 
305
  return $baseUrl;
306
  }
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  /**
309
  * Callback authorization url.
310
  * @return mixed|string
@@ -331,7 +333,7 @@ class Dotdigitalgroup_Email_Helper_Config
331
  $tokenUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
332
  } else {
333
 
334
- $tokenUrl = self::API_CONNECTOR_OAUTH_URL . self::API_CONNECTOR_OAUTH_URL_TOKEN;
335
  }
336
 
337
  return $tokenUrl;
@@ -351,7 +353,7 @@ class Dotdigitalgroup_Email_Helper_Config
351
  $logUserUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
352
  } else {
353
 
354
- $logUserUrl = self::API_CONNECTOR_OAUTH_URL . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
355
  }
356
  return $logUserUrl;
357
  }
11
  const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_credentials/api/username';
12
  const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_credentials/api/password';
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * SYNC SECTION.
16
  */
97
  const XML_PATH_CONNECTOR_CUSTOMER_LAST_BRAND_PURCHASED = 'connector_data_mapping/customer_data/last_brand_pur';
98
  const XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS = 'connector_data_mapping/customer_data/subscriber_status';
99
  const XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME = 'connector_data_mapping/customer_data/abandoned_prod_name';
100
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_COMPANY_NAME = 'connector_data_mapping/customer_data/billing_company';
101
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COMPANY_NAME = 'connector_data_mapping/customer_data/delivery_company';
102
 
103
  const XML_PATH_CONNECTOR_ENTERPRISE_CURRENT_BALANCE = 'connector_data_mapping/enterprise_data/reward_points';
104
  const XML_PATH_CONNECTOR_ENTERPRISE_REWARD_AMOUNT = 'connector_data_mapping/enterprise_data/reward_amount';
112
  * Dynamic Content
113
  */
114
  const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE = 'connector_dynamic_content/external_dynamic_content_urls/passcode';
 
115
  const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_WIHSLIST_DISPLAY = 'connector_dynamic_content/products/wishlist_display_type';
116
  const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE = 'connector_dynamic_content/products/review_display_type';
117
 
201
  /**
202
  * OAUTH
203
  */
 
204
  const API_CONNECTOR_OAUTH_URL_AUTHORISE = 'OAuth2/authorise.aspx?';
205
  const API_CONNECTOR_OAUTH_URL_TOKEN = 'OAuth2/Tokens.ashx';
206
  const API_CONNECTOR_OAUTH_URL_LOG_USER = '?oauthtoken=';
250
  */
251
  const PATH_FOR_API_ENDPOINT = 'connector/api/endpoint';
252
 
253
+ /**
254
+ * Trial Account
255
+ */
256
+ const API_CONNECTOR_TRIAL_FORM_URL = 'https://magentosignup.dotmailer.com/';
257
+ const API_CONNECTOR_TRIAL_FORM_SECRET = 'DmTrialFormSecret';
258
+
259
  /**
260
  * @param int $website
261
  *
283
  if ($this->getAuthorizeLinkFlag($website)){
284
  $website = Mage::app()->getWebsite($website);
285
 
286
+ $baseUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN)
287
+ . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
288
  } else {
289
+
290
+ $baseUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
291
  }
292
 
293
  return $baseUrl;
294
  }
295
 
296
+ /**
297
+ * Region aware authorize link.
298
+ * @param $website
299
+ *
300
+ * @return mixed
301
+ */
302
+ public function getRegionAuthorize($website)
303
+ {
304
+ $baseRegionBaseUrl = Mage::helper('ddg')->getWebsiteConfig(
305
+ Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT, $website) . DS;
306
+
307
+ return $baseRegionBaseUrl;
308
+ }
309
+
310
  /**
311
  * Callback authorization url.
312
  * @return mixed|string
333
  $tokenUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
334
  } else {
335
 
336
+ $tokenUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
337
  }
338
 
339
  return $tokenUrl;
353
  $logUserUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
354
  } else {
355
 
356
+ $logUserUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
357
  }
358
  return $logUserUrl;
359
  }
app/code/community/Dotdigitalgroup/Email/Helper/Dashboard.php CHANGED
@@ -2,171 +2,206 @@
2
 
3
  class Dotdigitalgroup_Email_Helper_Dashboard extends Mage_Core_Helper_Abstract
4
  {
5
- protected $_rewriteTypes = array(
6
- 'blocks',
7
- 'helpers',
8
- 'models',
9
- );
10
-
11
- public function getRewrites()
12
- {
13
- $rewrites = array(
14
- 'blocks',
15
- 'models',
16
- 'helpers',
17
- );
18
-
19
- /* @var $_magentoConfig Mage_Core_Model_Config */
20
- $_magentoConfig = Mage::getConfig();
21
-
22
- // Load config of each module because modules can overwrite config each other. Global config is already merged
23
- $modules = $_magentoConfig->getNode('modules')->children();
24
- foreach ($modules as $moduleName => $moduleData) {
25
- // Check only active modules
26
- if (!$moduleData->is('active')) {
27
- continue;
28
- }
29
-
30
- // Load config of module
31
- $configXmlFile = $_magentoConfig->getModuleDir('etc', $moduleName) . DIRECTORY_SEPARATOR . 'config.xml';
32
- if (!file_exists($configXmlFile)) {
33
- continue;
34
- }
35
-
36
- $xml = simplexml_load_file($configXmlFile);
37
- if ($xml) {
38
- $rewriteElements = $xml->xpath('//rewrite');
39
- foreach ($rewriteElements as $element) {
40
- foreach ($element->children() as $child) {
41
- $type = simplexml_import_dom(dom_import_simplexml($element)->parentNode->parentNode)->getName();
42
- if (!in_array($type, $this->_rewriteTypes)) {
43
- continue;
44
- }
45
- $groupClassName = simplexml_import_dom(dom_import_simplexml($element)->parentNode)->getName();
46
- if (!isset($rewrites[$type][$groupClassName . '/' . $child->getName()])) {
47
- $rewrites[$type][$groupClassName . '/' . $child->getName()] = array();
48
- }
49
- $rewrites[$type][$groupClassName . '/' . $child->getName()]['classes'][] = (string) $child;
50
- }
51
- }
52
- }
53
- }
54
-
55
- foreach ($rewrites as $type => $data) {
56
- if (count($data) > 0 && is_array($data)) {
57
- foreach ($data as $node => $rewriteInfo) {
58
- if (count($rewriteInfo['classes']) > 1) {
59
- if ($this->_isInheritanceConflict($rewriteInfo['classes'])) {
60
- $rewrites[$type][$node]['conflicts'][] = array(
61
- 'node' => $node,
62
- 'loaded_class' => $this->_getLoadedClass($type, $node)
63
- );
64
- }
65
- }
66
- }
67
- }
68
- }
69
-
70
- $rewrites = array_merge($rewrites, $this->_loadLocalAutoloaderRewrites());
71
-
72
- if (empty($rewrites['blocks']) && empty($rewrites['models'])
73
- && empty($rewrites['helpers']) && empty($rewrites['autoload'])
74
- ) {
75
- return false;
76
- }
77
-
78
- return $rewrites;
79
- }
80
-
81
-
82
- /**
83
- * Check if rewritten class has inherited the parent class.
84
- * If yes we have no conflict. The top class can extend every core class.
85
- * So we cannot check this.
86
- *
87
- * @var array $classes
88
- * @return bool
89
- */
90
- protected function _isInheritanceConflict($classes)
91
- {
92
- $classes = array_reverse($classes);
93
- $count = count($classes) - 1;
94
- for ($i = 0; $i < $count; $i++) {
95
- try {
96
- if (class_exists($classes[$i]) && class_exists($classes[$i + 1])) {
97
- if (!is_a($classes[$i], $classes[$i + 1], true)) {
98
- return true;
99
- }
100
- }
101
- } catch (Exception $e) {
102
- return true;
103
- }
104
- }
105
-
106
- return false;
107
- }
108
-
109
- /**
110
- * Returns loaded class by type like models or blocks
111
- *
112
- * @param string $type Class Type
113
- * @param string $classGroup Class Group Name
114
- *
115
- * @return string
116
- */
117
- protected function _getLoadedClass($type, $classGroup)
118
- {
119
- switch ($type) {
120
- case 'blocks':
121
- return Mage::getConfig()->getBlockClassName($classGroup);
122
-
123
- case 'helpers':
124
- return Mage::getConfig()->getHelperClassName($classGroup);
125
-
126
- default:
127
- case 'models':
128
- return Mage::getConfig()->getModelClassName($classGroup);
129
- break;
130
- }
131
- }
132
-
133
-
134
- /**
135
- * Searches for all rewrites over autoloader in "app/code/local" of
136
- * Mage, Enterprise Zend, Varien namespaces.
137
- *
138
- * @return array
139
- */
140
- protected function _loadLocalAutoloaderRewrites()
141
- {
142
- $return = array();
143
- $localCodeFolder = Mage::getBaseDir('code') . '/local';
144
-
145
- $folders = array(
146
- 'Mage' => $localCodeFolder . '/Mage',
147
- 'Enterprise' => $localCodeFolder . '/Enterprise',
148
- 'Varien' => $localCodeFolder . '/Varien',
149
- 'Zend' => $localCodeFolder . '/Zend',
150
- );
151
-
152
- foreach ($folders as $vendorPrefix => $folder) {
153
- if (is_dir($folder)) {
154
- $directory = new RecursiveDirectoryIterator($folder);
155
- $iterator = new RecursiveIteratorIterator($directory);
156
- $files = new RegexIterator($iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
157
-
158
- foreach ($files as $file) {
159
- $classFile = trim(str_replace($folder, '', realpath($file[0])), '/');
160
- $className = $vendorPrefix
161
- . '_'
162
- . str_replace(DIRECTORY_SEPARATOR, '_', $classFile);
163
- $className = substr($className, 0, -4); // replace .php extension
164
- $return['autoload'][$className]['classes'][] = $className;
165
- }
166
- }
167
- }
168
- return $return;
169
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
 
172
  }
2
 
3
  class Dotdigitalgroup_Email_Helper_Dashboard extends Mage_Core_Helper_Abstract
4
  {
5
+
6
+ protected $_rewriteTypes
7
+ = array(
8
+ 'blocks',
9
+ 'helpers',
10
+ 'models',
11
+ );
12
+
13
+ public function getRewrites()
14
+ {
15
+ $rewrites = array(
16
+ 'blocks',
17
+ 'models',
18
+ 'helpers',
19
+ );
20
+
21
+ /* @var $_magentoConfig Mage_Core_Model_Config */
22
+ $_magentoConfig = Mage::getConfig();
23
+
24
+ // Load config of each module because modules can overwrite config each other. Global config is already merged
25
+ $modules = $_magentoConfig->getNode('modules')->children();
26
+ foreach ($modules as $moduleName => $moduleData) {
27
+ // Check only active modules
28
+ if ( ! $moduleData->is('active')) {
29
+ continue;
30
+ }
31
+
32
+ // Load config of module
33
+ $configXmlFile = $_magentoConfig->getModuleDir('etc', $moduleName)
34
+ . DIRECTORY_SEPARATOR . 'config.xml';
35
+ if ( ! file_exists($configXmlFile)) {
36
+ continue;
37
+ }
38
+
39
+ $xml = simplexml_load_file($configXmlFile);
40
+ if ($xml) {
41
+ $rewriteElements = $xml->xpath('//rewrite');
42
+ foreach ($rewriteElements as $element) {
43
+ foreach ($element->children() as $child) {
44
+ $type = simplexml_import_dom(
45
+ dom_import_simplexml(
46
+ $element
47
+ )->parentNode->parentNode
48
+ )->getName();
49
+ if ( ! in_array($type, $this->_rewriteTypes)) {
50
+ continue;
51
+ }
52
+ $groupClassName = simplexml_import_dom(
53
+ dom_import_simplexml($element)->parentNode
54
+ )->getName();
55
+ if ( ! isset(
56
+ $rewrites[$type][$groupClassName . '/'
57
+ . $child->getName()]
58
+ )
59
+ ) {
60
+ $rewrites[$type][$groupClassName . '/'
61
+ . $child->getName()]
62
+ = array();
63
+ }
64
+ $rewrites[$type][$groupClassName . '/'
65
+ . $child->getName()]['classes'][]
66
+ = (string)$child;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ foreach ($rewrites as $type => $data) {
73
+ if (count($data) > 0 && is_array($data)) {
74
+ foreach ($data as $node => $rewriteInfo) {
75
+ if (count($rewriteInfo['classes']) > 1) {
76
+ if ($this->_isInheritanceConflict(
77
+ $rewriteInfo['classes']
78
+ )
79
+ ) {
80
+ $rewrites[$type][$node]['conflicts'][] = array(
81
+ 'node' => $node,
82
+ 'loaded_class' => $this->_getLoadedClass(
83
+ $type, $node
84
+ )
85
+ );
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ $rewrites = array_merge(
93
+ $rewrites, $this->_loadLocalAutoloaderRewrites()
94
+ );
95
+
96
+ if (empty($rewrites['blocks']) && empty($rewrites['models'])
97
+ && empty($rewrites['helpers'])
98
+ && empty($rewrites['autoload'])
99
+ ) {
100
+ return false;
101
+ }
102
+
103
+ return $rewrites;
104
+ }
105
+
106
+
107
+ /**
108
+ * Check if rewritten class has inherited the parent class.
109
+ * If yes we have no conflict. The top class can extend every core class.
110
+ * So we cannot check this.
111
+ *
112
+ * @var array $classes
113
+ * @return bool
114
+ */
115
+ protected function _isInheritanceConflict($classes)
116
+ {
117
+ $classes = array_reverse($classes);
118
+ $count = count($classes) - 1;
119
+ for ($i = 0; $i < $count; $i++) {
120
+ try {
121
+ if (class_exists($classes[$i])
122
+ && class_exists(
123
+ $classes[$i + 1]
124
+ )
125
+ ) {
126
+ if ( ! is_a($classes[$i], $classes[$i + 1], true)) {
127
+ return true;
128
+ }
129
+ }
130
+ } catch (Exception $e) {
131
+ return true;
132
+ }
133
+ }
134
+
135
+ return false;
136
+ }
137
+
138
+ /**
139
+ * Returns loaded class by type like models or blocks
140
+ *
141
+ * @param string $type Class Type
142
+ * @param string $classGroup Class Group Name
143
+ *
144
+ * @return string
145
+ */
146
+ protected function _getLoadedClass($type, $classGroup)
147
+ {
148
+ switch ($type) {
149
+ case 'blocks':
150
+ return Mage::getConfig()->getBlockClassName($classGroup);
151
+
152
+ case 'helpers':
153
+ return Mage::getConfig()->getHelperClassName($classGroup);
154
+
155
+ default:
156
+ case 'models':
157
+ return Mage::getConfig()->getModelClassName($classGroup);
158
+ }
159
+ }
160
+
161
+
162
+ /**
163
+ * Searches for all rewrites over autoloader in "app/code/local" of
164
+ * Mage, Enterprise Zend, Varien namespaces.
165
+ *
166
+ * @return array
167
+ */
168
+ protected function _loadLocalAutoloaderRewrites()
169
+ {
170
+ $return = array();
171
+ $localCodeFolder = Mage::getBaseDir('code') . '/local';
172
+
173
+ $folders = array(
174
+ 'Mage' => $localCodeFolder . '/Mage',
175
+ 'Enterprise' => $localCodeFolder . '/Enterprise',
176
+ 'Varien' => $localCodeFolder . '/Varien',
177
+ 'Zend' => $localCodeFolder . '/Zend',
178
+ );
179
+
180
+ foreach ($folders as $vendorPrefix => $folder) {
181
+ if (is_dir($folder)) {
182
+ $directory = new RecursiveDirectoryIterator($folder);
183
+ $iterator = new RecursiveIteratorIterator($directory);
184
+ $files = new RegexIterator(
185
+ $iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH
186
+ );
187
+
188
+ foreach ($files as $file) {
189
+ $classFile = trim(
190
+ str_replace($folder, '', realpath($file[0])), '/'
191
+ );
192
+ $className = $vendorPrefix
193
+ . '_'
194
+ . str_replace(DIRECTORY_SEPARATOR, '_', $classFile);
195
+ $className = substr(
196
+ $className, 0, -4
197
+ ); // replace .php extension
198
+ $return['autoload'][$className]['classes'][] = $className;
199
+ }
200
+ }
201
+ }
202
+
203
+ return $return;
204
+ }
205
 
206
 
207
  }
app/code/community/Dotdigitalgroup/Email/Helper/Data.php CHANGED
@@ -6,61 +6,88 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
6
  public function isEnabled($website = 0)
7
  {
8
  $website = Mage::app()->getWebsite($website);
9
- return (bool)$website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED);
 
 
 
10
  }
11
 
12
  /**
13
- * @param int/object $website
 
14
  * @return mixed
15
  */
16
  public function getApiUsername($website = 0)
17
  {
18
  $website = Mage::app()->getWebsite($website);
19
 
20
- return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME);
 
 
21
  }
22
 
23
  public function getApiPassword($website = 0)
24
  {
25
  $website = Mage::app()->getWebsite($website);
26
 
27
- return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_PASSWORD);
 
 
 
 
 
28
  }
29
 
30
  public function auth($authRequest)
31
  {
32
- if ($authRequest != Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE)) {
33
- $this->getRaygunClient()->Send('Authentication failed with code :' . $authRequest);
34
- //throw new Exception('Authentication failed : ' . $authRequest);
 
 
 
 
 
35
  return false;
36
  }
 
37
  return true;
38
  }
39
 
40
  public function getMappedCustomerId()
41
  {
42
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID);
 
 
43
  }
44
 
45
  public function getMappedOrderId()
46
  {
47
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID);
 
 
48
  }
49
 
50
  public function getPasscode()
51
  {
52
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE);
 
 
53
  }
54
 
55
  public function getLastOrderId()
56
  {
57
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID);
 
 
58
 
59
  }
60
 
61
  public function getLastQuoteId()
62
  {
63
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID);
 
 
64
 
65
  }
66
 
@@ -72,53 +99,68 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
72
  Mage::log($data, $level, $filename, $force = true);
73
  }
74
 
75
- return $this;
76
  }
77
 
78
  public function getDebugEnabled()
79
  {
80
- return (bool) Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED);
 
 
81
  }
82
 
83
  /**
84
  * Extension version number.
 
85
  * @return string
86
  */
87
  public function getConnectorVersion()
88
  {
89
- $modules = (array) Mage::getConfig()->getNode('modules')->children();
90
  if (isset($modules['Dotdigitalgroup_Email'])) {
91
  $moduleName = $modules['Dotdigitalgroup_Email'];
92
- return (string) $moduleName->version;
 
93
  }
 
94
  return '';
95
  }
96
 
97
 
98
  public function getPageTrackingEnabled()
99
  {
100
- return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED);
 
 
101
  }
102
 
103
  public function getRoiTrackingEnabled()
104
  {
105
- return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED);
 
 
106
  }
107
 
108
  public function getResourceAllocationEnabled()
109
  {
110
- return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_RESOURCE_ALLOCATION);
 
 
111
  }
112
 
113
  public function getMappedStoreName($website)
114
  {
115
- $mapped = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME);
116
- $storeName = ($mapped)? $mapped : '';
117
- return $storeName;
 
 
 
118
  }
119
 
120
  /**
121
  * Get the contact id for the custoemer based on website id.
 
122
  * @param $email
123
  * @param $websiteId
124
  *
@@ -126,7 +168,8 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
126
  */
127
  public function getContactId($email, $websiteId)
128
  {
129
- $contact = Mage::getModel('ddg_automation/contact')->loadByCustomerEmail($email, $websiteId);
 
130
  if ($contactId = $contact->getContactId()) {
131
  return $contactId;
132
  }
@@ -134,38 +177,49 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
134
  $client = $this->getWebsiteApiClient($websiteId);
135
  $response = $client->postContacts($email);
136
 
137
- if (isset($response->message))
138
  return false;
 
139
  //save contact id
140
- if (isset($response->id)){
141
  $contact->setContactId($response->id)
142
  ->save();
143
  }
 
144
  return $response->id;
145
  }
146
 
147
  public function getCustomerAddressBook($website)
148
  {
149
  $website = Mage::app()->getWebsite($website);
150
- return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID);
 
 
 
151
  }
152
 
153
  public function getSubscriberAddressBook($website)
154
  {
155
  $website = Mage::app()->getWebsite($website);
156
- return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID);
 
 
 
157
  }
158
 
159
  public function getGuestAddressBook($website)
160
  {
161
  $website = Mage::app()->getWebsite($website);
162
- return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID);
 
 
 
163
  }
164
 
165
  /**
166
  * @return $this
167
  */
168
- public function allowResourceFullExecution()
169
  {
170
  if ($this->getResourceAllocationEnabled()) {
171
 
@@ -176,12 +230,16 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
176
  /* and memory to 512 megabytes */
177
  ini_set('memory_limit', '512M');
178
  }
 
179
  return $this;
180
  }
 
181
  public function convert($size)
182
  {
183
- $unit=array('b','kb','mb','gb','tb','pb');
184
- return round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
 
 
185
  }
186
 
187
  /**
@@ -193,8 +251,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
193
  foreach (Mage::app()->getWebsites() as $website) {
194
  $websiteId = $website->getId();
195
  $apiUsername = $this->getApiUsername($website);
196
- $accounts[$apiUsername] = $apiUsername . ', websiteId: ' . $websiteId . ' name ' . $website->getName();
 
197
  }
 
198
  return implode('</br>', $accounts);
199
  }
200
 
@@ -207,10 +267,13 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
207
  public function getCustomAttributes($website = 0)
208
  {
209
  $website = Mage::app()->getWebsite($website);
210
- $attr = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS);
 
 
211
 
212
- if (!$attr)
213
  return array();
 
214
 
215
  return unserialize($attr);
216
  }
@@ -218,39 +281,50 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
218
 
219
  /**
220
  * Enterprise custom datafields attributes.
 
221
  * @param int $website
222
  *
223
  * @return array
224
  * @throws Mage_Core_Exception
225
  */
226
- public function getEnterpriseAttributes( $website = 0) {
 
227
  $website = Mage::app()->getWebsite($website);
228
  $result = array();
229
- $attrs = $website->getConfig('connector_data_mapping/enterprise_data');
 
 
230
 
231
- if(is_array($attrs)){
232
  //get individual mapped keys
233
- foreach ( $attrs as $key => $one ) {
234
- $config = $website->getConfig('connector_data_mapping/enterprise_data/' . $key);
 
 
235
  //check for the mapped field
236
- if ($config)
237
  $result[$key] = $config;
 
238
  }
239
  }
240
 
241
- if (empty($result))
242
  return false;
 
 
243
  return $result;
244
  }
245
 
246
  /**
247
- * @param $path
248
  * @param null|string|bool|int|Mage_Core_Model_Website $websiteId
 
249
  * @return mixed
250
  */
251
  public function getWebsiteConfig($path, $websiteId = 0)
252
  {
253
  $website = Mage::app()->getWebsite($websiteId);
 
254
  return $website->getConfig($path);
255
  }
256
 
@@ -263,11 +337,16 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
263
  */
264
  public function getWebsiteApiClient($website = 0)
265
  {
266
- if(!$this->isEnabled($website))
267
  return false;
 
268
 
269
- if (! $apiUsername = $this->getApiUsername($website) || ! $apiPassword = $this->getApiPassword($website))
 
 
 
270
  return false;
 
271
 
272
  $client = Mage::getModel('ddg_automation/apiconnector_client');
273
  $client->setApiUsername($this->getApiUsername($website))
@@ -289,11 +368,14 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
289
 
290
  /**
291
  * Autorisation url for OAUTH.
 
292
  * @return string
293
  */
294
  public function getAuthoriseUrl()
295
  {
296
- $clientId = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID);
 
 
297
 
298
  //callback uri if not set custom
299
  $redirectUri = $this->getRedirectUri();
@@ -308,7 +390,8 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
308
  );
309
 
310
  $authorizeBaseUrl = Mage::helper('ddg/config')->getAuthorizeLink();
311
- $url = $authorizeBaseUrl . http_build_query($params) . '&client_id=' . $clientId;
 
312
 
313
  return $url;
314
  }
@@ -322,54 +405,79 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
322
 
323
  /**
324
  * order status config value
 
325
  * @param int $website
 
326
  * @return mixed order status
327
  */
328
  public function getConfigSelectedStatus($website = 0)
329
  {
330
- $status = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS, $website);
331
- if($status)
332
- return explode(',',$status);
333
- else
 
 
 
334
  return false;
 
335
  }
336
 
337
  public function getConfigSelectedCustomOrderAttributes($website = 0)
338
  {
339
- $customAttributes = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES, $website);
340
- if($customAttributes)
341
- return explode(',',$customAttributes);
342
- else
 
 
 
343
  return false;
 
344
  }
345
 
346
  public function getConfigSelectedCustomQuoteAttributes($website = 0)
347
  {
348
- $customAttributes = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_QUOTE_ATTRIBUTES, $website);
349
- if($customAttributes)
350
- return explode(',',$customAttributes);
351
- else
 
 
 
352
  return false;
 
353
  }
354
 
355
  /**
356
  * check sweet tooth installed/active status
 
357
  * @return boolean
358
  */
359
  public function isSweetToothEnabled()
360
  {
361
- return (bool)Mage::getConfig()->getModuleConfig('TBT_Rewards')->is('active', 'true');
 
 
362
  }
363
 
364
  /**
365
  * check sweet tooth installed/active status and active status
 
366
  * @param Mage_Core_Model_Website $website
 
367
  * @return boolean
368
  */
369
  public function isSweetToothToGo($website)
370
  {
371
- $stMappingStatus = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE, $website);
372
- if($stMappingStatus && $this->isSweetToothEnabled()) return true;
 
 
 
 
 
 
373
  return false;
374
  }
375
 
@@ -384,29 +492,33 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
384
  array("customer_id = ?" => $customerId)
385
  );
386
  } catch (Exception $e) {
387
- Mage::logException($e);
388
  }
389
  }
390
 
391
  /**
392
- * Diff between to times;
 
 
 
393
  *
394
- * @param $time1
395
- * @param $time2
396
  * @return int
397
  */
398
- public function dateDiff($time1, $time2=NULL) {
399
- if (is_null($time2)) {
400
- $time2 = Mage::getModel('core/date')->date();
 
401
  }
402
- $time1 = strtotime($time1);
403
- $time2 = strtotime($time2);
404
- return $time2 - $time1;
 
405
  }
406
 
407
 
408
  /**
409
  * Disable website config when the request is made admin area only!
 
410
  * @param $path
411
  *
412
  * @throws Mage_Core_Exception
@@ -427,9 +539,11 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
427
 
428
  /**
429
  * number of customers with duplicate emails, emails as total number
 
430
  * @return Mage_Customer_Model_Resource_Customer_Collection
431
  */
432
- public function getCustomersWithDuplicateEmails( ) {
 
433
  $customers = Mage::getModel('customer/customer')->getCollection();
434
 
435
  //duplicate emails
@@ -448,12 +562,18 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
448
  */
449
  public function getRaygunClient()
450
  {
451
- $code = Mage::getstoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE);
 
 
452
 
453
  if ($this->raygunEnabled()) {
454
  //use async mode for sending.
455
- $async = Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_ASYNC);
456
- require_once Mage::getBaseDir('lib') . DS . 'Raygun4php' . DS . 'RaygunClient.php';
 
 
 
 
457
  return new Raygun4php\RaygunClient($code, $async);
458
  }
459
 
@@ -462,22 +582,28 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
462
 
463
  /**
464
  * Raygun logs.
465
- * @param $message
 
466
  * @param string $filename
467
  * @param int $line
468
  * @param array $tags
469
  *
470
  * @return int|null
471
  */
472
- public function rayLog($message, $filename = 'apiconnector/client.php', $line = 1, $tags = array())
473
- {
474
- //check if raygun has code enabled
475
- if (!$this->raygunEnabled())
 
 
 
 
476
  return;
 
477
 
478
- $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
479
 
480
- if (empty($tags)) {
481
  $tags = array(
482
  $baseUrl,
483
  Mage::getVersion()
@@ -488,12 +614,13 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
488
  //user, firstname, lastname, email, annonim, uuid
489
  $client->SetUser($baseUrl, null, null, $this->getApiUsername());
490
  $client->SetVersion($this->getConnectorVersion());
491
- $client->SendError(100, $message, $filename,$line, $tags);
492
  }
493
 
494
 
495
  /**
496
  * check for raygun application and if enabled.
 
497
  * @param int $websiteId
498
  *
499
  * @return mixed
@@ -503,13 +630,16 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
503
  {
504
  $website = Mage::app()->getWebsite($websiteId);
505
 
506
- return (bool)$website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE);
 
 
507
 
508
  }
509
 
510
  /**
511
  * Generate the baseurl for the default store
512
  * dynamic content will be displayed
 
513
  * @return string
514
  * @throws Mage_Core_Exception
515
  */
@@ -518,16 +648,20 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
518
  $website = Mage::app()->getRequest()->getParam('website', false);
519
 
520
  //set website url for the default store id
521
- $website = ($website)? Mage::app()->getWebsite( $website ) : 0;
522
 
523
  $defaultGroup = Mage::app()->getWebsite($website)
524
  ->getDefaultGroup();
525
 
526
- if (! $defaultGroup)
527
- return $mage = Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
 
 
 
528
 
529
  //base url
530
- $baseUrl = Mage::app()->getStore($defaultGroup->getDefaultStore())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
 
531
 
532
  return $baseUrl;
533
 
@@ -537,11 +671,15 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
537
  *
538
  *
539
  * @param int $store
 
540
  * @return mixed
541
  */
542
  public function isNewsletterSuccessDisabled($store = 0)
543
  {
544
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS, $store);
 
 
 
545
  }
546
 
547
  /**
@@ -549,7 +687,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
549
  */
550
  public function getEasyEmailCapture()
551
  {
552
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE);
 
 
553
  }
554
 
555
  /**
@@ -557,8 +697,11 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
557
  */
558
  public function getEasyEmailCaptureForNewsletter()
559
  {
560
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE_NEWSLETTER);
 
 
561
  }
 
562
  /**
563
  * get feefo logon config value
564
  *
@@ -566,7 +709,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
566
  */
567
  public function getFeefoLogon()
568
  {
569
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_LOGON);
 
 
570
  }
571
 
572
  /**
@@ -576,7 +721,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
576
  */
577
  public function getFeefoReviewsPerProduct()
578
  {
579
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_REVIEWS);
 
 
580
  }
581
 
582
  /**
@@ -586,41 +733,56 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
586
  */
587
  public function getFeefoLogoTemplate()
588
  {
589
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_TEMPLATE);
 
 
590
  }
591
 
592
- /**
593
- * @param $website
594
- * @return string
595
- */
596
- public function getReviewDisplayType($website)
597
- {
598
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE, $website);
599
- }
 
 
 
 
600
 
601
  /**
602
  * update data fields
603
  *
604
- * @param $email
605
  * @param Mage_Core_Model_Website $website
606
- * @param $storeName
607
  */
608
- public function updateDataFields($email, Mage_Core_Model_Website $website, $storeName)
609
- {
 
 
 
610
  $data = array();
611
- if($store_name = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME)){
 
 
 
612
  $data[] = array(
613
- 'Key' => $store_name,
614
  'Value' => $storeName
615
  );
616
  }
617
- if($website_name = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME)){
 
 
 
618
  $data[] = array(
619
- 'Key' => $website_name,
620
  'Value' => $website->getName()
621
  );
622
  }
623
- if(!empty($data)){
624
  //update data fields
625
  $client = $this->getWebsiteApiClient($website);
626
  $client->updateContactDatafieldsByEmail($email, $data);
@@ -629,25 +791,32 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
629
 
630
  /**
631
  * check connector SMTP installed/active status
 
632
  * @return boolean
633
  */
634
  public function isSmtpEnabled()
635
  {
636
- return (bool)Mage::getConfig()->getModuleConfig('Ddg_Transactional')->is('active', 'true');
 
637
  }
638
 
639
  /**
640
  * Is magento enterprise.
 
641
  * @return bool
642
  */
643
  public function isEnterprise()
644
  {
645
- return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
 
 
 
646
 
647
  }
648
 
649
  /**
650
  * Update last quote id datafield.
 
651
  * @param $quoteId
652
  * @param $email
653
  * @param $websiteId
@@ -672,17 +841,25 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
672
  public function disableRaygun()
673
  {
674
  $config = Mage::getModel('core/config');
675
- $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE, '');
 
 
 
676
  Mage::getConfig()->cleanCache();
677
  }
678
 
679
  public function enableRaygunCode()
680
  {
681
  $curl = new Varien_Http_Adapter_Curl();
682
- $curl->setConfig(array(
683
- 'timeout' => 2
684
- ));
685
- $curl->write(Zend_Http_Client::GET, Dotdigitalgroup_Email_Helper_Config::RAYGUN_API_CODE_URL, '1.0');
 
 
 
 
 
686
  $data = $curl->read();
687
 
688
  if ($data === false) {
@@ -692,15 +869,19 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
692
  $data = trim($data[1]);
693
  $curl->close();
694
 
695
- $xml = new SimpleXMLElement($data);
696
  $raygunCode = $xml->code;
697
 
698
  //not found
699
- if (!$raygunCode)
700
  return;
 
701
 
702
  $config = Mage::getModel('core/config');
703
- $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE, $raygunCode);
 
 
 
704
  }
705
 
706
  /**
@@ -708,10 +889,11 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
708
  *
709
  * @param $e Exception
710
  */
711
- public function sendRaygunException( $e )
712
  {
713
- if (!$this->raygunEnabled())
714
  return;
 
715
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
716
  $tags = array(
717
  $baseUrl,
@@ -732,8 +914,12 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
732
  */
733
  public function getOrderSyncEnabled($websiteId = 0)
734
  {
735
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, $websiteId);
 
 
 
736
  }
 
737
  /**
738
  * @param int $websiteId
739
  *
@@ -741,7 +927,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
741
  */
742
  public function getCatalogSyncEnabled($websiteId = 0)
743
  {
744
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CATALOG_ENABLED, $websiteId);
 
 
 
745
  }
746
 
747
  /**
@@ -751,7 +940,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
751
  */
752
  public function getContactSyncEnabled($websiteId = 0)
753
  {
754
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, $websiteId);
 
 
 
755
  }
756
 
757
  /**
@@ -761,7 +953,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
761
  */
762
  public function getGuestSyncEnabled($websiteId = 0)
763
  {
764
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED, $websiteId);
 
 
 
765
  }
766
 
767
  /**
@@ -771,7 +966,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
771
  */
772
  public function getSubscriberSyncEnabled($websiteId = 0)
773
  {
774
- return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, $websiteId);
 
 
 
775
  }
776
 
777
  /**
@@ -779,25 +977,31 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
779
  */
780
  public function getCronInstalled()
781
  {
782
- $lastCustomerSync = Mage::getModel('ddg_automation/cron')->getLastCustomerSync();
 
783
  $timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
784
 
785
  //last customer cron was less then 15 min
786
  if ($timespan <= 15 * 60) {
787
  return true;
788
  }
 
789
  return false;
790
  }
 
791
  /**
792
  * Get the config id by the automation type.
793
- * @param $automationType
 
794
  * @param int $websiteId
795
  *
796
  * @return mixed
797
  */
798
  public function getAutomationIdByType($automationType, $websiteId = 0)
799
  {
800
- $path = constant('Dotdigitalgroup_Email_Helper_Config::' . $automationType);
 
 
801
  $automationCampaignId = $this->getWebsiteConfig($path, $websiteId);
802
 
803
  return $automationCampaignId;
@@ -805,12 +1009,15 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
805
 
806
  public function getAbandonedProductName()
807
  {
808
- return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME);
 
 
809
 
810
  }
811
 
812
  /**
813
  * Update last quote id datafield.
 
814
  * @param $name
815
  * @param $email
816
  * @param $websiteId
@@ -843,7 +1050,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
843
  public function getApiResponseTimeLimit($websiteId = 0)
844
  {
845
  $website = Mage::app()->getWebsite($websiteId);
846
- $limit = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DEBUG_API_REQUEST_LIMIT);
 
 
847
 
848
  return $limit;
849
  }
@@ -855,27 +1064,32 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
855
  *
856
  * @return string
857
  */
858
- public function getAccountEmail( $website = 0)
859
  {
860
  $client = $this->getWebsiteApiClient($website);
861
- $info = $client->getAccountInfo();
862
  $email = '';
863
 
864
- if(isset($info->properties)){
865
  $properties = $info->properties;
866
 
867
- foreach ( $properties as $property ) {
868
 
869
- if ($property->name == 'MainEmail')
870
  $email = $property->value;
 
871
  }
872
  }
 
873
  return $email;
874
  }
875
 
876
  public function authIpAddress()
877
  {
878
- if ($ipString = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_IP_RESTRICTION_ADDRESSES)) {
 
 
 
879
  //string to array
880
  $ipArray = explode(',', $ipString);
881
  //remove white spaces
@@ -891,35 +1105,38 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
891
 
892
  return false;
893
  } else {
894
- //empty ip list will ignore the validation
895
- return true;
896
  }
897
  }
898
 
899
- /**
900
- * get log file content.
901
- *
902
- * @param string $filename
903
- *
904
- * @return string
905
- */
906
  public function getLogFileContent($filename = 'connector_api.log')
907
  {
908
- $path_to_log_file = Mage::getBaseDir('var') . DS . 'log' . DS . $filename;;
909
- //tail the length file content
910
- $lengthBefore = 500000;
 
911
 
912
- $handle = fopen($path_to_log_file, 'r');
913
- fseek($handle, -$lengthBefore, SEEK_END);
914
 
915
  if (!$handle) {
916
- return "Log file is not readable or does not exist at this moment. File path is ".$path_to_log_file;
 
917
  }
918
 
919
- $contents = fread($handle, filesize($path_to_log_file));
920
 
921
  if (!$contents) {
922
- return "Log file is not readable or does not exist at this moment. File path is ".$path_to_log_file;
 
923
  }
924
  fclose($handle);
925
 
@@ -927,69 +1144,803 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
927
  }
928
 
929
 
930
- /**
931
- * PRODUCT REVIEW REMINDER.
932
- */
933
- public function isReviewReminderEnabled($website)
934
- {
935
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_ENABLED, $website);
936
- }
937
-
938
- /**
939
- * @param $website
940
- * @return string
941
- */
942
- public function getReviewReminderOrderStatus($website)
943
- {
944
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_STATUS, $website);
945
- }
946
-
947
- /**
948
- * @param $website
949
- * @return int
950
- */
951
- public function getReviewReminderDelay($website)
952
- {
953
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_DELAY, $website);
954
- }
955
-
956
- /**
957
- * @param $website
958
- * @return int
959
- */
960
- public function getReviewReminderCampaign($website)
961
- {
962
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_CAMPAIGN, $website);
963
- }
964
-
965
- /**
966
- * @param $website
967
- * @return string
968
- */
969
- public function getReviewReminderAnchor($website)
970
- {
971
- return $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_ANCHOR, $website);
972
- }
973
-
974
-
975
- public function getDynamicStyles()
976
- {
977
- return $dynamicStyle = array(
978
- 'nameStyle' => explode(',', Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_STYLE)),
979
- 'priceStyle' => explode(',', Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_STYLE)),
980
- 'linkStyle' => explode(',', Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_STYLE)),
981
- 'otherStyle' => explode(',', Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_STYLE)),
982
- 'nameColor' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_COLOR),
983
- 'fontSize' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_FONT_SIZE),
984
- 'priceColor' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_COLOR),
985
- 'priceFontSize' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_FONT_SIZE),
986
- 'urlColor' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_COLOR),
987
- 'urlFontSize' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_FONT_SIZE),
988
- 'otherColor' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_COLOR),
989
- 'otherFontSize' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_FONT_SIZE),
990
- 'docFont' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_DOC_FONT),
991
- 'docBackgroundColor' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_DOC_BG_COLOR),
992
- 'dynamicStyling' => Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_STYLING)
993
- );
994
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
995
  }
6
  public function isEnabled($website = 0)
7
  {
8
  $website = Mage::app()->getWebsite($website);
9
+
10
+ return (bool)$website->getConfig(
11
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED
12
+ );
13
  }
14
 
15
  /**
16
+ * @param int /object $website
17
+ *
18
  * @return mixed
19
  */
20
  public function getApiUsername($website = 0)
21
  {
22
  $website = Mage::app()->getWebsite($website);
23
 
24
+ return $website->getConfig(
25
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME
26
+ );
27
  }
28
 
29
  public function getApiPassword($website = 0)
30
  {
31
  $website = Mage::app()->getWebsite($website);
32
 
33
+ return Mage::helper('core')->decrypt(
34
+ $website->getConfig(
35
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_PASSWORD
36
+ )
37
+ );
38
+
39
  }
40
 
41
  public function auth($authRequest)
42
  {
43
+ if ($authRequest != Mage::getStoreConfig(
44
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE
45
+ )
46
+ ) {
47
+ $this->getRaygunClient()->Send(
48
+ 'Authentication failed with code :' . $authRequest
49
+ );
50
+
51
  return false;
52
  }
53
+
54
  return true;
55
  }
56
 
57
  public function getMappedCustomerId()
58
  {
59
+ return Mage::getStoreConfig(
60
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID
61
+ );
62
  }
63
 
64
  public function getMappedOrderId()
65
  {
66
+ return Mage::getStoreConfig(
67
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID
68
+ );
69
  }
70
 
71
  public function getPasscode()
72
  {
73
+ return Mage::getStoreConfig(
74
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE
75
+ );
76
  }
77
 
78
  public function getLastOrderId()
79
  {
80
+ return Mage::getStoreConfig(
81
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID
82
+ );
83
 
84
  }
85
 
86
  public function getLastQuoteId()
87
  {
88
+ return Mage::getStoreConfig(
89
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID
90
+ );
91
 
92
  }
93
 
99
  Mage::log($data, $level, $filename, $force = true);
100
  }
101
 
102
+ return $this;
103
  }
104
 
105
  public function getDebugEnabled()
106
  {
107
+ return (bool)Mage::getStoreConfig(
108
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED
109
+ );
110
  }
111
 
112
  /**
113
  * Extension version number.
114
+ *
115
  * @return string
116
  */
117
  public function getConnectorVersion()
118
  {
119
+ $modules = (array)Mage::getConfig()->getNode('modules')->children();
120
  if (isset($modules['Dotdigitalgroup_Email'])) {
121
  $moduleName = $modules['Dotdigitalgroup_Email'];
122
+
123
+ return (string)$moduleName->version;
124
  }
125
+
126
  return '';
127
  }
128
 
129
 
130
  public function getPageTrackingEnabled()
131
  {
132
+ return (bool)Mage::getStoreConfig(
133
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED
134
+ );
135
  }
136
 
137
  public function getRoiTrackingEnabled()
138
  {
139
+ return (bool)Mage::getStoreConfig(
140
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED
141
+ );
142
  }
143
 
144
  public function getResourceAllocationEnabled()
145
  {
146
+ return (bool)Mage::getStoreConfig(
147
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_RESOURCE_ALLOCATION
148
+ );
149
  }
150
 
151
  public function getMappedStoreName($website)
152
  {
153
+ $mapped = $website->getConfig(
154
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME
155
+ );
156
+ $storeName = ($mapped) ? $mapped : '';
157
+
158
+ return $storeName;
159
  }
160
 
161
  /**
162
  * Get the contact id for the custoemer based on website id.
163
+ *
164
  * @param $email
165
  * @param $websiteId
166
  *
168
  */
169
  public function getContactId($email, $websiteId)
170
  {
171
+ $contact = Mage::getModel('ddg_automation/contact')
172
+ ->loadByCustomerEmail($email, $websiteId);
173
  if ($contactId = $contact->getContactId()) {
174
  return $contactId;
175
  }
177
  $client = $this->getWebsiteApiClient($websiteId);
178
  $response = $client->postContacts($email);
179
 
180
+ if (isset($response->message)) {
181
  return false;
182
+ }
183
  //save contact id
184
+ if (isset($response->id)) {
185
  $contact->setContactId($response->id)
186
  ->save();
187
  }
188
+
189
  return $response->id;
190
  }
191
 
192
  public function getCustomerAddressBook($website)
193
  {
194
  $website = Mage::app()->getWebsite($website);
195
+
196
+ return $website->getConfig(
197
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID
198
+ );
199
  }
200
 
201
  public function getSubscriberAddressBook($website)
202
  {
203
  $website = Mage::app()->getWebsite($website);
204
+
205
+ return $website->getConfig(
206
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID
207
+ );
208
  }
209
 
210
  public function getGuestAddressBook($website)
211
  {
212
  $website = Mage::app()->getWebsite($website);
213
+
214
+ return $website->getConfig(
215
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID
216
+ );
217
  }
218
 
219
  /**
220
  * @return $this
221
  */
222
+ public function allowResourceFullExecution()
223
  {
224
  if ($this->getResourceAllocationEnabled()) {
225
 
230
  /* and memory to 512 megabytes */
231
  ini_set('memory_limit', '512M');
232
  }
233
+
234
  return $this;
235
  }
236
+
237
  public function convert($size)
238
  {
239
+ $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
240
+
241
+ return round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' '
242
+ . $unit[$i];
243
  }
244
 
245
  /**
251
  foreach (Mage::app()->getWebsites() as $website) {
252
  $websiteId = $website->getId();
253
  $apiUsername = $this->getApiUsername($website);
254
+ $accounts[$apiUsername] = $apiUsername . ', websiteId: '
255
+ . $websiteId . ' name ' . $website->getName();
256
  }
257
+
258
  return implode('</br>', $accounts);
259
  }
260
 
267
  public function getCustomAttributes($website = 0)
268
  {
269
  $website = Mage::app()->getWebsite($website);
270
+ $attr = $website->getConfig(
271
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS
272
+ );
273
 
274
+ if (!$attr) {
275
  return array();
276
+ }
277
 
278
  return unserialize($attr);
279
  }
281
 
282
  /**
283
  * Enterprise custom datafields attributes.
284
+ *
285
  * @param int $website
286
  *
287
  * @return array
288
  * @throws Mage_Core_Exception
289
  */
290
+ public function getEnterpriseAttributes($website = 0)
291
+ {
292
  $website = Mage::app()->getWebsite($website);
293
  $result = array();
294
+ $attrs = $website->getConfig(
295
+ 'connector_data_mapping/enterprise_data'
296
+ );
297
 
298
+ if (is_array($attrs)) {
299
  //get individual mapped keys
300
+ foreach ($attrs as $key => $one) {
301
+ $config = $website->getConfig(
302
+ 'connector_data_mapping/enterprise_data/' . $key
303
+ );
304
  //check for the mapped field
305
+ if ($config) {
306
  $result[$key] = $config;
307
+ }
308
  }
309
  }
310
 
311
+ if (empty($result)) {
312
  return false;
313
+ }
314
+
315
  return $result;
316
  }
317
 
318
  /**
319
+ * @param $path
320
  * @param null|string|bool|int|Mage_Core_Model_Website $websiteId
321
+ *
322
  * @return mixed
323
  */
324
  public function getWebsiteConfig($path, $websiteId = 0)
325
  {
326
  $website = Mage::app()->getWebsite($websiteId);
327
+
328
  return $website->getConfig($path);
329
  }
330
 
337
  */
338
  public function getWebsiteApiClient($website = 0)
339
  {
340
+ if (!$this->isEnabled($website)) {
341
  return false;
342
+ }
343
 
344
+ if (!$apiUsername = $this->getApiUsername($website)
345
+ || !$apiPassword
346
+ = $this->getApiPassword($website)
347
+ ) {
348
  return false;
349
+ }
350
 
351
  $client = Mage::getModel('ddg_automation/apiconnector_client');
352
  $client->setApiUsername($this->getApiUsername($website))
368
 
369
  /**
370
  * Autorisation url for OAUTH.
371
+ *
372
  * @return string
373
  */
374
  public function getAuthoriseUrl()
375
  {
376
+ $clientId = Mage::getStoreConfig(
377
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID
378
+ );
379
 
380
  //callback uri if not set custom
381
  $redirectUri = $this->getRedirectUri();
390
  );
391
 
392
  $authorizeBaseUrl = Mage::helper('ddg/config')->getAuthorizeLink();
393
+ $url = $authorizeBaseUrl . http_build_query($params)
394
+ . '&client_id=' . $clientId;
395
 
396
  return $url;
397
  }
405
 
406
  /**
407
  * order status config value
408
+ *
409
  * @param int $website
410
+ *
411
  * @return mixed order status
412
  */
413
  public function getConfigSelectedStatus($website = 0)
414
  {
415
+ $status = $this->getWebsiteConfig(
416
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS,
417
+ $website
418
+ );
419
+ if ($status) {
420
+ return explode(',', $status);
421
+ } else {
422
  return false;
423
+ }
424
  }
425
 
426
  public function getConfigSelectedCustomOrderAttributes($website = 0)
427
  {
428
+ $customAttributes = $this->getWebsiteConfig(
429
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES,
430
+ $website
431
+ );
432
+ if ($customAttributes) {
433
+ return explode(',', $customAttributes);
434
+ } else {
435
  return false;
436
+ }
437
  }
438
 
439
  public function getConfigSelectedCustomQuoteAttributes($website = 0)
440
  {
441
+ $customAttributes = $this->getWebsiteConfig(
442
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_QUOTE_ATTRIBUTES,
443
+ $website
444
+ );
445
+ if ($customAttributes) {
446
+ return explode(',', $customAttributes);
447
+ } else {
448
  return false;
449
+ }
450
  }
451
 
452
  /**
453
  * check sweet tooth installed/active status
454
+ *
455
  * @return boolean
456
  */
457
  public function isSweetToothEnabled()
458
  {
459
+ return (bool)Mage::getConfig()->getModuleConfig('TBT_Rewards')->is(
460
+ 'active', 'true'
461
+ );
462
  }
463
 
464
  /**
465
  * check sweet tooth installed/active status and active status
466
+ *
467
  * @param Mage_Core_Model_Website $website
468
+ *
469
  * @return boolean
470
  */
471
  public function isSweetToothToGo($website)
472
  {
473
+ $stMappingStatus = $this->getWebsiteConfig(
474
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE,
475
+ $website
476
+ );
477
+ if ($stMappingStatus && $this->isSweetToothEnabled()) {
478
+ return true;
479
+ }
480
+
481
  return false;
482
  }
483
 
492
  array("customer_id = ?" => $customerId)
493
  );
494
  } catch (Exception $e) {
495
+ Mage::logException($e);
496
  }
497
  }
498
 
499
  /**
500
+ * Diff between to times.
501
+ *
502
+ * @param $timeOne
503
+ * @param null $timeTwo
504
  *
 
 
505
  * @return int
506
  */
507
+ public function dateDiff($timeOne, $timeTwo = null)
508
+ {
509
+ if (is_null($timeTwo)) {
510
+ $timeTwo = Mage::getModel('core/date')->date();
511
  }
512
+ $timeOne = strtotime($timeOne);
513
+ $timeTwo = strtotime($timeTwo);
514
+
515
+ return $timeTwo - $timeOne;
516
  }
517
 
518
 
519
  /**
520
  * Disable website config when the request is made admin area only!
521
+ *
522
  * @param $path
523
  *
524
  * @throws Mage_Core_Exception
539
 
540
  /**
541
  * number of customers with duplicate emails, emails as total number
542
+ *
543
  * @return Mage_Customer_Model_Resource_Customer_Collection
544
  */
545
+ public function getCustomersWithDuplicateEmails()
546
+ {
547
  $customers = Mage::getModel('customer/customer')->getCollection();
548
 
549
  //duplicate emails
562
  */
563
  public function getRaygunClient()
564
  {
565
+ $code = Mage::getstoreConfig(
566
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE
567
+ );
568
 
569
  if ($this->raygunEnabled()) {
570
  //use async mode for sending.
571
+ $async = Mage::getStoreConfigFlag(
572
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_ASYNC
573
+ );
574
+ require_once Mage::getBaseDir('lib') . DS . 'Raygun4php' . DS
575
+ . 'RaygunClient.php';
576
+
577
  return new Raygun4php\RaygunClient($code, $async);
578
  }
579
 
582
 
583
  /**
584
  * Raygun logs.
585
+ *
586
+ * @param $message
587
  * @param string $filename
588
  * @param int $line
589
  * @param array $tags
590
  *
591
  * @return int|null
592
  */
593
+ public function rayLog(
594
+ $message,
595
+ $filename = 'apiconnector/client.php',
596
+ $line = 1,
597
+ $tags = array()
598
+ ) {
599
+ //check if raygun has code enabled
600
+ if (!$this->raygunEnabled()) {
601
  return;
602
+ }
603
 
604
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
605
 
606
+ if (empty($tags)) {
607
  $tags = array(
608
  $baseUrl,
609
  Mage::getVersion()
614
  //user, firstname, lastname, email, annonim, uuid
615
  $client->SetUser($baseUrl, null, null, $this->getApiUsername());
616
  $client->SetVersion($this->getConnectorVersion());
617
+ $client->SendError(100, $message, $filename, $line, $tags);
618
  }
619
 
620
 
621
  /**
622
  * check for raygun application and if enabled.
623
+ *
624
  * @param int $websiteId
625
  *
626
  * @return mixed
630
  {
631
  $website = Mage::app()->getWebsite($websiteId);
632
 
633
+ return (bool)$website->getConfig(
634
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE
635
+ );
636
 
637
  }
638
 
639
  /**
640
  * Generate the baseurl for the default store
641
  * dynamic content will be displayed
642
+ *
643
  * @return string
644
  * @throws Mage_Core_Exception
645
  */
648
  $website = Mage::app()->getRequest()->getParam('website', false);
649
 
650
  //set website url for the default store id
651
+ $website = ($website) ? Mage::app()->getWebsite($website) : 0;
652
 
653
  $defaultGroup = Mage::app()->getWebsite($website)
654
  ->getDefaultGroup();
655
 
656
+ if (!$defaultGroup) {
657
+ return $mage = Mage::app()->getStore()->getBaseUrl(
658
+ Mage_Core_Model_Store::URL_TYPE_WEB
659
+ );
660
+ }
661
 
662
  //base url
663
+ $baseUrl = Mage::app()->getStore($defaultGroup->getDefaultStore())
664
+ ->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
665
 
666
  return $baseUrl;
667
 
671
  *
672
  *
673
  * @param int $store
674
+ *
675
  * @return mixed
676
  */
677
  public function isNewsletterSuccessDisabled($store = 0)
678
  {
679
+ return Mage::getStoreConfig(
680
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS,
681
+ $store
682
+ );
683
  }
684
 
685
  /**
687
  */
688
  public function getEasyEmailCapture()
689
  {
690
+ return Mage::getStoreConfigFlag(
691
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE
692
+ );
693
  }
694
 
695
  /**
697
  */
698
  public function getEasyEmailCaptureForNewsletter()
699
  {
700
+ return Mage::getStoreConfigFlag(
701
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE_NEWSLETTER
702
+ );
703
  }
704
+
705
  /**
706
  * get feefo logon config value
707
  *
709
  */
710
  public function getFeefoLogon()
711
  {
712
+ return $this->getWebsiteConfig(
713
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_LOGON
714
+ );
715
  }
716
 
717
  /**
721
  */
722
  public function getFeefoReviewsPerProduct()
723
  {
724
+ return $this->getWebsiteConfig(
725
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_REVIEWS
726
+ );
727
  }
728
 
729
  /**
733
  */
734
  public function getFeefoLogoTemplate()
735
  {
736
+ return $this->getWebsiteConfig(
737
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_TEMPLATE
738
+ );
739
  }
740
 
741
+ /**
742
+ * @param $website
743
+ *
744
+ * @return string
745
+ */
746
+ public function getReviewDisplayType($website)
747
+ {
748
+ return $this->getWebsiteConfig(
749
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE,
750
+ $website
751
+ );
752
+ }
753
 
754
  /**
755
  * update data fields
756
  *
757
+ * @param $email
758
  * @param Mage_Core_Model_Website $website
759
+ * @param $storeName
760
  */
761
+ public function updateDataFields(
762
+ $email,
763
+ Mage_Core_Model_Website $website,
764
+ $storeName
765
+ ) {
766
  $data = array();
767
+ if ($storeName = $website->getConfig(
768
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
769
+ )
770
+ ) {
771
  $data[] = array(
772
+ 'Key' => $storeName,
773
  'Value' => $storeName
774
  );
775
  }
776
+ if ($websiteName = $website->getConfig(
777
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
778
+ )
779
+ ) {
780
  $data[] = array(
781
+ 'Key' => $websiteName,
782
  'Value' => $website->getName()
783
  );
784
  }
785
+ if (!empty($data)) {
786
  //update data fields
787
  $client = $this->getWebsiteApiClient($website);
788
  $client->updateContactDatafieldsByEmail($email, $data);
791
 
792
  /**
793
  * check connector SMTP installed/active status
794
+ *
795
  * @return boolean
796
  */
797
  public function isSmtpEnabled()
798
  {
799
+ return (bool)Mage::getConfig()->getModuleConfig('Ddg_Transactional')
800
+ ->is('active', 'true');
801
  }
802
 
803
  /**
804
  * Is magento enterprise.
805
+ *
806
  * @return bool
807
  */
808
  public function isEnterprise()
809
  {
810
+ return Mage::getConfig()->getModuleConfig('Enterprise_Enterprise')
811
+ && Mage::getConfig()->getModuleConfig('Enterprise_AdminGws')
812
+ && Mage::getConfig()->getModuleConfig('Enterprise_Checkout')
813
+ && Mage::getConfig()->getModuleConfig('Enterprise_Customer');
814
 
815
  }
816
 
817
  /**
818
  * Update last quote id datafield.
819
+ *
820
  * @param $quoteId
821
  * @param $email
822
  * @param $websiteId
841
  public function disableRaygun()
842
  {
843
  $config = Mage::getModel('core/config');
844
+ $config->saveConfig(
845
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE,
846
+ ''
847
+ );
848
  Mage::getConfig()->cleanCache();
849
  }
850
 
851
  public function enableRaygunCode()
852
  {
853
  $curl = new Varien_Http_Adapter_Curl();
854
+ $curl->setConfig(
855
+ array(
856
+ 'timeout' => 2
857
+ )
858
+ );
859
+ $curl->write(
860
+ Zend_Http_Client::GET,
861
+ Dotdigitalgroup_Email_Helper_Config::RAYGUN_API_CODE_URL, '1.0'
862
+ );
863
  $data = $curl->read();
864
 
865
  if ($data === false) {
869
  $data = trim($data[1]);
870
  $curl->close();
871
 
872
+ $xml = new SimpleXMLElement($data);
873
  $raygunCode = $xml->code;
874
 
875
  //not found
876
+ if (!$raygunCode) {
877
  return;
878
+ }
879
 
880
  $config = Mage::getModel('core/config');
881
+ $config->saveConfig(
882
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE,
883
+ $raygunCode
884
+ );
885
  }
886
 
887
  /**
889
  *
890
  * @param $e Exception
891
  */
892
+ public function sendRaygunException($e)
893
  {
894
+ if (!$this->raygunEnabled()) {
895
  return;
896
+ }
897
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
898
  $tags = array(
899
  $baseUrl,
914
  */
915
  public function getOrderSyncEnabled($websiteId = 0)
916
  {
917
+ return Mage::getStoreConfigFlag(
918
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED,
919
+ $websiteId
920
+ );
921
  }
922
+
923
  /**
924
  * @param int $websiteId
925
  *
927
  */
928
  public function getCatalogSyncEnabled($websiteId = 0)
929
  {
930
+ return Mage::getStoreConfigFlag(
931
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CATALOG_ENABLED,
932
+ $websiteId
933
+ );
934
  }
935
 
936
  /**
940
  */
941
  public function getContactSyncEnabled($websiteId = 0)
942
  {
943
+ return Mage::getStoreConfigFlag(
944
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED,
945
+ $websiteId
946
+ );
947
  }
948
 
949
  /**
953
  */
954
  public function getGuestSyncEnabled($websiteId = 0)
955
  {
956
+ return Mage::getStoreConfigFlag(
957
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED,
958
+ $websiteId
959
+ );
960
  }
961
 
962
  /**
966
  */
967
  public function getSubscriberSyncEnabled($websiteId = 0)
968
  {
969
+ return Mage::getStoreConfigFlag(
970
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED,
971
+ $websiteId
972
+ );
973
  }
974
 
975
  /**
977
  */
978
  public function getCronInstalled()
979
  {
980
+ $lastCustomerSync = Mage::getModel('ddg_automation/cron')
981
+ ->getLastCustomerSync();
982
  $timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
983
 
984
  //last customer cron was less then 15 min
985
  if ($timespan <= 15 * 60) {
986
  return true;
987
  }
988
+
989
  return false;
990
  }
991
+
992
  /**
993
  * Get the config id by the automation type.
994
+ *
995
+ * @param $automationType
996
  * @param int $websiteId
997
  *
998
  * @return mixed
999
  */
1000
  public function getAutomationIdByType($automationType, $websiteId = 0)
1001
  {
1002
+ $path = constant(
1003
+ 'Dotdigitalgroup_Email_Helper_Config::' . $automationType
1004
+ );
1005
  $automationCampaignId = $this->getWebsiteConfig($path, $websiteId);
1006
 
1007
  return $automationCampaignId;
1009
 
1010
  public function getAbandonedProductName()
1011
  {
1012
+ return Mage::getStoreConfig(
1013
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME
1014
+ );
1015
 
1016
  }
1017
 
1018
  /**
1019
  * Update last quote id datafield.
1020
+ *
1021
  * @param $name
1022
  * @param $email
1023
  * @param $websiteId
1050
  public function getApiResponseTimeLimit($websiteId = 0)
1051
  {
1052
  $website = Mage::app()->getWebsite($websiteId);
1053
+ $limit = $website->getConfig(
1054
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DEBUG_API_REQUEST_LIMIT
1055
+ );
1056
 
1057
  return $limit;
1058
  }
1064
  *
1065
  * @return string
1066
  */
1067
+ public function getAccountEmail($website = 0)
1068
  {
1069
  $client = $this->getWebsiteApiClient($website);
1070
+ $info = $client->getAccountInfo();
1071
  $email = '';
1072
 
1073
+ if (isset($info->properties)) {
1074
  $properties = $info->properties;
1075
 
1076
+ foreach ($properties as $property) {
1077
 
1078
+ if ($property->name == 'MainEmail') {
1079
  $email = $property->value;
1080
+ }
1081
  }
1082
  }
1083
+
1084
  return $email;
1085
  }
1086
 
1087
  public function authIpAddress()
1088
  {
1089
+ if ($ipString = Mage::getStoreConfig(
1090
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_IP_RESTRICTION_ADDRESSES
1091
+ )
1092
+ ) {
1093
  //string to array
1094
  $ipArray = explode(',', $ipString);
1095
  //remove white spaces
1105
 
1106
  return false;
1107
  } else {
1108
+ //empty ip list will ignore the validation
1109
+ return true;
1110
  }
1111
  }
1112
 
1113
+ /**
1114
+ * get log file content.
1115
+ *
1116
+ * @param string $filename
1117
+ *
1118
+ * @return string
1119
+ */
1120
  public function getLogFileContent($filename = 'connector_api.log')
1121
  {
1122
+ $pathLogfile = Mage::getBaseDir('var') . DS . 'log' . DS
1123
+ . $filename;;
1124
+ //tail the length file content
1125
+ $lengthBefore = 500000;
1126
 
1127
+ $handle = fopen($pathLogfile, 'r');
1128
+ fseek($handle, -$lengthBefore, SEEK_END);
1129
 
1130
  if (!$handle) {
1131
+ return "Log file is not readable or does not exist at this moment. File path is "
1132
+ . $pathLogfile;
1133
  }
1134
 
1135
+ $contents = fread($handle, filesize($pathLogfile));
1136
 
1137
  if (!$contents) {
1138
+ return "Log file is not readable or does not exist at this moment. File path is "
1139
+ . $pathLogfile;
1140
  }
1141
  fclose($handle);
1142
 
1144
  }
1145
 
1146
 
1147
+ /**
1148
+ * PRODUCT REVIEW REMINDER.
1149
+ */
1150
+ public function isReviewReminderEnabled($website)
1151
+ {
1152
+ return $this->getWebsiteConfig(
1153
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_ENABLED,
1154
+ $website
1155
+ );
1156
+ }
1157
+
1158
+ /**
1159
+ * @param $website
1160
+ *
1161
+ * @return string
1162
+ */
1163
+ public function getReviewReminderOrderStatus($website)
1164
+ {
1165
+ return $this->getWebsiteConfig(
1166
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_STATUS,
1167
+ $website
1168
+ );
1169
+ }
1170
+
1171
+ /**
1172
+ * @param $website
1173
+ *
1174
+ * @return int
1175
+ */
1176
+ public function getReviewReminderDelay($website)
1177
+ {
1178
+ return $this->getWebsiteConfig(
1179
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_DELAY,
1180
+ $website
1181
+ );
1182
+ }
1183
+
1184
+ /**
1185
+ * @param $website
1186
+ *
1187
+ * @return int
1188
+ */
1189
+ public function getReviewReminderCampaign($website)
1190
+ {
1191
+ return $this->getWebsiteConfig(
1192
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_CAMPAIGN,
1193
+ $website
1194
+ );
1195
+ }
1196
+
1197
+ /**
1198
+ * @param $website
1199
+ *
1200
+ * @return string
1201
+ */
1202
+ public function getReviewReminderAnchor($website)
1203
+ {
1204
+ return $this->getWebsiteConfig(
1205
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_ANCHOR,
1206
+ $website
1207
+ );
1208
+ }
1209
+
1210
+
1211
+ public function getDynamicStyles()
1212
+ {
1213
+ return $dynamicStyle = array(
1214
+ 'nameStyle' => explode(
1215
+ ',', Mage::getStoreConfig(
1216
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_STYLE
1217
+ )
1218
+ ),
1219
+ 'priceStyle' => explode(
1220
+ ',', Mage::getStoreConfig(
1221
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_STYLE
1222
+ )
1223
+ ),
1224
+ 'linkStyle' => explode(
1225
+ ',', Mage::getStoreConfig(
1226
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_STYLE
1227
+ )
1228
+ ),
1229
+ 'otherStyle' => explode(
1230
+ ',', Mage::getStoreConfig(
1231
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_STYLE
1232
+ )
1233
+ ),
1234
+ 'nameColor' => Mage::getStoreConfig(
1235
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_COLOR
1236
+ ),
1237
+ 'fontSize' => Mage::getStoreConfig(
1238
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_FONT_SIZE
1239
+ ),
1240
+ 'priceColor' => Mage::getStoreConfig(
1241
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_COLOR
1242
+ ),
1243
+ 'priceFontSize' => Mage::getStoreConfig(
1244
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_FONT_SIZE
1245
+ ),
1246
+ 'urlColor' => Mage::getStoreConfig(
1247
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_COLOR
1248
+ ),
1249
+ 'urlFontSize' => Mage::getStoreConfig(
1250
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_FONT_SIZE
1251
+ ),
1252
+ 'otherColor' => Mage::getStoreConfig(
1253
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_COLOR
1254
+ ),
1255
+ 'otherFontSize' => Mage::getStoreConfig(
1256
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_FONT_SIZE
1257
+ ),
1258
+ 'docFont' => Mage::getStoreConfig(
1259
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_DOC_FONT
1260
+ ),
1261
+ 'docBackgroundColor' => Mage::getStoreConfig(
1262
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_DOC_BG_COLOR
1263
+ ),
1264
+ 'dynamicStyling' => Mage::getStoreConfig(
1265
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_STYLING
1266
+ )
1267
+ );
1268
+ }
1269
+
1270
+ /**
1271
+ * generate url for iframe for trial account popup
1272
+ *
1273
+ * @return string
1274
+ * @throws Mage_Core_Exception
1275
+ */
1276
+ public function getIframeFormUrl()
1277
+ {
1278
+ $formUrl = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_TRIAL_FORM_URL;
1279
+ $ipAddress = Mage::helper('core/http')->getRemoteAddr();
1280
+ $timezone = $this->getTimeZoneId();
1281
+ $culture = $this->getCultureId();
1282
+ $company = Mage::app()->getWebsite()->getConfig('general/store_information/name');
1283
+ $callback = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true) . 'connector/email/accountcallback';
1284
+ $secret = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_TRIAL_FORM_SECRET;
1285
+ //query params
1286
+ $params = array(
1287
+ 'callback' => $callback,
1288
+ 'company' => $company,
1289
+ 'culture' => $culture,
1290
+ 'timezone' => $timezone,
1291
+ 'ip' => $ipAddress,
1292
+ 'secret' => $secret
1293
+ );
1294
+ $url = $formUrl . '?' . http_build_query($params);
1295
+ return $url;
1296
+ }
1297
+
1298
+ /**
1299
+ * get time zone id for trial account
1300
+ *
1301
+ * @return string
1302
+ * @throws Mage_Core_Exception
1303
+ */
1304
+ public function getTimeZoneId()
1305
+ {
1306
+ $timeZone = Mage::app()->getWebsite()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
1307
+ $result = '085';
1308
+ if ($timeZone) {
1309
+ $timeZones = Array
1310
+ (
1311
+ Array("MageTimeZone" => "Australia/Darwin", "MicrosoftTimeZoneIndex" => "250"),
1312
+ Array("MageTimeZone" => "Australia/Melbourne", "MicrosoftTimeZoneIndex" => "260"),
1313
+ Array("MageTimeZone" => "Australia/Sydney", "MicrosoftTimeZoneIndex" => "260"),
1314
+ Array("MageTimeZone" => "Asia/Kabul", "MicrosoftTimeZoneIndex" => "175"),
1315
+ Array("MageTimeZone" => "America/Anchorage", "MicrosoftTimeZoneIndex" => "003"),
1316
+ Array("MageTimeZone" => "America/Juneau", "MicrosoftTimeZoneIndex" => "003"),
1317
+ Array("MageTimeZone" => "America/Nome", "MicrosoftTimeZoneIndex" => "003"),
1318
+ Array("MageTimeZone" => "America/Sitka", "MicrosoftTimeZoneIndex" => "003"),
1319
+ Array("MageTimeZone" => "America/Yakutat", "MicrosoftTimeZoneIndex" => "003"),
1320
+ Array("MageTimeZone" => "Asia/Aden", "MicrosoftTimeZoneIndex" => "150"),
1321
+ Array("MageTimeZone" => "Asia/Bahrain", "MicrosoftTimeZoneIndex" => "150"),
1322
+ Array("MageTimeZone" => "Asia/Kuwait", "MicrosoftTimeZoneIndex" => "150"),
1323
+ Array("MageTimeZone" => "Asia/Qatar", "MicrosoftTimeZoneIndex" => "150"),
1324
+ Array("MageTimeZone" => "Asia/Riyadh", "MicrosoftTimeZoneIndex" => "150"),
1325
+ Array("MageTimeZone" => "Asia/Dubai", "MicrosoftTimeZoneIndex" => "165"),
1326
+ Array("MageTimeZone" => "Asia/Muscat", "MicrosoftTimeZoneIndex" => "165"),
1327
+ Array("MageTimeZone" => "Etc/GMT-4", "MicrosoftTimeZoneIndex" => "165"),
1328
+ Array("MageTimeZone" => "Asia/Baghdad", "MicrosoftTimeZoneIndex" => "165"),
1329
+ Array("MageTimeZone" => "America/Argentina/La_Rioja", "MicrosoftTimeZoneIndex" => "070"),
1330
+ Array("MageTimeZone" => "America/Argentina/Rio_Gallegos", "MicrosoftTimeZoneIndex" => "070"),
1331
+ Array("MageTimeZone" => "America/Argentina/Salta", "MicrosoftTimeZoneIndex" => "070"),
1332
+ Array("MageTimeZone" => "America/Argentina/San_Juan", "MicrosoftTimeZoneIndex" => "070"),
1333
+ Array("MageTimeZone" => "America/Argentina/San_Luis", "MicrosoftTimeZoneIndex" => "070"),
1334
+ Array("MageTimeZone" => "America/Argentina/Tucuman", "MicrosoftTimeZoneIndex" => "070"),
1335
+ Array("MageTimeZone" => "America/Argentina/Ushuaia", "MicrosoftTimeZoneIndex" => "070"),
1336
+ Array("MageTimeZone" => "America/Buenos_Aires", "MicrosoftTimeZoneIndex" => "070"),
1337
+ Array("MageTimeZone" => "America/Catamarca", "MicrosoftTimeZoneIndex" => "070"),
1338
+ Array("MageTimeZone" => "America/Cordoba", "MicrosoftTimeZoneIndex" => "070"),
1339
+ Array("MageTimeZone" => "America/Jujuy", "MicrosoftTimeZoneIndex" => "070"),
1340
+ Array("MageTimeZone" => "America/Mendoza", "MicrosoftTimeZoneIndex" => "070"),
1341
+ Array("MageTimeZone" => "America/Glace_Bay", "MicrosoftTimeZoneIndex" => "050"),
1342
+ Array("MageTimeZone" => "America/Goose_Bay", "MicrosoftTimeZoneIndex" => "050"),
1343
+ Array("MageTimeZone" => "America/Halifax", "MicrosoftTimeZoneIndex" => "050"),
1344
+ Array("MageTimeZone" => "America/Moncton", "MicrosoftTimeZoneIndex" => "050"),
1345
+ Array("MageTimeZone" => "America/Thule", "MicrosoftTimeZoneIndex" => "050"),
1346
+ Array("MageTimeZone" => "Atlantic/Bermuda", "MicrosoftTimeZoneIndex" => "050"),
1347
+ Array("MageTimeZone" => "Asia/Baku", "MicrosoftTimeZoneIndex" => "170"),
1348
+ Array("MageTimeZone" => "America/Scoresbysund", "MicrosoftTimeZoneIndex" => "080"),
1349
+ Array("MageTimeZone" => "Atlantic/Azores", "MicrosoftTimeZoneIndex" => "080"),
1350
+ Array("MageTimeZone" => "America/Bahia", "MicrosoftTimeZoneIndex" => "065"),
1351
+ Array("MageTimeZone" => "Asia/Dhaka", "MicrosoftTimeZoneIndex" => "195"),
1352
+ Array("MageTimeZone" => "Asia/Thimphu", "MicrosoftTimeZoneIndex" => "195"),
1353
+ Array("MageTimeZone" => "America/Regina", "MicrosoftTimeZoneIndex" => "025"),
1354
+ Array("MageTimeZone" => "America/Swift_Current", "MicrosoftTimeZoneIndex" => "025"),
1355
+ Array("MageTimeZone" => "Atlantic/Cape_Verde", "MicrosoftTimeZoneIndex" => "083"),
1356
+ Array("MageTimeZone" => "Etc/GMT+1", "MicrosoftTimeZoneIndex" => "083"),
1357
+ Array("MageTimeZone" => "Asia/Yerevan", "MicrosoftTimeZoneIndex" => "170"),
1358
+ Array("MageTimeZone" => "Australia/Adelaide", "MicrosoftTimeZoneIndex" => "250"),
1359
+ Array("MageTimeZone" => "Australia/Broken_Hill", "MicrosoftTimeZoneIndex" => "250"),
1360
+ Array("MageTimeZone" => "America/Belize", "MicrosoftTimeZoneIndex" => "033"),
1361
+ Array("MageTimeZone" => "America/Costa_Rica", "MicrosoftTimeZoneIndex" => "033"),
1362
+ Array("MageTimeZone" => "America/El_Salvador", "MicrosoftTimeZoneIndex" => "033"),
1363
+ Array("MageTimeZone" => "America/Guatemala", "MicrosoftTimeZoneIndex" => "033"),
1364
+ Array("MageTimeZone" => "America/Managua", "MicrosoftTimeZoneIndex" => "033"),
1365
+ Array("MageTimeZone" => "America/Tegucigalpa", "MicrosoftTimeZoneIndex" => "033"),
1366
+ Array("MageTimeZone" => "Etc/GMT+6", "MicrosoftTimeZoneIndex" => "033"),
1367
+ Array("MageTimeZone" => "Pacific/Galapagos", "MicrosoftTimeZoneIndex" => "033"),
1368
+ Array("MageTimeZone" => "Antarctica/Vostok", "MicrosoftTimeZoneIndex" => "195"),
1369
+ Array("MageTimeZone" => "Asia/Almaty", "MicrosoftTimeZoneIndex" => "195"),
1370
+ Array("MageTimeZone" => "Asia/Bishkek", "MicrosoftTimeZoneIndex" => "195"),
1371
+ Array("MageTimeZone" => "Asia/Qyzylorda", "MicrosoftTimeZoneIndex" => "195"),
1372
+ Array("MageTimeZone" => "Etc/GMT-6", "MicrosoftTimeZoneIndex" => "195"),
1373
+ Array("MageTimeZone" => "Indian/Chagos", "MicrosoftTimeZoneIndex" => "195"),
1374
+ Array("MageTimeZone" => "America/Campo_Grande", "MicrosoftTimeZoneIndex" => "065"),
1375
+ Array("MageTimeZone" => "America/Cuiaba", "MicrosoftTimeZoneIndex" => "065"),
1376
+ Array("MageTimeZone" => "Europe/Belgrade", "MicrosoftTimeZoneIndex" => "095"),
1377
+ Array("MageTimeZone" => "Europe/Bratislava", "MicrosoftTimeZoneIndex" => "095"),
1378
+ Array("MageTimeZone" => "Europe/Budapest", "MicrosoftTimeZoneIndex" => "095"),
1379
+ Array("MageTimeZone" => "Europe/Ljubljana", "MicrosoftTimeZoneIndex" => "095"),
1380
+ Array("MageTimeZone" => "Europe/Podgorica", "MicrosoftTimeZoneIndex" => "095"),
1381
+ Array("MageTimeZone" => "Europe/Prague", "MicrosoftTimeZoneIndex" => "095"),
1382
+ Array("MageTimeZone" => "Europe/Tirane", "MicrosoftTimeZoneIndex" => "095"),
1383
+ Array("MageTimeZone" => "Europe/Sarajevo", "MicrosoftTimeZoneIndex" => "095"),
1384
+ Array("MageTimeZone" => "Europe/Skopje", "MicrosoftTimeZoneIndex" => "095"),
1385
+ Array("MageTimeZone" => "Europe/Warsaw", "MicrosoftTimeZoneIndex" => "095"),
1386
+ Array("MageTimeZone" => "Europe/Zagreb", "MicrosoftTimeZoneIndex" => "095"),
1387
+ Array("MageTimeZone" => "Antarctica/Macquarie", "MicrosoftTimeZoneIndex" => "280"),
1388
+ Array("MageTimeZone" => "Etc/GMT-11", "MicrosoftTimeZoneIndex" => "280"),
1389
+ Array("MageTimeZone" => "Pacific/Efate", "MicrosoftTimeZoneIndex" => "280"),
1390
+ Array("MageTimeZone" => "Pacific/Guadalcanal", "MicrosoftTimeZoneIndex" => "280"),
1391
+ Array("MageTimeZone" => "Pacific/Kosrae", "MicrosoftTimeZoneIndex" => "280"),
1392
+ Array("MageTimeZone" => "Pacific/Noumea", "MicrosoftTimeZoneIndex" => "280"),
1393
+ Array("MageTimeZone" => "Pacific/Ponape", "MicrosoftTimeZoneIndex" => "280"),
1394
+ Array("MageTimeZone" => "America/Chicago", "MicrosoftTimeZoneIndex" => "020"),
1395
+ Array("MageTimeZone" => "America/Indiana/Knox", "MicrosoftTimeZoneIndex" => "020"),
1396
+ Array("MageTimeZone" => "America/Indiana/Tell_City", "MicrosoftTimeZoneIndex" => "020"),
1397
+ Array("MageTimeZone" => "America/Matamoros", "MicrosoftTimeZoneIndex" => "020"),
1398
+ Array("MageTimeZone" => "America/Menominee", "MicrosoftTimeZoneIndex" => "020"),
1399
+ Array("MageTimeZone" => "America/North_Dakota/Beulah", "MicrosoftTimeZoneIndex" => "020"),
1400
+ Array("MageTimeZone" => "America/North_Dakota/Center", "MicrosoftTimeZoneIndex" => "020"),
1401
+ Array("MageTimeZone" => "America/North_Dakota/New_Salem", "MicrosoftTimeZoneIndex" => "020"),
1402
+ Array("MageTimeZone" => "America/Rainy_River", "MicrosoftTimeZoneIndex" => "020"),
1403
+ Array("MageTimeZone" => "America/Rankin_Inlet", "MicrosoftTimeZoneIndex" => "020"),
1404
+ Array("MageTimeZone" => "America/Resolute", "MicrosoftTimeZoneIndex" => "020"),
1405
+ Array("MageTimeZone" => "America/Winnipeg", "MicrosoftTimeZoneIndex" => "020"),
1406
+ Array("MageTimeZone" => "CST6CDT", "MicrosoftTimeZoneIndex" => "020"),
1407
+ Array("MageTimeZone" => "America/Bahia_Banderas", "MicrosoftTimeZoneIndex" => "020"),
1408
+ Array("MageTimeZone" => "America/Cancun", "MicrosoftTimeZoneIndex" => "020"),
1409
+ Array("MageTimeZone" => "America/Merida", "MicrosoftTimeZoneIndex" => "020"),
1410
+ Array("MageTimeZone" => "America/Mexico_City", "MicrosoftTimeZoneIndex" => "020"),
1411
+ Array("MageTimeZone" => "America/Monterrey", "MicrosoftTimeZoneIndex" => "020"),
1412
+ Array("MageTimeZone" => "Asia/Chongqing", "MicrosoftTimeZoneIndex" => "210"),
1413
+ Array("MageTimeZone" => "Asia/Harbin", "MicrosoftTimeZoneIndex" => "210"),
1414
+ Array("MageTimeZone" => "Asia/Hong_Kong", "MicrosoftTimeZoneIndex" => "210"),
1415
+ Array("MageTimeZone" => "Asia/Kashgar", "MicrosoftTimeZoneIndex" => "210"),
1416
+ Array("MageTimeZone" => "Asia/Macau", "MicrosoftTimeZoneIndex" => "210"),
1417
+ Array("MageTimeZone" => "Asia/Shanghai", "MicrosoftTimeZoneIndex" => "210"),
1418
+ Array("MageTimeZone" => "Asia/Urumqi", "MicrosoftTimeZoneIndex" => "210"),
1419
+ Array("MageTimeZone" => "Etc/GMT+12", "MicrosoftTimeZoneIndex" => "000"),
1420
+ Array("MageTimeZone" => "Africa/Addis_Ababa", "MicrosoftTimeZoneIndex" => "115"),
1421
+ Array("MageTimeZone" => "Africa/Asmera", "MicrosoftTimeZoneIndex" => "115"),
1422
+ Array("MageTimeZone" => "Africa/Dar_es_Salaam", "MicrosoftTimeZoneIndex" => "115"),
1423
+ Array("MageTimeZone" => "Africa/Djibouti", "MicrosoftTimeZoneIndex" => "115"),
1424
+ Array("MageTimeZone" => "Africa/Juba", "MicrosoftTimeZoneIndex" => "115"),
1425
+ Array("MageTimeZone" => "Africa/Kampala", "MicrosoftTimeZoneIndex" => "115"),
1426
+ Array("MageTimeZone" => "Africa/Khartoum", "MicrosoftTimeZoneIndex" => "115"),
1427
+ Array("MageTimeZone" => "Africa/Mogadishu", "MicrosoftTimeZoneIndex" => "115"),
1428
+ Array("MageTimeZone" => "Africa/Nairobi", "MicrosoftTimeZoneIndex" => "115"),
1429
+ Array("MageTimeZone" => "Antarctica/Syowa", "MicrosoftTimeZoneIndex" => "115"),
1430
+ Array("MageTimeZone" => "Etc/GMT-3", "MicrosoftTimeZoneIndex" => "115"),
1431
+ Array("MageTimeZone" => "Indian/Antananarivo", "MicrosoftTimeZoneIndex" => "115"),
1432
+ Array("MageTimeZone" => "Indian/Comoro", "MicrosoftTimeZoneIndex" => "115"),
1433
+ Array("MageTimeZone" => "Indian/Mayotte", "MicrosoftTimeZoneIndex" => "115"),
1434
+ Array("MageTimeZone" => "Australia/Brisbane", "MicrosoftTimeZoneIndex" => "260"),
1435
+ Array("MageTimeZone" => "Australia/Lindeman", "MicrosoftTimeZoneIndex" => "260"),
1436
+ Array("MageTimeZone" => "America/Sao_Paulo", "MicrosoftTimeZoneIndex" => "065"),
1437
+ Array("MageTimeZone" => "America/Detroit", "MicrosoftTimeZoneIndex" => "035"),
1438
+ Array("MageTimeZone" => "America/Grand_Turk", "MicrosoftTimeZoneIndex" => "035"),
1439
+ Array("MageTimeZone" => "America/Havana", "MicrosoftTimeZoneIndex" => "035"),
1440
+ Array("MageTimeZone" => "America/Indiana/Petersburg", "MicrosoftTimeZoneIndex" => "035"),
1441
+ Array("MageTimeZone" => "America/Indiana/Vincennes", "MicrosoftTimeZoneIndex" => "035"),
1442
+ Array("MageTimeZone" => "America/Indiana/Winamac", "MicrosoftTimeZoneIndex" => "035"),
1443
+ Array("MageTimeZone" => "America/Iqaluit", "MicrosoftTimeZoneIndex" => "035"),
1444
+ Array("MageTimeZone" => "America/Kentucky/Monticello", "MicrosoftTimeZoneIndex" => "035"),
1445
+ Array("MageTimeZone" => "America/Louisville", "MicrosoftTimeZoneIndex" => "035"),
1446
+ Array("MageTimeZone" => "America/Montreal", "MicrosoftTimeZoneIndex" => "035"),
1447
+ Array("MageTimeZone" => "America/Nassau", "MicrosoftTimeZoneIndex" => "035"),
1448
+ Array("MageTimeZone" => "America/New_York", "MicrosoftTimeZoneIndex" => "035"),
1449
+ Array("MageTimeZone" => "America/Nipigon", "MicrosoftTimeZoneIndex" => "035"),
1450
+ Array("MageTimeZone" => "America/Pangnirtung", "MicrosoftTimeZoneIndex" => "035"),
1451
+ Array("MageTimeZone" => "America/Port-au-Prince", "MicrosoftTimeZoneIndex" => "035"),
1452
+ Array("MageTimeZone" => "America/Thunder_Bay", "MicrosoftTimeZoneIndex" => "035"),
1453
+ Array("MageTimeZone" => "America/Toronto", "MicrosoftTimeZoneIndex" => "035"),
1454
+ Array("MageTimeZone" => "EST5EDT", "MicrosoftTimeZoneIndex" => "035"),
1455
+ Array("MageTimeZone" => "Africa/Cairo", "MicrosoftTimeZoneIndex" => "120"),
1456
+ Array("MageTimeZone" => "Asia/Yekaterinburg", "MicrosoftTimeZoneIndex" => "180"),
1457
+ Array("MageTimeZone" => "Europe/Helsinki", "MicrosoftTimeZoneIndex" => "125"),
1458
+ Array("MageTimeZone" => "Europe/Kiev", "MicrosoftTimeZoneIndex" => "125"),
1459
+ Array("MageTimeZone" => "Europe/Riga", "MicrosoftTimeZoneIndex" => "125"),
1460
+ Array("MageTimeZone" => "Europe/Simferopol", "MicrosoftTimeZoneIndex" => "125"),
1461
+ Array("MageTimeZone" => "Europe/Sofia", "MicrosoftTimeZoneIndex" => "125"),
1462
+ Array("MageTimeZone" => "Europe/Tallinn", "MicrosoftTimeZoneIndex" => "125"),
1463
+ Array("MageTimeZone" => "Europe/Uzhgorod", "MicrosoftTimeZoneIndex" => "125"),
1464
+ Array("MageTimeZone" => "Europe/Vilnius", "MicrosoftTimeZoneIndex" => "125"),
1465
+ Array("MageTimeZone" => "Europe/Zaporozhye", "MicrosoftTimeZoneIndex" => "125"),
1466
+ Array("MageTimeZone" => "Pacific/Fiji", "MicrosoftTimeZoneIndex" => "285"),
1467
+ Array("MageTimeZone" => "Atlantic/Canary", "MicrosoftTimeZoneIndex" => "085"),
1468
+ Array("MageTimeZone" => "Atlantic/Faeroe", "MicrosoftTimeZoneIndex" => "085"),
1469
+ Array("MageTimeZone" => "Atlantic/Madeira", "MicrosoftTimeZoneIndex" => "085"),
1470
+ Array("MageTimeZone" => "Europe/Dublin", "MicrosoftTimeZoneIndex" => "085"),
1471
+ Array("MageTimeZone" => "Europe/Guernsey", "MicrosoftTimeZoneIndex" => "085"),
1472
+ Array("MageTimeZone" => "Europe/Isle_of_Man", "MicrosoftTimeZoneIndex" => "085"),
1473
+ Array("MageTimeZone" => "Europe/Jersey", "MicrosoftTimeZoneIndex" => "085"),
1474
+ Array("MageTimeZone" => "Europe/Lisbon", "MicrosoftTimeZoneIndex" => "085"),
1475
+ Array("MageTimeZone" => "Europe/London", "MicrosoftTimeZoneIndex" => "085"),
1476
+ Array("MageTimeZone" => "Asia/Nicosia", "MicrosoftTimeZoneIndex" => "130"),
1477
+ Array("MageTimeZone" => "Europe/Athens", "MicrosoftTimeZoneIndex" => "130"),
1478
+ Array("MageTimeZone" => "Europe/Bucharest", "MicrosoftTimeZoneIndex" => "130"),
1479
+ Array("MageTimeZone" => "Europe/Chisinau", "MicrosoftTimeZoneIndex" => "130"),
1480
+ Array("MageTimeZone" => "Asia/Tbilisi", "MicrosoftTimeZoneIndex" => "170"),
1481
+ Array("MageTimeZone" => "America/Godthab", "MicrosoftTimeZoneIndex" => "073"),
1482
+ Array("MageTimeZone" => "Africa/Abidjan", "MicrosoftTimeZoneIndex" => "090"),
1483
+ Array("MageTimeZone" => "Africa/Accra", "MicrosoftTimeZoneIndex" => "090"),
1484
+ Array("MageTimeZone" => "Africa/Bamako", "MicrosoftTimeZoneIndex" => "090"),
1485
+ Array("MageTimeZone" => "Africa/Banjul", "MicrosoftTimeZoneIndex" => "090"),
1486
+ Array("MageTimeZone" => "Africa/Bissau", "MicrosoftTimeZoneIndex" => "090"),
1487
+ Array("MageTimeZone" => "Africa/Conakry", "MicrosoftTimeZoneIndex" => "090"),
1488
+ Array("MageTimeZone" => "Africa/Dakar", "MicrosoftTimeZoneIndex" => "090"),
1489
+ Array("MageTimeZone" => "Africa/Freetown", "MicrosoftTimeZoneIndex" => "090"),
1490
+ Array("MageTimeZone" => "Africa/Lome", "MicrosoftTimeZoneIndex" => "090"),
1491
+ Array("MageTimeZone" => "Africa/Monrovia", "MicrosoftTimeZoneIndex" => "090"),
1492
+ Array("MageTimeZone" => "Africa/Nouakchott", "MicrosoftTimeZoneIndex" => "090"),
1493
+ Array("MageTimeZone" => "Africa/Ouagadougou", "MicrosoftTimeZoneIndex" => "090"),
1494
+ Array("MageTimeZone" => "Africa/Sao_Tome", "MicrosoftTimeZoneIndex" => "090"),
1495
+ Array("MageTimeZone" => "Atlantic/Reykjavik", "MicrosoftTimeZoneIndex" => "090"),
1496
+ Array("MageTimeZone" => "Atlantic/St_Helena", "MicrosoftTimeZoneIndex" => "090"),
1497
+ Array("MageTimeZone" => "Etc/GMT+10", "MicrosoftTimeZoneIndex" => "002"),
1498
+ Array("MageTimeZone" => "Pacific/Honolulu", "MicrosoftTimeZoneIndex" => "002"),
1499
+ Array("MageTimeZone" => "Pacific/Johnston", "MicrosoftTimeZoneIndex" => "002"),
1500
+ Array("MageTimeZone" => "Pacific/Rarotonga", "MicrosoftTimeZoneIndex" => "002"),
1501
+ Array("MageTimeZone" => "Pacific/Tahiti", "MicrosoftTimeZoneIndex" => "002"),
1502
+ Array("MageTimeZone" => "Asia/Calcutta", "MicrosoftTimeZoneIndex" => "190"),
1503
+ Array("MageTimeZone" => "Asia/Tehran", "MicrosoftTimeZoneIndex" => "160"),
1504
+ Array("MageTimeZone" => "Asia/Jerusalem", "MicrosoftTimeZoneIndex" => "135"),
1505
+ Array("MageTimeZone" => "Asia/Amman", "MicrosoftTimeZoneIndex" => "150"),
1506
+ Array("MageTimeZone" => "Europe/Kaliningrad", "MicrosoftTimeZoneIndex" => "130"),
1507
+ Array("MageTimeZone" => "Europe/Minsk", "MicrosoftTimeZoneIndex" => "130"),
1508
+ Array("MageTimeZone" => "Asia/Pyongyang", "MicrosoftTimeZoneIndex" => "230"),
1509
+ Array("MageTimeZone" => "Asia/Seoul", "MicrosoftTimeZoneIndex" => "230"),
1510
+ Array("MageTimeZone" => "Africa/Tripoli", "MicrosoftTimeZoneIndex" => "120"),
1511
+ Array("MageTimeZone" => "Asia/Anadyr", "MicrosoftTimeZoneIndex" => "280"),
1512
+ Array("MageTimeZone" => "Asia/Kamchatka", "MicrosoftTimeZoneIndex" => "280"),
1513
+ Array("MageTimeZone" => "Asia/Magadan", "MicrosoftTimeZoneIndex" => "280"),
1514
+ Array("MageTimeZone" => "Indian/Mahe", "MicrosoftTimeZoneIndex" => "165"),
1515
+ Array("MageTimeZone" => "Indian/Mauritius", "MicrosoftTimeZoneIndex" => "165"),
1516
+ Array("MageTimeZone" => "Indian/Reunion", "MicrosoftTimeZoneIndex" => "165"),
1517
+ Array("MageTimeZone" => "Asia/Beirut", "MicrosoftTimeZoneIndex" => "158"),
1518
+ Array("MageTimeZone" => "America/Montevideo", "MicrosoftTimeZoneIndex" => "065"),
1519
+ Array("MageTimeZone" => "Africa/Casablanca", "MicrosoftTimeZoneIndex" => "113"),
1520
+ Array("MageTimeZone" => "Africa/El_Aaiun", "MicrosoftTimeZoneIndex" => "113"),
1521
+ Array("MageTimeZone" => "America/Boise", "MicrosoftTimeZoneIndex" => "010"),
1522
+ Array("MageTimeZone" => "America/Cambridge_Bay", "MicrosoftTimeZoneIndex" => "010"),
1523
+ Array("MageTimeZone" => "America/Denver", "MicrosoftTimeZoneIndex" => "010"),
1524
+ Array("MageTimeZone" => "America/Edmonton", "MicrosoftTimeZoneIndex" => "010"),
1525
+ Array("MageTimeZone" => "America/Inuvik", "MicrosoftTimeZoneIndex" => "010"),
1526
+ Array("MageTimeZone" => "America/Ojinaga", "MicrosoftTimeZoneIndex" => "010"),
1527
+ Array("MageTimeZone" => "America/Shiprock", "MicrosoftTimeZoneIndex" => "010"),
1528
+ Array("MageTimeZone" => "America/Yellowknife", "MicrosoftTimeZoneIndex" => "010"),
1529
+ Array("MageTimeZone" => "MST7MDT", "MicrosoftTimeZoneIndex" => "010"),
1530
+ Array("MageTimeZone" => "America/Chihuahua", "MicrosoftTimeZoneIndex" => "010"),
1531
+ Array("MageTimeZone" => "America/Mazatlan", "MicrosoftTimeZoneIndex" => "010"),
1532
+ Array("MageTimeZone" => "Asia/Rangoon", "MicrosoftTimeZoneIndex" => "203"),
1533
+ Array("MageTimeZone" => "Indian/Cocos", "MicrosoftTimeZoneIndex" => "203"),
1534
+ Array("MageTimeZone" => "Asia/Novokuznetsk", "MicrosoftTimeZoneIndex" => "201"),
1535
+ Array("MageTimeZone" => "Asia/Novosibirsk", "MicrosoftTimeZoneIndex" => "201"),
1536
+ Array("MageTimeZone" => "Asia/Omsk", "MicrosoftTimeZoneIndex" => "201"),
1537
+ Array("MageTimeZone" => "Africa/Windhoek", "MicrosoftTimeZoneIndex" => "120"),
1538
+ Array("MageTimeZone" => "Asia/Katmandu", "MicrosoftTimeZoneIndex" => "193"),
1539
+ Array("MageTimeZone" => "Antarctica/McMurdo", "MicrosoftTimeZoneIndex" => "290"),
1540
+ Array("MageTimeZone" => "Antarctica/South_Pole", "MicrosoftTimeZoneIndex" => "290"),
1541
+ Array("MageTimeZone" => "Pacific/Auckland", "MicrosoftTimeZoneIndex" => "290"),
1542
+ Array("MageTimeZone" => "America/St_Johns", "MicrosoftTimeZoneIndex" => "060"),
1543
+ Array("MageTimeZone" => "Asia/Irkutsk", "MicrosoftTimeZoneIndex" => "207"),
1544
+ Array("MageTimeZone" => "Asia/Krasnoyarsk", "MicrosoftTimeZoneIndex" => "207"),
1545
+ Array("MageTimeZone" => "America/Santiago", "MicrosoftTimeZoneIndex" => "056"),
1546
+ Array("MageTimeZone" => "Antarctica/Palmer", "MicrosoftTimeZoneIndex" => "004"),
1547
+ Array("MageTimeZone" => "America/Dawson", "MicrosoftTimeZoneIndex" => "004"),
1548
+ Array("MageTimeZone" => "America/Los_Angeles", "MicrosoftTimeZoneIndex" => "004"),
1549
+ Array("MageTimeZone" => "America/Tijuana", "MicrosoftTimeZoneIndex" => "004"),
1550
+ Array("MageTimeZone" => "America/Vancouver", "MicrosoftTimeZoneIndex" => "004"),
1551
+ Array("MageTimeZone" => "America/Whitehorse", "MicrosoftTimeZoneIndex" => "004"),
1552
+ Array("MageTimeZone" => "America/Santa_Isabel", "MicrosoftTimeZoneIndex" => "004"),
1553
+ Array("MageTimeZone" => "PST8PDT", "MicrosoftTimeZoneIndex" => "004"),
1554
+ Array("MageTimeZone" => "Asia/Karachi", "MicrosoftTimeZoneIndex" => "185"),
1555
+ Array("MageTimeZone" => "America/Asuncion", "MicrosoftTimeZoneIndex" => "065"),
1556
+ Array("MageTimeZone" => "Africa/Ceuta", "MicrosoftTimeZoneIndex" => "105"),
1557
+ Array("MageTimeZone" => "Europe/Brussels", "MicrosoftTimeZoneIndex" => "105"),
1558
+ Array("MageTimeZone" => "Europe/Copenhagen", "MicrosoftTimeZoneIndex" => "105"),
1559
+ Array("MageTimeZone" => "Europe/Madrid", "MicrosoftTimeZoneIndex" => "105"),
1560
+ Array("MageTimeZone" => "Europe/Paris", "MicrosoftTimeZoneIndex" => "105"),
1561
+ Array("MageTimeZone" => "Europe/Moscow", "MicrosoftTimeZoneIndex" => "145"),
1562
+ Array("MageTimeZone" => "Europe/Samara", "MicrosoftTimeZoneIndex" => "145"),
1563
+ Array("MageTimeZone" => "Europe/Volgograd", "MicrosoftTimeZoneIndex" => "145"),
1564
+ Array("MageTimeZone" => "America/Araguaina", "MicrosoftTimeZoneIndex" => "070"),
1565
+ Array("MageTimeZone" => "America/Belem", "MicrosoftTimeZoneIndex" => "070"),
1566
+ Array("MageTimeZone" => "America/Cayenne", "MicrosoftTimeZoneIndex" => "070"),
1567
+ Array("MageTimeZone" => "America/Fortaleza", "MicrosoftTimeZoneIndex" => "070"),
1568
+ Array("MageTimeZone" => "America/Maceio", "MicrosoftTimeZoneIndex" => "070"),
1569
+ Array("MageTimeZone" => "America/Paramaribo", "MicrosoftTimeZoneIndex" => "070"),
1570
+ Array("MageTimeZone" => "America/Recife", "MicrosoftTimeZoneIndex" => "070"),
1571
+ Array("MageTimeZone" => "America/Santarem", "MicrosoftTimeZoneIndex" => "070"),
1572
+ Array("MageTimeZone" => "Antarctica/Rothera", "MicrosoftTimeZoneIndex" => "070"),
1573
+ Array("MageTimeZone" => "Atlantic/Stanley", "MicrosoftTimeZoneIndex" => "070"),
1574
+ Array("MageTimeZone" => "Etc/GMT+3", "MicrosoftTimeZoneIndex" => "070"),
1575
+ Array("MageTimeZone" => "America/Bogota", "MicrosoftTimeZoneIndex" => "045"),
1576
+ Array("MageTimeZone" => "America/Cayman", "MicrosoftTimeZoneIndex" => "045"),
1577
+ Array("MageTimeZone" => "America/Coral_Harbour", "MicrosoftTimeZoneIndex" => "045"),
1578
+ Array("MageTimeZone" => "America/Eirunepe", "MicrosoftTimeZoneIndex" => "045"),
1579
+ Array("MageTimeZone" => "America/Guayaquil", "MicrosoftTimeZoneIndex" => "045"),
1580
+ Array("MageTimeZone" => "America/Jamaica", "MicrosoftTimeZoneIndex" => "045"),
1581
+ Array("MageTimeZone" => "America/Lima", "MicrosoftTimeZoneIndex" => "045"),
1582
+ Array("MageTimeZone" => "America/Panama", "MicrosoftTimeZoneIndex" => "045"),
1583
+ Array("MageTimeZone" => "America/Rio_Branco", "MicrosoftTimeZoneIndex" => "045"),
1584
+ Array("MageTimeZone" => "Etc/GMT+5", "MicrosoftTimeZoneIndex" => "045"),
1585
+ Array("MageTimeZone" => "America/Anguilla", "MicrosoftTimeZoneIndex" => "055"),
1586
+ Array("MageTimeZone" => "America/Antigua", "MicrosoftTimeZoneIndex" => "055"),
1587
+ Array("MageTimeZone" => "America/Aruba", "MicrosoftTimeZoneIndex" => "055"),
1588
+ Array("MageTimeZone" => "America/Barbados", "MicrosoftTimeZoneIndex" => "055"),
1589
+ Array("MageTimeZone" => "America/Blanc-Sablon", "MicrosoftTimeZoneIndex" => "055"),
1590
+ Array("MageTimeZone" => "America/Boa_Vista", "MicrosoftTimeZoneIndex" => "055"),
1591
+ Array("MageTimeZone" => "America/Curacao", "MicrosoftTimeZoneIndex" => "055"),
1592
+ Array("MageTimeZone" => "America/Dominica", "MicrosoftTimeZoneIndex" => "055"),
1593
+ Array("MageTimeZone" => "America/Grenada", "MicrosoftTimeZoneIndex" => "055"),
1594
+ Array("MageTimeZone" => "America/Guadeloupe", "MicrosoftTimeZoneIndex" => "055"),
1595
+ Array("MageTimeZone" => "America/Guyana", "MicrosoftTimeZoneIndex" => "055"),
1596
+ Array("MageTimeZone" => "America/Kralendijk", "MicrosoftTimeZoneIndex" => "055"),
1597
+ Array("MageTimeZone" => "America/La_Paz", "MicrosoftTimeZoneIndex" => "055"),
1598
+ Array("MageTimeZone" => "America/Lower_Princes", "MicrosoftTimeZoneIndex" => "055"),
1599
+ Array("MageTimeZone" => "America/Manaus", "MicrosoftTimeZoneIndex" => "055"),
1600
+ Array("MageTimeZone" => "America/Marigot", "MicrosoftTimeZoneIndex" => "055"),
1601
+ Array("MageTimeZone" => "America/Martinique", "MicrosoftTimeZoneIndex" => "055"),
1602
+ Array("MageTimeZone" => "America/Montserrat", "MicrosoftTimeZoneIndex" => "055"),
1603
+ Array("MageTimeZone" => "America/Port_of_Spain", "MicrosoftTimeZoneIndex" => "055"),
1604
+ Array("MageTimeZone" => "America/Porto_Velho", "MicrosoftTimeZoneIndex" => "055"),
1605
+ Array("MageTimeZone" => "America/Puerto_Rico", "MicrosoftTimeZoneIndex" => "055"),
1606
+ Array("MageTimeZone" => "America/Santo_Domingo", "MicrosoftTimeZoneIndex" => "055"),
1607
+ Array("MageTimeZone" => "America/St_Barthelemy", "MicrosoftTimeZoneIndex" => "055"),
1608
+ Array("MageTimeZone" => "America/St_Kitts", "MicrosoftTimeZoneIndex" => "055"),
1609
+ Array("MageTimeZone" => "America/St_Lucia", "MicrosoftTimeZoneIndex" => "055"),
1610
+ Array("MageTimeZone" => "America/St_Thomas", "MicrosoftTimeZoneIndex" => "055"),
1611
+ Array("MageTimeZone" => "America/St_Vincent", "MicrosoftTimeZoneIndex" => "055"),
1612
+ Array("MageTimeZone" => "America/Tortola", "MicrosoftTimeZoneIndex" => "055"),
1613
+ Array("MageTimeZone" => "Etc/GMT+4", "MicrosoftTimeZoneIndex" => "055"),
1614
+ Array("MageTimeZone" => "Antarctica/Davis", "MicrosoftTimeZoneIndex" => "205"),
1615
+ Array("MageTimeZone" => "Asia/Bangkok", "MicrosoftTimeZoneIndex" => "205"),
1616
+ Array("MageTimeZone" => "Asia/Hovd", "MicrosoftTimeZoneIndex" => "205"),
1617
+ Array("MageTimeZone" => "Asia/Jakarta", "MicrosoftTimeZoneIndex" => "205"),
1618
+ Array("MageTimeZone" => "Asia/Phnom_Penh", "MicrosoftTimeZoneIndex" => "205"),
1619
+ Array("MageTimeZone" => "Asia/Pontianak", "MicrosoftTimeZoneIndex" => "205"),
1620
+ Array("MageTimeZone" => "Asia/Saigon", "MicrosoftTimeZoneIndex" => "205"),
1621
+ Array("MageTimeZone" => "Asia/Vientiane", "MicrosoftTimeZoneIndex" => "205"),
1622
+ Array("MageTimeZone" => "Etc/GMT-7", "MicrosoftTimeZoneIndex" => "205"),
1623
+ Array("MageTimeZone" => "Indian/Christmas", "MicrosoftTimeZoneIndex" => "205"),
1624
+ Array("MageTimeZone" => "Pacific/Apia", "MicrosoftTimeZoneIndex" => "001"),
1625
+ Array("MageTimeZone" => "Asia/Brunei", "MicrosoftTimeZoneIndex" => "215"),
1626
+ Array("MageTimeZone" => "Asia/Kuala_Lumpur", "MicrosoftTimeZoneIndex" => "215"),
1627
+ Array("MageTimeZone" => "Asia/Kuching", "MicrosoftTimeZoneIndex" => "215"),
1628
+ Array("MageTimeZone" => "Asia/Makassar", "MicrosoftTimeZoneIndex" => "215"),
1629
+ Array("MageTimeZone" => "Asia/Manila", "MicrosoftTimeZoneIndex" => "215"),
1630
+ Array("MageTimeZone" => "Asia/Singapore", "MicrosoftTimeZoneIndex" => "215"),
1631
+ Array("MageTimeZone" => "Etc/GMT-8", "MicrosoftTimeZoneIndex" => "215"),
1632
+ Array("MageTimeZone" => "Africa/Blantyre", "MicrosoftTimeZoneIndex" => "140"),
1633
+ Array("MageTimeZone" => "Africa/Bujumbura", "MicrosoftTimeZoneIndex" => "140"),
1634
+ Array("MageTimeZone" => "Africa/Gaborone", "MicrosoftTimeZoneIndex" => "140"),
1635
+ Array("MageTimeZone" => "Africa/Harare", "MicrosoftTimeZoneIndex" => "140"),
1636
+ Array("MageTimeZone" => "Africa/Johannesburg", "MicrosoftTimeZoneIndex" => "140"),
1637
+ Array("MageTimeZone" => "Africa/Kigali", "MicrosoftTimeZoneIndex" => "140"),
1638
+ Array("MageTimeZone" => "Africa/Lubumbashi", "MicrosoftTimeZoneIndex" => "140"),
1639
+ Array("MageTimeZone" => "Africa/Lusaka", "MicrosoftTimeZoneIndex" => "140"),
1640
+ Array("MageTimeZone" => "Africa/Maputo", "MicrosoftTimeZoneIndex" => "140"),
1641
+ Array("MageTimeZone" => "Africa/Maseru", "MicrosoftTimeZoneIndex" => "140"),
1642
+ Array("MageTimeZone" => "Africa/Mbabane", "MicrosoftTimeZoneIndex" => "140"),
1643
+ Array("MageTimeZone" => "Etc/GMT-2", "MicrosoftTimeZoneIndex" => "140"),
1644
+ Array("MageTimeZone" => "Asia/Colombo", "MicrosoftTimeZoneIndex" => "200"),
1645
+ Array("MageTimeZone" => "Asia/Damascus", "MicrosoftTimeZoneIndex" => "158"),
1646
+ Array("MageTimeZone" => "Asia/Taipei", "MicrosoftTimeZoneIndex" => "220"),
1647
+ Array("MageTimeZone" => "Australia/Currie", "MicrosoftTimeZoneIndex" => "265"),
1648
+ Array("MageTimeZone" => "Australia/Hobart", "MicrosoftTimeZoneIndex" => "265"),
1649
+ Array("MageTimeZone" => "Asia/Dili", "MicrosoftTimeZoneIndex" => "235"),
1650
+ Array("MageTimeZone" => "Asia/Jayapura", "MicrosoftTimeZoneIndex" => "235"),
1651
+ Array("MageTimeZone" => "Asia/Tokyo", "MicrosoftTimeZoneIndex" => "235"),
1652
+ Array("MageTimeZone" => "Etc/GMT-9", "MicrosoftTimeZoneIndex" => "235"),
1653
+ Array("MageTimeZone" => "Pacific/Palau", "MicrosoftTimeZoneIndex" => "235"),
1654
+ Array("MageTimeZone" => "Etc/GMT-13", "MicrosoftTimeZoneIndex" => "300"),
1655
+ Array("MageTimeZone" => "Pacific/Enderbury", "MicrosoftTimeZoneIndex" => "300"),
1656
+ Array("MageTimeZone" => "Pacific/Fakaofo", "MicrosoftTimeZoneIndex" => "300"),
1657
+ Array("MageTimeZone" => "Pacific/Tongatapu", "MicrosoftTimeZoneIndex" => "300"),
1658
+ Array("MageTimeZone" => "Europe/Istanbul", "MicrosoftTimeZoneIndex" => "130"),
1659
+ Array("MageTimeZone" => "America/Indiana/Marengo", "MicrosoftTimeZoneIndex" => "040"),
1660
+ Array("MageTimeZone" => "America/Indiana/Vevay", "MicrosoftTimeZoneIndex" => "040"),
1661
+ Array("MageTimeZone" => "America/Indianapolis", "MicrosoftTimeZoneIndex" => "040"),
1662
+ Array("MageTimeZone" => "America/Creston", "MicrosoftTimeZoneIndex" => "015"),
1663
+ Array("MageTimeZone" => "America/Dawson_Creek", "MicrosoftTimeZoneIndex" => "015"),
1664
+ Array("MageTimeZone" => "America/Hermosillo", "MicrosoftTimeZoneIndex" => "015"),
1665
+ Array("MageTimeZone" => "America/Phoenix", "MicrosoftTimeZoneIndex" => "015"),
1666
+ Array("MageTimeZone" => "Etc/GMT+7", "MicrosoftTimeZoneIndex" => "015"),
1667
+ Array("MageTimeZone" => "America/Danmarkshavn", "MicrosoftTimeZoneIndex" => "085"),
1668
+ Array("MageTimeZone" => "Etc/GMT", "MicrosoftTimeZoneIndex" => "085"),
1669
+ Array("MageTimeZone" => "Etc/GMT-12", "MicrosoftTimeZoneIndex" => "285"),
1670
+ Array("MageTimeZone" => "Pacific/Funafuti", "MicrosoftTimeZoneIndex" => "285"),
1671
+ Array("MageTimeZone" => "Pacific/Kwajalein", "MicrosoftTimeZoneIndex" => "285"),
1672
+ Array("MageTimeZone" => "Pacific/Majuro", "MicrosoftTimeZoneIndex" => "285"),
1673
+ Array("MageTimeZone" => "Pacific/Nauru", "MicrosoftTimeZoneIndex" => "285"),
1674
+ Array("MageTimeZone" => "Pacific/Tarawa", "MicrosoftTimeZoneIndex" => "285"),
1675
+ Array("MageTimeZone" => "Pacific/Wake", "MicrosoftTimeZoneIndex" => "285"),
1676
+ Array("MageTimeZone" => "Pacific/Wallis", "MicrosoftTimeZoneIndex" => "285"),
1677
+ Array("MageTimeZone" => "America/Noronha", "MicrosoftTimeZoneIndex" => "075"),
1678
+ Array("MageTimeZone" => "Atlantic/South_Georgia", "MicrosoftTimeZoneIndex" => "075"),
1679
+ Array("MageTimeZone" => "Etc/GMT+2", "MicrosoftTimeZoneIndex" => "075"),
1680
+ Array("MageTimeZone" => "Etc/GMT+11", "MicrosoftTimeZoneIndex" => "280"),
1681
+ Array("MageTimeZone" => "Pacific/Midway", "MicrosoftTimeZoneIndex" => "280"),
1682
+ Array("MageTimeZone" => "Pacific/Niue", "MicrosoftTimeZoneIndex" => "280"),
1683
+ Array("MageTimeZone" => "Pacific/Pago_Pago", "MicrosoftTimeZoneIndex" => "280"),
1684
+ Array("MageTimeZone" => "Asia/Choibalsan", "MicrosoftTimeZoneIndex" => "227"),
1685
+ Array("MageTimeZone" => "Asia/Ulaanbaatar", "MicrosoftTimeZoneIndex" => "227"),
1686
+ Array("MageTimeZone" => "America/Caracas", "MicrosoftTimeZoneIndex" => "055"),
1687
+ Array("MageTimeZone" => "Asia/Sakhalin", "MicrosoftTimeZoneIndex" => "270"),
1688
+ Array("MageTimeZone" => "Asia/Ust-Nera", "MicrosoftTimeZoneIndex" => "270"),
1689
+ Array("MageTimeZone" => "Asia/Vladivostok", "MicrosoftTimeZoneIndex" => "270"),
1690
+ Array("MageTimeZone" => "Antarctica/Casey", "MicrosoftTimeZoneIndex" => "225"),
1691
+ Array("MageTimeZone" => "Australia/Perth", "MicrosoftTimeZoneIndex" => "225"),
1692
+ Array("MageTimeZone" => "Africa/Algiers", "MicrosoftTimeZoneIndex" => "113"),
1693
+ Array("MageTimeZone" => "Africa/Bangui", "MicrosoftTimeZoneIndex" => "113"),
1694
+ Array("MageTimeZone" => "Africa/Brazzaville", "MicrosoftTimeZoneIndex" => "113"),
1695
+ Array("MageTimeZone" => "Africa/Douala", "MicrosoftTimeZoneIndex" => "113"),
1696
+ Array("MageTimeZone" => "Africa/Kinshasa", "MicrosoftTimeZoneIndex" => "113"),
1697
+ Array("MageTimeZone" => "Africa/Lagos", "MicrosoftTimeZoneIndex" => "113"),
1698
+ Array("MageTimeZone" => "Africa/Libreville", "MicrosoftTimeZoneIndex" => "113"),
1699
+ Array("MageTimeZone" => "Africa/Luanda", "MicrosoftTimeZoneIndex" => "113"),
1700
+ Array("MageTimeZone" => "Africa/Malabo", "MicrosoftTimeZoneIndex" => "113"),
1701
+ Array("MageTimeZone" => "Africa/Ndjamena", "MicrosoftTimeZoneIndex" => "113"),
1702
+ Array("MageTimeZone" => "Africa/Niamey", "MicrosoftTimeZoneIndex" => "113"),
1703
+ Array("MageTimeZone" => "Africa/Porto-Novo", "MicrosoftTimeZoneIndex" => "113"),
1704
+ Array("MageTimeZone" => "Africa/Tunis", "MicrosoftTimeZoneIndex" => "113"),
1705
+ Array("MageTimeZone" => "Etc/GMT-1", "MicrosoftTimeZoneIndex" => "113"),
1706
+ Array("MageTimeZone" => "Arctic/Longyearbyen", "MicrosoftTimeZoneIndex" => "110"),
1707
+ Array("MageTimeZone" => "Europe/Amsterdam", "MicrosoftTimeZoneIndex" => "110"),
1708
+ Array("MageTimeZone" => "Europe/Andorra", "MicrosoftTimeZoneIndex" => "110"),
1709
+ Array("MageTimeZone" => "Europe/Berlin", "MicrosoftTimeZoneIndex" => "110"),
1710
+ Array("MageTimeZone" => "Europe/Busingen", "MicrosoftTimeZoneIndex" => "110"),
1711
+ Array("MageTimeZone" => "Europe/Gibraltar", "MicrosoftTimeZoneIndex" => "110"),
1712
+ Array("MageTimeZone" => "Europe/Luxembourg", "MicrosoftTimeZoneIndex" => "110"),
1713
+ Array("MageTimeZone" => "Europe/Malta", "MicrosoftTimeZoneIndex" => "110"),
1714
+ Array("MageTimeZone" => "Europe/Monaco", "MicrosoftTimeZoneIndex" => "110"),
1715
+ Array("MageTimeZone" => "Europe/Oslo", "MicrosoftTimeZoneIndex" => "110"),
1716
+ Array("MageTimeZone" => "Europe/Rome", "MicrosoftTimeZoneIndex" => "110"),
1717
+ Array("MageTimeZone" => "Europe/San_Marino", "MicrosoftTimeZoneIndex" => "110"),
1718
+ Array("MageTimeZone" => "Europe/Stockholm", "MicrosoftTimeZoneIndex" => "110"),
1719
+ Array("MageTimeZone" => "Europe/Vaduz", "MicrosoftTimeZoneIndex" => "110"),
1720
+ Array("MageTimeZone" => "Europe/Vatican", "MicrosoftTimeZoneIndex" => "110"),
1721
+ Array("MageTimeZone" => "Europe/Vienna", "MicrosoftTimeZoneIndex" => "110"),
1722
+ Array("MageTimeZone" => "Europe/Zurich", "MicrosoftTimeZoneIndex" => "110"),
1723
+ Array("MageTimeZone" => "Antarctica/Mawson", "MicrosoftTimeZoneIndex" => "185"),
1724
+ Array("MageTimeZone" => "Asia/Aqtau", "MicrosoftTimeZoneIndex" => "185"),
1725
+ Array("MageTimeZone" => "Asia/Aqtobe", "MicrosoftTimeZoneIndex" => "185"),
1726
+ Array("MageTimeZone" => "Asia/Ashgabat", "MicrosoftTimeZoneIndex" => "185"),
1727
+ Array("MageTimeZone" => "Asia/Dushanbe", "MicrosoftTimeZoneIndex" => "185"),
1728
+ Array("MageTimeZone" => "Asia/Oral", "MicrosoftTimeZoneIndex" => "185"),
1729
+ Array("MageTimeZone" => "Asia/Samarkand", "MicrosoftTimeZoneIndex" => "185"),
1730
+ Array("MageTimeZone" => "Asia/Tashkent", "MicrosoftTimeZoneIndex" => "185"),
1731
+ Array("MageTimeZone" => "Etc/GMT-5", "MicrosoftTimeZoneIndex" => "TEST"),
1732
+ Array("MageTimeZone" => "Indian/Kerguelen", "MicrosoftTimeZoneIndex" => "185"),
1733
+ Array("MageTimeZone" => "Indian/Maldives", "MicrosoftTimeZoneIndex" => "185"),
1734
+ Array("MageTimeZone" => "Antarctica/DumontDUrville", "MicrosoftTimeZoneIndex" => "275"),
1735
+ Array("MageTimeZone" => "Etc/GMT-10", "MicrosoftTimeZoneIndex" => "275"),
1736
+ Array("MageTimeZone" => "Pacific/Guam", "MicrosoftTimeZoneIndex" => "275"),
1737
+ Array("MageTimeZone" => "Pacific/Port_Moresby", "MicrosoftTimeZoneIndex" => "275"),
1738
+ Array("MageTimeZone" => "Pacific/Saipan", "MicrosoftTimeZoneIndex" => "275"),
1739
+ Array("MageTimeZone" => "Pacific/Truk", "MicrosoftTimeZoneIndex" => "275"),
1740
+ Array("MageTimeZone" => "Asia/Khandyga", "MicrosoftTimeZoneIndex" => "240"),
1741
+ Array("MageTimeZone" => "Asia/Yakutsk", "MicrosoftTimeZoneIndex" => "240"),
1742
+ );
1743
+ foreach ($timeZones as $time) {
1744
+ if ($time['MageTimeZone'] == $timeZone) {
1745
+ $result = $time['MicrosoftTimeZoneIndex'];
1746
+ }
1747
+ }
1748
+ }
1749
+ return $result;
1750
+ }
1751
+
1752
+ /**
1753
+ * get culture id needed for trial account
1754
+ *
1755
+ * @return mixed
1756
+ */
1757
+ public function getCultureId()
1758
+ {
1759
+ $fallback = 'en_US';
1760
+ $supportedCultures = array(
1761
+ 'en_US' => '1033',
1762
+ 'en_GB' => '2057',
1763
+ 'fr_FR' => '1036',
1764
+ 'es_ES' => '3082',
1765
+ 'de_DE' => '1031',
1766
+ 'it_IT' => '1040',
1767
+ 'ru_RU' => '1049',
1768
+ 'pt_PT' => '2070'
1769
+ );
1770
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
1771
+ if (isset($supportedCultures[$localeCode])) {
1772
+ return $supportedCultures[$localeCode];
1773
+ }
1774
+ return $supportedCultures[$fallback];
1775
+ }
1776
+
1777
+ /**
1778
+ * save api credentials
1779
+ *
1780
+ * @param $apiUser
1781
+ * @param $apiPass
1782
+ * @return bool
1783
+ */
1784
+ public function saveApiCreds($apiUser, $apiPass)
1785
+ {
1786
+ try {
1787
+ $apiPass = Mage::helper('core')->encrypt($apiPass);
1788
+ $config = new Mage_Core_Model_Config();
1789
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, '1');
1790
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME, $apiUser);
1791
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_PASSWORD, $apiPass);
1792
+ Mage::getConfig()->cleanCache();
1793
+ return true;
1794
+ } catch (Exception $e) {
1795
+ Mage::logException($e);
1796
+ return false;
1797
+ }
1798
+ }
1799
+
1800
+ /**
1801
+ * setup data fields
1802
+ *
1803
+ * @return bool
1804
+ */
1805
+ public function setupDataFields()
1806
+ {
1807
+ $error = false;
1808
+ $apiModel = Mage::helper('ddg')->getWebsiteApiClient();
1809
+ if (!$apiModel) {
1810
+ return false;
1811
+ } else {
1812
+ $dataFields = Mage::getModel('ddg_automation/connector_datafield')->getContactDatafields();
1813
+ foreach ($dataFields as $key => $dataField) {
1814
+ $response = $apiModel->postDataFields($dataField);
1815
+ //ignore existing datafields message
1816
+ if (isset($response->message) &&
1817
+ $response->message != Dotdigitalgroup_Email_Model_Apiconnector_Client::API_ERROR_DATAFIELD_EXISTS
1818
+ ) {
1819
+ $error = true;
1820
+ } else {
1821
+ try {
1822
+ //map the successfully created data field
1823
+ $config = new Mage_Core_Model_Config();
1824
+ $config->saveConfig('connector_data_mapping/customer_data/' . $key,
1825
+ strtoupper($dataField['name']));
1826
+ Mage::helper('ddg')->log('successfully connected : ' . $dataField['name']);
1827
+ } catch (Exception $e) {
1828
+ Mage::logException($e);
1829
+ $error = true;
1830
+ }
1831
+ }
1832
+ }
1833
+ if ($error) {
1834
+ return false;
1835
+ } else {
1836
+ Mage::getConfig()->cleanCache();
1837
+ return true;
1838
+ }
1839
+ }
1840
+ }
1841
+
1842
+ /**
1843
+ * create certain address books
1844
+ *
1845
+ * @return bool
1846
+ */
1847
+ public function createAddressBooks()
1848
+ {
1849
+ $addressBooks = array(
1850
+ array('name' => 'Magento_Customers', 'visibility' => 'Private'),
1851
+ array('name' => 'Magento_Subscribers', 'visibility' => 'Private'),
1852
+ array('name' => 'Magento_Guests', 'visibility' => 'Private'),
1853
+ );
1854
+ $addressBookMap = array(
1855
+ 'Magento_Customers' => Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID,
1856
+ 'Magento_Subscribers' => Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID,
1857
+ 'Magento_Guests' => Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID
1858
+ );
1859
+ $error = false;
1860
+ $client = Mage::helper('ddg')->getWebsiteApiClient();
1861
+ if (!$client) {
1862
+ return false;
1863
+ } else {
1864
+ foreach ($addressBooks as $addressBook) {
1865
+ $addressBookName = $addressBook['name'];
1866
+ $visibility = $addressBook['visibility'];
1867
+ if (strlen($addressBookName)) {
1868
+ $response = $client->postAddressBooks($addressBookName, $visibility);
1869
+ if (isset($response->message)) {
1870
+ $error = true;
1871
+ } else {
1872
+ try {
1873
+ //map the successfully created address book
1874
+ $config = new Mage_Core_Model_Config();
1875
+ $config->saveConfig($addressBookMap[$addressBookName], $response->id);
1876
+ Mage::helper('ddg')->log('successfully connected address book : ' . $addressBookName);
1877
+ } catch (Exception $e) {
1878
+ Mage::logException($e);
1879
+ $error = true;
1880
+ }
1881
+ }
1882
+ }
1883
+ }
1884
+ }
1885
+ if ($error) {
1886
+ return false;
1887
+ } else {
1888
+ Mage::getConfig()->cleanCache();
1889
+ return true;
1890
+ }
1891
+ }
1892
+
1893
+ /**
1894
+ * enable certain syncs for newly created trial account
1895
+ *
1896
+ * @return bool
1897
+ */
1898
+ public function enableSyncForTrial()
1899
+ {
1900
+ try {
1901
+ $config = new Mage_Core_Model_Config();
1902
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, '1');
1903
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED, '1');
1904
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, '1');
1905
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, '1');
1906
+ Mage::getConfig()->cleanCache();
1907
+ return true;
1908
+ } catch (Exception $e) {
1909
+ Mage::logException($e);
1910
+ return false;
1911
+ }
1912
+ }
1913
+
1914
+ /**
1915
+ * save api endpoint
1916
+ *
1917
+ * @param $value
1918
+ */
1919
+ public function saveApiEndPoint($value)
1920
+ {
1921
+ $config = Mage::getConfig();
1922
+ $config->saveConfig(
1923
+ Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
1924
+ $value
1925
+ );
1926
+ $config->cleanCache();
1927
+ }
1928
+
1929
+ /**
1930
+ * check if both frotnend and backend secure(HTTPS)
1931
+ *
1932
+ * @return bool
1933
+ */
1934
+ public function isFrontendAdminSecure()
1935
+ {
1936
+ $frontend = Mage::app()->getStore()->isFrontUrlSecure();
1937
+ $admin = Mage::app()->getStore()->isAdminUrlSecure();
1938
+ $current = Mage::app()->getStore()->isCurrentlySecure();
1939
+
1940
+ if ($frontend && $admin && $current) {
1941
+ return true;
1942
+ }
1943
+
1944
+ return false;
1945
+ }
1946
  }
app/code/community/Dotdigitalgroup/Email/Helper/File.php CHANGED
@@ -1,24 +1,26 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Data
 
4
  {
5
 
6
- const FILE_FULL_ACCESS_PERMISSION = '777';
7
 
8
  /**
9
  * Location of files we are building
10
  */
11
 
12
- protected $_output_folder; // set in _construct
13
- protected $_output_archive_folder; // set in _construct
14
 
15
- protected $delimiter; // set in _construct
16
- protected $enclosure; // set in _construct
17
 
18
  public function __construct()
19
  {
20
- $this->_output_folder = Mage::getBaseDir('var') . DS . 'export' . DS . 'email';
21
- $this->_output_archive_folder = $this->_output_folder . DS . 'archive';
 
22
 
23
  $this->delimiter = ','; // tab character
24
  $this->enclosure = '"';
@@ -27,60 +29,67 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
27
 
28
  public function getOutputFolder()
29
  {
30
- $this->pathExists($this->_output_folder);
31
- return $this->_output_folder;
 
32
  } // end
33
 
34
  public function getArchiveFolder()
35
  {
36
- $this->pathExists($this->_output_archive_folder);
37
- return $this->_output_archive_folder;
 
38
  } // end
39
 
40
  /* Return the full filepath */
41
- public function getFilePath($filename)
42
  {
43
  return $this->getOutputFolder() . DS . $filename;
44
  }
45
 
46
- public function archiveCSV($filename)
47
  {
48
- $this->moveFile($this->getOutputFolder(), $this->getArchiveFolder(), $filename);
 
 
49
  }
50
 
51
  /**
52
  * Moves the output file from one folder to the next
53
- * @param $source_folder
54
- * @param $dest_folder
 
55
  * @param $filename
56
  */
57
- public function moveFile($source_folder, $dest_folder, $filename )
58
  {
59
  // generate the full file paths
60
- $source_filepath = $source_folder . DS . $filename;
61
- $dest_filepath = $dest_folder . DS . $filename;
62
 
63
  // rename the file
64
- rename($source_filepath, $dest_filepath);
65
 
66
  } // end
67
 
68
 
69
  /**
70
  * Output an array to the output file FORCING Quotes around all fields
 
71
  * @param $filepath
72
  * @param $csv
73
  */
74
  public function outputForceQuotesCSV($filepath, $csv)
75
  {
76
- $fqCsv = $this->arrayToCsv($csv,chr(9),'"',true,false);
77
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
78
  $fp = fopen($filepath, "a");
79
 
80
  // for some reason passing the preset delimiter/enclosure variables results in error
81
- // $this->delimiter $this->enclosure
82
- if (fwrite($fp, $fqCsv) == 0 ) {
83
- Mage::throwException(Mage::helper('ddg')->__('Problem writing CSV file'));
 
84
  }
85
  fclose($fp);
86
 
@@ -89,6 +98,7 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
89
 
90
  /**
91
  * Output an array to the output file
 
92
  * @param $filepath
93
  * @param $csv
94
  */
@@ -98,9 +108,11 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
98
  $handle = fopen($filepath, "a");
99
 
100
  // for some reason passing the preset delimiter/enclosure variables results in error
101
- //$this->delimiter $this->enclosure
102
- if (fputcsv($handle, $csv, ',', '"') == 0 ) {
103
- Mage::throwException(Mage::helper('ddg')->__('Problem writing CSV file'));
 
 
104
  }
105
 
106
  fclose($handle);
@@ -110,78 +122,97 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
110
 
111
  /**
112
  * If the path does not exist then create it
 
113
  * @param string $path
114
  */
115
  public function pathExists($path)
116
  {
117
- if (!is_dir($path)) {
118
  mkdir($path, 0775, true);
119
  } // end
120
-
121
- return;
122
-
123
- } // end
124
 
125
 
126
- protected function arrayToCsv( array &$fields, $delimiter, $enclosure, $encloseAll = false, $nullToMysqlNull = false )
127
- {
128
- $delimiter_esc = preg_quote($delimiter, '/');
129
- $enclosure_esc = preg_quote($enclosure, '/');
 
130
 
131
  $output = array();
132
- foreach ( $fields as $field ) {
133
  if ($field === null && $nullToMysqlNull) {
134
  $output[] = 'NULL';
135
  continue;
136
  }
137
 
138
  // Enclose fields containing $delimiter, $enclosure or whitespace
139
- if ($encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field )) {
140
- $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
 
 
 
 
 
 
141
  } else {
142
  $output[] = $field;
143
  }
144
  }
145
 
146
- return implode( $delimiter, $output )."\n";
147
  }
148
 
149
  /**
150
  * Delete file or directory
 
151
  * @param $path
 
152
  * @return bool
153
  */
154
  public function deleteDir($path)
155
  {
156
  $class_func = array(__CLASS__, __FUNCTION__);
157
- return is_file($path) ?
158
- unlink($path) :
159
- array_map($class_func, glob($path.'/*')) == rmdir($path);
 
 
 
160
  }
161
 
162
 
163
  public function getWebsiteCustomerMappingDatafields($website)
164
  {
165
- $store = $website->getDefaultStore();
166
- $mappedData = Mage::getStoreConfig('connector_data_mapping/customer_data', $store);
 
 
167
  unset($mappedData['custom_attributes']);
168
  unset($mappedData['abandoned_prod_name']);
169
 
170
- //enterprise datafields
171
- if (Mage::helper('ddg')->isEnterprise()) {
172
 
173
- $enterpriseMapping = Mage::helper( 'ddg' )->getEnterpriseAttributes( $website );
174
- if ( $enterpriseMapping ) {
175
- $mappedData = array_merge( $mappedData, $enterpriseMapping );
176
- }
177
- }
 
 
178
 
179
- $mappedRewardData = $this->getWebsiteCustomerRewardMappingDatafields($website);
180
- if($mappedRewardData) $mappedData = array_merge($mappedData, $mappedRewardData);
 
 
 
 
181
 
182
  foreach ($mappedData as $key => $value) {
183
- if (! $value)
184
  unset($mappedData[$key]);
 
185
  }
186
 
187
  return $mappedData;
@@ -190,29 +221,35 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
190
  public function getWebsiteCustomerRewardMappingDatafields($website)
191
  {
192
  $helper = Mage::helper('ddg');
193
- if($helper->isSweetToothToGo($website)) {
194
- $store = $website->getDefaultStore();
195
- $mappedData = Mage::getStoreConfig('connector_data_mapping/sweet_tooth', $store);
 
 
196
  unset($mappedData['active']);
 
197
  return $mappedData;
198
  }
 
199
  return false;
200
  }
201
 
202
- /**
203
- * @param $path
204
- *
205
- * @return bool
206
- */
207
- public function getPathPermission($path) {
208
-
209
- //check for directory created before looking into permission
210
- if (is_dir($path)) {
211
- clearstatcache( null, $path );
212
-
213
- return decoct( fileperms( $path ) & 0777 );
214
- }
215
- //the file is not created and return the passing value
216
- return 755;
217
- }
 
 
218
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Helper_File
4
+ extends Dotdigitalgroup_Email_Helper_Data
5
  {
6
 
7
+ const FILE_FULL_ACCESS_PERMISSION = '777';
8
 
9
  /**
10
  * Location of files we are building
11
  */
12
 
13
+ protected $_outputFolder; // set in _construct
14
+ protected $_outputArchiveFolder; // set in _construct
15
 
16
+ public $delimiter; // set in _construct
17
+ public $enclosure; // set in _construct
18
 
19
  public function __construct()
20
  {
21
+ $this->_outputFolder = Mage::getBaseDir('var') . DS . 'export'
22
+ . DS . 'email';
23
+ $this->_outputArchiveFolder = $this->_outputFolder . DS . 'archive';
24
 
25
  $this->delimiter = ','; // tab character
26
  $this->enclosure = '"';
29
 
30
  public function getOutputFolder()
31
  {
32
+ $this->pathExists($this->_outputFolder);
33
+
34
+ return $this->_outputFolder;
35
  } // end
36
 
37
  public function getArchiveFolder()
38
  {
39
+ $this->pathExists($this->_outputArchiveFolder);
40
+
41
+ return $this->_outputArchiveFolder;
42
  } // end
43
 
44
  /* Return the full filepath */
45
+ public function getFilePath($filename)
46
  {
47
  return $this->getOutputFolder() . DS . $filename;
48
  }
49
 
50
+ public function archiveCSV($filename)
51
  {
52
+ $this->moveFile(
53
+ $this->getOutputFolder(), $this->getArchiveFolder(), $filename
54
+ );
55
  }
56
 
57
  /**
58
  * Moves the output file from one folder to the next
59
+ *
60
+ * @param $sourceFolder
61
+ * @param $destFolder
62
  * @param $filename
63
  */
64
+ public function moveFile($sourceFolder, $destFolder, $filename)
65
  {
66
  // generate the full file paths
67
+ $sourceFilepath = $sourceFolder . DS . $filename;
68
+ $destFilepath = $destFolder . DS . $filename;
69
 
70
  // rename the file
71
+ rename($sourceFilepath, $destFilepath);
72
 
73
  } // end
74
 
75
 
76
  /**
77
  * Output an array to the output file FORCING Quotes around all fields
78
+ *
79
  * @param $filepath
80
  * @param $csv
81
  */
82
  public function outputForceQuotesCSV($filepath, $csv)
83
  {
84
+ $fqCsv = $this->arrayToCsv($csv, chr(9), '"', true, false);
85
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
86
  $fp = fopen($filepath, "a");
87
 
88
  // for some reason passing the preset delimiter/enclosure variables results in error
89
+ if (fwrite($fp, $fqCsv) == 0) {
90
+ Mage::throwException(
91
+ Mage::helper('ddg')->__('Problem writing CSV file')
92
+ );
93
  }
94
  fclose($fp);
95
 
98
 
99
  /**
100
  * Output an array to the output file
101
+ *
102
  * @param $filepath
103
  * @param $csv
104
  */
108
  $handle = fopen($filepath, "a");
109
 
110
  // for some reason passing the preset delimiter/enclosure variables results in error
111
+ //$this->delimiter $this->enclosure
112
+ if (fputcsv($handle, $csv, ',', '"') == 0) {
113
+ Mage::throwException(
114
+ Mage::helper('ddg')->__('Problem writing CSV file')
115
+ );
116
  }
117
 
118
  fclose($handle);
122
 
123
  /**
124
  * If the path does not exist then create it
125
+ *
126
  * @param string $path
127
  */
128
  public function pathExists($path)
129
  {
130
+ if ( ! is_dir($path)) {
131
  mkdir($path, 0775, true);
132
  } // end
133
+ }
 
 
 
134
 
135
 
136
+ protected function arrayToCsv(array &$fields, $delimiter, $enclosure,
137
+ $encloseAll = false, $nullToMysqlNull = false
138
+ ) {
139
+ $delimiterEsc = preg_quote($delimiter, '/');
140
+ $enclosureEsc = preg_quote($enclosure, '/');
141
 
142
  $output = array();
143
+ foreach ($fields as $field) {
144
  if ($field === null && $nullToMysqlNull) {
145
  $output[] = 'NULL';
146
  continue;
147
  }
148
 
149
  // Enclose fields containing $delimiter, $enclosure or whitespace
150
+ if ($encloseAll
151
+ || preg_match(
152
+ "/(?:${delimiterEsc}|${enclosureEsc}|\s)/", $field
153
+ )
154
+ ) {
155
+ $output[] = $enclosure . str_replace(
156
+ $enclosure, $enclosure . $enclosure, $field
157
+ ) . $enclosure;
158
  } else {
159
  $output[] = $field;
160
  }
161
  }
162
 
163
+ return implode($delimiter, $output) . "\n";
164
  }
165
 
166
  /**
167
  * Delete file or directory
168
+ *
169
  * @param $path
170
+ *
171
  * @return bool
172
  */
173
  public function deleteDir($path)
174
  {
175
  $class_func = array(__CLASS__, __FUNCTION__);
176
+
177
+ return is_file($path)
178
+ ?
179
+ unlink($path)
180
+ :
181
+ array_map($class_func, glob($path . '/*')) == rmdir($path);
182
  }
183
 
184
 
185
  public function getWebsiteCustomerMappingDatafields($website)
186
  {
187
+ $store = $website->getDefaultStore();
188
+ $mappedData = Mage::getStoreConfig(
189
+ 'connector_data_mapping/customer_data', $store
190
+ );
191
  unset($mappedData['custom_attributes']);
192
  unset($mappedData['abandoned_prod_name']);
193
 
194
+ //enterprise datafields
195
+ if (Mage::helper('ddg')->isEnterprise()) {
196
 
197
+ $enterpriseMapping = Mage::helper('ddg')->getEnterpriseAttributes(
198
+ $website
199
+ );
200
+ if ($enterpriseMapping) {
201
+ $mappedData = array_merge($mappedData, $enterpriseMapping);
202
+ }
203
+ }
204
 
205
+ $mappedRewardData = $this->getWebsiteCustomerRewardMappingDatafields(
206
+ $website
207
+ );
208
+ if ($mappedRewardData) {
209
+ $mappedData = array_merge($mappedData, $mappedRewardData);
210
+ }
211
 
212
  foreach ($mappedData as $key => $value) {
213
+ if ( ! $value) {
214
  unset($mappedData[$key]);
215
+ }
216
  }
217
 
218
  return $mappedData;
221
  public function getWebsiteCustomerRewardMappingDatafields($website)
222
  {
223
  $helper = Mage::helper('ddg');
224
+ if ($helper->isSweetToothToGo($website)) {
225
+ $store = $website->getDefaultStore();
226
+ $mappedData = Mage::getStoreConfig(
227
+ 'connector_data_mapping/sweet_tooth', $store
228
+ );
229
  unset($mappedData['active']);
230
+
231
  return $mappedData;
232
  }
233
+
234
  return false;
235
  }
236
 
237
+ /**
238
+ * @param $path
239
+ *
240
+ * @return bool
241
+ */
242
+ public function getPathPermission($path)
243
+ {
244
+
245
+ //check for directory created before looking into permission
246
+ if (is_dir($path)) {
247
+ clearstatcache(null, $path);
248
+
249
+ return decoct(fileperms($path) & 0777);
250
+ }
251
+
252
+ //the file is not created and return the passing value
253
+ return 755;
254
+ }
255
  }
app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php CHANGED
@@ -2,32 +2,34 @@
2
 
3
  class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
4
  {
5
- const XML_PATH_RELATED_PRODUCTS_TYPE = 'connector_dynamic_content/products/related_display_type';
6
- const XML_PATH_UPSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/upsell_display_type';
7
- const XML_PATH_CROSSSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/crosssell_display_type';
8
- const XML_PATH_BESTSELLER_PRODUCT_TYPE = 'connector_dynamic_content/products/bestsellers_display_type';
9
- const XML_PATH_MOSTVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/most_viewed_display_type';
10
- const XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/recently_viewed_display_type';
11
- const XML_PATH_PRODUCTPUSH_TYPE = 'connector_dynamic_content/manual_product_search/display_type';
12
-
13
-
14
- const XML_PATH_RELATED_PRODUCTS_ITEMS = 'connector_dynamic_content/products/related_items_to_display';
15
- const XML_PATH_UPSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/upsell_items_to_display';
16
- const XML_PATH_CROSSSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/crosssell_items_to_display';
17
- const XML_PATH_BESTSELLER_PRODUCT_ITEMS = 'connector_dynamic_content/products/bestsellers_items_to_display';
18
- const XML_PATH_MOSTVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/most_viewed_items_to_display';
 
19
  const XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/recently_viewed_items_to_display';
20
 
21
- const XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS = 'connector_dynamic_content/manual_product_search/items_to_display';
22
- const XML_PATH_BESTSELLER_TIME_PERIOD = 'connector_dynamic_content/products/bestsellers_time_period';
23
- const XML_PATH_MOSTVIEWED_TIME_PERIOD = 'connector_dynamic_content/products/most_viewed_time_period';
24
- const XML_PATH_PRODUCTPUSH_ITEMS = 'connector_dynamic_content/manual_product_search/products_push_items';
25
- const XML_PATH_FALLBACK_PRODUCTS_ITEMS = 'connector_dynamic_content/fallback_products/product_list';
26
 
27
  public $periods = array('week', 'month', 'year');
28
 
29
  /**
30
  * Dispay type
 
31
  * @return mixed|string grid:list
32
  */
33
  public function getDisplayType()
@@ -35,7 +37,7 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
35
  $mode = Mage::app()->getRequest()->getActionName();
36
  $type = '';
37
 
38
- switch($mode){
39
  case 'related':
40
  $type = $this->getRelatedProductsType();
41
  break;
@@ -52,7 +54,7 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
52
  $type = $this->getMostViewedProductsType();
53
  break;
54
  case 'recentlyviewed':
55
- $type = $this->getRecentlyviewedProductsType();
56
  break;
57
  case 'push':
58
  $type = $this->getProductpushProductsType();
@@ -98,37 +100,52 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
98
  }
99
 
100
 
101
- /**
102
- * Limit of products displayed.
103
- * @param $mode
104
- *
105
- * @return int|mixed
106
- */
107
- public function getDisplayLimitByMode($mode)
 
108
  {
109
  $result = 0;
110
 
111
- switch($mode){
112
  case 'related':
113
- $result = Mage::getStoreConfig(self::XML_PATH_RELATED_PRODUCTS_ITEMS);
 
 
114
  break;
115
  case 'upsell':
116
- $result = Mage::getStoreConfig(self::XML_PATH_UPSELL_PRODUCTS_ITEMS);
 
 
117
  break;
118
  case 'crosssell':
119
- $result = Mage::getStoreConfig(self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS);
 
 
120
  break;
121
  case 'bestsellers':
122
- $result = Mage::getStoreConfig(self::XML_PATH_BESTSELLER_PRODUCT_ITEMS);
 
 
123
  break;
124
  case 'mostviewed':
125
- $result = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS);
 
 
126
  break;
127
  case 'recentlyviewed':
128
- $result = Mage::getStoreConfig(self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS);
 
 
129
  break;
130
  case 'push':
131
- $result = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS);
 
 
132
  }
133
 
134
  return $result;
@@ -136,9 +153,16 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
136
 
137
  public function getFallbackIds()
138
  {
139
- $fallbackIds = Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS);
140
- if ($fallbackIds)
141
- return explode(',', Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS));
 
 
 
 
 
 
 
142
  return array();
143
  }
144
 
@@ -146,12 +170,19 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
146
  {
147
  $now = new Zend_Date();
148
  $period = '';
149
- if ($config == 'mostviewed')
150
- $period = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_TIME_PERIOD);
151
- elseif($config == 'bestsellers') {
152
- $period = Mage::getStoreConfig( self::XML_PATH_BESTSELLER_TIME_PERIOD );
153
- }elseif($config == 'recentlyviewed')
154
- $period = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_TIME_PERIOD);
 
 
 
 
 
 
 
155
 
156
  if ($period == 'week') {
157
  $sub = Zend_Date::WEEK;
2
 
3
  class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
4
  {
5
+
6
+ const XML_PATH_RELATED_PRODUCTS_TYPE = 'connector_dynamic_content/products/related_display_type';
7
+ const XML_PATH_UPSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/upsell_display_type';
8
+ const XML_PATH_CROSSSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/crosssell_display_type';
9
+ const XML_PATH_BESTSELLER_PRODUCT_TYPE = 'connector_dynamic_content/products/bestsellers_display_type';
10
+ const XML_PATH_MOSTVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/most_viewed_display_type';
11
+ const XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/recently_viewed_display_type';
12
+ const XML_PATH_PRODUCTPUSH_TYPE = 'connector_dynamic_content/manual_product_search/display_type';
13
+
14
+
15
+ const XML_PATH_RELATED_PRODUCTS_ITEMS = 'connector_dynamic_content/products/related_items_to_display';
16
+ const XML_PATH_UPSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/upsell_items_to_display';
17
+ const XML_PATH_CROSSSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/crosssell_items_to_display';
18
+ const XML_PATH_BESTSELLER_PRODUCT_ITEMS = 'connector_dynamic_content/products/bestsellers_items_to_display';
19
+ const XML_PATH_MOSTVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/most_viewed_items_to_display';
20
  const XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/recently_viewed_items_to_display';
21
 
22
+ const XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS = 'connector_dynamic_content/manual_product_search/items_to_display';
23
+ const XML_PATH_BESTSELLER_TIME_PERIOD = 'connector_dynamic_content/products/bestsellers_time_period';
24
+ const XML_PATH_MOSTVIEWED_TIME_PERIOD = 'connector_dynamic_content/products/most_viewed_time_period';
25
+ const XML_PATH_PRODUCTPUSH_ITEMS = 'connector_dynamic_content/manual_product_search/products_push_items';
26
+ const XML_PATH_FALLBACK_PRODUCTS_ITEMS = 'connector_dynamic_content/fallback_products/product_list';
27
 
28
  public $periods = array('week', 'month', 'year');
29
 
30
  /**
31
  * Dispay type
32
+ *
33
  * @return mixed|string grid:list
34
  */
35
  public function getDisplayType()
37
  $mode = Mage::app()->getRequest()->getActionName();
38
  $type = '';
39
 
40
+ switch ($mode) {
41
  case 'related':
42
  $type = $this->getRelatedProductsType();
43
  break;
54
  $type = $this->getMostViewedProductsType();
55
  break;
56
  case 'recentlyviewed':
57
+ $type = $this->getRecentlyviewedProductsType();
58
  break;
59
  case 'push':
60
  $type = $this->getProductpushProductsType();
100
  }
101
 
102
 
103
+ /**
104
+ * Limit of products displayed.
105
+ *
106
+ * @param $mode
107
+ *
108
+ * @return int|mixed
109
+ */
110
+ public function getDisplayLimitByMode($mode)
111
  {
112
  $result = 0;
113
 
114
+ switch ($mode) {
115
  case 'related':
116
+ $result = Mage::getStoreConfig(
117
+ self::XML_PATH_RELATED_PRODUCTS_ITEMS
118
+ );
119
  break;
120
  case 'upsell':
121
+ $result = Mage::getStoreConfig(
122
+ self::XML_PATH_UPSELL_PRODUCTS_ITEMS
123
+ );
124
  break;
125
  case 'crosssell':
126
+ $result = Mage::getStoreConfig(
127
+ self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS
128
+ );
129
  break;
130
  case 'bestsellers':
131
+ $result = Mage::getStoreConfig(
132
+ self::XML_PATH_BESTSELLER_PRODUCT_ITEMS
133
+ );
134
  break;
135
  case 'mostviewed':
136
+ $result = Mage::getStoreConfig(
137
+ self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS
138
+ );
139
  break;
140
  case 'recentlyviewed':
141
+ $result = Mage::getStoreConfig(
142
+ self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS
143
+ );
144
  break;
145
  case 'push':
146
+ $result = Mage::getStoreConfig(
147
+ self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS
148
+ );
149
  }
150
 
151
  return $result;
153
 
154
  public function getFallbackIds()
155
  {
156
+ $fallbackIds = Mage::getStoreConfig(
157
+ self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
158
+ );
159
+ if ($fallbackIds) {
160
+ return explode(
161
+ ',',
162
+ Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS)
163
+ );
164
+ }
165
+
166
  return array();
167
  }
168
 
170
  {
171
  $now = new Zend_Date();
172
  $period = '';
173
+ if ($config == 'mostviewed') {
174
+ $period = Mage::getStoreConfig(
175
+ self::XML_PATH_MOSTVIEWED_TIME_PERIOD
176
+ );
177
+ } elseif ($config == 'bestsellers') {
178
+ $period = Mage::getStoreConfig(
179
+ self::XML_PATH_BESTSELLER_TIME_PERIOD
180
+ );
181
+ } elseif ($config == 'recentlyviewed') {
182
+ $period = Mage::getStoreConfig(
183
+ self::XML_PATH_MOSTVIEWED_TIME_PERIOD
184
+ );
185
+ }
186
 
187
  if ($period == 'week') {
188
  $sub = Zend_Date::WEEK;
app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php CHANGED
@@ -1,20 +1,25 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Helper_Transactional extends Mage_Core_Helper_Abstract
 
 
3
  {
4
 
5
- const XML_PATH_DDG_TRANSACTIONAL_ENABLED = 'connector_transactional_emails/ddg_transactional/enabled';
6
- const XML_PATH_DDG_TRANSACTIONAL_HOST = 'connector_transactional_emails/ddg_transactional/host';
7
- const XML_PATH_DDG_TRANSACTIONAL_USERNAME = 'connector_transactional_emails/ddg_transactional/username';
8
- const XML_PATH_DDG_TRANSACTIONAL_PASSWORD = 'connector_transactional_emails/ddg_transactional/password';
9
- const XML_PATH_DDG_TRANSACTIONAL_PORT = 'connector_transactional_emails/ddg_transactional/port';
10
- const XML_PATH_DDG_TRANSACTIONAL_DEBUG = 'connector_transactional_emails/ddg_transactional/debug';
11
 
12
 
13
  public function isEnabled()
14
  {
15
- return Mage::getStoreConfigFlag(self::XML_PATH_DDG_TRANSACTIONAL_ENABLED);
 
 
16
 
17
  }
 
18
  public function getSmtpHost()
19
  {
20
 
@@ -49,17 +54,21 @@ class Dotdigitalgroup_Email_Helper_Transactional extends Mage_Core_Helper_Abstra
49
  public function getTransport()
50
  {
51
  $config = array(
52
- 'port' =>$this->getSmtpPort(),
53
  'auth' => 'login',
54
  'username' => $this->getSmtpUsername(),
55
  'password' => $this->getSmtpPassword(),
56
  'ssl' => 'tls'
57
  );
58
 
59
- if ($this->isDebugEnabled())
60
- Mage::log('Mail transport config : '. implode(',', $config));
 
 
 
 
 
61
 
62
- $transport = new Zend_Mail_Transport_Smtp($this->getSmtpHost(), $config);
63
  return $transport;
64
  }
65
  }
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Transactional
4
+ extends Mage_Core_Helper_Abstract
5
  {
6
 
7
+ const XML_PATH_DDG_TRANSACTIONAL_ENABLED = 'connector_transactional_emails/ddg_transactional/enabled';
8
+ const XML_PATH_DDG_TRANSACTIONAL_HOST = 'connector_transactional_emails/ddg_transactional/host';
9
+ const XML_PATH_DDG_TRANSACTIONAL_USERNAME = 'connector_transactional_emails/ddg_transactional/username';
10
+ const XML_PATH_DDG_TRANSACTIONAL_PASSWORD = 'connector_transactional_emails/ddg_transactional/password';
11
+ const XML_PATH_DDG_TRANSACTIONAL_PORT = 'connector_transactional_emails/ddg_transactional/port';
12
+ const XML_PATH_DDG_TRANSACTIONAL_DEBUG = 'connector_transactional_emails/ddg_transactional/debug';
13
 
14
 
15
  public function isEnabled()
16
  {
17
+ return Mage::getStoreConfigFlag(
18
+ self::XML_PATH_DDG_TRANSACTIONAL_ENABLED
19
+ );
20
 
21
  }
22
+
23
  public function getSmtpHost()
24
  {
25
 
54
  public function getTransport()
55
  {
56
  $config = array(
57
+ 'port' => $this->getSmtpPort(),
58
  'auth' => 'login',
59
  'username' => $this->getSmtpUsername(),
60
  'password' => $this->getSmtpPassword(),
61
  'ssl' => 'tls'
62
  );
63
 
64
+ if ($this->isDebugEnabled()) {
65
+ Mage::log('Mail transport config : ' . implode(',', $config));
66
+ }
67
+
68
+ $transport = new Zend_Mail_Transport_Smtp(
69
+ $this->getSmtpHost(), $config
70
+ );
71
 
 
72
  return $transport;
73
  }
74
  }
app/code/community/Dotdigitalgroup/Email/Model/Abstract/Rest.php CHANGED
@@ -2,29 +2,34 @@
2
 
3
  abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
4
  {
5
- protected $url;
6
- protected $verb;
7
- protected $requestBody;
8
- protected $requestLength;
 
9
  protected $_apiUsername;
10
  protected $_apiPassword;
11
- protected $acceptType;
12
- protected $responseBody;
13
- protected $responseInfo;
14
- protected $curlError;
15
- protected $isNotJson = false;
16
-
17
- public function __construct($website = 0) // ($url = null, $verb = 'GET', $requestBody = null)
18
- {
19
- $this->url = null; //$url;
20
- $this->verb = 'GET'; //$verb;
21
- $this->requestBody = null; //$requestBody;
22
- $this->requestLength = 0;
23
- $this->_apiUsername = (string)Mage::helper('ddg')->getApiUsername($website);
24
- $this->_apiPassword = (string)Mage::helper('ddg')->getApiPassword($website);
25
- $this->acceptType = 'application/json';
26
- $this->responseBody = null;
27
- $this->responseInfo = null;
 
 
 
 
28
 
29
  if ($this->requestBody !== null) {
30
  $this->buildPostBody();
@@ -33,69 +38,74 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
33
 
34
  protected function prettyPrint($json)
35
  {
36
- $result = '';
37
- $level = 0;
38
- $prev_char = '';
39
- $in_quotes = false;
40
- $ends_line_level = NULL;
41
- $json_length = strlen( $json );
42
-
43
- for ($i = 0; $i < $json_length; $i++) {
44
- $char = $json[$i];
45
- $new_line_level = NULL;
46
- $post = "";
47
- if ($ends_line_level !== NULL) {
48
- $new_line_level = $ends_line_level;
49
- $ends_line_level = NULL;
50
  }
51
- if ($char === '"' && $prev_char != '\\') {
52
- $in_quotes = !$in_quotes;
53
- } elseif (! $in_quotes) {
54
  switch ($char) {
55
- case '}': case ']':
56
- $level--;
57
- $ends_line_level = NULL;
58
- $new_line_level = $level;
59
- break;
 
60
 
61
- case '{': case '[':
62
- $level++;
 
63
  case ',':
64
- $ends_line_level = $level;
65
  break;
66
 
67
  case ':':
68
  $post = " ";
69
  break;
70
 
71
- case " ": case "\t": case "\n": case "\r":
72
- $char = "";
73
- $ends_line_level = $new_line_level;
74
- $new_line_level = NULL;
75
- break;
 
 
 
76
  }
77
  }
78
- if ($new_line_level !== NULL) {
79
- $result .= "\n".str_repeat( "\t", $new_line_level );
80
  }
81
- $result .= $char.$post;
82
- $prev_char = $char;
83
  }
84
 
85
  return $result;
86
  }
87
 
88
  /**
89
- * returns the object as JSON.
90
- *
91
- * @param bool $pretty
92
- *
93
- * @return string
94
- */
95
- public function toJSON($pretty=false)
96
  {
97
 
98
- if (!$pretty) {
99
  return json_encode($this->expose());
100
  } else {
101
  return $this->prettyPrint(json_encode($this->expose()));
@@ -103,9 +113,10 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
103
  }
104
 
105
  /**
106
- * exposes the class as an array of objects
107
- * @return array
108
- */
 
109
  public function expose()
110
  {
111
 
@@ -115,36 +126,35 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
115
 
116
 
117
  /**
118
- * Reset the client.
119
- *
120
- * @return $this
121
- */
122
- public function flush ()
123
  {
124
- $this->_apiUsername = '';
125
- $this->_apiPassword = '';
126
- $this->requestBody = null;
127
- $this->requestLength = 0;
128
- $this->verb = 'GET';
129
- $this->responseBody = null;
130
- $this->responseInfo = null;
 
131
  return $this;
132
  }
133
 
134
  /**
135
- * Execute the curl request.
136
- *
137
- * @return null
138
- * @throws Exception
139
- */
140
  public function execute()
141
  {
142
  $ch = curl_init();
143
  $this->setAuth($ch);
144
- try
145
- {
146
- switch (strtoupper($this->verb))
147
- {
148
  case 'GET':
149
  $this->executeGet($ch);
150
  break;
@@ -158,72 +168,76 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
158
  $this->executeDelete($ch);
159
  break;
160
  default:
161
- throw new InvalidArgumentException('Current verb (' . $this->verb . ') is an invalid REST verb.');
 
 
 
162
  }
163
- }catch (InvalidArgumentException $e){
164
  curl_close($ch);
165
  throw $e;
166
- }catch (Exception $e){
167
  curl_close($ch);
168
  throw $e;
169
  }
170
 
171
- /**
172
- * check and debug api request total time
173
- */
174
- if (Mage::helper('ddg')->getDebugEnabled()){
175
- $info = $this->getResponseInfo();
176
- //the response info data is set
177
- if (isset($info['url']) && isset($info['total_time'])){
178
- $url = $info['url'];
179
- $time = $info['total_time'];
180
- $totalTime = sprintf(' time : %g sec', $time);
181
- $check = Mage::helper('ddg')->getApiResponseTimeLimit();
182
- $limit = ($check)? $check : '2';
183
- $message = $this->verb . ', ' . $url. $totalTime;
184
- //check for slow queries
185
- if ( $time > $limit) {
186
- //log the slow queries
187
- Mage::helper( 'ddg' )->log( $message )
188
- ->rayLog($message);
189
- }
190
- }
191
- }
192
-
193
- return $this->responseBody;
194
  }
195
 
196
  /**
197
- * Post data.
198
- *
199
- * @param null $data
200
- *
201
- * @return $this
202
- */
203
  public function buildPostBody($data = null)
204
  {
205
  $this->requestBody = json_encode($data);
 
206
  return $this;
207
  }
208
 
209
  /**
210
- * Execute curl get request.
211
- *
212
- * @param $ch
213
- */
214
  protected function executeGet($ch)
215
  {
216
  $this->doExecute($ch);
217
  }
218
 
219
  /**
220
- * Execute post request.
221
- *
222
- * @param $ch
223
- */
224
  protected function executePost($ch)
225
  {
226
- if (!is_string($this->requestBody)) {
227
  $this->buildPostBody();
228
  }
229
 
@@ -233,26 +247,26 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
233
  $this->doExecute($ch);
234
  }
235
 
236
- /**
237
- * Post from the file.
238
- *
239
- * @param $filename
240
- */
241
- protected function buildPostBodyFromFile($filename)
242
- {
243
- $this->requestBody = array (
244
- 'file' => '@'.$filename
245
  );
246
  }
247
 
248
- /**
249
- * Execute put.
250
- *
251
- * @param $ch
252
- */
253
- protected function executePut($ch)
254
  {
255
- if (!is_string($this->requestBody)) {
256
  $this->buildPostBody();
257
  }
258
 
@@ -271,37 +285,37 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
271
  fclose($fh);
272
  }
273
 
274
- /**
275
- * Ececute delete.
276
- *
277
- * @param $ch
278
- */
279
- protected function executeDelete($ch)
280
  {
281
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
282
 
283
  $this->doExecute($ch);
284
  }
285
 
286
- /**
287
- * Execute request.
288
- *
289
- * @param $ch
290
- */
291
- protected function doExecute(&$ch)
292
  {
293
  $this->setCurlOpts($ch);
294
 
295
- if($this->isNotJson)
296
  $this->responseBody = curl_exec($ch);
297
- else
298
  $this->responseBody = json_decode(curl_exec($ch));
 
299
 
300
- $this->responseInfo = curl_getinfo($ch);
301
 
302
  //if curl error found
303
- if(curl_errno($ch))
304
- {
305
  //save the error
306
  $this->curlError = curl_error($ch);
307
  }
@@ -309,172 +323,183 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
309
  curl_close($ch);
310
  }
311
 
312
- /**
313
- * curl options.
314
- *
315
- * @param $ch
316
- */
317
- protected function setCurlOpts(&$ch)
318
  {
319
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
320
  curl_setopt($ch, CURLOPT_URL, $this->url);
321
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
322
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
323
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
324
- curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $this->acceptType ,'Content-Type: application/json'));
 
 
 
325
  }
326
 
327
- /**
328
- * basic auth.
329
- *
330
- * @param $ch
331
- */
332
- protected function setAuth(&$ch)
333
  {
334
- if ($this->_apiUsername !== null && $this->_apiPassword !== null)
335
- {
336
  curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_DIGEST);
337
- curl_setopt($ch, CURLOPT_USERPWD, $this->_apiUsername . ':' . $this->_apiPassword);
 
 
 
338
  }
339
  }
340
 
341
- /**
342
- * Get accept type.
343
- *
344
- * @return string
345
- */
346
- public function getAcceptType()
347
  {
348
  return $this->acceptType;
349
  }
350
 
351
- /**
352
- * set accept type.
353
- *
354
- * @param $acceptType
355
- */
356
- public function setAcceptType($acceptType)
357
  {
358
  $this->acceptType = $acceptType;
359
  }
360
 
361
 
362
- /**
363
- * get api username.
364
- *
365
- * @return string
366
- */
367
- public function getApiUsername()
368
- {
369
- return $this->_apiUsername;
370
- }
371
-
372
- /**
373
- * set api username.
374
- *
375
- * @param $apiUsername
376
- *
377
- * @return $this
378
- */
379
- public function setApiUsername($apiUsername)
380
- {
381
- $this->_apiUsername = $apiUsername;
382
- return $this;
383
- }
384
- /**
385
- * Get api password.
386
- *
387
- * @return string
388
- */
389
- public function getApiPassword()
 
 
390
  {
391
  return $this->_apiPassword;
392
  }
393
 
394
- /**
395
- * set api password.
396
- * @param $apiPassword
397
- *
398
- * @return $this
399
- */
400
- public function setApiPassword($apiPassword)
 
401
  {
402
  $this->_apiPassword = $apiPassword;
 
403
  return $this;
404
  }
405
 
406
- /**
407
- * get response body.
408
- *
409
- * @return string/object
410
- */
411
- public function getResponseBody()
412
  {
413
  return $this->responseBody;
414
  }
415
 
416
- /**
417
- * get response info.
418
- *
419
- * @return null
420
- */
421
- public function getResponseInfo()
422
  {
423
  return $this->responseInfo;
424
  }
425
 
426
- /**
427
- * get url.
428
- *
429
- * @return string
430
- */
431
- public function getUrl()
432
  {
433
  return $this->url;
434
  }
435
 
436
- /**
437
- * set url.
438
- *
439
- * @param $url
440
- *
441
- * @return $this
442
- */
443
- public function setUrl($url)
444
  {
445
  $this->url = $url;
 
446
  return $this;
447
  }
448
 
449
- /**
450
- * get the verb.
451
- *
452
- * @return string
453
- */
454
- public function getVerb ()
455
  {
456
  return $this->verb;
457
  }
458
 
459
- /**
460
- * set the verb.
461
- *
462
- * @param $verb
463
- *
464
- * @return $this
465
- */
466
- public function setVerb ($verb)
467
  {
468
  $this->verb = $verb;
 
469
  return $this;
470
  }
471
 
472
  public function getCurlError()
473
  {
474
  //if curl error
475
- if(!empty($this->curlError)){
476
  //log curl error
477
- $message = 'CURL ERROR '. $this->curlError;
478
  Mage::helper('ddg')->log($message)
479
  ->rayLog($message, 'apiconnector/rest.php', __LINE__);
480
 
@@ -487,6 +512,7 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
487
  public function setIsNotJsonTrue()
488
  {
489
  $this->isNotJson = true;
 
490
  return $this;
491
  }
492
  }
2
 
3
  abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
4
  {
5
+
6
+ public $url;
7
+ public $verb;
8
+ public $requestBody;
9
+ public $requestLength;
10
  protected $_apiUsername;
11
  protected $_apiPassword;
12
+ public $acceptType;
13
+ public $responseBody;
14
+ public $responseInfo;
15
+ public $curlError;
16
+ public $isNotJson = false;
17
+
18
+ public function __construct($website = 0
19
+ ) {
20
+ $this->url = null; //$url;
21
+ $this->verb = 'GET'; //$verb;
22
+ $this->requestBody = null; //$requestBody;
23
+ $this->requestLength = 0;
24
+ $this->_apiUsername = (string)Mage::helper('ddg')->getApiUsername(
25
+ $website
26
+ );
27
+ $this->_apiPassword = (string)Mage::helper('ddg')->getApiPassword(
28
+ $website
29
+ );
30
+ $this->acceptType = 'application/json';
31
+ $this->responseBody = null;
32
+ $this->responseInfo = null;
33
 
34
  if ($this->requestBody !== null) {
35
  $this->buildPostBody();
38
 
39
  protected function prettyPrint($json)
40
  {
41
+ $result = '';
42
+ $level = 0;
43
+ $prevChar = '';
44
+ $inQuotes = false;
45
+ $endsLineLevel = null;
46
+ $jsonLength = strlen($json);
47
+
48
+ for ($i = 0; $i < $jsonLength; $i++) {
49
+ $char = $json[$i];
50
+ $newLineLevel = null;
51
+ $post = "";
52
+ if ($endsLineLevel !== null) {
53
+ $newLineLevel = $endsLineLevel;
54
+ $endsLineLevel = null;
55
  }
56
+ if ($char === '"' && $prevChar != '\\') {
57
+ $inQuotes = ! $inQuotes;
58
+ } elseif ( ! $inQuotes) {
59
  switch ($char) {
60
+ case '}':
61
+ case ']':
62
+ $level--;
63
+ $endsLineLevel = null;
64
+ $newLineLevel = $level;
65
+ break;
66
 
67
+ case '{':
68
+ case '[':
69
+ $level++;
70
  case ',':
71
+ $endsLineLevel = $level;
72
  break;
73
 
74
  case ':':
75
  $post = " ";
76
  break;
77
 
78
+ case " ":
79
+ case "\t":
80
+ case "\n":
81
+ case "\r":
82
+ $char = "";
83
+ $endsLineLevel = $newLineLevel;
84
+ $newLineLevel = null;
85
+ break;
86
  }
87
  }
88
+ if ($newLineLevel !== null) {
89
+ $result .= "\n" . str_repeat("\t", $newLineLevel);
90
  }
91
+ $result .= $char . $post;
92
+ $prevChar = $char;
93
  }
94
 
95
  return $result;
96
  }
97
 
98
  /**
99
+ * returns the object as JSON.
100
+ *
101
+ * @param bool $pretty
102
+ *
103
+ * @return string
104
+ */
105
+ public function toJSON($pretty = false)
106
  {
107
 
108
+ if ( ! $pretty) {
109
  return json_encode($this->expose());
110
  } else {
111
  return $this->prettyPrint(json_encode($this->expose()));
113
  }
114
 
115
  /**
116
+ * exposes the class as an array of objects
117
+ *
118
+ * @return array
119
+ */
120
  public function expose()
121
  {
122
 
126
 
127
 
128
  /**
129
+ * Reset the client.
130
+ *
131
+ * @return $this
132
+ */
133
+ public function flush()
134
  {
135
+ $this->_apiUsername = '';
136
+ $this->_apiPassword = '';
137
+ $this->requestBody = null;
138
+ $this->requestLength = 0;
139
+ $this->verb = 'GET';
140
+ $this->responseBody = null;
141
+ $this->responseInfo = null;
142
+
143
  return $this;
144
  }
145
 
146
  /**
147
+ * Execute the curl request.
148
+ *
149
+ * @return null
150
+ * @throws Exception
151
+ */
152
  public function execute()
153
  {
154
  $ch = curl_init();
155
  $this->setAuth($ch);
156
+ try {
157
+ switch (strtoupper($this->verb)) {
 
 
158
  case 'GET':
159
  $this->executeGet($ch);
160
  break;
168
  $this->executeDelete($ch);
169
  break;
170
  default:
171
+ throw new InvalidArgumentException(
172
+ 'Current verb (' . $this->verb
173
+ . ') is an invalid REST verb.'
174
+ );
175
  }
176
+ } catch (InvalidArgumentException $e) {
177
  curl_close($ch);
178
  throw $e;
179
+ } catch (Exception $e) {
180
  curl_close($ch);
181
  throw $e;
182
  }
183
 
184
+ /**
185
+ * check and debug api request total time
186
+ */
187
+ if (Mage::helper('ddg')->getDebugEnabled()) {
188
+ $info = $this->getResponseInfo();
189
+ //the response info data is set
190
+ if (isset($info['url']) && isset($info['total_time'])) {
191
+ $url = $info['url'];
192
+ $time = $info['total_time'];
193
+ $totalTime = sprintf(' time : %g sec', $time);
194
+ $check = Mage::helper('ddg')->getApiResponseTimeLimit();
195
+ $limit = ($check) ? $check : '2';
196
+ $message = $this->verb . ', ' . $url . $totalTime;
197
+ //check for slow queries
198
+ if ($time > $limit) {
199
+ //log the slow queries
200
+ Mage::helper('ddg')->log($message)
201
+ ->rayLog($message);
202
+ }
203
+ }
204
+ }
205
+
206
+ return $this->responseBody;
207
  }
208
 
209
  /**
210
+ * Post data.
211
+ *
212
+ * @param null $data
213
+ *
214
+ * @return $this
215
+ */
216
  public function buildPostBody($data = null)
217
  {
218
  $this->requestBody = json_encode($data);
219
+
220
  return $this;
221
  }
222
 
223
  /**
224
+ * Execute curl get request.
225
+ *
226
+ * @param $ch
227
+ */
228
  protected function executeGet($ch)
229
  {
230
  $this->doExecute($ch);
231
  }
232
 
233
  /**
234
+ * Execute post request.
235
+ *
236
+ * @param $ch
237
+ */
238
  protected function executePost($ch)
239
  {
240
+ if ( ! is_string($this->requestBody)) {
241
  $this->buildPostBody();
242
  }
243
 
247
  $this->doExecute($ch);
248
  }
249
 
250
+ /**
251
+ * Post from the file.
252
+ *
253
+ * @param $filename
254
+ */
255
+ protected function buildPostBodyFromFile($filename)
256
+ {
257
+ $this->requestBody = array(
258
+ 'file' => '@' . $filename
259
  );
260
  }
261
 
262
+ /**
263
+ * Execute put.
264
+ *
265
+ * @param $ch
266
+ */
267
+ protected function executePut($ch)
268
  {
269
+ if ( ! is_string($this->requestBody)) {
270
  $this->buildPostBody();
271
  }
272
 
285
  fclose($fh);
286
  }
287
 
288
+ /**
289
+ * Ececute delete.
290
+ *
291
+ * @param $ch
292
+ */
293
+ protected function executeDelete($ch)
294
  {
295
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
296
 
297
  $this->doExecute($ch);
298
  }
299
 
300
+ /**
301
+ * Execute request.
302
+ *
303
+ * @param $ch
304
+ */
305
+ protected function doExecute(&$ch)
306
  {
307
  $this->setCurlOpts($ch);
308
 
309
+ if ($this->isNotJson) {
310
  $this->responseBody = curl_exec($ch);
311
+ } else {
312
  $this->responseBody = json_decode(curl_exec($ch));
313
+ }
314
 
315
+ $this->responseInfo = curl_getinfo($ch);
316
 
317
  //if curl error found
318
+ if (curl_errno($ch)) {
 
319
  //save the error
320
  $this->curlError = curl_error($ch);
321
  }
323
  curl_close($ch);
324
  }
325
 
326
+ /**
327
+ * curl options.
328
+ *
329
+ * @param $ch
330
+ */
331
+ protected function setCurlOpts(&$ch)
332
  {
333
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
334
  curl_setopt($ch, CURLOPT_URL, $this->url);
335
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
336
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
337
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
338
+ curl_setopt(
339
+ $ch, CURLOPT_HTTPHEADER, array('Accept: ' . $this->acceptType,
340
+ 'Content-Type: application/json')
341
+ );
342
  }
343
 
344
+ /**
345
+ * basic auth.
346
+ *
347
+ * @param $ch
348
+ */
349
+ protected function setAuth(&$ch)
350
  {
351
+ if ($this->_apiUsername !== null && $this->_apiPassword !== null) {
 
352
  curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_DIGEST);
353
+ curl_setopt(
354
+ $ch, CURLOPT_USERPWD,
355
+ $this->_apiUsername . ':' . $this->_apiPassword
356
+ );
357
  }
358
  }
359
 
360
+ /**
361
+ * Get accept type.
362
+ *
363
+ * @return string
364
+ */
365
+ public function getAcceptType()
366
  {
367
  return $this->acceptType;
368
  }
369
 
370
+ /**
371
+ * set accept type.
372
+ *
373
+ * @param $acceptType
374
+ */
375
+ public function setAcceptType($acceptType)
376
  {
377
  $this->acceptType = $acceptType;
378
  }
379
 
380
 
381
+ /**
382
+ * get api username.
383
+ *
384
+ * @return string
385
+ */
386
+ public function getApiUsername()
387
+ {
388
+ return $this->_apiUsername;
389
+ }
390
+
391
+ /**
392
+ * set api username.
393
+ *
394
+ * @param $apiUsername
395
+ *
396
+ * @return $this
397
+ */
398
+ public function setApiUsername($apiUsername)
399
+ {
400
+ $this->_apiUsername = $apiUsername;
401
+
402
+ return $this;
403
+ }
404
+
405
+ /**
406
+ * Get api password.
407
+ *
408
+ * @return string
409
+ */
410
+ public function getApiPassword()
411
  {
412
  return $this->_apiPassword;
413
  }
414
 
415
+ /**
416
+ * set api password.
417
+ *
418
+ * @param $apiPassword
419
+ *
420
+ * @return $this
421
+ */
422
+ public function setApiPassword($apiPassword)
423
  {
424
  $this->_apiPassword = $apiPassword;
425
+
426
  return $this;
427
  }
428
 
429
+ /**
430
+ * get response body.
431
+ *
432
+ * @return string/object
433
+ */
434
+ public function getResponseBody()
435
  {
436
  return $this->responseBody;
437
  }
438
 
439
+ /**
440
+ * get response info.
441
+ *
442
+ * @return null
443
+ */
444
+ public function getResponseInfo()
445
  {
446
  return $this->responseInfo;
447
  }
448
 
449
+ /**
450
+ * get url.
451
+ *
452
+ * @return string
453
+ */
454
+ public function getUrl()
455
  {
456
  return $this->url;
457
  }
458
 
459
+ /**
460
+ * set url.
461
+ *
462
+ * @param $url
463
+ *
464
+ * @return $this
465
+ */
466
+ public function setUrl($url)
467
  {
468
  $this->url = $url;
469
+
470
  return $this;
471
  }
472
 
473
+ /**
474
+ * get the verb.
475
+ *
476
+ * @return string
477
+ */
478
+ public function getVerb()
479
  {
480
  return $this->verb;
481
  }
482
 
483
+ /**
484
+ * set the verb.
485
+ *
486
+ * @param $verb
487
+ *
488
+ * @return $this
489
+ */
490
+ public function setVerb($verb)
491
  {
492
  $this->verb = $verb;
493
+
494
  return $this;
495
  }
496
 
497
  public function getCurlError()
498
  {
499
  //if curl error
500
+ if ( ! empty($this->curlError)) {
501
  //log curl error
502
+ $message = 'CURL ERROR ' . $this->curlError;
503
  Mage::helper('ddg')->log($message)
504
  ->rayLog($message, 'apiconnector/rest.php', __LINE__);
505
 
512
  public function setIsNotJsonTrue()
513
  {
514
  $this->isNotJson = true;
515
+
516
  return $this;
517
  }
518
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Content.php CHANGED
@@ -6,116 +6,133 @@
6
  class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
7
  {
8
 
9
- /**
10
- * css style that can be used to alert based on result
11
- * @var
12
- */
13
- public $style;
14
-
15
- /**
16
- * @return mixed
17
- */
18
- public function getTitle() {
19
- return $this->title;
20
- }
21
-
22
- /**
23
- * @param $title
24
- *
25
- * @return $this
26
- */
27
- public function setTitle( $title ) {
28
- $this->title = $title;
29
- return $this;
30
- }
31
-
32
- /**
33
- * title to be displayed as a key for the status
34
- * @var
35
- */
36
- public $title;
37
-
38
- /**
39
- * message to be displayd in the body
40
- * @var
41
- */
42
- public $message;
43
-
44
- /**
45
- * how to fix message
46
- * @var
47
- */
48
- public $howto = array();
49
-
50
- /**
51
- * @return mixed
52
- */
53
-
54
- /**
55
- * table data
56
- * @var
57
- */
58
- public $table = array();
59
-
60
- public function getHowto() {
61
- return $this->howto;
62
- }
63
-
64
- /**
65
- * @param $howto
66
- *
67
- * @return $this
68
- */
69
- public function setHowto( $howto ) {
70
- $this->howto[] = $howto;
71
- return $this;
72
- }
73
-
74
- /**
75
- * @return mixed
76
- */
77
- public function getMessage() {
78
- return $this->message;
79
- }
80
-
81
- /**
82
- * @param $message
83
- *
84
- * @return $this
85
- */
86
- public function setMessage( $message ) {
87
- $this->message = $message;
88
- return $this;
89
- }
90
-
91
- /**
92
- * @return mixed
93
- */
94
- public function getStyle() {
95
- return $this->style;
96
- }
97
-
98
- /**
99
- * @param $style
100
- *
101
- * @return $this
102
- */
103
- public function setStyle( $style ) {
104
- $this->style = $style;
105
- return $this;
106
- }
107
-
108
- public function setTable($table)
109
- {
110
- $this->table[] = $table;
111
- return $this;
112
- }
113
-
114
- public function getTable() {
115
- return $this->table;
116
- }
117
-
118
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
 
121
  }
6
  class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
7
  {
8
 
9
+ /**
10
+ * css style that can be used to alert based on result
11
+ *
12
+ * @var
13
+ */
14
+ public $style;
15
+
16
+ /**
17
+ * @return mixed
18
+ */
19
+ public function getTitle()
20
+ {
21
+ return $this->title;
22
+ }
23
+
24
+ /**
25
+ * @param $title
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setTitle($title)
30
+ {
31
+ $this->title = $title;
32
+
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * title to be displayed as a key for the status
38
+ *
39
+ * @var
40
+ */
41
+ public $title;
42
+
43
+ /**
44
+ * message to be displayd in the body
45
+ *
46
+ * @var
47
+ */
48
+ public $message;
49
+
50
+ /**
51
+ * how to fix message
52
+ *
53
+ * @var
54
+ */
55
+ public $howto = array();
56
+
57
+ /**
58
+ * @return mixed
59
+ */
60
+
61
+ /**
62
+ * table data
63
+ *
64
+ * @var
65
+ */
66
+ public $table = array();
67
+
68
+ public function getHowto()
69
+ {
70
+ return $this->howto;
71
+ }
72
+
73
+ /**
74
+ * @param $howto
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setHowto($howto)
79
+ {
80
+ $this->howto[] = $howto;
81
+
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * @return mixed
87
+ */
88
+ public function getMessage()
89
+ {
90
+ return $this->message;
91
+ }
92
+
93
+ /**
94
+ * @param $message
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setMessage($message)
99
+ {
100
+ $this->message = $message;
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * @return mixed
107
+ */
108
+ public function getStyle()
109
+ {
110
+ return $this->style;
111
+ }
112
+
113
+ /**
114
+ * @param $style
115
+ *
116
+ * @return $this
117
+ */
118
+ public function setStyle($style)
119
+ {
120
+ $this->style = $style;
121
+
122
+ return $this;
123
+ }
124
+
125
+ public function setTable($table)
126
+ {
127
+ $this->table[] = $table;
128
+
129
+ return $this;
130
+ }
131
+
132
+ public function getTable()
133
+ {
134
+ return $this->table;
135
+ }
136
 
137
 
138
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Abandoned.php CHANGED
@@ -1,8 +1,10 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned extends Mage_Core_Model_Abstract
 
4
  {
5
- protected $storeIds;
 
6
 
7
  /**
8
  * prepare collection and needed columns
@@ -17,22 +19,28 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned ex
17
  ->addFieldToFilter('main_table.is_active', '1')
18
  ->setOrder('updated_at');
19
 
20
- if (is_array($this->storeIds) && !empty($this->storeIds)) {
21
- $collection->addFieldToFilter('store_id', array('in' => $this->storeIds));
 
 
22
  }
23
 
24
- $adapter = $collection->getConnection();
25
  $averageExpr = $adapter->getCheckSql(
26
  'COUNT(main_table.entity_id) > 0',
27
  'SUM(main_table.subtotal)/COUNT(main_table.entity_id)',
28
- 0);
29
-
30
- $collection->getSelect()->columns(array(
31
- 'lifetime' => 'SUM(main_table.subtotal)',
32
- 'average' => $averageExpr,
33
- 'total_count' => "COUNT(main_table.entity_id)",
34
- 'day_count' => "ROUND(COUNT(main_table.entity_id) / DATEDIFF(date(MAX(main_table.updated_at)) , date(MIN(main_table.updated_at))), 2)"
35
- ));
 
 
 
 
36
  return $collection;
37
  }
38
 
@@ -40,20 +48,23 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned ex
40
  * @param int $store
41
  * @param int $website
42
  * @param int $group
 
43
  * @return Varien_Object
44
  * @throws Mage_Core_Exception
45
  */
46
- public function getLifeTimeAbandoned($store = 0, $website = 0, $group =0)
47
  {
48
  if ($store) {
49
  $this->storeIds = array($store => $store);
50
- } else if ($website){
51
- $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
52
  $this->storeIds = $storeIds;
53
- } else if ($group){
54
- $storeIds = Mage::app()->getGroup($group)->getStoreIds();
55
  $this->storeIds = $storeIds;
56
  }
57
- return $this->getPreparedCollection()->getFirstItem();
 
 
58
  }
59
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned
4
+ extends Mage_Core_Model_Abstract
5
  {
6
+
7
+ public $storeIds;
8
 
9
  /**
10
  * prepare collection and needed columns
19
  ->addFieldToFilter('main_table.is_active', '1')
20
  ->setOrder('updated_at');
21
 
22
+ if (is_array($this->storeIds) && ! empty($this->storeIds)) {
23
+ $collection->addFieldToFilter(
24
+ 'store_id', array('in' => $this->storeIds)
25
+ );
26
  }
27
 
28
+ $adapter = $collection->getConnection();
29
  $averageExpr = $adapter->getCheckSql(
30
  'COUNT(main_table.entity_id) > 0',
31
  'SUM(main_table.subtotal)/COUNT(main_table.entity_id)',
32
+ 0
33
+ );
34
+
35
+ $collection->getSelect()->columns(
36
+ array(
37
+ 'lifetime' => 'SUM(main_table.subtotal)',
38
+ 'average' => $averageExpr,
39
+ 'total_count' => "COUNT(main_table.entity_id)",
40
+ 'day_count' => "ROUND(COUNT(main_table.entity_id) / DATEDIFF(date(MAX(main_table.updated_at)) , date(MIN(main_table.updated_at))), 2)"
41
+ )
42
+ );
43
+
44
  return $collection;
45
  }
46
 
48
  * @param int $store
49
  * @param int $website
50
  * @param int $group
51
+ *
52
  * @return Varien_Object
53
  * @throws Mage_Core_Exception
54
  */
55
+ public function getLifeTimeAbandoned($store = 0, $website = 0, $group = 0)
56
  {
57
  if ($store) {
58
  $this->storeIds = array($store => $store);
59
+ } else if ($website) {
60
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
61
  $this->storeIds = $storeIds;
62
+ } else if ($group) {
63
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
64
  $this->storeIds = $storeIds;
65
  }
66
+
67
+ return $this->getPreparedCollection()->setPageSize(1)->setCurPage(1)
68
+ ->getFirstItem();
69
  }
70
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Customer.php CHANGED
@@ -1,8 +1,10 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer extends Mage_Core_Model_Abstract
 
4
  {
5
- protected $storeIds;
 
6
 
7
  /**
8
  * prepare collection and needed columns
@@ -13,14 +15,18 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
13
  {
14
  $collection = Mage::getResourceModel('customer/customer_collection');
15
 
16
- if (is_array($this->storeIds) && !empty($this->storeIds)) {
17
- $collection->addAttributeToFilter('store_id', array('in' => $this->storeIds));
 
 
18
  }
19
 
20
- $collection->getSelect()->columns(array(
21
- 'total_count' => "COUNT(*)",
22
- 'day_count' => "ROUND(COUNT(*) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
23
- ));
 
 
24
 
25
  return $collection;
26
  }
@@ -29,20 +35,24 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
29
  * @param int $store
30
  * @param int $website
31
  * @param int $group
 
32
  * @return Varien_Object
33
  * @throws Mage_Core_Exception
34
  */
35
- public function getLifeTimeTimeCustomer($store = 0, $website = 0, $group =0)
 
36
  {
37
  if ($store) {
38
  $this->storeIds = array($store => $store);
39
- } else if ($website){
40
- $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
41
  $this->storeIds = $storeIds;
42
- } else if ($group){
43
- $storeIds = Mage::app()->getGroup($group)->getStoreIds();
44
  $this->storeIds = $storeIds;
45
  }
46
- return $this->getPreparedCollection()->setPageSize(1)->setCurPage(1)->getFirstItem();
 
 
47
  }
48
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer
4
+ extends Mage_Core_Model_Abstract
5
  {
6
+
7
+ public $storeIds;
8
 
9
  /**
10
  * prepare collection and needed columns
15
  {
16
  $collection = Mage::getResourceModel('customer/customer_collection');
17
 
18
+ if (is_array($this->storeIds) && ! empty($this->storeIds)) {
19
+ $collection->addAttributeToFilter(
20
+ 'store_id', array('in' => $this->storeIds)
21
+ );
22
  }
23
 
24
+ $collection->getSelect()->columns(
25
+ array(
26
+ 'total_count' => "COUNT(*)",
27
+ 'day_count' => "ROUND(COUNT(*) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
28
+ )
29
+ );
30
 
31
  return $collection;
32
  }
35
  * @param int $store
36
  * @param int $website
37
  * @param int $group
38
+ *
39
  * @return Varien_Object
40
  * @throws Mage_Core_Exception
41
  */
42
+ public function getLifeTimeTimeCustomer($store = 0, $website = 0, $group = 0
43
+ )
44
  {
45
  if ($store) {
46
  $this->storeIds = array($store => $store);
47
+ } else if ($website) {
48
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
49
  $this->storeIds = $storeIds;
50
+ } else if ($group) {
51
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
52
  $this->storeIds = $storeIds;
53
  }
54
+
55
+ return $this->getPreparedCollection()->setPageSize(1)->setCurPage(1)
56
+ ->getFirstItem();
57
  }
58
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Orders.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders extends Mage_Core_Model_Abstract
 
4
  {
 
5
  /**
6
  * calculate sales and prepare columns
7
  *
8
  * @param int $isFilter
 
9
  * @return Mage_Reports_Model_Resource_Order_Collection
10
  */
11
  protected function calculateSales($isFilter = 0)
@@ -26,43 +29,56 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders exten
26
  $averageExpr = $adapter->getCheckSql(
27
  'SUM(main_table.orders_count) > 0',
28
  'SUM(main_table.total_revenue_amount)/SUM(main_table.orders_count)',
29
- 0);
30
- $collection->getSelect()->columns(array(
31
- 'lifetime' => 'SUM(main_table.total_revenue_amount)',
32
- 'average' => $averageExpr,
33
- 'total_count' => "SUM(main_table.orders_count)",
34
- 'day_count' => "ROUND(SUM(main_table.orders_count) / DATEDIFF(date(MAX(period)) , date(MIN(period))), 2)"
35
- ));
 
 
 
36
 
37
- if (!$isFilter) {
38
- $collection->addFieldToFilter('store_id',
39
- array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
 
 
 
40
  );
41
  }
42
- $collection->getSelect()->where('main_table.order_status NOT IN(?)', $statuses);
 
 
43
  } else {
44
  $collection->setMainTable('sales/order');
45
  $collection->removeAllFieldsFromSelect();
46
 
47
- $expr = Mage::getResourceModel('ddg_automation/contact')->getSalesAmountExpression($collection);
 
48
 
49
  if ($isFilter == 0) {
50
  $expr = '(' . $expr . ') * main_table.base_to_global_rate';
51
  }
52
 
53
  $collection->getSelect()
54
- ->columns(array(
55
- 'lifetime' => "SUM({$expr})",
56
- 'average' => "AVG({$expr})",
57
- 'total_count' => "COUNT({$expr})",
58
- 'day_count' => "ROUND(COUNT({$expr}) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
59
- ))
 
 
60
  ->where('main_table.status NOT IN(?)', $statuses)
61
- ->where('main_table.state NOT IN(?)', array(
 
62
  Mage_Sales_Model_Order::STATE_NEW,
63
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
64
  );
65
  }
 
66
  return $collection;
67
  }
68
 
@@ -70,20 +86,21 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders exten
70
  * @param int $store
71
  * @param int $website
72
  * @param int $group
 
73
  * @return Varien_Object
74
  * @throws Mage_Core_Exception
75
  */
76
- public function getLifetimeSales($store = 0, $website = 0, $group =0)
77
  {
78
- $isFilter = $store || $website || $group;
79
  $collection = $this->calculateSales($isFilter);
80
 
81
  if ($store) {
82
  $collection->addFieldToFilter('store_id', $store);
83
- } else if ($website){
84
  $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
85
  $collection->addFieldToFilter('store_id', array('in' => $storeIds));
86
- } else if ($group){
87
  $storeIds = Mage::app()->getGroup($group)->getStoreIds();
88
  $collection->addFieldToFilter('store_id', array('in' => $storeIds));
89
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders
4
+ extends Mage_Core_Model_Abstract
5
  {
6
+
7
  /**
8
  * calculate sales and prepare columns
9
  *
10
  * @param int $isFilter
11
+ *
12
  * @return Mage_Reports_Model_Resource_Order_Collection
13
  */
14
  protected function calculateSales($isFilter = 0)
29
  $averageExpr = $adapter->getCheckSql(
30
  'SUM(main_table.orders_count) > 0',
31
  'SUM(main_table.total_revenue_amount)/SUM(main_table.orders_count)',
32
+ 0
33
+ );
34
+ $collection->getSelect()->columns(
35
+ array(
36
+ 'lifetime' => 'SUM(main_table.total_revenue_amount)',
37
+ 'average' => $averageExpr,
38
+ 'total_count' => "SUM(main_table.orders_count)",
39
+ 'day_count' => "ROUND(SUM(main_table.orders_count) / DATEDIFF(date(MAX(period)) , date(MIN(period))), 2)"
40
+ )
41
+ );
42
 
43
+ if ( ! $isFilter) {
44
+ $collection->addFieldToFilter(
45
+ 'store_id',
46
+ array('eq' => Mage::app()->getStore(
47
+ Mage_Core_Model_Store::ADMIN_CODE
48
+ )->getId())
49
  );
50
  }
51
+ $collection->getSelect()->where(
52
+ 'main_table.order_status NOT IN(?)', $statuses
53
+ );
54
  } else {
55
  $collection->setMainTable('sales/order');
56
  $collection->removeAllFieldsFromSelect();
57
 
58
+ $expr = Mage::getResourceModel('ddg_automation/contact')
59
+ ->getSalesAmountExpression($collection);
60
 
61
  if ($isFilter == 0) {
62
  $expr = '(' . $expr . ') * main_table.base_to_global_rate';
63
  }
64
 
65
  $collection->getSelect()
66
+ ->columns(
67
+ array(
68
+ 'lifetime' => "SUM({$expr})",
69
+ 'average' => "AVG({$expr})",
70
+ 'total_count' => "COUNT({$expr})",
71
+ 'day_count' => "ROUND(COUNT({$expr}) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
72
+ )
73
+ )
74
  ->where('main_table.status NOT IN(?)', $statuses)
75
+ ->where(
76
+ 'main_table.state NOT IN(?)', array(
77
  Mage_Sales_Model_Order::STATE_NEW,
78
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
79
  );
80
  }
81
+
82
  return $collection;
83
  }
84
 
86
  * @param int $store
87
  * @param int $website
88
  * @param int $group
89
+ *
90
  * @return Varien_Object
91
  * @throws Mage_Core_Exception
92
  */
93
+ public function getLifetimeSales($store = 0, $website = 0, $group = 0)
94
  {
95
+ $isFilter = $store || $website || $group;
96
  $collection = $this->calculateSales($isFilter);
97
 
98
  if ($store) {
99
  $collection->addFieldToFilter('store_id', $store);
100
+ } else if ($website) {
101
  $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
102
  $collection->addFieldToFilter('store_id', array('in' => $storeIds));
103
+ } else if ($group) {
104
  $storeIds = Mage::app()->getGroup($group)->getStoreIds();
105
  $collection->addFieldToFilter('store_id', array('in' => $storeIds));
106
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php CHANGED
@@ -1,160 +1,187 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends Mage_Core_Model_Abstract
 
4
  {
5
- protected $rfm = array();
6
- protected $_store = 0;
7
- protected $_group = 0;
8
- protected $_website = 0;
 
9
 
10
  protected $_resultCount;
11
 
12
- const RECENCY = 'Recency';
13
- const FREQUENCY = 'Frequency';
14
- const MONETARY = 'Monetary';
15
-
16
- /**
17
- * prepare collection and needed columns
18
- *
19
- * @return Mage_Sales_Model_Resource_Order_Collection
20
- * @throws Mage_Core_Exception
21
- */
22
- protected function getPreparedCollection()
23
- {
24
- $statuses = Mage::getSingleton('sales/config')
25
- ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
26
- if (empty($statuses)) {
27
- $statuses = array(0);
28
- }
29
-
30
- $collection = Mage::getResourceModel('sales/order_collection');
31
- $collection
32
- ->addFieldToFilter('status', array('nin' => $statuses))
33
- ->addFieldToFilter('state',
34
- array('nin' => array(
35
- Mage_Sales_Model_Order::STATE_NEW,
36
- Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
37
- )
38
- )
39
- ->addFieldToFilter('customer_id', array('neq' => 'null'))
40
- ->addOrder('created_at');
41
-
42
- if ($this->_store) {
43
- $collection->addFieldToFilter('store_id', $this->_store);
44
- } else if ($this->_website){
45
- $storeIds = Mage::app()->getWebsite($this->_website)->getStoreIds();
46
- $collection->addFieldToFilter('store_id', array('in' => $storeIds));
47
- } else if ($this->_group){
48
- $storeIds = Mage::app()->getGroup($this->_group)->getStoreIds();
49
- $collection->addFieldToFilter('store_id', array('in' => $storeIds));
50
- }
51
-
52
- $expr = Mage::getResourceModel('ddg_automation/contact')->getSalesAmountExpression($collection);
53
- $isFilter = $this->_store || $this->_website || $this->_group;
54
- if ($isFilter == 0) {
55
- $expr = '(' . $expr . ') * main_table.base_to_global_rate';
56
- }
57
-
58
- $collection->getSelect()
59
- ->reset(Zend_Db_Select::COLUMNS)
60
- ->columns(array(
61
- 'customer_total_orders' => "count(*)",
62
- 'customer_average_order_value' => "SUM({$expr})/count(*)",
63
- 'last_order_days_ago' => "DATEDIFF(date(NOW()) , date(MAX(created_at)))"
64
- ))
65
- ->group('customer_id');
66
-
67
- return $collection;
68
- }
69
-
70
- /**
71
- * calculate quartiles
72
- *
73
- * @param $array
74
- * @return array
75
- */
 
 
 
 
 
76
  protected function calculateQuartile($array)
77
  {
78
  $count = $this->_resultCount;
79
- if ($count == 0)
80
  return array(
81
- "Low" => 0,
82
  "Medium" => 0,
83
- "High" => 0
84
  );
 
85
 
86
- $first = intval(round(.25 * ($count + 1)));
87
  $second = intval(round(.50 * ($count + 1)));
88
- $third = intval(round(.75 * ($count + 1)));
89
 
90
- if (!array_key_exists($first, $array))
91
  $first = $this->getClosest($first, $array);
 
92
 
93
- if (!array_key_exists($second, $array))
94
  $second = $this->getClosest($second, $array);
 
95
 
96
- if (!array_key_exists($third, $array))
97
  $third = $this->getClosest($third, $array);
 
98
 
99
  return array(
100
- "Low" => $array[$first],
101
  "Medium" => $array[$second],
102
- "High" => $array[$third]
103
  );
104
  }
105
 
106
- /**
107
- * find closest index key from array
108
- *
109
- * @param $search
110
- * @param $arr
111
- * @return mix
112
- */
113
- protected function getClosest($search, $arr) {
114
- $closest = null;
115
- foreach($arr as $key => $value) {
116
- if($search == $key)
117
- return $search;
118
- if($closest == null || abs($search - $closest) > abs($key - $search)) {
119
- $closest = $key;
120
- }
121
- }
122
- return $closest;
123
- }
124
-
125
- /**
126
- * prepare rfm data
127
- */
 
 
 
 
 
 
 
 
128
  protected function prepareRfm()
129
  {
130
- $collection = $this->getPreparedCollection();
131
- $contactResource = Mage::getResourceModel('ddg_automation/contact');
132
 
133
- $values = $contactResource->prepareFrequency($collection);
134
- $this->_resultCount = count($values);
 
 
135
  $this->rfm[self::FREQUENCY] = $this->calculateQuartile($values);
136
 
137
 
138
- $values = $contactResource->prepareRecency($collection);
 
 
139
  $this->rfm[self::RECENCY] = $this->calculateQuartile($values);
140
 
141
- $values = $contactResource->prepareMonetary($collection);
 
 
142
  $this->rfm[self::MONETARY] = $this->calculateQuartile($values);
143
  }
144
 
145
- /**
146
- * @param int $store
147
- * @param int $website
148
- * @param int $group
149
- * @return array
150
- */
151
- public function getPreparedRfm($store = 0, $website = 0, $group =0)
152
- {
153
- $this->_store = $store;
154
- $this->_group = $group;
155
- $this->_website = $website;
156
-
157
- $this->prepareRfm();
158
- return $this->rfm;
159
- }
 
 
160
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm
4
+ extends Mage_Core_Model_Abstract
5
  {
6
+
7
+ public $rfm = array();
8
+ protected $_store = 0;
9
+ protected $_group = 0;
10
+ protected $_website = 0;
11
 
12
  protected $_resultCount;
13
 
14
+ const RECENCY = 'Recency';
15
+ const FREQUENCY = 'Frequency';
16
+ const MONETARY = 'Monetary';
17
+
18
+ /**
19
+ * prepare collection and needed columns
20
+ *
21
+ * @return Mage_Sales_Model_Resource_Order_Collection
22
+ * @throws Mage_Core_Exception
23
+ */
24
+ protected function getPreparedCollection()
25
+ {
26
+ $statuses = Mage::getSingleton('sales/config')
27
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
28
+ if (empty($statuses)) {
29
+ $statuses = array(0);
30
+ }
31
+
32
+ $collection = Mage::getResourceModel('sales/order_collection');
33
+ $collection
34
+ ->addFieldToFilter('status', array('nin' => $statuses))
35
+ ->addFieldToFilter(
36
+ 'state',
37
+ array('nin' => array(
38
+ Mage_Sales_Model_Order::STATE_NEW,
39
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
40
+ )
41
+ )
42
+ ->addFieldToFilter('customer_id', array('neq' => 'null'))
43
+ ->addOrder('created_at');
44
+
45
+ if ($this->_store) {
46
+ $collection->addFieldToFilter('store_id', $this->_store);
47
+ } else if ($this->_website) {
48
+ $storeIds = Mage::app()->getWebsite($this->_website)->getStoreIds();
49
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
50
+ } else if ($this->_group) {
51
+ $storeIds = Mage::app()->getGroup($this->_group)->getStoreIds();
52
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
53
+ }
54
+
55
+ $expr = Mage::getResourceModel('ddg_automation/contact')
56
+ ->getSalesAmountExpression($collection);
57
+ $isFilter = $this->_store || $this->_website || $this->_group;
58
+ if ($isFilter == 0) {
59
+ $expr = '(' . $expr . ') * main_table.base_to_global_rate';
60
+ }
61
+
62
+ $collection->getSelect()
63
+ ->reset(Zend_Db_Select::COLUMNS)
64
+ ->columns(
65
+ array(
66
+ 'customer_total_orders' => "count(*)",
67
+ 'customer_average_order_value' => "SUM({$expr})/count(*)",
68
+ 'last_order_days_ago' => "DATEDIFF(date(NOW()) , date(MAX(created_at)))"
69
+ )
70
+ )
71
+ ->group('customer_id');
72
+
73
+ return $collection;
74
+ }
75
+
76
+ /**
77
+ * calculate quartiles
78
+ *
79
+ * @param $array
80
+ *
81
+ * @return array
82
+ */
83
  protected function calculateQuartile($array)
84
  {
85
  $count = $this->_resultCount;
86
+ if ($count == 0) {
87
  return array(
88
+ "Low" => 0,
89
  "Medium" => 0,
90
+ "High" => 0
91
  );
92
+ }
93
 
94
+ $first = intval(round(.25 * ($count + 1)));
95
  $second = intval(round(.50 * ($count + 1)));
96
+ $third = intval(round(.75 * ($count + 1)));
97
 
98
+ if ( ! array_key_exists($first, $array)) {
99
  $first = $this->getClosest($first, $array);
100
+ }
101
 
102
+ if ( ! array_key_exists($second, $array)) {
103
  $second = $this->getClosest($second, $array);
104
+ }
105
 
106
+ if ( ! array_key_exists($third, $array)) {
107
  $third = $this->getClosest($third, $array);
108
+ }
109
 
110
  return array(
111
+ "Low" => $array[$first],
112
  "Medium" => $array[$second],
113
+ "High" => $array[$third]
114
  );
115
  }
116
 
117
+ /**
118
+ * find closest index key from array
119
+ *
120
+ * @param $search
121
+ * @param $arr
122
+ *
123
+ * @return mix
124
+ */
125
+ protected function getClosest($search, $arr)
126
+ {
127
+ $closest = null;
128
+ foreach ($arr as $key => $value) {
129
+ if ($search == $key) {
130
+ return $search;
131
+ }
132
+ if ($closest == null
133
+ || abs($search - $closest) > abs(
134
+ $key - $search
135
+ )
136
+ ) {
137
+ $closest = $key;
138
+ }
139
+ }
140
+
141
+ return $closest;
142
+ }
143
+
144
+ /**
145
+ * prepare rfm data
146
+ */
147
  protected function prepareRfm()
148
  {
149
+ $collection = $this->getPreparedCollection();
150
+ $contactResource = Mage::getResourceModel('ddg_automation/contact');
151
 
152
+ $values = $contactResource->prepareFrequency(
153
+ $collection
154
+ );
155
+ $this->_resultCount = count($values);
156
  $this->rfm[self::FREQUENCY] = $this->calculateQuartile($values);
157
 
158
 
159
+ $values = $contactResource->prepareRecency(
160
+ $collection
161
+ );
162
  $this->rfm[self::RECENCY] = $this->calculateQuartile($values);
163
 
164
+ $values = $contactResource->prepareMonetary(
165
+ $collection
166
+ );
167
  $this->rfm[self::MONETARY] = $this->calculateQuartile($values);
168
  }
169
 
170
+ /**
171
+ * @param int $store
172
+ * @param int $website
173
+ * @param int $group
174
+ *
175
+ * @return array
176
+ */
177
+ public function getPreparedRfm($store = 0, $website = 0, $group = 0)
178
+ {
179
+ $this->_store = $store;
180
+ $this->_group = $group;
181
+ $this->_website = $website;
182
+
183
+ $this->prepareRfm();
184
+
185
+ return $this->rfm;
186
+ }
187
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php CHANGED
@@ -1,90 +1,109 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Subscriber extends Mage_Core_Model_Abstract
 
4
  {
5
- protected $storeIds;
6
-
7
- protected function calculateOperationalDaysFromOrder()
8
- {
9
- $collection = Mage::getResourceModel('sales/order_collection');
10
- $collection->addFieldToSelect('created_at');
11
-
12
- if (is_array($this->storeIds) && !empty($this->storeIds)) {
13
- $collection->addFieldToFilter('store_id', array('in' => $this->storeIds));
14
- }
15
-
16
- $collection->getSelect()->columns(array(
17
- 'days' => "DATEDIFF(date(NOW()) , date(MIN(created_at)))"
18
- ));
19
- return $collection->setPageSize(1)->setCurPage(1)->getFirstItem()->getDays();
20
- }
21
-
22
- protected function _getCollection(){
23
- $collection = Mage::getResourceModel('newsletter/subscriber_collection');
24
- $collection->addFieldToFilter('subscriber_status', array('neq' => '3'));
25
-
26
- if (is_array($this->storeIds) && !empty($this->storeIds)) {
27
- $collection->addFieldToFilter('store_id', array('in' => $this->storeIds));
28
- }
29
- return $collection;
30
- }
31
-
32
- /**
33
- * prepare collection
34
- *
35
- * @return Varien_Object
36
- */
37
- protected function getPreparedCollection()
38
- {
39
- //all active subscribers
40
- $collection = $this->_getCollection();
41
- $totalSubscribers = $collection->getSize();
42
-
43
- //all active subscribers who are also customers
44
- $customerSubscribers = $collection->addFieldToFilter('customer_id', array('neq' => '0'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  $customerSubscriberCount = $customerSubscribers->getSize();
46
 
47
- $days = $this->calculateOperationalDaysFromOrder();
48
- if($days)
49
- $subscribersPerDay = number_format($totalSubscribers/$days, 2);
50
- else
51
- $subscribersPerDay = $totalSubscribers;
52
-
53
- $resultObject = new Varien_Object;
54
- $resultObject
55
- ->setTotalSubscriber($totalSubscribers)
56
- ->setTotalSubscriberCustomer($customerSubscriberCount)
57
- ->setSubscribersPerDay($subscribersPerDay);
58
-
59
- return $resultObject;
60
- }
61
-
62
- /**
63
- * @param int $store
64
- * @param int $website
65
- * @param int $group
66
- * @return Varien_Object
67
- * @throws Mage_Core_Exception
68
- */
69
- public function getLifetimeSubscribers($store = 0, $website = 0, $group =0)
70
- {
71
- if ($store) {
72
- $this->storeIds = array($store => $store);
73
- } else if ($website){
74
- $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
75
- $this->storeIds = $storeIds;
76
- } else if ($group){
77
- $storeIds = Mage::app()->getGroup($group)->getStoreIds();
78
- $this->storeIds = $storeIds;
79
- }
80
- return $this->getPreparedCollection();
81
- }
82
-
83
- /**
84
- * @return string
85
- */
86
- public function getTitle()
87
- {
88
- return "Subscribers Analytical Data";
89
- }
 
 
 
90
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Subscriber
4
+ extends Mage_Core_Model_Abstract
5
  {
6
+
7
+ public $storeIds;
8
+
9
+ protected function calculateOperationalDaysFromOrder()
10
+ {
11
+ $collection = Mage::getResourceModel('sales/order_collection');
12
+ $collection->addFieldToSelect('created_at');
13
+
14
+ if (is_array($this->storeIds) && ! empty($this->storeIds)) {
15
+ $collection->addFieldToFilter(
16
+ 'store_id', array('in' => $this->storeIds)
17
+ );
18
+ }
19
+
20
+ $collection->getSelect()->columns(
21
+ array(
22
+ 'days' => "DATEDIFF(date(NOW()) , date(MIN(created_at)))"
23
+ )
24
+ );
25
+
26
+ return $collection->setPageSize(1)->setCurPage(1)->getFirstItem()
27
+ ->getDays();
28
+ }
29
+
30
+ protected function _getCollection()
31
+ {
32
+ $collection = Mage::getResourceModel(
33
+ 'newsletter/subscriber_collection'
34
+ );
35
+ $collection->addFieldToFilter('subscriber_status', array('neq' => '3'));
36
+
37
+ if (is_array($this->storeIds) && ! empty($this->storeIds)) {
38
+ $collection->addFieldToFilter(
39
+ 'store_id', array('in' => $this->storeIds)
40
+ );
41
+ }
42
+
43
+ return $collection;
44
+ }
45
+
46
+ /**
47
+ * prepare collection
48
+ *
49
+ * @return Varien_Object
50
+ */
51
+ protected function getPreparedCollection()
52
+ {
53
+ //all active subscribers
54
+ $collection = $this->_getCollection();
55
+ $totalSubscribers = $collection->getSize();
56
+
57
+ //all active subscribers who are also customers
58
+ $customerSubscribers = $collection->addFieldToFilter(
59
+ 'customer_id', array('neq' => '0')
60
+ );
61
  $customerSubscriberCount = $customerSubscribers->getSize();
62
 
63
+ $days = $this->calculateOperationalDaysFromOrder();
64
+ if ($days) {
65
+ $subscribersPerDay = number_format($totalSubscribers / $days, 2);
66
+ } else {
67
+ $subscribersPerDay = $totalSubscribers;
68
+ }
69
+
70
+ $resultObject = new Varien_Object;
71
+ $resultObject
72
+ ->setTotalSubscriber($totalSubscribers)
73
+ ->setTotalSubscriberCustomer($customerSubscriberCount)
74
+ ->setSubscribersPerDay($subscribersPerDay);
75
+
76
+ return $resultObject;
77
+ }
78
+
79
+ /**
80
+ * @param int $store
81
+ * @param int $website
82
+ * @param int $group
83
+ *
84
+ * @return Varien_Object
85
+ * @throws Mage_Core_Exception
86
+ */
87
+ public function getLifetimeSubscribers($store = 0, $website = 0, $group = 0)
88
+ {
89
+ if ($store) {
90
+ $this->storeIds = array($store => $store);
91
+ } else if ($website) {
92
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
93
+ $this->storeIds = $storeIds;
94
+ } else if ($group) {
95
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
96
+ $this->storeIds = $storeIds;
97
+ }
98
+
99
+ return $this->getPreparedCollection();
100
+ }
101
+
102
+ /**
103
+ * @return string
104
+ */
105
+ public function getTitle()
106
+ {
107
+ return "Subscribers Analytical Data";
108
+ }
109
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php CHANGED
@@ -6,118 +6,132 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Observer
6
  /**
7
  * API Sync and Data Mapping.
8
  * Reset contacts for reimport.
 
9
  * @return $this
10
  */
11
  public function actionConfigResetContacts()
12
  {
13
  $contactModel = Mage::getModel('ddg_automation/contact');
14
- $numImported = $contactModel->getNumberOfImportedContacs();
15
- $updated = $contactModel->getResource()->resetAllContacts();
16
- Mage::helper('ddg')->log('-- Imported contacts: ' . $numImported . ' reseted : ' . $updated . ' --');
 
 
 
17
 
18
  /**
19
- * check for addressbook mapping and disable if no address selected.
20
  */
21
- $this->_checkAddressBookMapping(Mage::app()->getRequest()->getParam('website'));
 
 
22
 
23
  return $this;
24
  }
25
 
26
  /**
27
- * Check if the transactional data feature is enabled
28
- * To use the wishlist and order sync this needs to be enabled.
 
29
  */
30
- public function checkFeatureActive()
31
  {
32
- //scope to retrieve the website id
33
- $scopeId = 0;
34
- if ($website = Mage::app()->getRequest()->getParam('website')) {
35
- //use webiste
36
- $scope = 'websites';
37
- $scopeId = Mage::app()->getWebsite($website)->getId();
38
- } else {
39
- //set to default
40
- $scope = "default";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
- //webiste by id
43
- $website = Mage::app()->getWebsite($scopeId);
44
-
45
- //configuration saved for the wishlist and order sync
46
- $wishlistEnabled = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, $scope, $scopeId);
47
- $orderEnabled = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED);
48
-
49
- //only for modification for order and wishlist
50
- if ($orderEnabled || $wishlistEnabled) {
51
- //client by website id
52
- $client = Mage::helper('ddg')->getWebsiteApiClient($scopeId);
53
-
54
- //call request for account info
55
- $response = $client->getAccountInfo();
56
-
57
- //properties must be checked
58
- if (isset($response->properties)) {
59
- $accountInfo = $response->properties;
60
- $result = $this->_checkForOption(Dotdigitalgroup_Email_Model_Apiconnector_Client::API_ERROR_TRANS_ALLOWANCE, $accountInfo);
61
-
62
- //account is disabled to use transactional data
63
- if (! $result) {
64
- $message = 'Transactional Data For This Account Is Disabled. Call Support To Enable.';
65
- //send admin message
66
- Mage::getSingleton('adminhtml/session')->addError($message);
67
-
68
- //send raygun message for trans data
69
- Mage::helper('ddg')->rayLog($message);
70
- //disable the config for wishlist and order sync
71
- $config = Mage::getConfig();
72
- $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, 0, $scope, $scopeId);
73
- $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, 0, $scope, $scopeId);
74
- $config->cleanCache();
75
- }
76
- }
77
  }
78
 
79
- return $this;
80
-
81
  }
82
 
83
  /**
84
  * API Credentials.
85
  * Installation and validation confirmation.
 
86
  * @return $this
87
  */
88
  public function actionConfigSaveApi()
89
  {
90
  $groups = Mage::app()->getRequest()->getPost('groups');
91
- if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit']))
 
 
92
  return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
- $apiUsername = isset($groups['api']['fields']['username']['value'])? $groups['api']['fields']['username']['value'] : false;
95
- $apiPassword = isset($groups['api']['fields']['password']['value'])? $groups['api']['fields']['password']['value'] : false;
96
  //skip if the inherit option is selected
97
  if ($apiUsername && $apiPassword) {
98
  Mage::helper('ddg')->log('----VALIDATING ACCOUNT---');
99
  $testModel = Mage::getModel('ddg_automation/apiconnector_test');
 
100
  $isValid = $testModel->validate($apiUsername, $apiPassword);
101
- $config = Mage::getConfig();
 
 
102
  if (! $isValid) {
103
  /**
104
  * Disable invalid Api credentials
105
  */
106
- $scopeId = 0;
107
- if ($website = Mage::app()->getRequest()->getParam('website')) {
108
- $scope = 'websites';
109
- $scopeId = Mage::app()->getWebsite($website)->getId();
110
- } else {
111
- $scope = "default";
112
- }
113
- $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, 0, $scope, $scopeId);
114
  }
115
 
116
  //check if returned value is an object
117
- if(is_object($isValid)){
118
  //save endpoint for account
119
- foreach($isValid->properties as $property){
120
- if($property->name == 'ApiEndpoint' && strlen($property->value)){
 
 
 
 
121
  $config->saveConfig(
122
  Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
123
  $property->value
@@ -127,118 +141,75 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Observer
127
  }
128
  }
129
  $config->cleanCache();
130
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ddg')->__('API Credentials Valid.'));
131
  }
 
132
  return $this;
133
  }
134
 
135
- protected function _checkAddressBookMapping( $website ) {
136
-
137
- $helper = Mage::helper('ddg');
138
- $customerAddressBook = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID, $website);
139
- $subscriberAddressBook = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID, $website);
140
-
141
- if (! $customerAddressBook && $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, $website)){
142
-
143
- $helper->disableConfigForWebsite(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED);
144
- Mage::getSingleton('adminhtml/session')->addNotice('The Contact Sync Disabled - No Addressbook Selected !');
145
- }
146
- if (! $subscriberAddressBook && $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, $website)) {
147
- $helper->disableConfigForWebsite( Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED );
148
- Mage::getSingleton('adminhtml/session')->addNotice('The Subscriber Sync Disabled - No Addressbook Selected !');
149
- }
150
-
151
  }
152
 
153
  /**
154
- * Check for name option in array.
155
  *
156
- * @param $name
157
- * @param $data
158
  *
159
- * @return bool
160
  */
161
- protected function _checkForOption($name, $data) {
162
- //loop for all options
163
- foreach ( $data as $one ) {
164
-
165
- if ($one->name == $name) {
166
- return true;
167
- }
 
 
 
168
  }
169
 
170
- return false;
171
  }
172
 
173
  /**
174
- * Update Feed for latest releases.
175
  *
 
 
 
 
 
176
  */
177
- public function updateFeed()
178
- {
179
- Mage::getModel('ddg_automation/feed')->checkForUpgrade();
180
- }
 
 
 
 
181
 
 
 
 
 
 
 
182
 
183
- /**
184
- * Add modified segment for contact.
185
- * @param $observer
186
- *
187
- * @return $this
188
- */
189
- public function connectorCustomerSegmentChanged($observer)
190
- {
191
- $segmentsIds = $observer->getEvent()->getSegmentIds();
192
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
193
- $websiteId = Mage::app()->getStore()->getWebsiteId();
194
-
195
- if (!empty($segmentsIds) && $customerId) {
196
- $this->addContactsFromWebsiteSegments($customerId, $segmentsIds, $websiteId);
197
- }
198
-
199
- return $this;
200
- }
201
-
202
-
203
- /**
204
- * Add segment ids.
205
- * @param $customerId
206
- * @param $segmentIds
207
- * @param $websiteId
208
- *
209
- * @return $this
210
- */
211
- protected function addContactsFromWebsiteSegments($customerId, $segmentIds, $websiteId){
212
-
213
- if (empty($segmentIds) || ! $customerId)
214
- return $this;
215
- $segmentIds = implode(',', $segmentIds);
216
-
217
- $contact = Mage::getModel('ddg_automation/contact')->getCollection()
218
- ->addFieldToFilter('customer_id', $customerId)
219
- ->addFieldToFilter('website_id', $websiteId)
220
- ->setPageSize(1)
221
- ->getFirstItem();
222
- try {
223
-
224
- $contact->setSegmentIds($segmentIds)
225
- ->setEmailImported()
226
- ->save();
227
-
228
- }catch (Exception $e){
229
- Mage::logException($e);
230
- }
231
-
232
- return $this;
233
- }
234
-
235
- protected function getCustomerSegmentIdsForWebsite($customerId, $websiteId){
236
- $segmentIds = Mage::getModel('ddg_automation/contact')->getCollection()
237
- ->addFieldToFilter('website_id', $websiteId)
238
- ->addFieldToFilter('customer_id', $customerId)
239
- ->getFirstItem()
240
- ->getSegmentIds();
241
-
242
- return $segmentIds;
243
- }
244
  }
6
  /**
7
  * API Sync and Data Mapping.
8
  * Reset contacts for reimport.
9
+ *
10
  * @return $this
11
  */
12
  public function actionConfigResetContacts()
13
  {
14
  $contactModel = Mage::getModel('ddg_automation/contact');
15
+ $numImported = $contactModel->getNumberOfImportedContacs();
16
+ $updated = $contactModel->getResource()->resetAllContacts();
17
+ Mage::helper('ddg')->log(
18
+ '-- Imported contacts: ' . $numImported . ' reseted : ' . $updated
19
+ . ' --'
20
+ );
21
 
22
  /**
23
+ * Check for addressbook mapping and disable if no address selected.
24
  */
25
+ $this->checkAddressBookMapping(
26
+ Mage::app()->getRequest()->getParam('website')
27
+ );
28
 
29
  return $this;
30
  }
31
 
32
  /**
33
+ * Check for mapping configuration, and disable subscriber/contact sync if not mapped.
34
+ *
35
+ * @param $website
36
  */
37
+ protected function checkAddressBookMapping($website)
38
  {
39
+
40
+ $helper = Mage::helper('ddg');
41
+ $customerAddressBook = $helper->getWebsiteConfig(
42
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID,
43
+ $website
44
+ );
45
+ $subscriberAddressBook = $helper->getWebsiteConfig(
46
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID,
47
+ $website
48
+ );
49
+
50
+ if (! $customerAddressBook
51
+ && $helper->getWebsiteConfig(
52
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED,
53
+ $website
54
+ )
55
+ ) {
56
+
57
+ $helper->disableConfigForWebsite(
58
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED
59
+ );
60
+ Mage::getSingleton('adminhtml/session')->addNotice(
61
+ 'The Contact Sync Disabled - No Addressbook Selected !'
62
+ );
63
  }
64
+ if (! $subscriberAddressBook
65
+ && $helper->getWebsiteConfig(
66
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED,
67
+ $website
68
+ )
69
+ ) {
70
+ $helper->disableConfigForWebsite(
71
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED
72
+ );
73
+ Mage::getSingleton('adminhtml/session')->addNotice(
74
+ 'The Subscriber Sync Disabled - No Addressbook Selected !'
75
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
 
 
 
78
  }
79
 
80
  /**
81
  * API Credentials.
82
  * Installation and validation confirmation.
83
+ *
84
  * @return $this
85
  */
86
  public function actionConfigSaveApi()
87
  {
88
  $groups = Mage::app()->getRequest()->getPost('groups');
89
+ if (isset($groups['api']['fields']['username']['inherit'])
90
+ || isset($groups['api']['fields']['password']['inherit'])
91
+ ) {
92
  return $this;
93
+ }
94
+
95
+ $apiUsername = isset($groups['api']['fields']['username']['value'])
96
+ ? $groups['api']['fields']['username']['value'] : false;
97
+ $scopeId = 0;
98
+ if ($website = Mage::app()->getRequest()->getParam('website')) {
99
+ $scope = 'websites';
100
+ $scopeId = Mage::app()->getWebsite($website)->getId();
101
+ } else {
102
+ $scope = "default";
103
+ }
104
+
105
+ $apiPassword = Mage::helper('ddg')->getApiPassword($website);
106
 
 
 
107
  //skip if the inherit option is selected
108
  if ($apiUsername && $apiPassword) {
109
  Mage::helper('ddg')->log('----VALIDATING ACCOUNT---');
110
  $testModel = Mage::getModel('ddg_automation/apiconnector_test');
111
+
112
  $isValid = $testModel->validate($apiUsername, $apiPassword);
113
+ $config = Mage::getConfig();
114
+
115
+
116
  if (! $isValid) {
117
  /**
118
  * Disable invalid Api credentials
119
  */
120
+ $config->saveConfig(
121
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED,
122
+ 0, $scope, $scopeId
123
+ );
 
 
 
 
124
  }
125
 
126
  //check if returned value is an object
127
+ if (is_object($isValid)) {
128
  //save endpoint for account
129
+ foreach ($isValid->properties as $property) {
130
+ if ($property->name == 'ApiEndpoint'
131
+ && strlen(
132
+ $property->value
133
+ )
134
+ ) {
135
  $config->saveConfig(
136
  Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
137
  $property->value
141
  }
142
  }
143
  $config->cleanCache();
 
144
  }
145
+
146
  return $this;
147
  }
148
 
149
+ /**
150
+ * Update Feed for latest releases.
151
+ *
152
+ */
153
+ public function updateFeed()
154
+ {
155
+ Mage::getModel('ddg_automation/feed')->checkForUpgrade();
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
  /**
159
+ * Add modified segment for contact.
160
  *
161
+ * @param $observer
 
162
  *
163
+ * @return $this
164
  */
165
+ public function connectorCustomerSegmentChanged($observer)
166
+ {
167
+ $segmentsIds = $observer->getEvent()->getSegmentIds();
168
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
169
+ $websiteId = Mage::app()->getStore()->getWebsiteId();
170
+
171
+ if (! empty($segmentsIds) && $customerId) {
172
+ $this->addContactsFromWebsiteSegments(
173
+ $customerId, $segmentsIds, $websiteId
174
+ );
175
  }
176
 
177
+ return $this;
178
  }
179
 
180
  /**
181
+ * Add segment ids.
182
  *
183
+ * @param $customerId
184
+ * @param $segmentIds
185
+ * @param $websiteId
186
+ *
187
+ * @return $this
188
  */
189
+ protected function addContactsFromWebsiteSegments($customerId, $segmentIds,
190
+ $websiteId
191
+ ) {
192
+
193
+ if (empty($segmentIds) || ! $customerId) {
194
+ return $this;
195
+ }
196
+ $segmentIds = implode(',', $segmentIds);
197
 
198
+ $contact = Mage::getModel('ddg_automation/contact')->getCollection()
199
+ ->addFieldToFilter('customer_id', $customerId)
200
+ ->addFieldToFilter('website_id', $websiteId)
201
+ ->setPageSize(1)
202
+ ->getFirstItem();
203
+ try {
204
 
205
+ $contact->setSegmentIds($segmentIds)
206
+ ->setEmailImported()
207
+ ->save();
208
+
209
+ } catch (Exception $e) {
210
+ Mage::logException($e);
211
+ }
212
+
213
+ return $this;
214
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php CHANGED
@@ -1,45 +1,51 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbooks
4
  {
5
- /**
6
- * Returns the address books options.
7
- *
8
- * @return array
9
- */
10
- public function toOptionArray()
11
- {
 
12
  $fields = array();
13
- // Add a "Do Not Map" Option
14
- $fields[] = array('value' => 0, 'label' => Mage::helper('ddg')->__('-- Please Select --'));
15
- $website = Mage::app()->getRequest()->getParam('website');
16
-
17
- $enabled = Mage::helper('ddg')->isEnabled($website);
18
-
19
- //get address books options
20
- if ($enabled) {
21
- $client = Mage::getModel( 'ddg_automation/apiconnector_client' );
22
- $client->setApiUsername( Mage::helper( 'ddg' )->getApiUsername( $website ) )
23
- ->setApiPassword( Mage::helper( 'ddg' )->getApiPassword( $website ) );
24
-
25
- $savedAddressBooks = Mage::registry( 'addressbooks' );
26
- //get saved address books from registry
27
- if ( $savedAddressBooks ) {
28
- $addressBooks = $savedAddressBooks;
29
- } else {
30
- // api all address books
31
- $addressBooks = $client->getAddressBooks();
32
- Mage::register( 'addressbooks', $addressBooks );
33
- }
34
-
35
- //set up fields with book id and label
36
- foreach ( $addressBooks as $book ) {
37
- //check for address book id before displaying, IMPORTANT :Test address book cannot be used through api
38
- if ( isset( $book->id ) && $book->name != 'Test') {
39
- $fields[] = array( 'value' => $book->id, 'label' => $book->name );
40
- }
41
- }
42
- }
 
 
 
 
 
43
 
44
  return $fields;
45
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbooks
4
  {
5
+
6
+ /**
7
+ * Returns the address books options.
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
  $fields = array();
14
+ // Add a "Do Not Map" Option
15
+ $fields[] = array('value' => 0, 'label' => Mage::helper('ddg')->__(
16
+ '-- Please Select --'
17
+ ));
18
+ $website = Mage::app()->getRequest()->getParam('website');
19
+
20
+ $enabled = Mage::helper('ddg')->isEnabled($website);
21
+
22
+ //get address books options
23
+ if ($enabled) {
24
+ $client = Mage::getModel('ddg_automation/apiconnector_client');
25
+ $client->setApiUsername(
26
+ Mage::helper('ddg')->getApiUsername($website)
27
+ )
28
+ ->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
29
+
30
+ $savedAddressBooks = Mage::registry('addressbooks');
31
+ //get saved address books from registry
32
+ if ($savedAddressBooks) {
33
+ $addressBooks = $savedAddressBooks;
34
+ } else {
35
+ // api all address books
36
+ $addressBooks = $client->getAddressBooks();
37
+ Mage::register('addressbooks', $addressBooks);
38
+ }
39
+
40
+ //set up fields with book id and label
41
+ foreach ($addressBooks as $book) {
42
+ //check for address book id before displaying, IMPORTANT :Test address book cannot be used through api
43
+ if (isset($book->id) && $book->name != 'Test') {
44
+ $fields[] = array('value' => $book->id,
45
+ 'label' => $book->name);
46
+ }
47
+ }
48
+ }
49
 
50
  return $fields;
51
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbookspref.php CHANGED
@@ -2,72 +2,83 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbookspref
4
  {
5
- protected function getWebsite()
6
- {
7
- $website = Mage::app()->getWebsite();
8
- $websiteParam = Mage::app()->getRequest()->getParam('website');
9
- if($websiteParam)
10
- $website = Mage::app()->getWebsite($websiteParam);
11
- return $website;
12
- }
13
 
14
- /**
15
- * get address books
16
- *
17
- * @return null
18
- */
19
- protected function getAddressBooks()
20
- {
21
- $website = $this->getWebsite();
22
- $client = Mage::getModel( 'ddg_automation/apiconnector_client' );
23
- $client->setApiUsername( Mage::helper( 'ddg' )->getApiUsername( $website ) )
24
- ->setApiPassword( Mage::helper( 'ddg' )->getApiPassword( $website ) );
25
 
26
- $savedAddressBooks = Mage::registry( 'addressbooks' );
27
- //get saved address books from registry
28
- if ( $savedAddressBooks ) {
29
- $addressBooks = $savedAddressBooks;
30
- } else {
31
- // api all address books
32
- $addressBooks = $client->getAddressBooks();
33
- Mage::register( 'addressbooks', $addressBooks );
34
- }
35
- return $addressBooks;
36
- }
37
 
38
- /**
39
- * addressbook options
40
- *
41
- * @return array
42
- * @throws Mage_Core_Exception
43
- */
44
- public function toOptionArray()
45
- {
46
- $fields = array();
47
- $website = $this->getWebsite();
 
48
 
49
- $enabled = Mage::helper('ddg')->isEnabled($website);
 
 
 
 
 
 
 
 
50
 
51
- //get address books options
52
- if ($enabled) {
53
- $addressBooks = $this->getAddressBooks();
54
- //set the error message to the select option
55
- if ( isset( $addressBooks->message ) ) {
56
- $fields[] = array( 'value' => 0, 'label' => Mage::helper( 'ddg' )->__( $addressBooks->message) );
57
- }
58
 
59
- $subscriberAddressBook = Mage::helper('ddg')->getSubscriberAddressBook(Mage::app()->getWebsite());
 
 
 
 
 
 
 
 
 
60
 
61
- //set up fields with book id and label
62
- if ($addressBooks) {
63
- foreach ( $addressBooks as $book ) {
64
- if ( isset( $book->id ) && $book->visibility == 'Public' && $book->id != $subscriberAddressBook ) {
65
- $fields[] = array( 'value' => $book->id, 'label' => $book->name );
66
- }
67
- }
68
- }
69
- }
70
 
71
- return $fields;
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbookspref
4
  {
 
 
 
 
 
 
 
 
5
 
6
+ protected function getWebsite()
7
+ {
8
+ $website = Mage::app()->getWebsite();
9
+ $websiteParam = Mage::app()->getRequest()->getParam('website');
10
+ if ($websiteParam) {
11
+ $website = Mage::app()->getWebsite($websiteParam);
12
+ }
 
 
 
 
13
 
14
+ return $website;
15
+ }
 
 
 
 
 
 
 
 
 
16
 
17
+ /**
18
+ * get address books
19
+ *
20
+ * @return null
21
+ */
22
+ protected function getAddressBooks()
23
+ {
24
+ $website = $this->getWebsite();
25
+ $client = Mage::getModel('ddg_automation/apiconnector_client');
26
+ $client->setApiUsername(Mage::helper('ddg')->getApiUsername($website))
27
+ ->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
28
 
29
+ $savedAddressBooks = Mage::registry('addressbooks');
30
+ //get saved address books from registry
31
+ if ($savedAddressBooks) {
32
+ $addressBooks = $savedAddressBooks;
33
+ } else {
34
+ // api all address books
35
+ $addressBooks = $client->getAddressBooks();
36
+ Mage::register('addressbooks', $addressBooks);
37
+ }
38
 
39
+ return $addressBooks;
40
+ }
 
 
 
 
 
41
 
42
+ /**
43
+ * addressbook options
44
+ *
45
+ * @return array
46
+ * @throws Mage_Core_Exception
47
+ */
48
+ public function toOptionArray()
49
+ {
50
+ $fields = array();
51
+ $website = $this->getWebsite();
52
 
53
+ $enabled = Mage::helper('ddg')->isEnabled($website);
 
 
 
 
 
 
 
 
54
 
55
+ //get address books options
56
+ if ($enabled) {
57
+ $addressBooks = $this->getAddressBooks();
58
+ //set the error message to the select option
59
+ if (isset($addressBooks->message)) {
60
+ $fields[] = array('value' => 0,
61
+ 'label' => Mage::helper('ddg')->__(
62
+ $addressBooks->message
63
+ ));
64
+ }
65
+
66
+ $subscriberAddressBook = Mage::helper('ddg')
67
+ ->getSubscriberAddressBook(Mage::app()->getWebsite());
68
+
69
+ //set up fields with book id and label
70
+ if ($addressBooks) {
71
+ foreach ($addressBooks as $book) {
72
+ if (isset($book->id) && $book->visibility == 'Public'
73
+ && $book->id != $subscriberAddressBook
74
+ ) {
75
+ $fields[] = array('value' => $book->id,
76
+ 'label' => $book->name);
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ return $fields;
83
+ }
84
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Abandonedlimit.php CHANGED
@@ -3,41 +3,46 @@
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Abandonedlimit
4
  {
5
 
6
- /**
7
- * available times
8
- * @var array
9
- */
10
- protected $_times = array(0,1,2,3,4,5,6,12,24,36,48,60,72,84,96,108,120, 240);
 
 
 
11
 
12
 
13
- /**
14
- * send to campain options hours
15
- * @return array
16
- */
17
- public function toOptionArray()
18
- {
19
- $result = $row = array();
20
- $i = 0;
21
- foreach ($this->_times as $one) {
 
22
 
23
 
24
- if ($i == 0)
25
- $row = array('value' => $one, 'label' => Mage::helper('ddg')->__('No Limit'));
26
- elseif ($i == 1) {
27
- $row = array(
28
- 'value' => $one,
29
- 'label' => Mage::helper( 'ddg' )->__( $one . ' Hour' )
30
- );
31
- } else {
32
- $row = array(
33
- 'value' => $one,
34
- 'label' => Mage::helper( 'ddg' )->__( $one . ' Hours' )
35
- );
36
- }
37
- $result[] = $row;
38
- $i++;
39
- }
 
40
 
41
- return $result;
42
- }
43
  }
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Abandonedlimit
4
  {
5
 
6
+ /**
7
+ * available times
8
+ *
9
+ * @var array
10
+ */
11
+ protected $_times
12
+ = array(0, 1, 2, 3, 4, 5, 6, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120,
13
+ 240);
14
 
15
 
16
+ /**
17
+ * send to campain options hours
18
+ *
19
+ * @return array
20
+ */
21
+ public function toOptionArray()
22
+ {
23
+ $result = $row = array();
24
+ $i = 0;
25
+ foreach ($this->_times as $one) {
26
 
27
 
28
+ if ($i == 0) {
29
+ $row = array('value' => $one,
30
+ 'label' => Mage::helper('ddg')->__('No Limit'));
31
+ } elseif ($i == 1) {
32
+ $row = array(
33
+ 'value' => $one,
34
+ 'label' => Mage::helper('ddg')->__($one . ' Hour')
35
+ );
36
+ } else {
37
+ $row = array(
38
+ 'value' => $one,
39
+ 'label' => Mage::helper('ddg')->__($one . ' Hours')
40
+ );
41
+ }
42
+ $result[] = $row;
43
+ $i++;
44
+ }
45
 
46
+ return $result;
47
+ }
48
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Attributes.php CHANGED
@@ -2,21 +2,25 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Attributes
4
  {
 
5
  /**
6
  * Returns custom order attributes
 
7
  * @return array
8
  */
9
  public function toOptionArray()
10
  {
11
- $fields = Mage::getResourceModel('ddg_automation/order')->getOrderTableDescription();
 
12
 
13
  $customFields = array();
14
- foreach($fields as $key => $field){
15
  $customFields[] = array(
16
  'value' => $field['COLUMN_NAME'],
17
  'label' => $field['COLUMN_NAME']
18
  );
19
  }
 
20
  return $customFields;
21
  }
22
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Attributes
4
  {
5
+
6
  /**
7
  * Returns custom order attributes
8
+ *
9
  * @return array
10
  */
11
  public function toOptionArray()
12
  {
13
+ $fields = Mage::getResourceModel('ddg_automation/order')
14
+ ->getOrderTableDescription();
15
 
16
  $customFields = array();
17
+ foreach ($fields as $key => $field) {
18
  $customFields[] = array(
19
  'value' => $field['COLUMN_NAME'],
20
  'label' => $field['COLUMN_NAME']
21
  );
22
  }
23
+
24
  return $customFields;
25
  }
26
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Cronexpressionsone.php CHANGED
@@ -2,12 +2,16 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionsone
4
  {
 
5
  public function toOptionArray()
6
  {
7
  return array(
8
- array('value' => '*/5 * * * *', 'label' => Mage::helper('ddg')->__('Every 5 Minutes')),
9
- array('value' => '*/10 * * * *', 'label' => Mage::helper('ddg')->__('Every 10 Minutes')),
10
- array('value' => '*/15 * * * *', 'label' => Mage::helper('ddg')->__('Every 15 Minutes')),
 
 
 
11
  );
12
  }
13
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionsone
4
  {
5
+
6
  public function toOptionArray()
7
  {
8
  return array(
9
+ array('value' => '*/5 * * * *',
10
+ 'label' => Mage::helper('ddg')->__('Every 5 Minutes')),
11
+ array('value' => '*/10 * * * *',
12
+ 'label' => Mage::helper('ddg')->__('Every 10 Minutes')),
13
+ array('value' => '*/15 * * * *',
14
+ 'label' => Mage::helper('ddg')->__('Every 15 Minutes')),
15
  );
16
  }
17
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Cronexpressionstwo.php CHANGED
@@ -2,12 +2,16 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionstwo
4
  {
 
5
  public function toOptionArray()
6
  {
7
  return array(
8
- array('value' => '*/15 * * * *', 'label' => Mage::helper('ddg')->__('Every 15 Minutes')),
9
- array('value' => '*/30 * * * *', 'label' => Mage::helper('ddg')->__('Every 30 Minutes')),
10
- array('value' => '00 * * * *', 'label' => Mage::helper('ddg')->__('Every 60 Minutes')),
 
 
 
11
  );
12
  }
13
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionstwo
4
  {
5
+
6
  public function toOptionArray()
7
  {
8
  return array(
9
+ array('value' => '*/15 * * * *',
10
+ 'label' => Mage::helper('ddg')->__('Every 15 Minutes')),
11
+ array('value' => '*/30 * * * *',
12
+ 'label' => Mage::helper('ddg')->__('Every 30 Minutes')),
13
+ array('value' => '00 * * * *',
14
+ 'label' => Mage::helper('ddg')->__('Every 60 Minutes')),
15
  );
16
  }
17
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Frequency.php CHANGED
@@ -2,14 +2,19 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Frequency
4
  {
5
- public function toOptionArray()
6
- {
7
- return array(
8
- array('value' => '1', 'label' => Mage::helper('ddg')->__('1 Hour')),
9
- array('value' => '2', 'label' => Mage::helper('ddg')->__('2 Hours')),
10
- array('value' => '6', 'label' => Mage::helper('ddg')->__('6 Hours')),
11
- array('value' => '12', 'label' => Mage::helper('ddg')->__('12 Hours')),
12
- array('value' => '24', 'label' => Mage::helper('ddg')->__('24 Hours'))
13
- );
14
- }
 
 
 
 
 
15
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Frequency
4
  {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => '1', 'label' => Mage::helper('ddg')->__('1 Hour')),
10
+ array('value' => '2',
11
+ 'label' => Mage::helper('ddg')->__('2 Hours')),
12
+ array('value' => '6',
13
+ 'label' => Mage::helper('ddg')->__('6 Hours')),
14
+ array('value' => '12',
15
+ 'label' => Mage::helper('ddg')->__('12 Hours')),
16
+ array('value' => '24',
17
+ 'label' => Mage::helper('ddg')->__('24 Hours'))
18
+ );
19
+ }
20
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Quoteattributes.php CHANGED
@@ -2,20 +2,23 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Quoteattributes
4
  {
 
5
  /**
6
  * @return array
7
  */
8
  public function toOptionArray()
9
  {
10
- $fields = Mage::getResourceModel('ddg_automation/quote')->getQuoteTableDescription();
 
11
 
12
  $customFields = array();
13
- foreach($fields as $key => $field){
14
  $customFields[] = array(
15
  'value' => $field['COLUMN_NAME'],
16
  'label' => $field['COLUMN_NAME']
17
  );
18
  }
 
19
  return $customFields;
20
  }
21
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Quoteattributes
4
  {
5
+
6
  /**
7
  * @return array
8
  */
9
  public function toOptionArray()
10
  {
11
+ $fields = Mage::getResourceModel('ddg_automation/quote')
12
+ ->getQuoteTableDescription();
13
 
14
  $customFields = array();
15
+ foreach ($fields as $key => $field) {
16
  $customFields[] = array(
17
  'value' => $field['COLUMN_NAME'],
18
  'label' => $field['COLUMN_NAME']
19
  );
20
  }
21
+
22
  return $customFields;
23
  }
24
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Transdata.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Transdata
4
  {
 
5
  /**
6
  * @return array
7
  */
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Transdata
4
  {
5
+
6
  /**
7
  * @return array
8
  */
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Attributes.php CHANGED
@@ -2,9 +2,12 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Attributes
4
  {
 
5
  public function toOptionArray()
6
  {
7
- $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
 
 
8
  ->addVisibleFilter();
9
 
10
  $attributeArray = array(
@@ -14,12 +17,13 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Attributes
14
  )
15
  );
16
 
17
- foreach($attributes as $attribute){
18
  $attributeArray[] = array(
19
  'label' => $attribute->getFrontendLabel(),
20
  'value' => $attribute->getAttributeCode()
21
  );
22
  }
 
23
  return $attributeArray;
24
  }
25
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Attributes
4
  {
5
+
6
  public function toOptionArray()
7
  {
8
+ $attributes = Mage::getResourceModel(
9
+ 'catalog/product_attribute_collection'
10
+ )
11
  ->addVisibleFilter();
12
 
13
  $attributeArray = array(
17
  )
18
  );
19
 
20
+ foreach ($attributes as $attribute) {
21
  $attributeArray[] = array(
22
  'label' => $attribute->getFrontendLabel(),
23
  'value' => $attribute->getAttributeCode()
24
  );
25
  }
26
+
27
  return $attributeArray;
28
  }
29
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Automation/Programme.php CHANGED
@@ -3,42 +3,44 @@
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Automation_Programme
4
  {
5
 
6
- /**
7
- * @return array
8
- * @throws Mage_Core_Exception
9
- */
10
- public function toOptionArray()
11
- {
12
- $fields = array();
13
- $websiteCode = Mage::app()->getRequest()->getParam('website', false);
14
-
15
- //website code param
16
- if (! $websiteCode)
17
- $websiteCode = 0;//use admin
18
-
19
- $website = Mage::app()->getWebsite($websiteCode);
20
-
21
- $fields[] = array('value' => '0', 'label' => Mage::helper('ddg')->__('-- Disabled --'));
22
-
23
- if (Mage::helper('ddg')->isEnabled($website)) {
24
-
25
- $client = Mage::helper('ddg')->getWebsiteApiClient( $website );
26
- $programmes = $client->getPrograms();
27
- if ($programmes) {
28
- foreach ( $programmes as $one ) {
29
- if ( isset( $one->id ) ) {
30
- if ( $one->status == 'Active' ) {
31
- $fields[] = array(
32
- 'value' => $one->id,
33
- 'label' => Mage::helper( 'ddg' )->__( $one->name )
34
- );
35
- }
36
- }
37
- }
38
- }
39
- }
40
-
41
- return $fields;
42
- }
 
 
43
 
44
  }
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Automation_Programme
4
  {
5
 
6
+ /**
7
+ * @return array
8
+ * @throws Mage_Core_Exception
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ $fields = array();
13
+ $websiteCode = Mage::app()->getRequest()->getParam('website', false);
14
+
15
+ //website code param
16
+ if ( ! $websiteCode) {
17
+ $websiteCode = 0;
18
+ }//use admin
19
+
20
+ $website = Mage::app()->getWebsite($websiteCode);
21
+
22
+ $fields[] = array('value' => '0',
23
+ 'label' => Mage::helper('ddg')->__('-- Disabled --'));
24
+
25
+ if (Mage::helper('ddg')->isEnabled($website)) {
26
+
27
+ $client = Mage::helper('ddg')->getWebsiteApiClient($website);
28
+ $programmes = $client->getPrograms();
29
+ if ($programmes) {
30
+ foreach ($programmes as $one) {
31
+ if (isset($one->id)) {
32
+ if ($one->status == 'Active') {
33
+ $fields[] = array(
34
+ 'value' => $one->id,
35
+ 'label' => Mage::helper('ddg')->__($one->name)
36
+ );
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ return $fields;
44
+ }
45
 
46
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php CHANGED
@@ -3,54 +3,59 @@
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Campaigns
4
  {
5
 
6
- /**
7
- * Returns the campaigns options.
8
- *
9
- * @return array
10
- * @throws Mage_Core_Exception
11
- */
12
- public function toOptionArray()
13
  {
14
  $fields = array();
15
  $websiteName = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  $website = Mage::app()->getRequest()->getParam('website', false);
18
- if ($website)
19
  $website = Mage::app()->getWebsite($website);
20
- else
21
  $website = 0;
22
- $fields[] = array('value' => '0', 'label' => Mage::helper('ddg')->__('-- Please Select --'));
 
 
 
23
 
24
- if ($websiteName) {
25
  $website = Mage::app()->getWebsite($websiteName);
26
  }
27
 
28
- $enabled = Mage::helper('ddg')->isEnabled($website);
29
 
30
- //api enabled get campaigns
31
- if ($enabled) {
32
- $client = Mage::helper( 'ddg' )->getWebsiteApiClient( $website );
33
 
34
- $savedCampaigns = Mage::registry( 'savedcampigns' );
35
 
36
- //get campaigns from registry
37
- if ( $savedCampaigns ) {
38
- $campaigns = $savedCampaigns;
39
- } else {
40
- $campaigns = $client->getCampaigns();
41
- Mage::unregister( 'savedcampigns' );
42
- Mage::register( 'savedcampigns', $campaigns );
43
- }
44
 
45
- foreach ( $campaigns as $one ) {
46
- if ( isset( $one->id ) ) {
47
  $fields[] = array(
48
  'value' => $one->id,
49
- 'label' => Mage::helper('ddg')->__(addslashes($one->name))
 
 
50
  );
51
- }
52
- }
53
- }
54
 
55
  return $fields;
56
  }
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Campaigns
4
  {
5
 
6
+ /**
7
+ * Returns the campaigns options.
8
+ *
9
+ * @return array
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ public function toOptionArray()
13
  {
14
  $fields = array();
15
  $websiteName = Mage::app()->getRequest()->getParam('website', false);
16
 
17
  $website = Mage::app()->getRequest()->getParam('website', false);
18
+ if ($website) {
19
  $website = Mage::app()->getWebsite($website);
20
+ } else {
21
  $website = 0;
22
+ }
23
+ $fields[] = array('value' => '0', 'label' => Mage::helper('ddg')->__(
24
+ '-- Please Select --'
25
+ ));
26
 
27
+ if ($websiteName) {
28
  $website = Mage::app()->getWebsite($websiteName);
29
  }
30
 
31
+ $enabled = Mage::helper('ddg')->isEnabled($website);
32
 
33
+ //api enabled get campaigns
34
+ if ($enabled) {
35
+ $client = Mage::helper('ddg')->getWebsiteApiClient($website);
36
 
37
+ $savedCampaigns = Mage::registry('savedcampigns');
38
 
39
+ //get campaigns from registry
40
+ if ($savedCampaigns) {
41
+ $campaigns = $savedCampaigns;
42
+ } else {
43
+ $campaigns = $client->getCampaigns();
44
+ Mage::unregister('savedcampigns');
45
+ Mage::register('savedcampigns', $campaigns);
46
+ }
47
 
48
+ foreach ($campaigns as $one) {
49
+ if (isset($one->id)) {
50
  $fields[] = array(
51
  'value' => $one->id,
52
+ 'label' => Mage::helper('ddg')->__(
53
+ addslashes($one->name)
54
+ )
55
  );
56
+ }
57
+ }
58
+ }
59
 
60
  return $fields;
61
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Imported.php CHANGED
@@ -2,15 +2,16 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Imported
4
  {
5
- /**
6
- * Contact imported options.
7
- *
8
- * @return array
9
- */
10
- public function getOptions()
 
11
  {
12
  return array(
13
- '1' => Mage::helper('ddg')->__('Imported'),
14
  'null' => Mage::helper('ddg')->__('Not Imported'),
15
  );
16
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Imported
4
  {
5
+
6
+ /**
7
+ * Contact imported options.
8
+ *
9
+ * @return array
10
+ */
11
+ public function getOptions()
12
  {
13
  return array(
14
+ '1' => Mage::helper('ddg')->__('Imported'),
15
  'null' => Mage::helper('ddg')->__('Not Imported'),
16
  );
17
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Modified.php CHANGED
@@ -2,15 +2,16 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Modified
4
  {
5
- /**
6
- * Contact imported options.
7
- *
8
- * @return array
9
- */
10
- public function getOptions()
 
11
  {
12
  return array(
13
- '1' => Mage::helper('ddg')->__('Modified'),
14
  'null' => Mage::helper('ddg')->__('Not Modified'),
15
  );
16
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Modified
4
  {
5
+
6
+ /**
7
+ * Contact imported options.
8
+ *
9
+ * @return array
10
+ */
11
+ public function getOptions()
12
  {
13
  return array(
14
+ '1' => Mage::helper('ddg')->__('Modified'),
15
  'null' => Mage::helper('ddg')->__('Not Modified'),
16
  );
17
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Customer/Attributes/Select.php CHANGED
@@ -3,31 +3,35 @@
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Customer_Attributes_Select
4
  {
5
 
6
- /**
7
- * customer custom attributes.
8
- *
9
- * @return array
10
- */
11
- public function toOptionArray()
12
  {
13
 
14
  $options = array();
15
  //exclude attributes from mapping
16
- $excluded =
17
- array('created_at', 'created_in', 'dob', 'dotmailer_contact_id', 'email', 'firstname', 'lastname', 'gender',
18
- 'group_id', 'password_hash', 'prefix', 'rp_token', 'rp_token_create_at', 'website_id');
 
 
 
19
  $attributes = Mage::getModel('customer/customer')->getAttributes();
20
 
21
  foreach ($attributes as $attribute) {
22
  if ($attribute->getFrontendLabel()) {
23
  $code = $attribute->getAttributeCode();
24
- //escape the label in case of quotes
25
- $label = addslashes($attribute->getFrontendLabel());
26
- if(!in_array($code, $excluded))
27
  $options[] = array(
28
  'value' => $attribute->getAttributeCode(),
29
  'label' => $label
30
  );
 
31
  }
32
  }
33
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Customer_Attributes_Select
4
  {
5
 
6
+ /**
7
+ * customer custom attributes.
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
  {
13
 
14
  $options = array();
15
  //exclude attributes from mapping
16
+ $excluded
17
+ = array('created_at', 'created_in', 'dob',
18
+ 'dotmailer_contact_id', 'email', 'firstname',
19
+ 'lastname', 'gender',
20
+ 'group_id', 'password_hash', 'prefix', 'rp_token',
21
+ 'rp_token_create_at', 'website_id');
22
  $attributes = Mage::getModel('customer/customer')->getAttributes();
23
 
24
  foreach ($attributes as $attribute) {
25
  if ($attribute->getFrontendLabel()) {
26
  $code = $attribute->getAttributeCode();
27
+ //escape the label in case of quotes
28
+ $label = addslashes($attribute->getFrontendLabel());
29
+ if ( ! in_array($code, $excluded)) {
30
  $options[] = array(
31
  'value' => $attribute->getAttributeCode(),
32
  'label' => $label
33
  );
34
+ }
35
  }
36
  }
37
 
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datafields.php CHANGED
@@ -2,53 +2,60 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datafields
4
  {
 
5
  /**
6
  * Datafields option.
 
7
  * @return array
8
  */
9
  public function toOptionArray()
10
  {
11
  $fields = array();
12
  $helper = Mage::helper('ddg');
13
- //default data option
14
- $fields[] = array('value' => 0, 'label' => Mage::helper('ddg')->__('-- Please Select --'));
15
-
16
- $website = Mage::app()->getRequest()->getParam('website', 0);
17
- $client = $helper->getWebsiteApiClient($website);
18
-
19
- //get datafields options
20
- if ($helper->isEnabled($website)) {
21
-
22
- $savedDatafields = Mage::registry( 'datafields' );
23
-
24
- //get saved datafileds from registry
25
- if ( $savedDatafields ) {
26
- $datafields = $savedDatafields;
27
- } else {
28
- //grab the datafields request and save to register
29
- $datafields = $client->getDataFields();
30
- Mage::register( 'datafields', $datafields );
31
- }
32
-
33
- //set the api error message for the first option
34
- if ( isset( $datafields->message ) ) {
35
-
36
- //message
37
- $fields[] = array( 'value' => 0, 'label' => Mage::helper( 'ddg' )->__( $datafields->message ) );
38
-
39
- } elseif(is_array($datafields)) {
40
-
41
- //loop for all datafields option
42
- foreach ( $datafields as $datafield ) {
43
- if ( isset( $datafield->name ) ) {
44
- $fields[] = array(
45
- 'value' => $datafield->name,
46
- 'label' => Mage::helper( 'ddg' )->__( $datafield->name )
47
- );
48
- }
49
- }
50
- }
51
- }
 
 
 
 
 
52
 
53
  return $fields;
54
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datafields
4
  {
5
+
6
  /**
7
  * Datafields option.
8
+ *
9
  * @return array
10
  */
11
  public function toOptionArray()
12
  {
13
  $fields = array();
14
  $helper = Mage::helper('ddg');
15
+ //default data option
16
+ $fields[] = array('value' => 0, 'label' => Mage::helper('ddg')->__(
17
+ '-- Please Select --'
18
+ ));
19
+
20
+ $website = Mage::app()->getRequest()->getParam('website', 0);
21
+ $client = $helper->getWebsiteApiClient($website);
22
+
23
+ //get datafields options
24
+ if ($helper->isEnabled($website)) {
25
+
26
+ $savedDatafields = Mage::registry('datafields');
27
+
28
+ //get saved datafileds from registry
29
+ if ($savedDatafields) {
30
+ $datafields = $savedDatafields;
31
+ } else {
32
+ //grab the datafields request and save to register
33
+ $datafields = $client->getDataFields();
34
+ Mage::register('datafields', $datafields);
35
+ }
36
+
37
+ //set the api error message for the first option
38
+ if (isset($datafields->message)) {
39
+
40
+ //message
41
+ $fields[] = array('value' => 0,
42
+ 'label' => Mage::helper('ddg')->__(
43
+ $datafields->message
44
+ ));
45
+
46
+ } elseif (is_array($datafields)) {
47
+
48
+ //loop for all datafields option
49
+ foreach ($datafields as $datafield) {
50
+ if (isset($datafield->name)) {
51
+ $fields[] = array(
52
+ 'value' => $datafield->name,
53
+ 'label' => Mage::helper('ddg')->__($datafield->name)
54
+ );
55
+ }
56
+ }
57
+ }
58
+ }
59
 
60
  return $fields;
61
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldaccess.php CHANGED
@@ -2,16 +2,19 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldaccess
4
  {
5
- /**
6
- * @return array
7
- */
8
- public function toOptionArray()
9
- {
10
- $dataType = array(
11
- array('value' => 'Private', 'label' => Mage::helper('ddg')->__('Private')),
12
- array('value' => 'Public', 'label' => Mage::helper('ddg')->__('Public')),
13
- );
14
 
15
- return $dataType;
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldaccess
4
  {
 
 
 
 
 
 
 
 
 
5
 
6
+ /**
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ $dataType = array(
12
+ array('value' => 'Private',
13
+ 'label' => Mage::helper('ddg')->__('Private')),
14
+ array('value' => 'Public',
15
+ 'label' => Mage::helper('ddg')->__('Public')),
16
+ );
17
+
18
+ return $dataType;
19
+ }
20
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldtype.php CHANGED
@@ -2,18 +2,24 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldtype
4
  {
 
5
  /**
6
  * Datafield model type.
7
  * Data mapping.
 
8
  * @return array
9
  */
10
  public function toOptionArray()
11
  {
12
  $dataType = array(
13
- array('value' => 'String', 'label' => Mage::helper('ddg')->__('String')),
14
- array('value' => 'Numeric', 'label' => Mage::helper('ddg')->__('Numeric')),
15
- array('value' => 'Date', 'label' => Mage::helper('ddg')->__('Date')),
16
- array('value' => 'Boolean', 'label' => Mage::helper('ddg')->__('Yes/No'))
 
 
 
 
17
  );
18
 
19
  return $dataType;
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldtype
4
  {
5
+
6
  /**
7
  * Datafield model type.
8
  * Data mapping.
9
+ *
10
  * @return array
11
  */
12
  public function toOptionArray()
13
  {
14
  $dataType = array(
15
+ array('value' => 'String',
16
+ 'label' => Mage::helper('ddg')->__('String')),
17
+ array('value' => 'Numeric',
18
+ 'label' => Mage::helper('ddg')->__('Numeric')),
19
+ array('value' => 'Date',
20
+ 'label' => Mage::helper('ddg')->__('Date')),
21
+ array('value' => 'Boolean',
22
+ 'label' => Mage::helper('ddg')->__('Yes/No'))
23
  );
24
 
25
  return $dataType;
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Displaytype.php CHANGED
@@ -2,15 +2,17 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Displaytype
4
  {
5
- /**
6
- * Display type mode.
7
- *
8
- * @return array
9
- */
10
- public function toOptionArray()
 
11
  {
12
  return array(
13
- array('value' => 'grid', 'label' => Mage::helper('ddg')->__('Grid')),
 
14
  array('value' => 'list', 'label' => Mage::helper('ddg')->__('List'))
15
  );
16
 
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Displaytype
4
  {
5
+
6
+ /**
7
+ * Display type mode.
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
  {
13
  return array(
14
+ array('value' => 'grid',
15
+ 'label' => Mage::helper('ddg')->__('Grid')),
16
  array('value' => 'list', 'label' => Mage::helper('ddg')->__('List'))
17
  );
18
 
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Gridview.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Gridview
4
  {
 
5
  /**
6
  * grid display options.
7
  *
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Gridview
4
  {
5
+
6
  /**
7
  * grid display options.
8
  *
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Fontpicker.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontpicker
4
  {
 
5
  /**
6
  * Options getter. web safe fonts
7
  *
@@ -11,25 +12,29 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontpicker
11
  {
12
  return array(
13
  array('value' => "Arial, Helvetica, sans-serif",
14
- 'label' => Mage::helper('ddg')->__("Arial, Helvetica")),
15
  array('value' => "'Arial Black', Gadget, sans-serif",
16
- 'label' => Mage::helper('ddg')->__("Arial Black, Gadget")),
17
  array('value' => "'Courier New', Courier, monospace",
18
- 'label' => Mage::helper('ddg')->__("Courier New, Courier")),
19
  array('value' => "Georgia, serif",
20
- 'label' => Mage::helper('ddg')->__("Georgia")),
21
  array('value' => "'MS Sans Serif', Geneva, sans-serif",
22
- 'label' => Mage::helper('ddg')->__("MS Sans Serif, Geneva")),
23
  array('value' => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
24
- 'label' => Mage::helper('ddg')->__("Palatino Linotype, Book Antiqua")),
 
 
25
  array('value' => "Tahoma, Geneva, sans-serif",
26
- 'label' => Mage::helper('ddg')->__("Tahoma, Geneva")),
27
  array('value' => "'Times New Roman', Times, serif",
28
- 'label' => Mage::helper('ddg')->__("Times New Roman, Times")),
29
  array('value' => "'Trebuchet MS', Helvetica, sans-serif",
30
- 'label' => Mage::helper('ddg')->__("Trebuchet MS, Helvetica")),
 
 
31
  array('value' => "Verdana, Geneva, sans-serif",
32
- 'label' => Mage::helper('ddg')->__("Verdana, Geneva")),
33
  );
34
  }
35
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontpicker
4
  {
5
+
6
  /**
7
  * Options getter. web safe fonts
8
  *
12
  {
13
  return array(
14
  array('value' => "Arial, Helvetica, sans-serif",
15
+ 'label' => Mage::helper('ddg')->__("Arial, Helvetica")),
16
  array('value' => "'Arial Black', Gadget, sans-serif",
17
+ 'label' => Mage::helper('ddg')->__("Arial Black, Gadget")),
18
  array('value' => "'Courier New', Courier, monospace",
19
+ 'label' => Mage::helper('ddg')->__("Courier New, Courier")),
20
  array('value' => "Georgia, serif",
21
+ 'label' => Mage::helper('ddg')->__("Georgia")),
22
  array('value' => "'MS Sans Serif', Geneva, sans-serif",
23
+ 'label' => Mage::helper('ddg')->__("MS Sans Serif, Geneva")),
24
  array('value' => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
25
+ 'label' => Mage::helper('ddg')->__(
26
+ "Palatino Linotype, Book Antiqua"
27
+ )),
28
  array('value' => "Tahoma, Geneva, sans-serif",
29
+ 'label' => Mage::helper('ddg')->__("Tahoma, Geneva")),
30
  array('value' => "'Times New Roman', Times, serif",
31
+ 'label' => Mage::helper('ddg')->__("Times New Roman, Times")),
32
  array('value' => "'Trebuchet MS', Helvetica, sans-serif",
33
+ 'label' => Mage::helper('ddg')->__(
34
+ "Trebuchet MS, Helvetica"
35
+ )),
36
  array('value' => "Verdana, Geneva, sans-serif",
37
+ 'label' => Mage::helper('ddg')->__("Verdana, Geneva")),
38
  );
39
  }
40
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Fontsize.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontsize
4
  {
 
5
  /**
6
  * Options getter. Styling options
7
  *
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontsize
4
  {
5
+
6
  /**
7
  * Options getter. Styling options
8
  *
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Bulklimit.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Bulklimit
4
+ {
5
+ /**
6
+ * @return array
7
+ */
8
+ public function toOptionArray()
9
+ {
10
+ return array(
11
+ array('value' => '1', 'label' => '1'),
12
+ array('value' => '2', 'label' => '2'),
13
+ array('value' => '3', 'label' => '3'),
14
+ array('value' => '4', 'label' => '4'),
15
+ array('value' => '5', 'label' => '5')
16
+ );
17
+ }
18
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Mode.php CHANGED
@@ -10,13 +10,13 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Mode
10
  public function getOptions()
11
  {
12
  return array(
13
- Dotdigitalgroup_Email_Model_Importer::MODE_BULK => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_BULK),
14
- Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE),
15
- Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE_DELETE => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE_DELETE),
16
- Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_DELETE => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_DELETE),
17
- Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_UPDATE => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_UPDATE),
18
- Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_RESUBSCRIBED => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_RESUBSCRIBED),
19
- Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_EMAIL_UPDATE => Mage::helper('ddg')->__(Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_EMAIL_UPDATE)
20
  );
21
  }
22
  }
10
  public function getOptions()
11
  {
12
  return array(
13
+ Dotdigitalgroup_Email_Model_Importer::MODE_BULK => Mage::helper('ddg')->__('Bulk'),
14
+ Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE => Mage::helper('ddg')->__('Single'),
15
+ Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE_DELETE => Mage::helper('ddg')->__('Single Delete'),
16
+ Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_DELETE => Mage::helper('ddg')->__('Contact Delete'),
17
+ Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_RESUBSCRIBED => Mage::helper('ddg')->__('Subscriber Resubscribed'),
18
+ Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_UPDATE => Mage::helper('ddg')->__('Subscriber Update'),
19
+ Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_EMAIL_UPDATE => Mage::helper('ddg')->__('Contact Email Update')
20
  );
21
  }
22
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Status.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Status
4
  {
 
5
  /**
6
  * Contact imported options.
7
  *
@@ -10,10 +11,18 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Status
10
  public function getOptions()
11
  {
12
  return array(
13
- Dotdigitalgroup_Email_Model_Importer::NOT_IMPORTED => Mage::helper('ddg')->__('Not Imported'),
14
- Dotdigitalgroup_Email_Model_Importer::IMPORTING => Mage::helper('ddg')->__('Importing'),
15
- Dotdigitalgroup_Email_Model_Importer::IMPORTED => Mage::helper('ddg')->__('Imported'),
16
- Dotdigitalgroup_Email_Model_Importer::FAILED => Mage::helper('ddg')->__('Failed'),
 
 
 
 
 
 
 
 
17
  );
18
  }
19
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Status
4
  {
5
+
6
  /**
7
  * Contact imported options.
8
  *
11
  public function getOptions()
12
  {
13
  return array(
14
+ Dotdigitalgroup_Email_Model_Importer::NOT_IMPORTED => Mage::helper(
15
+ 'ddg'
16
+ )->__('Not Imported'),
17
+ Dotdigitalgroup_Email_Model_Importer::IMPORTING => Mage::helper(
18
+ 'ddg'
19
+ )->__('Importing'),
20
+ Dotdigitalgroup_Email_Model_Importer::IMPORTED => Mage::helper(
21
+ 'ddg'
22
+ )->__('Imported'),
23
+ Dotdigitalgroup_Email_Model_Importer::FAILED => Mage::helper(
24
+ 'ddg'
25
+ )->__('Failed'),
26
  );
27
  }
28
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Interval.php CHANGED
@@ -5,34 +5,38 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Interval
5
 
6
  /**
7
  * available times
 
8
  * @var array
9
  */
10
- protected $_times = array(1,2,3,4,5,6,12,24,36,48,60,72,84,96,108,120, 240);
 
 
11
 
12
 
13
  /**
14
  * send to campain options hours
 
15
  * @return array
16
  */
17
  public function toOptionArray()
18
  {
19
  $result = $row = array();
20
- $i = 0;
21
  foreach ($this->_times as $one) {
22
 
23
  if ($i == 0) {
24
- $row = array(
25
- 'value' => $one,
26
- 'label' => Mage::helper( 'ddg' )->__( $one . ' Hour' )
27
- );
28
  } else {
29
- $row = array(
30
- 'value' => $one,
31
- 'label' => Mage::helper( 'ddg' )->__( $one . ' Hours' )
32
- );
33
  }
34
  $result[] = $row;
35
- $i++;
36
  }
37
 
38
  return $result;
5
 
6
  /**
7
  * available times
8
+ *
9
  * @var array
10
  */
11
+ protected $_times
12
+ = array(1, 2, 3, 4, 5, 6, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120,
13
+ 240);
14
 
15
 
16
  /**
17
  * send to campain options hours
18
+ *
19
  * @return array
20
  */
21
  public function toOptionArray()
22
  {
23
  $result = $row = array();
24
+ $i = 0;
25
  foreach ($this->_times as $one) {
26
 
27
  if ($i == 0) {
28
+ $row = array(
29
+ 'value' => $one,
30
+ 'label' => Mage::helper('ddg')->__($one . ' Hour')
31
+ );
32
  } else {
33
+ $row = array(
34
+ 'value' => $one,
35
+ 'label' => Mage::helper('ddg')->__($one . ' Hours')
36
+ );
37
  }
38
  $result[] = $row;
39
+ $i++;
40
  }
41
 
42
  return $result;
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Intervalminute.php CHANGED
@@ -2,20 +2,29 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Intervalminute
4
  {
 
5
  /**
6
  * lost basket hour options
 
7
  * @return array
8
  */
9
  public function toOptionArray()
10
  {
11
  return array(
12
- array('value' => "15", 'label' => Mage::helper('ddg')->__('15 Minutes')),
13
- array('value' => "20", 'label' => Mage::helper('ddg')->__('20 Minutes')),
14
- array('value' => "25", 'label' => Mage::helper('ddg')->__('25 Minutes')),
15
- array('value' => "30", 'label' => Mage::helper('ddg')->__('30 Minutes')),
16
- array('value' => "40", 'label' => Mage::helper('ddg')->__('40 Minutes')),
17
- array('value' => "50", 'label' => Mage::helper('ddg')->__('50 Minutes')),
18
- array('value' => "60", 'label' => Mage::helper('ddg')->__('60 Minutes')),
 
 
 
 
 
 
 
19
  );
20
  }
21
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Intervalminute
4
  {
5
+
6
  /**
7
  * lost basket hour options
8
+ *
9
  * @return array
10
  */
11
  public function toOptionArray()
12
  {
13
  return array(
14
+ array('value' => "15",
15
+ 'label' => Mage::helper('ddg')->__('15 Minutes')),
16
+ array('value' => "20",
17
+ 'label' => Mage::helper('ddg')->__('20 Minutes')),
18
+ array('value' => "25",
19
+ 'label' => Mage::helper('ddg')->__('25 Minutes')),
20
+ array('value' => "30",
21
+ 'label' => Mage::helper('ddg')->__('30 Minutes')),
22
+ array('value' => "40",
23
+ 'label' => Mage::helper('ddg')->__('40 Minutes')),
24
+ array('value' => "50",
25
+ 'label' => Mage::helper('ddg')->__('50 Minutes')),
26
+ array('value' => "60",
27
+ 'label' => Mage::helper('ddg')->__('60 Minutes')),
28
  );
29
  }
30
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Orderstatus.php CHANGED
@@ -2,21 +2,24 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Orderstatus
4
  {
 
5
  /**
6
  * Returns the order statuses
 
7
  * @return array
8
  */
9
  public function toOptionArray()
10
  {
11
  $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
12
- $options = array();
13
 
14
- foreach ($statuses as $code=>$label) {
15
  $options[] = array(
16
  'value' => $code,
17
  'label' => $label
18
  );
19
  }
 
20
  return $options;
21
  }
22
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Orderstatus
4
  {
5
+
6
  /**
7
  * Returns the order statuses
8
+ *
9
  * @return array
10
  */
11
  public function toOptionArray()
12
  {
13
  $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
14
+ $options = array();
15
 
16
+ foreach ($statuses as $code => $label) {
17
  $options[] = array(
18
  'value' => $code,
19
  'label' => $label
20
  );
21
  }
22
+
23
  return $options;
24
  }
25
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Publicdatafields.php CHANGED
@@ -2,62 +2,72 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Publicdatafields
4
  {
5
- protected function getWebsite()
6
- {
7
- $website = Mage::app()->getWebsite();
8
- $websiteParam = Mage::app()->getRequest()->getParam('website');
9
- if($websiteParam)
10
- $website = Mage::app()->getWebsite($websiteParam);
11
- return $website;
12
- }
13
-
14
- /**
15
- * get data fields
16
- *
17
- * @return mixed
18
- */
19
- protected function getDataFields()
20
- {
21
- $helper = Mage::helper('ddg');
22
- $website = $this->getWebsite();
23
- $client = $helper->getWebsiteApiClient($website);
24
-
25
- //grab the datafields request and save to register
26
- $datafields = $client->getDataFields();
27
-
28
- return $datafields;
29
- }
 
 
 
30
 
31
  /**
32
  * Datafields option.
 
33
  * @return array
34
  */
35
  public function toOptionArray()
36
  {
37
- $fields = array();
38
- $helper = Mage::helper('ddg');
39
- $website = $this->getWebsite();
40
-
41
- //get datafields options
42
- if ($helper->isEnabled($website)) {
43
- $datafields = $this->getDataFields();
44
-
45
- //set the api error message for the first option
46
- if ( isset( $datafields->message ) ) {
47
- //message
48
- $fields[] = array( 'value' => 0, 'label' => Mage::helper( 'ddg' )->__( $datafields->message ) );
49
- } else {
50
- //loop for all datafields option
51
- foreach ( $datafields as $datafield ) {
52
- if ( isset( $datafield->name ) && $datafield->visibility == 'Public') {
53
- $fields[] = array(
54
- 'value' => $datafield->name,
55
- 'label' => Mage::helper( 'ddg' )->__( $datafield->name )
56
- );
57
- }
58
- }
59
- }
60
- }
 
 
 
 
 
 
61
  return $fields;
62
  }
63
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Publicdatafields
4
  {
5
+
6
+ protected function getWebsite()
7
+ {
8
+ $website = Mage::app()->getWebsite();
9
+ $websiteParam = Mage::app()->getRequest()->getParam('website');
10
+ if ($websiteParam) {
11
+ $website = Mage::app()->getWebsite($websiteParam);
12
+ }
13
+
14
+ return $website;
15
+ }
16
+
17
+ /**
18
+ * get data fields
19
+ *
20
+ * @return mixed
21
+ */
22
+ protected function getDataFields()
23
+ {
24
+ $helper = Mage::helper('ddg');
25
+ $website = $this->getWebsite();
26
+ $client = $helper->getWebsiteApiClient($website);
27
+
28
+ //grab the datafields request and save to register
29
+ $datafields = $client->getDataFields();
30
+
31
+ return $datafields;
32
+ }
33
 
34
  /**
35
  * Datafields option.
36
+ *
37
  * @return array
38
  */
39
  public function toOptionArray()
40
  {
41
+ $fields = array();
42
+ $helper = Mage::helper('ddg');
43
+ $website = $this->getWebsite();
44
+
45
+ //get datafields options
46
+ if ($helper->isEnabled($website)) {
47
+ $datafields = $this->getDataFields();
48
+
49
+ //set the api error message for the first option
50
+ if (isset($datafields->message)) {
51
+ //message
52
+ $fields[] = array('value' => 0,
53
+ 'label' => Mage::helper('ddg')->__(
54
+ $datafields->message
55
+ ));
56
+ } else {
57
+ //loop for all datafields option
58
+ foreach ($datafields as $datafield) {
59
+ if (isset($datafield->name)
60
+ && $datafield->visibility == 'Public'
61
+ ) {
62
+ $fields[] = array(
63
+ 'value' => $datafield->name,
64
+ 'label' => Mage::helper('ddg')->__($datafield->name)
65
+ );
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
  return $fields;
72
  }
73
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Reviews/Delay.php CHANGED
@@ -2,14 +2,17 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Reviews_Delay
4
  {
 
5
  /**
6
  * Returns the values for field delay
 
7
  * @return array
8
  */
9
  public function toOptionArray()
10
  {
11
  return array(
12
- array('value' => '', 'label' => Mage::helper('ddg')->__('-- Please Select --')),
 
13
  array('value' => 1, 'label' => '1'),
14
  array('value' => 2, 'label' => '2'),
15
  array('value' => 3, 'label' => '3'),
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Reviews_Delay
4
  {
5
+
6
  /**
7
  * Returns the values for field delay
8
+ *
9
  * @return array
10
  */
11
  public function toOptionArray()
12
  {
13
  return array(
14
+ array('value' => '',
15
+ 'label' => Mage::helper('ddg')->__('-- Please Select --')),
16
  array('value' => 1, 'label' => '1'),
17
  array('value' => 2, 'label' => '2'),
18
  array('value' => 3, 'label' => '3'),
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Condition.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
4
  {
 
5
  /**
6
  * options array
7
  *
@@ -11,9 +12,12 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
11
  {
12
  $options = array(
13
  array('value' => 'eq', 'label' => Mage::helper('ddg')->__('is')),
14
- array('value' => 'neq', 'label' => Mage::helper('ddg')->__('is not')),
15
- array('value' => 'null', 'label' => Mage::helper('ddg')->__('is empty')),
 
 
16
  );
 
17
  return $options;
18
  }
19
 
@@ -21,6 +25,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
21
  * get condition options according to type
22
  *
23
  * @param $type
 
24
  * @return array
25
  */
26
  public function getInputTypeOptions($type)
@@ -44,11 +49,20 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
44
  */
45
  public function optionsForNumericType()
46
  {
47
- $options = $this->toOptionArray();
48
- $options[] = array('value' => 'gteq', 'label' => Mage::helper('ddg')->__('equals or greater than'));
49
- $options[] = array('value' => 'lteq', 'label' => Mage::helper('ddg')->__('equals or less then'));
50
- $options[] = array('value' => 'gt', 'label' => Mage::helper('ddg')->__('greater than'));
51
- $options[] = array('value' => 'lt', 'label' => Mage::helper('ddg')->__('less than'));
 
 
 
 
 
 
 
 
 
52
  return $options;
53
  }
54
 
@@ -59,9 +73,14 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
59
  */
60
  public function optionsForStringType()
61
  {
62
- $options = $this->toOptionArray();
63
- $options[] = array('value' => 'like', 'label' => Mage::helper('ddg')->__('contains'));
64
- $options[] = array('value' => 'nlike', 'label' => Mage::helper('ddg')->__('does not contains'));
 
 
 
 
 
65
  return $options;
66
  }
67
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
4
  {
5
+
6
  /**
7
  * options array
8
  *
12
  {
13
  $options = array(
14
  array('value' => 'eq', 'label' => Mage::helper('ddg')->__('is')),
15
+ array('value' => 'neq',
16
+ 'label' => Mage::helper('ddg')->__('is not')),
17
+ array('value' => 'null',
18
+ 'label' => Mage::helper('ddg')->__('is empty')),
19
  );
20
+
21
  return $options;
22
  }
23
 
25
  * get condition options according to type
26
  *
27
  * @param $type
28
+ *
29
  * @return array
30
  */
31
  public function getInputTypeOptions($type)
49
  */
50
  public function optionsForNumericType()
51
  {
52
+ $options = $this->toOptionArray();
53
+ $options[] = array('value' => 'gteq',
54
+ 'label' => Mage::helper('ddg')->__(
55
+ 'equals or greater than'
56
+ ));
57
+ $options[] = array('value' => 'lteq',
58
+ 'label' => Mage::helper('ddg')->__(
59
+ 'equals or less then'
60
+ ));
61
+ $options[] = array('value' => 'gt',
62
+ 'label' => Mage::helper('ddg')->__('greater than'));
63
+ $options[] = array('value' => 'lt',
64
+ 'label' => Mage::helper('ddg')->__('less than'));
65
+
66
  return $options;
67
  }
68
 
73
  */
74
  public function optionsForStringType()
75
  {
76
+ $options = $this->toOptionArray();
77
+ $options[] = array('value' => 'like',
78
+ 'label' => Mage::helper('ddg')->__('contains'));
79
+ $options[] = array('value' => 'nlike',
80
+ 'label' => Mage::helper('ddg')->__(
81
+ 'does not contains'
82
+ ));
83
+
84
  return $options;
85
  }
86
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Type.php CHANGED
@@ -7,24 +7,36 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Type
7
  * get input type
8
  *
9
  * @param $attribute
 
10
  * @return string
11
  */
12
  public function getInputType($attribute)
13
  {
14
  switch ($attribute) {
15
- case 'subtotal': case 'grand_total': case 'items_qty':
 
 
16
  return 'numeric';
17
 
18
- case 'method': case 'shipping_method': case 'country_id': case 'region_id': case 'customer_group_id':
 
 
 
 
19
  return 'select';
20
 
21
  default:
22
- $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attribute);
23
- if($attribute->getFrontend()->getInputType() == 'price')
 
 
24
  return 'numeric';
25
- if ($attribute->usesSource())
 
26
  return 'select';
 
27
  }
 
28
  return 'string';
29
  }
30
 
@@ -36,17 +48,29 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Type
36
  public function defaultOptions()
37
  {
38
  return array(
39
- 'method' => Mage::helper('adminhtml')->__('Payment Method'),
40
- 'shipping_method' => Mage::helper('adminhtml')->__('Shipping Method'),
41
- 'country_id' => Mage::helper('adminhtml')->__('Shipping Country'),
42
- 'city' => Mage::helper('adminhtml')->__('Shipping Town'),
43
- 'region_id' =>Mage::helper('adminhtml')->__( 'Shipping State/Province'),
44
- 'customer_group_id' =>Mage::helper('adminhtml')->__( 'Customer Group'),
45
- 'coupon_code' =>Mage::helper('adminhtml')->__( 'Coupon'),
46
- 'subtotal' =>Mage::helper('adminhtml')->__( 'Subtotal'),
47
- 'grand_total' =>Mage::helper('adminhtml')->__( 'Grand Total'),
48
- 'items_qty' =>Mage::helper('adminhtml')->__( 'Total Qty'),
49
- 'customer_email' => Mage::helper('adminhtml')->__('Email'),
 
 
 
 
 
 
 
 
 
 
 
 
50
  );
51
  }
52
 
@@ -57,16 +81,18 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Type
57
  */
58
  public function toOptionArray()
59
  {
60
- $defaultOptions = $this->defaultOptions();
61
- $productCondition = Mage::getModel('salesrule/rule_condition_product');
62
- $productAttributes = $productCondition->loadAttributeOptions()->getAttributeOption();
63
- $pAttributes = array();
64
- foreach ($productAttributes as $code=>$label) {
 
65
  if (strpos($code, 'quote_item_') === false) {
66
  $pAttributes[$code] = Mage::helper('adminhtml')->__($label);
67
  }
68
  }
69
  $options = array_merge($defaultOptions, $pAttributes);
 
70
  return $options;
71
  }
72
  }
7
  * get input type
8
  *
9
  * @param $attribute
10
+ *
11
  * @return string
12
  */
13
  public function getInputType($attribute)
14
  {
15
  switch ($attribute) {
16
+ case 'subtotal':
17
+ case 'grand_total':
18
+ case 'items_qty':
19
  return 'numeric';
20
 
21
+ case 'method':
22
+ case 'shipping_method':
23
+ case 'country_id':
24
+ case 'region_id':
25
+ case 'customer_group_id':
26
  return 'select';
27
 
28
  default:
29
+ $attribute = Mage::getSingleton('eav/config')->getAttribute(
30
+ 'catalog_product', $attribute
31
+ );
32
+ if ($attribute->getFrontend()->getInputType() == 'price') {
33
  return 'numeric';
34
+ }
35
+ if ($attribute->usesSource()) {
36
  return 'select';
37
+ }
38
  }
39
+
40
  return 'string';
41
  }
42
 
48
  public function defaultOptions()
49
  {
50
  return array(
51
+ 'method' => Mage::helper('adminhtml')->__(
52
+ 'Payment Method'
53
+ ),
54
+ 'shipping_method' => Mage::helper('adminhtml')->__(
55
+ 'Shipping Method'
56
+ ),
57
+ 'country_id' => Mage::helper('adminhtml')->__(
58
+ 'Shipping Country'
59
+ ),
60
+ 'city' => Mage::helper('adminhtml')->__(
61
+ 'Shipping Town'
62
+ ),
63
+ 'region_id' => Mage::helper('adminhtml')->__(
64
+ 'Shipping State/Province'
65
+ ),
66
+ 'customer_group_id' => Mage::helper('adminhtml')->__(
67
+ 'Customer Group'
68
+ ),
69
+ 'coupon_code' => Mage::helper('adminhtml')->__('Coupon'),
70
+ 'subtotal' => Mage::helper('adminhtml')->__('Subtotal'),
71
+ 'grand_total' => Mage::helper('adminhtml')->__('Grand Total'),
72
+ 'items_qty' => Mage::helper('adminhtml')->__('Total Qty'),
73
+ 'customer_email' => Mage::helper('adminhtml')->__('Email'),
74
  );
75
  }
76
 
81
  */
82
  public function toOptionArray()
83
  {
84
+ $defaultOptions = $this->defaultOptions();
85
+ $productCondition = Mage::getModel('salesrule/rule_condition_product');
86
+ $productAttributes = $productCondition->loadAttributeOptions()
87
+ ->getAttributeOption();
88
+ $pAttributes = array();
89
+ foreach ($productAttributes as $code => $label) {
90
  if (strpos($code, 'quote_item_') === false) {
91
  $pAttributes[$code] = Mage::helper('adminhtml')->__($label);
92
  }
93
  }
94
  $options = array_merge($defaultOptions, $pAttributes);
95
+
96
  return $options;
97
  }
98
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Value.php CHANGED
@@ -2,75 +2,99 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Value
4
  {
 
5
  /**
6
  * get element type
7
  *
8
  * @param $attribute
 
9
  * @return string
10
  */
11
  public function getValueElementType($attribute)
12
  {
13
  switch ($attribute) {
14
- case 'method': case 'shipping_method': case 'country_id': case 'region_id': case 'customer_group_id':
 
 
 
 
15
  return 'select';
16
  default:
17
- $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attribute);
 
 
18
  if ($attribute->usesSource()) {
19
  return 'select';
20
  }
21
  }
 
22
  return 'text';
23
  }
24
 
25
  /**
26
  * get options array
27
  *
28
- * @param $attribute
29
- * @param bool $is_empty
 
30
  * @return array
31
  * @throws Mage_Core_Exception
32
  */
33
- public function getValueSelectOptions($attribute, $is_empty = false)
34
  {
35
  $options = array();
36
- if($is_empty){
37
  $options = Mage::getModel('adminhtml/system_config_source_yesno')
38
  ->toOptionArray();
 
39
  return $options;
40
  }
41
 
42
  switch ($attribute) {
43
  case 'country_id':
44
- $options = Mage::getModel('adminhtml/system_config_source_country')
 
 
45
  ->toOptionArray();
46
  break;
47
 
48
  case 'region_id':
49
- $options = Mage::getModel('adminhtml/system_config_source_allregion')
 
 
50
  ->toOptionArray();
51
  break;
52
 
53
  case 'shipping_method':
54
- $options = Mage::getModel('adminhtml/system_config_source_shipping_allmethods')
 
 
55
  ->toOptionArray();
56
  break;
57
 
58
  case 'method':
59
- $options = Mage::getModel('adminhtml/system_config_source_payment_allmethods')
 
 
60
  ->toOptionArray();
61
  break;
62
 
63
  case 'customer_group_id':
64
- $options = Mage::getModel('adminhtml/system_config_source_customer_group')
 
 
65
  ->toOptionArray();
66
  break;
67
 
68
  default:
69
- $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attribute);
 
 
70
  if ($attribute->usesSource()) {
71
  $options = $attribute->getSource()->getAllOptions(false);
72
  }
73
  }
 
74
  return $options;
75
  }
76
 
@@ -81,7 +105,9 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Value
81
  */
82
  public function toOptionArray()
83
  {
84
- $options = Mage::getModel('adminhtml/system_config_source_payment_allmethods')
 
 
85
  ->toOptionArray();
86
 
87
  return $options;
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Value
4
  {
5
+
6
  /**
7
  * get element type
8
  *
9
  * @param $attribute
10
+ *
11
  * @return string
12
  */
13
  public function getValueElementType($attribute)
14
  {
15
  switch ($attribute) {
16
+ case 'method':
17
+ case 'shipping_method':
18
+ case 'country_id':
19
+ case 'region_id':
20
+ case 'customer_group_id':
21
  return 'select';
22
  default:
23
+ $attribute = Mage::getSingleton('eav/config')->getAttribute(
24
+ 'catalog_product', $attribute
25
+ );
26
  if ($attribute->usesSource()) {
27
  return 'select';
28
  }
29
  }
30
+
31
  return 'text';
32
  }
33
 
34
  /**
35
  * get options array
36
  *
37
+ * @param $attribute
38
+ * @param bool $isEmpty
39
+ *
40
  * @return array
41
  * @throws Mage_Core_Exception
42
  */
43
+ public function getValueSelectOptions($attribute, $isEmpty = false)
44
  {
45
  $options = array();
46
+ if ($isEmpty) {
47
  $options = Mage::getModel('adminhtml/system_config_source_yesno')
48
  ->toOptionArray();
49
+
50
  return $options;
51
  }
52
 
53
  switch ($attribute) {
54
  case 'country_id':
55
+ $options = Mage::getModel(
56
+ 'adminhtml/system_config_source_country'
57
+ )
58
  ->toOptionArray();
59
  break;
60
 
61
  case 'region_id':
62
+ $options = Mage::getModel(
63
+ 'adminhtml/system_config_source_allregion'
64
+ )
65
  ->toOptionArray();
66
  break;
67
 
68
  case 'shipping_method':
69
+ $options = Mage::getModel(
70
+ 'adminhtml/system_config_source_shipping_allmethods'
71
+ )
72
  ->toOptionArray();
73
  break;
74
 
75
  case 'method':
76
+ $options = Mage::getModel(
77
+ 'adminhtml/system_config_source_payment_allmethods'
78
+ )
79
  ->toOptionArray();
80
  break;
81
 
82
  case 'customer_group_id':
83
+ $options = Mage::getModel(
84
+ 'adminhtml/system_config_source_customer_group'
85
+ )
86
  ->toOptionArray();
87
  break;
88
 
89
  default:
90
+ $attribute = Mage::getSingleton('eav/config')->getAttribute(
91
+ 'catalog_product', $attribute
92
+ );
93
  if ($attribute->usesSource()) {
94
  $options = $attribute->getSource()->getAllOptions(false);
95
  }
96
  }
97
+
98
  return $options;
99
  }
100
 
105
  */
106
  public function toOptionArray()
107
  {
108
+ $options = Mage::getModel(
109
+ 'adminhtml/system_config_source_payment_allmethods'
110
+ )
111
  ->toOptionArray();
112
 
113
  return $options;
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Styling.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Styling
4
  {
 
5
  /**
6
  * Options getter. Styling options
7
  *
@@ -10,7 +11,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Styling
10
  public function toOptionArray()
11
  {
12
  return array(
13
- array('value' => 'nostyle', 'label' => 'No Style'),
14
  array('value' => 'bold', 'label' => 'Bold'),
15
  array('value' => 'italic', 'label' => 'Italic'),
16
  array('value' => 'underline', 'label' => 'Underline')
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Styling
4
  {
5
+
6
  /**
7
  * Options getter. Styling options
8
  *
11
  public function toOptionArray()
12
  {
13
  return array(
14
+ array('value' => 'nostyle', 'label' => 'No Style'),
15
  array('value' => 'bold', 'label' => 'Bold'),
16
  array('value' => 'italic', 'label' => 'Italic'),
17
  array('value' => 'underline', 'label' => 'Underline')
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sweettooth/Yesno.php CHANGED
@@ -11,15 +11,17 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sweettooth_Yesno
11
  public function toOptionArray()
12
  {
13
  $status = Mage::helper('ddg')->isSweetToothEnabled();
14
- if($status){
15
  return array(
16
- array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
17
- array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
 
 
18
  );
19
  }
20
 
21
  return array(
22
- array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
23
  );
24
  }
25
 
11
  public function toOptionArray()
12
  {
13
  $status = Mage::helper('ddg')->isSweetToothEnabled();
14
+ if ($status) {
15
  return array(
16
+ array('value' => 1,
17
+ 'label' => Mage::helper('adminhtml')->__('Yes')),
18
+ array('value' => 0,
19
+ 'label' => Mage::helper('adminhtml')->__('No')),
20
  );
21
  }
22
 
23
  return array(
24
+ array('value' => 0, 'label' => Mage::helper('adminhtml')->__('No')),
25
  );
26
  }
27
 
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Attributes.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Attributes
4
  {
 
5
  /**
6
  * all attributes type catalog
7
  *
@@ -9,20 +10,24 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Attributes
9
  */
10
  public function toOptionArray()
11
  {
12
- $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
 
 
13
  $attributeArray = array();
14
 
15
  //exclude these from showing in the options
16
- $exclude = array('gallery', 'image', 'media_gallery', 'small_image', 'thumbnail');
 
17
 
18
  foreach ($attributes as $attribute) {
19
- if (!in_array($attribute->getData('attribute_code'), $exclude)) {
20
  $attributeArray[] = array(
21
  'label' => $attribute->getData('frontend_label'),
22
  'value' => $attribute->getData('attribute_code')
23
  );
24
  }
25
  }
 
26
  return $attributeArray;
27
  }
28
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Attributes
4
  {
5
+
6
  /**
7
  * all attributes type catalog
8
  *
10
  */
11
  public function toOptionArray()
12
  {
13
+ $attributes = Mage::getResourceModel(
14
+ 'catalog/product_attribute_collection'
15
+ )->addVisibleFilter();
16
  $attributeArray = array();
17
 
18
  //exclude these from showing in the options
19
+ $exclude = array('gallery', 'image', 'media_gallery', 'small_image',
20
+ 'thumbnail');
21
 
22
  foreach ($attributes as $attribute) {
23
+ if ( ! in_array($attribute->getData('attribute_code'), $exclude)) {
24
  $attributeArray[] = array(
25
  'label' => $attribute->getData('frontend_label'),
26
  'value' => $attribute->getData('attribute_code')
27
  );
28
  }
29
  }
30
+
31
  return $attributeArray;
32
  }
33
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Type.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Type
4
  {
 
5
  /**
6
  * Options getter. Styling options
7
  *
@@ -11,6 +12,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Type
11
  {
12
  $options = Mage::getModel('catalog/product_type')->getAllOptions();
13
  array_shift($options);
 
14
  return $options;
15
  }
16
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Type
4
  {
5
+
6
  /**
7
  * Options getter. Styling options
8
  *
12
  {
13
  $options = Mage::getModel('catalog/product_type')->getAllOptions();
14
  array_shift($options);
15
+
16
  return $options;
17
  }
18
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Values.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Values
4
  {
 
5
  /**
6
  * Options getter. Styling options
7
  *
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Values
4
  {
5
+
6
  /**
7
  * Options getter. Styling options
8
  *
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Visibility.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Visibility
4
  {
 
5
  /**
6
  * Options getter. Styling options
7
  *
@@ -9,8 +10,10 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Visibility
9
  */
10
  public function toOptionArray()
11
  {
12
- $options = Mage::getModel('catalog/product_visibility')->getAllOptions();
 
13
  array_shift($options);
 
14
  return $options;
15
  }
16
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Visibility
4
  {
5
+
6
  /**
7
  * Options getter. Styling options
8
  *
10
  */
11
  public function toOptionArray()
12
  {
13
+ $options = Mage::getModel('catalog/product_visibility')->getAllOptions(
14
+ );
15
  array_shift($options);
16
+
17
  return $options;
18
  }
19
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Yesno.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Yesno
4
- {
5
- /**
6
- * Options getter
7
- *
8
- * @return array
9
- */
10
- public function toOptionArray()
11
- {
12
- //get current scope website code, set the code to admin if empty
13
- $websiteCode = (Mage::getSingleton('adminhtml/config_data')->getWebsite())? Mage::getSingleton('adminhtml/config_data')->getWebsite() : 'admin';
14
-
15
- //for current scope website check if entry exist in registry. if not than
16
- //than get account data and store it in registry to re-use
17
- if (! Mage::registry('ddg-account-info-'.$websiteCode)) {
18
- //websites with code as key
19
- $websites = Mage::app()->getWebsites(true, true);
20
- $website = $websites[$websiteCode];
21
-
22
- //if scope is empty or no id than load default
23
- if (empty($website) or !$website->getId())
24
- $website = 0;
25
-
26
- $apiUsername = Mage::helper('ddg')->getApiUsername($website);
27
- $apiPassword = Mage::helper('ddg')->getApiPassword($website);
28
- $data = Mage::getModel('ddg_automation/apiconnector_client')
29
- ->setApiUsername($apiUsername)
30
- ->setApiPassword($apiPassword)
31
- ->getAccountInfo();
32
-
33
- //save entry in registry for current website scope
34
- Mage::register('ddg-account-info-'.$websiteCode, $data);
35
- }
36
-
37
- //get from registry
38
- $data = Mage::registry('ddg-account-info-'.$websiteCode);
39
- //if properties property exist
40
- if (isset($data->properties)) {
41
- $propertyNames = array();
42
- //loop all and save property names
43
- foreach ($data->properties as $one) {
44
- $propertyNames[] = $one->name;
45
- }
46
-
47
- //only return Yes/No option if data allowance properties exist
48
- if(in_array('TransactionalDataAllowanceInMegabytes', $propertyNames) &&
49
- in_array('TransactionalDataUsageInMegabytes', $propertyNames)){
50
- return array(
51
- array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
52
- array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
53
- );
54
- }
55
- }
56
-
57
- //return default message if above is scenarios are failed.
58
- return array(
59
- array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Not enabled on account'))
60
- );
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Mode.php CHANGED
@@ -1,12 +1,13 @@
1
  <?php
 
2
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Mode
3
  {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- 'smtp' => Mage::helper('ddg')->__('SMTP')
8
- //'api' => Mage::helper('ddg')->__('API')
9
- );
10
 
11
- }
 
 
 
 
 
 
12
  }
1
  <?php
2
+
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Mode
4
  {
 
 
 
 
 
 
5
 
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ 'smtp' => Mage::helper('ddg')->__('SMTP')
10
+ );
11
+
12
+ }
13
  }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Port.php CHANGED
@@ -1,15 +1,16 @@
1
  <?php
 
2
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Port
3
  {
4
 
5
- public function toOptionArray()
6
- {
7
- return array(
8
- '25' => Mage::helper('ddg')->__("25"),
9
- '2525' => Mage::helper('ddg')->__("2525"),
10
- '587' => Mage::helper('ddg')->__("587")
11
- );
12
 
13
 
14
- }
15
  }
1
  <?php
2
+
3
  class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Port
4
  {
5
 
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ '25' => Mage::helper('ddg')->__("25"),
10
+ '2525' => Mage::helper('ddg')->__("2525"),
11
+ '587' => Mage::helper('ddg')->__("587")
12
+ );
13
 
14
 
15
+ }
16
  }
app/code/community/Dotdigitalgroup/Email/Model/Api2/Subscriber/Rest/Admin/V1.php CHANGED
@@ -1,111 +1,130 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Api2_Subscriber_Rest_Admin_V1 extends Mage_Api2_Model_Resource
 
4
  {
5
- /**
6
- * Create a subscriber
7
- * @return array
8
- */
9
-
10
- public function _create() {
11
- //Create Subscriber
12
- $requestData = $this->getRequest()->getBodyParams();
13
-
14
- $email = $requestData['subscriber_email'];
15
- //email is set
16
- if ($email) {
17
- try {
18
- $customerId = (isset($requestData['customer_id']))? $requestData['customer_id'] : 0;
19
- $storeId = (isset($requestData['store_id']))? $requestData['store_id'] : 1;
20
- //subscriber status 1- subscribed, 3 - unsubscribed
21
- $status = (isset($requestData['status']))? $requestData['status'] : 3;
22
- //additional data for subscriber
23
- $data = array(
24
- 'subscriber_email' => $email,
25
- 'customer_id' => $customerId,
26
- 'subscriber_status' => $status,
27
- 'store_id' => $storeId
28
- );
29
-
30
- //save subscriber
31
- Mage::getModel('newsletter/subscriber')->setData($data)
32
- ->save();
33
-
34
- }catch (Mage_Api2_Exception $e){
35
- Mage::helper('ddg')->log($e->getMessage());
36
- }catch (Exception $e){
37
- Mage::logException($e);
38
- }
39
-
40
- $json = array('email' => $email);
41
- return json_encode($json);
42
- }
43
-
44
- }
45
-
46
- /**
47
- * Retrieve a subscriber name by email
48
- * @return string
49
- */
50
-
51
- public function _retrieve()
52
- {
53
- $email = $this->getRequest()->getParam('email', false);
54
- if (! $email) {
55
- Mage::helper('ddg')->log('Subscriber id is not set');
56
- return array();
57
- }
58
- try {
59
-
60
- $data = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getData();
61
- return json_encode($data);
62
-
63
- }catch (Mage_Api2_Exception $e){
64
- Mage::helper('ddg')->log($e->getMessage());
65
- }catch (Exception $e){
66
- Mage::logException($e);
67
- }
68
- }
69
-
70
- /**
71
- * Update subscriber data.
72
- * @throws Exception
73
- */
74
- public function _update()
75
- {
76
- //Update Subscriber
77
- $requestData = $this->getRequest()->getBodyParams();
78
-
79
- //check for scubscriber email
80
- if ($email = $requestData['subscriber_email']) {
81
- try {
82
- $customerId = ( isset( $requestData['customer_id'] ) ) ? $requestData['customer_id'] : 0;
83
- $storeId = ( isset( $requestData['store_id'] ) ) ? $requestData['store_id'] : 1;
84
- //subscriber status 1- subscribed, 3 - unsubscribed
85
- $status = ( isset( $requestData['status'] ) ) ? $requestData['status'] : 3;
86
- //additional data for subscriber
87
- $data = array(
88
- 'customer_id' => $customerId,
89
- 'subscriber_status' => $status,
90
- 'store_id' => $storeId
91
- );
92
- //update subscriber
93
- $subscriber = Mage::getModel( 'newsletter/subscriber' )->loadByEmail( $email );
94
- if ( $subscriber->getId() ) {
95
- $subscriber->setCustomerId( $customerId )
96
- ->setSubscriberStatus( $status )
97
- ->setStoreId( $storeId )
98
- ->save();
99
- } else {
100
- Mage::helper( 'ddg' )->log( "REST Subscriber not found : " . $email);
101
- }
102
-
103
- return json_encode( $data );
104
- }catch (Mage_Api2_Exception $e){
105
- Mage::helper('ddg')->log($e->getMessage());
106
- }catch (Exception $e){
107
- Mage::logException($e);
108
- }
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  }
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Api2_Subscriber_Rest_Admin_V1
4
+ extends Mage_Api2_Model_Resource
5
  {
6
+
7
+ /**
8
+ * Create a subscriber
9
+ *
10
+ * @return array
11
+ */
12
+
13
+ public function _create()
14
+ {
15
+ //Create Subscriber
16
+ $requestData = $this->getRequest()->getBodyParams();
17
+
18
+ $email = $requestData['subscriber_email'];
19
+ //email is set
20
+ if ($email) {
21
+ try {
22
+ $customerId = (isset($requestData['customer_id']))
23
+ ? $requestData['customer_id'] : 0;
24
+ $storeId = (isset($requestData['store_id']))
25
+ ? $requestData['store_id'] : 1;
26
+ //subscriber status 1- subscribed, 3 - unsubscribed
27
+ $status = (isset($requestData['status']))
28
+ ? $requestData['status'] : 3;
29
+ //additional data for subscriber
30
+ $data = array(
31
+ 'subscriber_email' => $email,
32
+ 'customer_id' => $customerId,
33
+ 'subscriber_status' => $status,
34
+ 'store_id' => $storeId
35
+ );
36
+
37
+ //save subscriber
38
+ Mage::getModel('newsletter/subscriber')->setData($data)
39
+ ->save();
40
+
41
+ } catch (Mage_Api2_Exception $e) {
42
+ Mage::helper('ddg')->log($e->getMessage());
43
+ } catch (Exception $e) {
44
+ Mage::logException($e);
45
+ }
46
+
47
+ $json = array('email' => $email);
48
+
49
+ return json_encode($json);
50
+ }
51
+
52
+ }
53
+
54
+ /**
55
+ * Retrieve a subscriber name by email
56
+ *
57
+ * @return string
58
+ */
59
+
60
+ public function _retrieve()
61
+ {
62
+ $email = $this->getRequest()->getParam('email', false);
63
+ if ( ! $email) {
64
+ Mage::helper('ddg')->log('Subscriber id is not set');
65
+
66
+ return array();
67
+ }
68
+ try {
69
+
70
+ $data = Mage::getModel('newsletter/subscriber')->loadByEmail($email)
71
+ ->getData();
72
+
73
+ return json_encode($data);
74
+
75
+ } catch (Mage_Api2_Exception $e) {
76
+ Mage::helper('ddg')->log($e->getMessage());
77
+ } catch (Exception $e) {
78
+ Mage::logException($e);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Update subscriber data.
84
+ *
85
+ * @throws Exception
86
+ */
87
+ public function _update()
88
+ {
89
+ //Update Subscriber
90
+ $requestData = $this->getRequest()->getBodyParams();
91
+
92
+ //check for scubscriber email
93
+ if ($email = $requestData['subscriber_email']) {
94
+ try {
95
+ $customerId = (isset($requestData['customer_id']))
96
+ ? $requestData['customer_id'] : 0;
97
+ $storeId = (isset($requestData['store_id']))
98
+ ? $requestData['store_id'] : 1;
99
+ //subscriber status 1- subscribed, 3 - unsubscribed
100
+ $status = (isset($requestData['status']))
101
+ ? $requestData['status'] : 3;
102
+ //additional data for subscriber
103
+ $data = array(
104
+ 'customer_id' => $customerId,
105
+ 'subscriber_status' => $status,
106
+ 'store_id' => $storeId
107
+ );
108
+ //update subscriber
109
+ $subscriber = Mage::getModel('newsletter/subscriber')
110
+ ->loadByEmail($email);
111
+ if ($subscriber->getId()) {
112
+ $subscriber->setCustomerId($customerId)
113
+ ->setSubscriberStatus($status)
114
+ ->setStoreId($storeId)
115
+ ->save();
116
+ } else {
117
+ Mage::helper('ddg')->log(
118
+ "REST Subscriber not found : " . $email
119
+ );
120
+ }
121
+
122
+ return json_encode($data);
123
+ } catch (Mage_Api2_Exception $e) {
124
+ Mage::helper('ddg')->log($e->getMessage());
125
+ } catch (Exception $e) {
126
+ Mage::logException($e);
127
+ }
128
+ }
129
+ }
130
  }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Client.php CHANGED
@@ -1,57 +1,49 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Email_Model_Abstract_Rest
 
4
  {
 
5
  const APICONNECTOR_VERSION = 'V2';
6
 
7
  const REST_WAIT_UPLOAD_TIME = 5;
8
  //rest api data
9
- const REST_ACCOUNT_INFO = 'https://r1-api.dotmailer.com/v2/account-info';
10
- const REST_CONTACTS = '/v2/contacts/';
11
- const REST_CONTACTS_IMPORT = '/v2/contacts/import/';
12
- const REST_ADDRESS_BOOKS = '/v2/address-books/';
13
- const REST_DATA_FILEDS = '/v2/data-fields';
14
- const REST_TRANSACTIONAL_DATA_IMPORT = '/v2/contacts/transactional-data/import/';
15
- const REST_TRANSACTIONAL_DATA = '/v2/contacts/transactional-data/';
16
- const REST_CAMPAIGN_SEND = '/v2/campaigns/send';
17
- const REST_CONTACTS_SUPPRESSED_SINCE = '/v2/contacts/suppressed-since/';
18
- const REST_DATA_FIELDS_CAMPAIGNS = '/v2/campaigns';
19
- const REST_SMS_MESSAGE_SEND_TO = '/v2/sms-messages/send-to/';
20
- const REST_CONTACTS_RESUBSCRIBE = '/v2/contacts/resubscribe';
21
- const REST_CAMPAIGN_FROM_ADDRESS_LIST = '/v2/custom-from-addresses';
22
- const REST_CREATE_CAMPAIGN = '/v2/campaigns';
23
- const REST_PROGRAM = '/v2/programs/';
24
- const REST_PROGRAM_ENROLMENTS = '/v2/programs/enrolments';
25
- const REST_TEMPLATES = '/v2/templates';
26
 
27
  //rest error responces
28
- const API_ERROR_API_EXCEEDED = 'Your account has generated excess API activity and is being temporarily capped. Please contact support. ERROR_APIUSAGE_EXCEEDED';
29
- const API_ERROR_TRANS_ALLOWANCE = 'TransactionalDataAllowanceInMegabytes';
30
- const API_ERROR_EMAIL_NOT_VALID = 'Email is not a valid email address. ERROR_PARAMETER_INVALID';
31
- const API_ERROR_FEATURENOTACTIVE = 'Error: ERROR_FEATURENOTACTIVE';
32
- const API_ERROR_REPORT_NOT_FOUND = 'Import is not processed yet or completed with error. ERROR_IMPORT_REPORT_NOT_FOUND';
33
- const API_ERROR_TRANS_NOT_EXISTS = 'Error: ERROR_TRANSACTIONAL_DATA_DOES_NOT_EXIST';
34
- const API_ERROR_DATAFIELD_EXISTS = 'Field already exists. ERROR_NON_UNIQUE_DATAFIELD';
35
- const API_ERROR_CONTACT_NOT_FOUND = 'Error: ERROR_CONTACT_NOT_FOUND';
36
- const API_ERROR_PROGRAM_NOT_ACTIVE = 'Error: ERROR_PROGRAM_NOT_ACTIVE';
37
- const API_ERROR_ENROLMENT_EXCEEDED = 'Error: ERROR_ENROLMENT_ALLOWANCE_EXCEEDED ';
38
- const API_ERROR_SEND_NOT_PERMITTED = 'Send not permitted at this time. ERROR_CAMPAIGN_SENDNOTPERMITTED';
39
- const API_ERROR_CONTACT_SUPPRESSED = 'Contact is suppressed. ERROR_CONTACT_SUPPRESSED';
40
- const API_ERROR_AUTHORIZATION_DENIED = 'Authorization has been denied for this request.';
41
- const API_ERROR_ADDRESSBOOK_NOT_FOUND = 'Error: ERROR_ADDRESSBOOK_NOT_FOUND';
42
 
43
 
44
  protected $_limit = 10;
45
  public $fileHelper;
46
  protected $_filename;
47
- protected $_api_helper;
48
- protected $_address_book_id;
49
- protected $_customers_filename;
50
- protected $_subscribers_filename;
51
- protected $_customers_address_book_id;
52
- protected $_subscribers_address_book_id;
53
- protected $_customers_file_slug = 'customer_sync';
54
- protected $_subscribers_file_slug = 'subscriber_sync';
55
  public $result = array('error' => false, 'message' => '');
56
  protected $_apiEndpoint;
57
 
@@ -67,20 +59,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
67
 
68
  protected function _checkApiEndPoint()
69
  {
70
- $apiEndpoint = Mage::helper('ddg')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT);
71
- if(!$apiEndpoint){
 
 
72
  $helper = Mage::helper('ddg');
73
  $this->setApiUsername($helper->getApiUsername())
74
  ->setApiPassword($helper->getApiPassword());
75
 
76
  $accountInfo = $this->getAccountInfo();
77
  //check if returned value is an object
78
- if(is_object($accountInfo) && !isset($accountInfo->message)){
79
  //save endpoint for account
80
- foreach($accountInfo->properties as $property){
81
- if($property->name == 'ApiEndpoint' && strlen($property->value)){
 
 
 
 
82
  $apiEndpoint = $property->value;
83
- $config = Mage::getConfig();
84
  $config->saveConfig(
85
  Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
86
  $property->value
@@ -92,8 +90,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
92
  }
93
 
94
  //check api endpoint again
95
- if(!$apiEndpoint)
96
- throw new Exception('API endpoint cannot be empty. Re-save api credentials to retrieve API endpoint.');
 
 
 
 
 
 
97
  }
98
 
99
  $this->_apiEndpoint = $apiEndpoint;
@@ -101,23 +105,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
101
 
102
  /**
103
  * Excluded api response that we don't want to send.
 
104
  * @var array
105
  */
106
- public $exludeMessages = array(
107
- self::API_ERROR_FEATURENOTACTIVE,
108
- self::API_ERROR_PROGRAM_NOT_ACTIVE,
109
- self::API_ERROR_CONTACT_SUPPRESSED,
110
- self::API_ERROR_DATAFIELD_EXISTS,
111
- self::API_ERROR_AUTHORIZATION_DENIED,
112
- self::API_ERROR_ENROLMENT_EXCEEDED,
113
- self::API_ERROR_SEND_NOT_PERMITTED,
114
- self::API_ERROR_TRANS_NOT_EXISTS,
115
- self::API_ERROR_ADDRESSBOOK_NOT_FOUND
116
- );
 
117
 
118
  /**
119
  * @param $apiUsername
120
  * @param $apiPassword
 
121
  * @return bool|mixed
122
  */
123
  public function validate($apiUsername, $apiPassword)
@@ -128,18 +135,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
128
  $accountInfo = $this->getAccountInfo();
129
 
130
  if (isset($accountInfo->message)) {
131
- Mage::getSingleton('adminhtml/session')->addError($accountInfo->message);
 
 
132
  $message = 'VALIDATION ERROR : ' . $accountInfo->message;
133
  Mage::helper('ddg')->log($message);
 
134
  return false;
135
  }
 
136
  return $accountInfo;
137
  }
 
138
  return false;
139
  }
 
140
  /**
141
  * Gets a contact by ID. Unsubscribed or suppressed contacts will not be retrieved.
 
142
  * @param $id
 
143
  * @return null
144
  */
145
  public function getContactById($id)
@@ -149,9 +164,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
149
  ->setVerb('GET');
150
  $response = $this->execute();
151
 
152
- if(isset($response->message)) {
153
- $message = 'GET CONTACT INFO ID ' . $url . ', ' . $response->message;
154
- Mage::helper( 'ddg' )->log( $message );
 
155
  }
156
 
157
  return $response;
@@ -161,36 +177,49 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
161
  * Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
162
  * Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
163
  * The ID of returned object can be used to query import progress.
 
164
  * @param $filename
165
  * @param $addressBookId
 
166
  * @return mixed
167
  */
168
 
169
  public function postAddressBookContactsImport($filename, $addressBookId)
170
  {
171
- $url = $this->_apiEndpoint . "/v2/address-books/{$addressBookId}/contacts/import";
 
172
  $helper = Mage::helper('ddg');
173
 
174
  $ch = curl_init($url);
175
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
176
- curl_setopt($ch, CURLOPT_USERPWD, $this->getApiUsername() . ':' . $this->getApiPassword());
 
 
 
177
 
178
  //case the deprication of @filename for uploading
179
  if (function_exists('curl_file_create')) {
180
  curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
181
- $args['file'] = curl_file_create(Mage::helper('ddg/file')->getFilePath($filename), 'text/csv');
 
 
182
  curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
183
 
184
  } else {
185
  //standart use of curl file
186
- curl_setopt($ch, CURLOPT_POSTFIELDS, array (
187
- 'file' => '@'.Mage::helper('ddg/file')->getFilePath($filename)
188
- ));
 
 
 
 
189
  }
190
 
191
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
192
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
193
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 
194
  'Content-Type: multipart/form-data')
195
  );
196
 
@@ -198,40 +227,50 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
198
  $result = curl_exec($ch);
199
 
200
  //if curl error found
201
- if(curl_errno($ch))
202
- {
203
  //save the error
204
  $this->curlError = curl_error($ch);
205
  }
206
 
207
  $result = json_decode($result);
208
  if (isset($result->message)) {
209
- $message = 'POST ADDRESS BOOK ' . $addressBookId . ', CONTACT IMPORT : ' . ' filename ' . $filename . ' Username ' . $this->getApiUsername() . $result->message;
 
 
210
  $helper->log($message);
211
  Mage::helper('ddg')->log($result)
212
  ->rayLog($result->message);
213
  }
 
214
  return $result;
215
  }
216
 
217
  /**
218
  * Adds a contact to a given address book.
 
219
  * @param $addressBookId
220
  * @param $apiContact
 
221
  * @return mixed|null
222
  */
223
  public function postAddressBookContacts($addressBookId, $apiContact)
224
  {
225
- $url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId . '/contacts';
 
226
  $this->setUrl($url)
227
  ->setVerb("POST")
228
  ->buildPostBody($apiContact);
229
 
230
  $response = $this->execute();
231
 
232
- //log the error
233
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
234
- $message = 'POST ADDRESS BOOK CONTACTS ' . $url . ', ' . $response->message;
 
 
 
 
 
235
  Mage::helper('ddg')->log($message)
236
  ->rayLog($response->message);
237
  }
@@ -241,14 +280,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
241
 
242
  /**
243
  * Deletes all contacts from a given address book.
 
244
  * @param $addressBookId
245
  * @param $contactId
 
246
  * @return null
247
  */
248
  public function deleteAddressBookContact($addressBookId, $contactId)
249
  {
250
 
251
- $url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId . '/contacts/' . $contactId;
 
252
  $this->setUrl($url)
253
  ->setVerb('DELETE');
254
 
@@ -257,27 +299,38 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
257
 
258
  /**
259
  * Gets a report with statistics about what was successfully imported, and what was unable to be imported.
 
260
  * @param $importId
 
261
  * @return mixed
262
  */
263
  public function getContactsImportReport($importId)
264
  {
265
- $url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $importId . "/report";
 
266
  $this->setUrl($url)
267
  ->setVerb('GET');
268
  $response = $this->execute();
269
  //log error
270
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
271
- $message = 'GET CONTACTS IMPORT REPORT . ' . $url . ' message : ' . $response->message;
272
- Mage::helper( 'ddg' )->log( $message )
273
- ->rayLog( $response->message);
 
 
 
 
 
274
  }
 
275
  return $response;
276
  }
277
 
278
  /**
279
  * Gets a contact by email address.
 
280
  * @param $email
 
281
  * @return mixed
282
  */
283
  public function getContactByEmail($email)
@@ -288,11 +341,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
288
 
289
  $response = $this->execute();
290
 
291
- //log error
292
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
293
- $message = 'GET CONTACT BY email : ' . $email . ' ' . $response->message;
 
 
 
 
 
294
  Mage::helper('ddg')->log($message)
295
- ->rayLog($response->message);
296
  }
297
 
298
  return $response;
@@ -300,6 +358,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
300
 
301
  /**
302
  * Get all address books.
 
303
  * @return null
304
  */
305
  public function getAddressBooks()
@@ -309,9 +368,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
309
  ->setVerb("GET");
310
 
311
  $response = $this->execute();
312
- //log error
313
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
314
- $message = 'GET ALL ADDRESS BOOKS : ' . $url . ', ' . $response->message;
 
 
 
 
 
315
  Mage::helper('ddg')->log($message)
316
  ->rayLog($response->message);
317
  }
@@ -321,6 +385,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
321
 
322
  /**
323
  * Gets an address book by ID.
 
324
  * @param $id
325
  *
326
  * @return null
@@ -336,7 +401,9 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
336
  $response = $this->execute();
337
 
338
  if (isset($response->message)) {
339
- Mage::helper('ddg')->log('GET ADDRESS BOOK BY ID '. $id . ', ' . $response->message);
 
 
340
  }
341
 
342
  return $response;
@@ -344,26 +411,33 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
344
 
345
  /**
346
  * Creates an address book.
 
347
  * @param $name
 
348
  * @return null
349
  */
350
  public function postAddressBooks($name, $visibility = 'Public')
351
  {
352
  $data = array(
353
- 'Name' => $name,
354
  'Visibility' => $visibility
355
  );
356
- $url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS;
357
  $this->setUrl($url)
358
  ->setVerb('POST')
359
  ->buildPostBody($data);
360
 
361
  $response = $this->execute();
362
  //log error
363
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
364
- $message = 'Postaddressbooks ' . $response->message . ', url :' . $url ;
 
 
 
 
 
365
  Mage::helper('ddg')->log($message)
366
- ->rayLog($response->message);
367
  }
368
 
369
  return $response;
@@ -371,6 +445,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
371
 
372
  /**
373
  * Get list of all campaigns.
 
374
  * @return mixed
375
  */
376
  public function getCampaigns()
@@ -380,11 +455,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
380
  ->setVerb('GET');
381
 
382
  $response = $this->execute();
383
- //log error
384
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
385
- $message = 'GET CAMPAIGNS ' . $response->message . ' api user : ' . $this->getApiUsername();
 
 
 
 
 
386
  Mage::helper('ddg')->log($message)
387
- ->rayLog($response->message);
388
  }
389
 
390
  return $response;
@@ -392,36 +472,45 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
392
 
393
  /**
394
  * Creates a data field within the account.
395
- * @param $data string/array
396
- * @param string $type string, numeric, date, boolean
 
397
  * @param string $visibility public, private
398
- * @param bool $defaultValue
 
399
  * @return mixed
400
  */
401
- public function postDataFields($data, $type = 'String', $visibility = 'public', $defaultValue = false)
402
- {
 
403
  $url = $this->_apiEndpoint . self::REST_DATA_FILEDS;
404
  //set default value for the numeric datatype
405
- if($type == 'numeric' && !$defaultValue)
406
  $defaultValue = 0;
 
407
  //set data for the string datatype
408
  if (is_string($data)) {
409
  $data = array(
410
- 'Name' => $data,
411
- 'Type' => $type,
412
  'Visibility' => $visibility
413
  );
414
  //default value
415
- if($defaultValue)
416
  $data['DefaultValue'] = $defaultValue;
 
417
  }
418
  $this->setUrl($url)
419
  ->buildPostBody($data)
420
  ->setVerb('POST');
421
 
422
  $response = $this->execute();
423
- //log error
424
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
425
  $message = 'POST CREATE DATAFIELDS ' . $response->message;
426
  Mage::helper('ddg')->log($message)
427
  ->log($data)
@@ -433,6 +522,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
433
 
434
  /**
435
  * Deletes a data field within the account.
 
436
  * @param $name
437
  *
438
  * @return mixed
@@ -445,8 +535,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
445
 
446
  $response = $this->execute();
447
  //log error
448
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
449
- $message = 'DELETE DATA FIELD :' . $name . ' ' . $response->message;
 
 
 
 
450
  Mage::helper('ddg')->log($message)
451
  ->rayLog($response->message);
452
  }
@@ -456,6 +550,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
456
 
457
  /**
458
  * Lists the data fields within the account.
 
459
  * @return mixed
460
  */
461
  public function getDataFields()
@@ -465,8 +560,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
465
  ->setVerb('GET');
466
 
467
  $response = $this->execute();
468
- //log error
469
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
470
  $message = 'GET ALL DATAFIELDS ' . $response->message;
471
  Mage::helper('ddg')->log($message)
472
  ->rayLog($response->message);
@@ -477,8 +576,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
477
 
478
  /**
479
  * Updates a contact.
 
480
  * @param $contactId
481
  * @param $data
 
482
  * @return object
483
  */
484
  public function updateContact($contactId, $data)
@@ -489,9 +590,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
489
  ->buildPostBody($data);
490
 
491
  $response = $this->execute();
492
- //log error
493
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
494
- $message = 'ERROR : UPDATE SINGLE CONTACT : ' . $url . ' message : ' . $response->message;
 
 
 
 
 
495
  Mage::helper('ddg')->log($message)
496
  ->log($data)
497
  ->rayLog($response->message);
@@ -502,7 +608,9 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
502
 
503
  /**
504
  * Deletes a contact.
 
505
  * @param $contactId
 
506
  * @return null
507
  */
508
  public function deleteContact($contactId)
@@ -512,17 +620,23 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
512
  ->setVerb('DELETE');
513
 
514
  $response = $this->execute();
515
- //log error
516
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
517
  $message = 'DELETE CONTACT : ' . $url . ', ' . $response->message;
518
  Mage::helper('ddg')->log($message)
519
  ->rayLog($response->message);
520
  }
 
521
  return $response;
522
  }
523
 
524
  /**
525
  * Update contact datafields by email.
 
526
  * @param $email
527
  * @param $dataFields
528
  *
@@ -533,25 +647,31 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
533
  {
534
  $apiContact = $this->postContacts($email);
535
  //do not create for non contact id set
536
- if (! isset($apiContact->id)) {
537
  return $apiContact;
538
  } else {
539
  //get the contact id for this email
540
  $contactId = $apiContact->id;
541
  }
542
- $data = array(
543
- 'Email' => $email,
544
  'EmailType' => 'Html');
545
  $data['DataFields'] = $dataFields;
546
- $url = $this->_apiEndpoint . self::REST_CONTACTS . $contactId;
 
547
  $this->setUrl($url)
548
  ->setVerb('PUT')
549
  ->buildPostBody($data);
550
 
551
  $response = $this->execute();
552
- //log error
553
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
554
- $message = 'ERROR: UPDATE CONTACT DATAFIELD ' . $url . ' message : ' . $response->message;
 
 
 
 
 
555
  Mage::helper('ddg')->log($message)
556
  ->log($data)
557
  ->rayLog($response->message);
@@ -563,15 +683,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
563
  /**
564
  * Sends a specified campaign to one or more address books, segments or contacts at a specified time.
565
  * Leave the address book array empty to send to All Contacts.
 
566
  * @param $campaignId
567
  * @param $contacts
 
568
  * @return mixed
569
  */
570
  public function postCampaignsSend($campaignId, $contacts)
571
  {
572
  $data = array(
573
- 'username' => $this->getApiUsername(),
574
- 'password' => $this->getApiPassword(),
575
  "campaignId" => $campaignId,
576
  "ContactIds" => $contacts
577
  );
@@ -580,9 +702,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
580
  ->buildPostBody($data);
581
 
582
  $response = $this->execute();
583
- //log error
584
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
585
- $message = 'SENDING CAMPAIGN ' . $response->message;
 
 
 
 
586
  Mage::helper('ddg')->log($message)
587
  ->log($data)
588
  ->rayLog($response->message);
@@ -593,21 +719,27 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
593
 
594
  /**
595
  * Creates a contact.
 
596
  * @param $email
 
597
  * @return mixed
598
  */
599
  public function postContacts($email)
600
  {
601
- //validate email before creating a contact
602
- $valid = preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email);
603
- if (! $valid) {
604
- $object = new stdClass();
605
- return $object->message = 'Not valid email :' . $email;
606
- }
607
-
608
- $url = $this->_apiEndpoint . self::REST_CONTACTS;
 
 
 
 
609
  $data = array(
610
- 'Email' => $email,
611
  'EmailType' => 'Html',
612
  );
613
  $this->setUrl($url)
@@ -615,9 +747,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
615
  ->buildPostBody($data);
616
 
617
  $response = $this->execute();
618
- //log error
619
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
620
- $message = 'CREATE A NEW CONTACT : ' . $response->message;
 
 
 
 
621
  Mage::helper('ddg')->log($message)
622
  ->rayLog($response->message);
623
  }
@@ -628,21 +764,31 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
628
 
629
  /**
630
  * Gets a list of suppressed contacts after a given date along with the reason for suppression.
 
631
  * @param $dateString
632
  * @param $select
633
  * @param $skip
 
634
  * @return object
635
  */
636
- public function getContactsSuppressedSinceDate($dateString, $select = 1000, $skip = 0)
637
- {
638
- $url = $this->_apiEndpoint . self::REST_CONTACTS_SUPPRESSED_SINCE . $dateString . '?select=' . $select . '&skip=' . $skip;
 
 
639
  $this->setUrl($url)
640
  ->setVerb("GET");
641
 
642
  $response = $this->execute();
643
- //log error
644
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
645
- $message = 'GET CONTACTS SUPPRESSED SINSE : ' . $dateString . ' select ' . $select . ' skip : ' . $skip . ' response : ' . $response->message;
 
 
 
 
 
 
646
  Mage::helper('ddg')->log($message)
647
  ->rayLog($response->message);
648
  }
@@ -652,30 +798,38 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
652
 
653
  /**
654
  * Adds multiple pieces of transactional data to contacts asynchronously, returning an identifier that can be used to check for import progress.
 
655
  * @param $collectionName
656
  * @param $transactionalData
 
657
  * @return object
658
  */
659
- public function postContactsTransactionalDataImport($transactionalData, $collectionName = 'Orders')
660
- {
 
661
  $orders = array();
662
  foreach ($transactionalData as $one) {
663
  if (isset($one->email)) {
664
  $orders[] = array(
665
- 'Key' => $one->id,
666
  'ContactIdentifier' => $one->email,
667
- 'Json' => json_encode($one)
668
  );
669
  }
670
  }
671
- $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT . $collectionName;
 
672
  $this->setURl($url)
673
  ->setVerb('POST')
674
  ->buildPostBody($orders);
675
 
676
  $response = $this->execute();
677
- // log error
678
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
679
  $message = ' SEND MULTI TRANSACTIONAL DATA ' . $response->message;
680
  Mage::helper('ddg')->log($message)
681
  ->rayLog($response->message);
@@ -687,33 +841,45 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
687
  /**
688
  * Adds a single piece of transactional data to a contact.
689
  *
690
- * @param $data
691
  * @param string $collectionName
692
  *
693
  * @return null
694
  * @throws Exception
695
  */
696
- public function postContactsTransactionalData($data, $collectionName = 'Orders')
697
- {
698
- $order = $this->getContactsTransactionalDataByKey($collectionName, $data->id);
699
- if(isset($order->message) && $order->message == self::API_ERROR_TRANS_NOT_EXISTS){
700
- $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA . $collectionName;
701
- }else{
702
- $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA . $collectionName . '/' . $order->key ;
 
 
 
 
 
 
 
703
  }
704
  $apiData = array(
705
- 'Key' => $data->id,
706
  'ContactIdentifier' => $data->email,
707
- 'Json' => json_encode($data->expose())
708
  );
709
 
710
  $this->setUrl($url)
711
  ->setVerb('POST')
712
  ->buildPostBody($apiData);
713
  $response = $this->execute();
714
- //log error
715
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
716
- $message = 'POST CONTACTS TRANSACTIONAL DATA ' . $response->message;
 
 
 
 
 
717
  Mage::helper('ddg')->log($message)
718
  ->log($apiData)
719
  ->rayLog($response->message);
@@ -724,13 +890,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
724
 
725
  /**
726
  * Gets a piece of transactional data by key.
 
727
  * @param $name
728
  * @param $key
 
729
  * @return null
730
  */
731
  public function getContactsTransactionalDataByKey($name, $key)
732
  {
733
- $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA . $name . '/' . $key;
 
734
  $this->setUrl($url)
735
  ->setVerb('GET');
736
 
@@ -739,13 +908,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
739
 
740
  /**
741
  * Deletes all transactional data for a contact.
742
- * @param $email
 
743
  * @param string $collectionName
 
744
  * @return object
745
  */
746
- public function deleteContactTransactionalData($email, $collectionName = 'Orders')
747
- {
748
- $url = $this->_apiEndpoint . '/v2/contacts/' . $email . '/transactional-data/' . $collectionName ;
 
 
749
  $this->setUrl($url)
750
  ->setVerb('DELETE');
751
 
@@ -754,6 +927,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
754
 
755
  /**
756
  * Gets a summary of information about the current status of the account.
 
757
  * @return mixed
758
  */
759
  public function getAccountInfo()
@@ -763,34 +937,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
763
  ->setVerb('GET');
764
 
765
  $response = $this->execute();
766
- //log error
767
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
768
- $message = 'GET ACCOUNT INFO for api user : ' . $this->getApiUsername() . ' ' . $response->message;
769
- Mage::helper('ddg')->log($message)
770
- ->rayLog($response->message);
771
- }
772
-
773
- return $response;
774
- }
775
-
776
- /**
777
- * Send a single SMS message.
778
- * @param $telephoneNumber
779
- * @param $message
780
- * @return object
781
- */
782
- public function postSmsMessagesSendTo($telephoneNumber, $message)
783
- {
784
- $data = array('Message' => $message);
785
- $url = $this->_apiEndpoint . self::REST_SMS_MESSAGE_SEND_TO . $telephoneNumber;
786
- $this->setUrl($url)
787
- ->setVerb('POST')
788
- ->buildPostBody($data);
789
-
790
- $response = $this->execute();
791
- //log error
792
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
793
- $message = 'POST SMS MESSAGE SEND to ' . $telephoneNumber . ' message: ' . $message . ' error: ' . $response->message;
794
  Mage::helper('ddg')->log($message)
795
  ->rayLog($response->message);
796
  }
@@ -798,25 +952,32 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
798
  return $response;
799
  }
800
 
801
-
802
  /**
803
  * Deletes multiple contacts from an address book.
 
804
  * @param $addressBookId
805
  * @param $contactIds
 
806
  * @return object
807
  */
808
  public function deleteAddressBookContactsInbulk($addressBookId, $contactIds)
809
  {
810
- $url = $this->_apiEndpoint . '/v2/address-books/' . $addressBookId . '/contacts/inbulk';
 
811
  $data = array('ContactIds' => array($contactIds[0]));
812
  $this->setUrl($url)
813
  ->setVerb('DELETE')
814
  ->buildPostBody($data);
815
 
816
  $response = $this->execute();
817
- //log error
818
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
819
- $message = 'DELETE BULK ADDRESS BOOK CONTACTS ' . $response->message . ' address book ' . $addressBookId;
 
 
 
 
 
820
  Mage::helper('ddg')->log($message)
821
  ->rayLog($response->message);
822
  }
@@ -824,17 +985,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
824
  return $response;
825
  }
826
 
827
- /**
828
- * Resubscribes a previously unsubscribed contact.
829
- *
830
- * @param $apiContact
831
- *
832
- * @return null
833
- * @throws Exception
834
- */
835
  public function postContactsResubscribe($apiContact)
836
  {
837
- $url = $this->_apiEndpoint . self::REST_CONTACTS_RESUBSCRIBE;
838
  $data = array(
839
  'UnsubscribedContact' => $apiContact
840
  );
@@ -844,13 +1005,19 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
844
 
845
  $response = $this->execute();
846
  //log error
847
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
848
- $message = 'Resubscribe : ' . $url . ', message :' . $response->message;
 
 
 
 
 
849
  Mage::helper('ddg')->log($message)
850
  ->log($data)
851
  ->rayLog($response->message);
852
  }
853
- return $response;
 
854
  }
855
 
856
  /**
@@ -867,9 +1034,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
867
  ->setVerb('GET');
868
 
869
  $response = $this->execute();
870
- //log error
871
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
872
- $message = 'GET CampaignFromAddressList ' . $response->message . ' api user : ' . $this->getApiUsername();
 
 
 
 
 
873
  Mage::helper('ddg')->log($message)
874
  ->rayLog($response->message);
875
  }
@@ -877,14 +1049,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
877
  return $response;
878
  }
879
 
880
- /**
881
- * Creates a campaign.
882
- *
883
- * @param $data
884
- *
885
- * @return null
886
- * @throws Exception
887
- */
888
  public function postCampaign($data)
889
  {
890
  $url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN;
@@ -893,8 +1065,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
893
  ->buildPostBody($data);
894
 
895
  $response = $this->execute();
896
- //log error
897
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
898
  $message = ' CREATE CAMPAIGN ' . $response->message;
899
  Mage::helper('ddg')->log($message)
900
  ->rayLog($response->message);
@@ -915,10 +1091,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
915
  ->setVerb('GET');
916
 
917
  $response = $this->execute();
918
- //log error
919
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
920
- $message = 'Get programmes : ' . $response->message ;
921
- Mage::helper( 'ddg' )->log($message)
 
 
 
 
922
  ->rayLog($response->message);
923
  }
924
 
@@ -927,6 +1107,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
927
 
928
  /**
929
  * Creates an enrolment.
 
930
  * @param $data
931
  *
932
  * @return null
@@ -940,8 +1121,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
940
  ->buildPostBody($data);
941
 
942
  $response = $this->execute();
943
- //log error
944
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
945
  $message = 'Post programs enrolments : ' . $response->message;
946
  Mage::helper('ddg')->log($message)
947
  ->log($data)
@@ -953,20 +1138,25 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
953
 
954
  /**
955
  * Gets a program by id.
 
956
  * @param $id
957
  *
958
  * @return null
959
  * @throws Exception
960
  */
961
- public function getProgramById( $id )
962
  {
963
- $url = $this->_apiEndpoint . self::REST_PROGRAM . $id;
964
  $this->setUrl($url)
965
  ->setVerb('GET');
966
 
967
  $response = $this->execute();
968
- //log error
969
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
970
  $message = 'Get program by id ' . $id . ', ' . $response->message;
971
  Mage::helper('ddg')->log($message)
972
  ->rayLog($response->message);
@@ -977,6 +1167,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
977
 
978
  /**
979
  * Gets a summary of reporting information for a specified campaign.
 
980
  * @param $campaignId
981
  *
982
  * @return null
@@ -984,15 +1175,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
984
  */
985
  public function getCampaignSummary($campaignId)
986
  {
987
- $url = $this->_apiEndpoint . '/v2/campaigns/' . $campaignId . '/summary';
 
988
 
989
  $this->setUrl($url)
990
  ->setVerb('GET');
991
  $response = $this->execute();
992
- //log error
993
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
994
- $message = 'Get Campaign Summary ' . $response->message . ' ,url : ' . $url;
995
- Mage::helper('ddg')->log( $message )
 
 
 
 
 
996
  ->rayLog($response->message);
997
  }
998
 
@@ -1001,25 +1198,34 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1001
 
1002
  /**
1003
  * Deletes a piece of transactional data by key.
1004
- * @param $key
 
1005
  * @param string $collectionName
 
1006
  * @return object
1007
  */
1008
- public function deleteContactsTransactionalData($key, $collectionName = 'Orders')
1009
- {
1010
- $url = $this->_apiEndpoint . '/v2/contacts/transactional-data/' . $collectionName .'/' . $key ;
 
 
1011
  $this->setUrl($url)
1012
  ->setVerb('DELETE');
1013
  $response = $this->execute();
1014
 
1015
- if (isset($response->message))
1016
- Mage::helper('ddg')->log('DELETE CONTACTS TRANSACTIONAL DATA : ' . $url . ' ' . $response->message);
 
 
 
 
1017
 
1018
  return $response;
1019
  }
1020
 
1021
  /**
1022
  * Adds a document to a campaign as an attachment.
 
1023
  * @param $campaignId
1024
  * @param $data
1025
  *
@@ -1028,42 +1234,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1028
  */
1029
  public function postCampaignAttachments($campaignId, $data)
1030
  {
1031
- $url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN . "/$campaignId/attachments";
 
1032
  $this->setURl($url)
1033
  ->setVerb('POST')
1034
  ->buildPostBody($data);
1035
  $result = $this->execute();
1036
 
1037
  if (isset($result->message)) {
1038
- Mage::helper('ddg')->log(' CAMPAIGN ATTACHMENT ' . $result->message);
1039
- }
1040
- return $result;
1041
- }
1042
-
1043
-
1044
- public function getNostoProducts($slotName, $email)
1045
- {
1046
- $recommended = Dotdigitalgroup_Email_Helper_Config::API_ENDPOINT . '/recommendations/email';
1047
- $token = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_NOSTO);
1048
-
1049
- //check for strin length
1050
- if (strlen($slotName) > 1 && strlen($email) > 1) {
1051
-
1052
- $recommended .= '?elements=' . $slotName;
1053
- $recommended .= '&emails=' . $email;
1054
- }
1055
-
1056
- $this->setApiUsername('')
1057
- ->setApiPassword($token)
1058
- ->setUrl($recommended)
1059
- ->setVerb('GET');
1060
-
1061
- $result = $this->execute();
1062
-
1063
- if (isset($result->message)) {
1064
- $message = $result->message;
1065
- Mage::helper('ddg')->log($message);
1066
- Mage::helper('ddg')->log("Nosto recommendation slot name : $slotName , email : $email");
1067
  }
1068
 
1069
  return $result;
@@ -1073,18 +1254,25 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1073
  * get contact address books
1074
  *
1075
  * @param $contactId
 
1076
  * @return object
1077
  * @throws Exception
1078
  */
1079
  public function getContactAddressBooks($contactId)
1080
  {
1081
- $url = $this->_apiEndpoint . '/v2/contacts/' . $contactId . '/address-books' ;
 
1082
  $this->setUrl($url)
1083
  ->setVerb('GET');
1084
  $response = $this->execute();
1085
- //log error
1086
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1087
- $message = 'GET CONTACTS ADDRESS BOOKS contact: ' . $contactId . $response->message;
 
 
 
 
 
1088
  Mage::helper('ddg')->log($message)
1089
  ->rayLog($response->message);
1090
  }
@@ -1100,17 +1288,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1100
  */
1101
  public function getApiTemplateList()
1102
  {
1103
- $url = $this->_apiEndpoint . self::REST_TEMPLATES;
1104
  $this->setUrl($url)
1105
  ->setVerb('GET');
1106
 
1107
- $response = $this->execute();
1108
 
1109
- //log error
1110
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1111
- $message = 'GET API CONTACT LIST ' . $response->message;
 
 
 
 
1112
  Mage::helper('ddg')->log($message)
1113
- ->rayLog($response->message);
1114
  }
1115
 
1116
  return $response;
@@ -1120,19 +1312,24 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1120
  * Gets a template by ID.
1121
  *
1122
  * @param $templateId
 
1123
  * @return object
1124
  * @throws Exception
1125
  */
1126
  public function getApiTemplate($templateId)
1127
  {
1128
- $url = $this->_apiEndpoint . self::REST_TEMPLATES . '/' . $templateId;
1129
  $this->setUrl($url)
1130
  ->setVerb('GET');
1131
 
1132
  $response = $this->execute();
1133
- //log error
1134
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1135
- $message = 'GET API CONTACT LIST ' . $response->message;
 
 
 
 
1136
  Mage::helper('ddg')->log($message)
1137
  ->rayLog($response->message);
1138
  }
@@ -1142,31 +1339,40 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1142
 
1143
  /**
1144
  * Adds multiple pieces of transactional data to account asynchronously, returning an identifier that can be used to check for import progress.
 
1145
  * @param $collectionName
1146
  * @param $transactionalData
 
1147
  * @return object
1148
  */
1149
- public function postAccountTransactionalDataImport($transactionalData, $collectionName = 'Catalog_Default')
1150
- {
 
1151
  $orders = array();
1152
  foreach ($transactionalData as $one) {
1153
  if (isset($one->id)) {
1154
  $orders[] = array(
1155
- 'Key' => $one->id,
1156
  'ContactIdentifier' => 'account',
1157
- 'Json' => json_encode($one->expose())
1158
  );
1159
  }
1160
  }
1161
- $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT . $collectionName;
 
1162
  $this->setURl($url)
1163
  ->setVerb('POST')
1164
  ->buildPostBody($orders);
1165
 
1166
  $response = $this->execute();
1167
- //log error
1168
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1169
- $message = ' SEND MULTI TRANSACTIONAL DATA TO ACCOUNT' . $response->message;
 
 
 
 
 
1170
  Mage::helper('ddg')->log($message)
1171
  ->rayLog($response->message);
1172
  }
@@ -1176,15 +1382,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1176
 
1177
  public function getCampaignsWithActivitySinceDate($dateTime)
1178
  {
1179
- $url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS . '/with-activity-since/' . $dateTime;
 
1180
 
1181
  $this->setUrl($url)
1182
  ->setVerb('GET');
1183
 
1184
  $response = $this->execute();
1185
- //log error
1186
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1187
- $message = 'GET CAMPAIGNS WITH ACTIVITY SINCE DATE ' . $response->message;
 
 
 
 
 
1188
  Mage::helper('ddg')->log($message)
1189
  ->rayLog($response->message);
1190
  }
@@ -1194,15 +1406,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1194
 
1195
  public function getCampaignActivityByContactId($campaignId, $contactId)
1196
  {
1197
- $url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS . '/' . $campaignId . '/activities/' . $contactId;
 
1198
 
1199
  $this->setUrl($url)
1200
  ->setVerb('GET');
1201
 
1202
  $response = $this->execute();
1203
- //log error
1204
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1205
- $message = 'GET CAMPAIGN ACTIVITY BY CONTACT ID ' . $response->message;
 
 
 
 
 
1206
  Mage::helper('ddg')->log($message)
1207
  ->rayLog($response->message);
1208
  }
@@ -1214,6 +1432,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1214
  * Gets the import status of a previously started contact import.
1215
  *
1216
  * @param $importId
 
1217
  * @return object
1218
  */
1219
  public function getContactsImportByImportId($importId)
@@ -1223,9 +1442,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1223
  $this->setUrl($url)
1224
  ->setVerb('GET');
1225
 
1226
- $response = $this->execute();
1227
  //log error
1228
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
 
 
 
 
1229
  $message = 'GET CONTACTS IMPORT BY IMPORT ID ' . $response->message;
1230
  Mage::helper('ddg')->log($message)
1231
  ->rayLog($response->message);
@@ -1238,19 +1461,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1238
  * Gets the import status of a previously started transactional import.
1239
  *
1240
  * @param $importId
 
1241
  * @return object
1242
  */
1243
  public function getContactsTransactionalDataImportByImportId($importId)
1244
  {
1245
- $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT . $importId;
 
1246
 
1247
  $this->setUrl($url)
1248
  ->setVerb('GET');
1249
 
1250
- $response = $this->execute();
1251
- //log error
1252
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1253
- $message = 'GET CONTACTS TRANSACTIONAL DATA IMPORT BY IMPORT ID ' . $response->message;
 
 
 
 
 
1254
  Mage::helper('ddg')->log($message)
1255
  ->rayLog($response->message);
1256
  }
@@ -1262,12 +1492,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1262
  * get contact import report faults
1263
  *
1264
  * @param $id
 
1265
  * @return bool|null
1266
  * @throws Exception
1267
  */
1268
  public function getContactImportReportFaults($id)
1269
  {
1270
- $url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $id . '/report-faults';
 
1271
  $this->setUrl($url)
1272
  ->setVerb('GET');
1273
 
@@ -1275,13 +1507,19 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
1275
  $response = $this->execute();
1276
 
1277
  //if string is JSON than there is a error message
1278
- if(json_decode($response)){
1279
  //log error
1280
- if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
1281
- $message = 'GET CONTACT IMPORT REPORT FAULTS: ' . $response->message;
 
 
 
 
 
1282
  Mage::helper('ddg')->log($message)
1283
  ->rayLog($response->message);
1284
  }
 
1285
  return false;
1286
  }
1287
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Client
4
+ extends Dotdigitalgroup_Email_Model_Abstract_Rest
5
  {
6
+
7
  const APICONNECTOR_VERSION = 'V2';
8
 
9
  const REST_WAIT_UPLOAD_TIME = 5;
10
  //rest api data
11
+ const REST_ACCOUNT_INFO = 'https://r1-api.dotmailer.com/v2/account-info';
12
+ const REST_CONTACTS = '/v2/contacts/';
13
+ const REST_CONTACTS_IMPORT = '/v2/contacts/import/';
14
+ const REST_ADDRESS_BOOKS = '/v2/address-books/';
15
+ const REST_DATA_FILEDS = '/v2/data-fields';
16
+ const REST_TRANSACTIONAL_DATA_IMPORT = '/v2/contacts/transactional-data/import/';
17
+ const REST_TRANSACTIONAL_DATA = '/v2/contacts/transactional-data/';
18
+ const REST_CAMPAIGN_SEND = '/v2/campaigns/send';
19
+ const REST_CONTACTS_SUPPRESSED_SINCE = '/v2/contacts/suppressed-since/';
20
+ const REST_DATA_FIELDS_CAMPAIGNS = '/v2/campaigns';
21
+ const REST_CONTACTS_RESUBSCRIBE = '/v2/contacts/resubscribe';
22
+ const REST_CAMPAIGN_FROM_ADDRESS_LIST = '/v2/custom-from-addresses';
23
+ const REST_CREATE_CAMPAIGN = '/v2/campaigns';
24
+ const REST_PROGRAM = '/v2/programs/';
25
+ const REST_PROGRAM_ENROLMENTS = '/v2/programs/enrolments';
26
+ const REST_TEMPLATES = '/v2/templates';
 
27
 
28
  //rest error responces
29
+ const API_ERROR_API_EXCEEDED = 'Your account has generated excess API activity and is being temporarily capped. Please contact support. ERROR_APIUSAGE_EXCEEDED';
30
+ const API_ERROR_EMAIL_NOT_VALID = 'Email is not a valid email address. ERROR_PARAMETER_INVALID';
31
+ const API_ERROR_FEATURENOTACTIVE = 'Error: ERROR_FEATURENOTACTIVE';
32
+ const API_ERROR_REPORT_NOT_FOUND = 'Import is not processed yet or completed with error. ERROR_IMPORT_REPORT_NOT_FOUND';
33
+ const API_ERROR_TRANS_NOT_EXISTS = 'Error: ERROR_TRANSACTIONAL_DATA_DOES_NOT_EXIST';
34
+ const API_ERROR_DATAFIELD_EXISTS = 'Field already exists. ERROR_NON_UNIQUE_DATAFIELD';
35
+ const API_ERROR_CONTACT_NOT_FOUND = 'Error: ERROR_CONTACT_NOT_FOUND';
36
+ const API_ERROR_PROGRAM_NOT_ACTIVE = 'Error: ERROR_PROGRAM_NOT_ACTIVE';
37
+ const API_ERROR_ENROLMENT_EXCEEDED = 'Error: ERROR_ENROLMENT_ALLOWANCE_EXCEEDED ';
38
+ const API_ERROR_SEND_NOT_PERMITTED = 'Send not permitted at this time. ERROR_CAMPAIGN_SENDNOTPERMITTED';
39
+ const API_ERROR_CONTACT_SUPPRESSED = 'Contact is suppressed. ERROR_CONTACT_SUPPRESSED';
40
+ const API_ERROR_AUTHORIZATION_DENIED = 'Authorization has been denied for this request.';
41
+ const API_ERROR_ADDRESSBOOK_NOT_FOUND = 'Error: ERROR_ADDRESSBOOK_NOT_FOUND';
 
42
 
43
 
44
  protected $_limit = 10;
45
  public $fileHelper;
46
  protected $_filename;
 
 
 
 
 
 
 
 
47
  public $result = array('error' => false, 'message' => '');
48
  protected $_apiEndpoint;
49
 
59
 
60
  protected function _checkApiEndPoint()
61
  {
62
+ $apiEndpoint = Mage::helper('ddg')->getWebsiteConfig(
63
+ Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT
64
+ );
65
+ if ( ! $apiEndpoint) {
66
  $helper = Mage::helper('ddg');
67
  $this->setApiUsername($helper->getApiUsername())
68
  ->setApiPassword($helper->getApiPassword());
69
 
70
  $accountInfo = $this->getAccountInfo();
71
  //check if returned value is an object
72
+ if (is_object($accountInfo) && ! isset($accountInfo->message)) {
73
  //save endpoint for account
74
+ foreach ($accountInfo->properties as $property) {
75
+ if ($property->name == 'ApiEndpoint'
76
+ && strlen(
77
+ $property->value
78
+ )
79
+ ) {
80
  $apiEndpoint = $property->value;
81
+ $config = Mage::getConfig();
82
  $config->saveConfig(
83
  Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
84
  $property->value
90
  }
91
 
92
  //check api endpoint again
93
+ if (!$apiEndpoint && isset($accountInfo->message)) {
94
+ $helper->log('API endpoint could not be saved. Error from api: ' . $accountInfo->message);
95
+ Mage::getSingleton('adminhtml/session')
96
+ ->addWarning(
97
+ 'API endpoint cannot be saved. Error from api: ' . $accountInfo->message .
98
+ ' Check credentials and re-save to save api endpoint. '
99
+ );
100
+ }
101
  }
102
 
103
  $this->_apiEndpoint = $apiEndpoint;
105
 
106
  /**
107
  * Excluded api response that we don't want to send.
108
+ *
109
  * @var array
110
  */
111
+ public $exludeMessages
112
+ = array(
113
+ self::API_ERROR_FEATURENOTACTIVE,
114
+ self::API_ERROR_PROGRAM_NOT_ACTIVE,
115
+ self::API_ERROR_CONTACT_SUPPRESSED,
116
+ self::API_ERROR_DATAFIELD_EXISTS,
117
+ self::API_ERROR_AUTHORIZATION_DENIED,
118
+ self::API_ERROR_ENROLMENT_EXCEEDED,
119
+ self::API_ERROR_SEND_NOT_PERMITTED,
120
+ self::API_ERROR_TRANS_NOT_EXISTS,
121
+ self::API_ERROR_ADDRESSBOOK_NOT_FOUND
122
+ );
123
 
124
  /**
125
  * @param $apiUsername
126
  * @param $apiPassword
127
+ *
128
  * @return bool|mixed
129
  */
130
  public function validate($apiUsername, $apiPassword)
135
  $accountInfo = $this->getAccountInfo();
136
 
137
  if (isset($accountInfo->message)) {
138
+ Mage::getSingleton('adminhtml/session')->addError(
139
+ $accountInfo->message
140
+ );
141
  $message = 'VALIDATION ERROR : ' . $accountInfo->message;
142
  Mage::helper('ddg')->log($message);
143
+
144
  return false;
145
  }
146
+
147
  return $accountInfo;
148
  }
149
+
150
  return false;
151
  }
152
+
153
  /**
154
  * Gets a contact by ID. Unsubscribed or suppressed contacts will not be retrieved.
155
+ *
156
  * @param $id
157
+ *
158
  * @return null
159
  */
160
  public function getContactById($id)
164
  ->setVerb('GET');
165
  $response = $this->execute();
166
 
167
+ if (isset($response->message)) {
168
+ $message = 'GET CONTACT INFO ID ' . $url . ', '
169
+ . $response->message;
170
+ Mage::helper('ddg')->log($message);
171
  }
172
 
173
  return $response;
177
  * Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
178
  * Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
179
  * The ID of returned object can be used to query import progress.
180
+ *
181
  * @param $filename
182
  * @param $addressBookId
183
+ *
184
  * @return mixed
185
  */
186
 
187
  public function postAddressBookContactsImport($filename, $addressBookId)
188
  {
189
+ $url = $this->_apiEndpoint
190
+ . "/v2/address-books/{$addressBookId}/contacts/import";
191
  $helper = Mage::helper('ddg');
192
 
193
  $ch = curl_init($url);
194
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
195
+ curl_setopt(
196
+ $ch, CURLOPT_USERPWD,
197
+ $this->getApiUsername() . ':' . $this->getApiPassword()
198
+ );
199
 
200
  //case the deprication of @filename for uploading
201
  if (function_exists('curl_file_create')) {
202
  curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
203
+ $args['file'] = curl_file_create(
204
+ Mage::helper('ddg/file')->getFilePath($filename), 'text/csv'
205
+ );
206
  curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
207
 
208
  } else {
209
  //standart use of curl file
210
+ curl_setopt(
211
+ $ch, CURLOPT_POSTFIELDS, array(
212
+ 'file' => '@' . Mage::helper('ddg/file')->getFilePath(
213
+ $filename
214
+ )
215
+ )
216
+ );
217
  }
218
 
219
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
220
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
221
+ curl_setopt(
222
+ $ch, CURLOPT_HTTPHEADER, array(
223
  'Content-Type: multipart/form-data')
224
  );
225
 
227
  $result = curl_exec($ch);
228
 
229
  //if curl error found
230
+ if (curl_errno($ch)) {
 
231
  //save the error
232
  $this->curlError = curl_error($ch);
233
  }
234
 
235
  $result = json_decode($result);
236
  if (isset($result->message)) {
237
+ $message = 'POST ADDRESS BOOK ' . $addressBookId
238
+ . ', CONTACT IMPORT : ' . ' filename ' . $filename
239
+ . ' Username ' . $this->getApiUsername() . $result->message;
240
  $helper->log($message);
241
  Mage::helper('ddg')->log($result)
242
  ->rayLog($result->message);
243
  }
244
+
245
  return $result;
246
  }
247
 
248
  /**
249
  * Adds a contact to a given address book.
250
+ *
251
  * @param $addressBookId
252
  * @param $apiContact
253
+ *
254
  * @return mixed|null
255
  */
256
  public function postAddressBookContacts($addressBookId, $apiContact)
257
  {
258
+ $url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId
259
+ . '/contacts';
260
  $this->setUrl($url)
261
  ->setVerb("POST")
262
  ->buildPostBody($apiContact);
263
 
264
  $response = $this->execute();
265
 
266
+ //log the error
267
+ if (isset($response->message)
268
+ && ! in_array(
269
+ $response->message, $this->exludeMessages
270
+ )
271
+ ) {
272
+ $message = 'POST ADDRESS BOOK CONTACTS ' . $url . ', '
273
+ . $response->message;
274
  Mage::helper('ddg')->log($message)
275
  ->rayLog($response->message);
276
  }
280
 
281
  /**
282
  * Deletes all contacts from a given address book.
283
+ *
284
  * @param $addressBookId
285
  * @param $contactId
286
+ *
287
  * @return null
288
  */
289
  public function deleteAddressBookContact($addressBookId, $contactId)
290
  {
291
 
292
+ $url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId
293
+ . '/contacts/' . $contactId;
294
  $this->setUrl($url)
295
  ->setVerb('DELETE');
296
 
299
 
300
  /**
301
  * Gets a report with statistics about what was successfully imported, and what was unable to be imported.
302
+ *
303
  * @param $importId
304
+ *
305
  * @return mixed
306
  */
307
  public function getContactsImportReport($importId)
308
  {
309
+ $url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $importId
310
+ . "/report";
311
  $this->setUrl($url)
312
  ->setVerb('GET');
313
  $response = $this->execute();
314
  //log error
315
+ if (isset($response->message)
316
+ && ! in_array(
317
+ $response->message, $this->exludeMessages
318
+ )
319
+ ) {
320
+ $message = 'GET CONTACTS IMPORT REPORT . ' . $url . ' message : '
321
+ . $response->message;
322
+ Mage::helper('ddg')->log($message)
323
+ ->rayLog($response->message);
324
  }
325
+
326
  return $response;
327
  }
328
 
329
  /**
330
  * Gets a contact by email address.
331
+ *
332
  * @param $email
333
+ *
334
  * @return mixed
335
  */
336
  public function getContactByEmail($email)
341
 
342
  $response = $this->execute();
343
 
344
+ //log error
345
+ if (isset($response->message)
346
+ && ! in_array(
347
+ $response->message, $this->exludeMessages
348
+ )
349
+ ) {
350
+ $message = 'GET CONTACT BY email : ' . $email . ' '
351
+ . $response->message;
352
  Mage::helper('ddg')->log($message)
353
+ ->rayLog($response->message);
354
  }
355
 
356
  return $response;
358
 
359
  /**
360
  * Get all address books.
361
+ *
362
  * @return null
363
  */
364
  public function getAddressBooks()
368
  ->setVerb("GET");
369
 
370
  $response = $this->execute();
371
+ //log error
372
+ if (isset($response->message)
373
+ && ! in_array(
374
+ $response->message, $this->exludeMessages
375
+ )
376
+ ) {
377
+ $message = 'GET ALL ADDRESS BOOKS : ' . $url . ', '
378
+ . $response->message;
379
  Mage::helper('ddg')->log($message)
380
  ->rayLog($response->message);
381
  }
385
 
386
  /**
387
  * Gets an address book by ID.
388
+ *
389
  * @param $id
390
  *
391
  * @return null
401
  $response = $this->execute();
402
 
403
  if (isset($response->message)) {
404
+ Mage::helper('ddg')->log(
405
+ 'GET ADDRESS BOOK BY ID ' . $id . ', ' . $response->message
406
+ );
407
  }
408
 
409
  return $response;
411
 
412
  /**
413
  * Creates an address book.
414
+ *
415
  * @param $name
416
+ *
417
  * @return null
418
  */
419
  public function postAddressBooks($name, $visibility = 'Public')
420
  {
421
  $data = array(
422
+ 'Name' => $name,
423
  'Visibility' => $visibility
424
  );
425
+ $url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS;
426
  $this->setUrl($url)
427
  ->setVerb('POST')
428
  ->buildPostBody($data);
429
 
430
  $response = $this->execute();
431
  //log error
432
+ if (isset($response->message)
433
+ && ! in_array(
434
+ $response->message, $this->exludeMessages
435
+ )
436
+ ) {
437
+ $message = 'Postaddressbooks ' . $response->message . ', url :'
438
+ . $url;
439
  Mage::helper('ddg')->log($message)
440
+ ->rayLog($response->message);
441
  }
442
 
443
  return $response;
445
 
446
  /**
447
  * Get list of all campaigns.
448
+ *
449
  * @return mixed
450
  */
451
  public function getCampaigns()
455
  ->setVerb('GET');
456
 
457
  $response = $this->execute();
458
+ //log error
459
+ if (isset($response->message)
460
+ && ! in_array(
461
+ $response->message, $this->exludeMessages
462
+ )
463
+ ) {
464
+ $message = 'GET CAMPAIGNS ' . $response->message . ' api user : '
465
+ . $this->getApiUsername();
466
  Mage::helper('ddg')->log($message)
467
+ ->rayLog($response->message);
468
  }
469
 
470
  return $response;
472
 
473
  /**
474
  * Creates a data field within the account.
475
+ *
476
+ * @param $data string/array
477
+ * @param string $type string, numeric, date, boolean
478
  * @param string $visibility public, private
479
+ * @param bool $defaultValue
480
+ *
481
  * @return mixed
482
  */
483
+ public function postDataFields($data, $type = 'String',
484
+ $visibility = 'public', $defaultValue = false
485
+ ) {
486
  $url = $this->_apiEndpoint . self::REST_DATA_FILEDS;
487
  //set default value for the numeric datatype
488
+ if ($type == 'numeric' && ! $defaultValue) {
489
  $defaultValue = 0;
490
+ }
491
  //set data for the string datatype
492
  if (is_string($data)) {
493
  $data = array(
494
+ 'Name' => $data,
495
+ 'Type' => $type,
496
  'Visibility' => $visibility
497
  );
498
  //default value
499
+ if ($defaultValue) {
500
  $data['DefaultValue'] = $defaultValue;
501
+ }
502
  }
503
  $this->setUrl($url)
504
  ->buildPostBody($data)
505
  ->setVerb('POST');
506
 
507
  $response = $this->execute();
508
+ //log error
509
+ if (isset($response->message)
510
+ && ! in_array(
511
+ $response->message, $this->exludeMessages
512
+ )
513
+ ) {
514
  $message = 'POST CREATE DATAFIELDS ' . $response->message;
515
  Mage::helper('ddg')->log($message)
516
  ->log($data)
522
 
523
  /**
524
  * Deletes a data field within the account.
525
+ *
526
  * @param $name
527
  *
528
  * @return mixed
535
 
536
  $response = $this->execute();
537
  //log error
538
+ if (isset($response->message)
539
+ && ! in_array(
540
+ $response->message, $this->exludeMessages
541
+ )
542
+ ) {
543
+ $message = 'DELETE DATA FIELD :' . $name . ' ' . $response->message;
544
  Mage::helper('ddg')->log($message)
545
  ->rayLog($response->message);
546
  }
550
 
551
  /**
552
  * Lists the data fields within the account.
553
+ *
554
  * @return mixed
555
  */
556
  public function getDataFields()
560
  ->setVerb('GET');
561
 
562
  $response = $this->execute();
563
+ //log error
564
+ if (isset($response->message)
565
+ && ! in_array(
566
+ $response->message, $this->exludeMessages
567
+ )
568
+ ) {
569
  $message = 'GET ALL DATAFIELDS ' . $response->message;
570
  Mage::helper('ddg')->log($message)
571
  ->rayLog($response->message);
576
 
577
  /**
578
  * Updates a contact.
579
+ *
580
  * @param $contactId
581
  * @param $data
582
+ *
583
  * @return object
584
  */
585
  public function updateContact($contactId, $data)
590
  ->buildPostBody($data);
591
 
592
  $response = $this->execute();
593
+ //log error
594
+ if (isset($response->message)
595
+ && ! in_array(
596
+ $response->message, $this->exludeMessages
597
+ )
598
+ ) {
599
+ $message = 'ERROR : UPDATE SINGLE CONTACT : ' . $url . ' message : '
600
+ . $response->message;
601
  Mage::helper('ddg')->log($message)
602
  ->log($data)
603
  ->rayLog($response->message);
608
 
609
  /**
610
  * Deletes a contact.
611
+ *
612
  * @param $contactId
613
+ *
614
  * @return null
615
  */
616
  public function deleteContact($contactId)
620
  ->setVerb('DELETE');
621
 
622
  $response = $this->execute();
623
+ //log error
624
+ if (isset($response->message)
625
+ && ! in_array(
626
+ $response->message, $this->exludeMessages
627
+ )
628
+ ) {
629
  $message = 'DELETE CONTACT : ' . $url . ', ' . $response->message;
630
  Mage::helper('ddg')->log($message)
631
  ->rayLog($response->message);
632
  }
633
+
634
  return $response;
635
  }
636
 
637
  /**
638
  * Update contact datafields by email.
639
+ *
640
  * @param $email
641
  * @param $dataFields
642
  *
647
  {
648
  $apiContact = $this->postContacts($email);
649
  //do not create for non contact id set
650
+ if ( ! isset($apiContact->id)) {
651
  return $apiContact;
652
  } else {
653
  //get the contact id for this email
654
  $contactId = $apiContact->id;
655
  }
656
+ $data = array(
657
+ 'Email' => $email,
658
  'EmailType' => 'Html');
659
  $data['DataFields'] = $dataFields;
660
+ $url = $this->_apiEndpoint . self::REST_CONTACTS
661
+ . $contactId;
662
  $this->setUrl($url)
663
  ->setVerb('PUT')
664
  ->buildPostBody($data);
665
 
666
  $response = $this->execute();
667
+ //log error
668
+ if (isset($response->message)
669
+ && ! in_array(
670
+ $response->message, $this->exludeMessages
671
+ )
672
+ ) {
673
+ $message = 'ERROR: UPDATE CONTACT DATAFIELD ' . $url . ' message : '
674
+ . $response->message;
675
  Mage::helper('ddg')->log($message)
676
  ->log($data)
677
  ->rayLog($response->message);
683
  /**
684
  * Sends a specified campaign to one or more address books, segments or contacts at a specified time.
685
  * Leave the address book array empty to send to All Contacts.
686
+ *
687
  * @param $campaignId
688
  * @param $contacts
689
+ *
690
  * @return mixed
691
  */
692
  public function postCampaignsSend($campaignId, $contacts)
693
  {
694
  $data = array(
695
+ 'username' => $this->getApiUsername(),
696
+ 'password' => $this->getApiPassword(),
697
  "campaignId" => $campaignId,
698
  "ContactIds" => $contacts
699
  );
702
  ->buildPostBody($data);
703
 
704
  $response = $this->execute();
705
+ //log error
706
+ if (isset($response->message)
707
+ && ! in_array(
708
+ $response->message, $this->exludeMessages
709
+ )
710
+ ) {
711
+ $message = 'SENDING CAMPAIGN ' . $response->message;
712
  Mage::helper('ddg')->log($message)
713
  ->log($data)
714
  ->rayLog($response->message);
719
 
720
  /**
721
  * Creates a contact.
722
+ *
723
  * @param $email
724
+ *
725
  * @return mixed
726
  */
727
  public function postContacts($email)
728
  {
729
+ //validate email before creating a contact
730
+ $valid = preg_match(
731
+ "/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix",
732
+ $email
733
+ );
734
+ if ( ! $valid) {
735
+ $object = new stdClass();
736
+
737
+ return $object->message = 'Not valid email :' . $email;
738
+ }
739
+
740
+ $url = $this->_apiEndpoint . self::REST_CONTACTS;
741
  $data = array(
742
+ 'Email' => $email,
743
  'EmailType' => 'Html',
744
  );
745
  $this->setUrl($url)
747
  ->buildPostBody($data);
748
 
749
  $response = $this->execute();
750
+ //log error
751
+ if (isset($response->message)
752
+ && ! in_array(
753
+ $response->message, $this->exludeMessages
754
+ )
755
+ ) {
756
+ $message = 'CREATE A NEW CONTACT : ' . $response->message;
757
  Mage::helper('ddg')->log($message)
758
  ->rayLog($response->message);
759
  }
764
 
765
  /**
766
  * Gets a list of suppressed contacts after a given date along with the reason for suppression.
767
+ *
768
  * @param $dateString
769
  * @param $select
770
  * @param $skip
771
+ *
772
  * @return object
773
  */
774
+ public function getContactsSuppressedSinceDate($dateString, $select = 1000,
775
+ $skip = 0
776
+ ) {
777
+ $url = $this->_apiEndpoint . self::REST_CONTACTS_SUPPRESSED_SINCE
778
+ . $dateString . '?select=' . $select . '&skip=' . $skip;
779
  $this->setUrl($url)
780
  ->setVerb("GET");
781
 
782
  $response = $this->execute();
783
+ //log error
784
+ if (isset($response->message)
785
+ && ! in_array(
786
+ $response->message, $this->exludeMessages
787
+ )
788
+ ) {
789
+ $message = 'GET CONTACTS SUPPRESSED SINSE : ' . $dateString
790
+ . ' select ' . $select . ' skip : ' . $skip . ' response : '
791
+ . $response->message;
792
  Mage::helper('ddg')->log($message)
793
  ->rayLog($response->message);
794
  }
798
 
799
  /**
800
  * Adds multiple pieces of transactional data to contacts asynchronously, returning an identifier that can be used to check for import progress.
801
+ *
802
  * @param $collectionName
803
  * @param $transactionalData
804
+ *
805
  * @return object
806
  */
807
+ public function postContactsTransactionalDataImport($transactionalData,
808
+ $collectionName = 'Orders'
809
+ ) {
810
  $orders = array();
811
  foreach ($transactionalData as $one) {
812
  if (isset($one->email)) {
813
  $orders[] = array(
814
+ 'Key' => $one->id,
815
  'ContactIdentifier' => $one->email,
816
+ 'Json' => json_encode($one)
817
  );
818
  }
819
  }
820
+ $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
821
+ . $collectionName;
822
  $this->setURl($url)
823
  ->setVerb('POST')
824
  ->buildPostBody($orders);
825
 
826
  $response = $this->execute();
827
+ // log error
828
+ if (isset($response->message)
829
+ && ! in_array(
830
+ $response->message, $this->exludeMessages
831
+ )
832
+ ) {
833
  $message = ' SEND MULTI TRANSACTIONAL DATA ' . $response->message;
834
  Mage::helper('ddg')->log($message)
835
  ->rayLog($response->message);
841
  /**
842
  * Adds a single piece of transactional data to a contact.
843
  *
844
+ * @param $data
845
  * @param string $collectionName
846
  *
847
  * @return null
848
  * @throws Exception
849
  */
850
+ public function postContactsTransactionalData($data,
851
+ $collectionName = 'Orders'
852
+ ) {
853
+ $order = $this->getContactsTransactionalDataByKey(
854
+ $collectionName, $data->id
855
+ );
856
+ if (isset($order->message)
857
+ && $order->message == self::API_ERROR_TRANS_NOT_EXISTS
858
+ ) {
859
+ $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA
860
+ . $collectionName;
861
+ } else {
862
+ $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA
863
+ . $collectionName . '/' . $order->key;
864
  }
865
  $apiData = array(
866
+ 'Key' => $data->id,
867
  'ContactIdentifier' => $data->email,
868
+ 'Json' => json_encode($data->expose())
869
  );
870
 
871
  $this->setUrl($url)
872
  ->setVerb('POST')
873
  ->buildPostBody($apiData);
874
  $response = $this->execute();
875
+ //log error
876
+ if (isset($response->message)
877
+ && ! in_array(
878
+ $response->message, $this->exludeMessages
879
+ )
880
+ ) {
881
+ $message = 'POST CONTACTS TRANSACTIONAL DATA '
882
+ . $response->message;
883
  Mage::helper('ddg')->log($message)
884
  ->log($apiData)
885
  ->rayLog($response->message);
890
 
891
  /**
892
  * Gets a piece of transactional data by key.
893
+ *
894
  * @param $name
895
  * @param $key
896
+ *
897
  * @return null
898
  */
899
  public function getContactsTransactionalDataByKey($name, $key)
900
  {
901
+ $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA . $name . '/'
902
+ . $key;
903
  $this->setUrl($url)
904
  ->setVerb('GET');
905
 
908
 
909
  /**
910
  * Deletes all transactional data for a contact.
911
+ *
912
+ * @param $email
913
  * @param string $collectionName
914
+ *
915
  * @return object
916
  */
917
+ public function deleteContactTransactionalData($email,
918
+ $collectionName = 'Orders'
919
+ ) {
920
+ $url = $this->_apiEndpoint . '/v2/contacts/' . $email
921
+ . '/transactional-data/' . $collectionName;
922
  $this->setUrl($url)
923
  ->setVerb('DELETE');
924
 
927
 
928
  /**
929
  * Gets a summary of information about the current status of the account.
930
+ *
931
  * @return mixed
932
  */
933
  public function getAccountInfo()
937
  ->setVerb('GET');
938
 
939
  $response = $this->execute();
940
+ //log error
941
+ if (isset($response->message)
942
+ && ! in_array(
943
+ $response->message, $this->exludeMessages
944
+ )
945
+ ) {
946
+ $message = 'GET ACCOUNT INFO for api user : '
947
+ . $this->getApiUsername() . ' ' . $response->message;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
  Mage::helper('ddg')->log($message)
949
  ->rayLog($response->message);
950
  }
952
  return $response;
953
  }
954
 
 
955
  /**
956
  * Deletes multiple contacts from an address book.
957
+ *
958
  * @param $addressBookId
959
  * @param $contactIds
960
+ *
961
  * @return object
962
  */
963
  public function deleteAddressBookContactsInbulk($addressBookId, $contactIds)
964
  {
965
+ $url = $this->_apiEndpoint . '/v2/address-books/' . $addressBookId
966
+ . '/contacts/inbulk';
967
  $data = array('ContactIds' => array($contactIds[0]));
968
  $this->setUrl($url)
969
  ->setVerb('DELETE')
970
  ->buildPostBody($data);
971
 
972
  $response = $this->execute();
973
+ //log error
974
+ if (isset($response->message)
975
+ && ! in_array(
976
+ $response->message, $this->exludeMessages
977
+ )
978
+ ) {
979
+ $message = 'DELETE BULK ADDRESS BOOK CONTACTS ' . $response->message
980
+ . ' address book ' . $addressBookId;
981
  Mage::helper('ddg')->log($message)
982
  ->rayLog($response->message);
983
  }
985
  return $response;
986
  }
987
 
988
+ /**
989
+ * Resubscribes a previously unsubscribed contact.
990
+ *
991
+ * @param $apiContact
992
+ *
993
+ * @return null
994
+ * @throws Exception
995
+ */
996
  public function postContactsResubscribe($apiContact)
997
  {
998
+ $url = $this->_apiEndpoint . self::REST_CONTACTS_RESUBSCRIBE;
999
  $data = array(
1000
  'UnsubscribedContact' => $apiContact
1001
  );
1005
 
1006
  $response = $this->execute();
1007
  //log error
1008
+ if (isset($response->message)
1009
+ && ! in_array(
1010
+ $response->message, $this->exludeMessages
1011
+ )
1012
+ ) {
1013
+ $message = 'Resubscribe : ' . $url . ', message :'
1014
+ . $response->message;
1015
  Mage::helper('ddg')->log($message)
1016
  ->log($data)
1017
  ->rayLog($response->message);
1018
  }
1019
+
1020
+ return $response;
1021
  }
1022
 
1023
  /**
1034
  ->setVerb('GET');
1035
 
1036
  $response = $this->execute();
1037
+ //log error
1038
+ if (isset($response->message)
1039
+ && ! in_array(
1040
+ $response->message, $this->exludeMessages
1041
+ )
1042
+ ) {
1043
+ $message = 'GET CampaignFromAddressList ' . $response->message
1044
+ . ' api user : ' . $this->getApiUsername();
1045
  Mage::helper('ddg')->log($message)
1046
  ->rayLog($response->message);
1047
  }
1049
  return $response;
1050
  }
1051
 
1052
+ /**
1053
+ * Creates a campaign.
1054
+ *
1055
+ * @param $data
1056
+ *
1057
+ * @return null
1058
+ * @throws Exception
1059
+ */
1060
  public function postCampaign($data)
1061
  {
1062
  $url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN;
1065
  ->buildPostBody($data);
1066
 
1067
  $response = $this->execute();
1068
+ //log error
1069
+ if (isset($response->message)
1070
+ && ! in_array(
1071
+ $response->message, $this->exludeMessages
1072
+ )
1073
+ ) {
1074
  $message = ' CREATE CAMPAIGN ' . $response->message;
1075
  Mage::helper('ddg')->log($message)
1076
  ->rayLog($response->message);
1091
  ->setVerb('GET');
1092
 
1093
  $response = $this->execute();
1094
+ //log error
1095
+ if (isset($response->message)
1096
+ && ! in_array(
1097
+ $response->message, $this->exludeMessages
1098
+ )
1099
+ ) {
1100
+ $message = 'Get programmes : ' . $response->message;
1101
+ Mage::helper('ddg')->log($message)
1102
  ->rayLog($response->message);
1103
  }
1104
 
1107
 
1108
  /**
1109
  * Creates an enrolment.
1110
+ *
1111
  * @param $data
1112
  *
1113
  * @return null
1121
  ->buildPostBody($data);
1122
 
1123
  $response = $this->execute();
1124
+ //log error
1125
+ if (isset($response->message)
1126
+ && ! in_array(
1127
+ $response->message, $this->exludeMessages
1128
+ )
1129
+ ) {
1130
  $message = 'Post programs enrolments : ' . $response->message;
1131
  Mage::helper('ddg')->log($message)
1132
  ->log($data)
1138
 
1139
  /**
1140
  * Gets a program by id.
1141
+ *
1142
  * @param $id
1143
  *
1144
  * @return null
1145
  * @throws Exception
1146
  */
1147
+ public function getProgramById($id)
1148
  {
1149
+ $url = $this->_apiEndpoint . self::REST_PROGRAM . $id;
1150
  $this->setUrl($url)
1151
  ->setVerb('GET');
1152
 
1153
  $response = $this->execute();
1154
+ //log error
1155
+ if (isset($response->message)
1156
+ && ! in_array(
1157
+ $response->message, $this->exludeMessages
1158
+ )
1159
+ ) {
1160
  $message = 'Get program by id ' . $id . ', ' . $response->message;
1161
  Mage::helper('ddg')->log($message)
1162
  ->rayLog($response->message);
1167
 
1168
  /**
1169
  * Gets a summary of reporting information for a specified campaign.
1170
+ *
1171
  * @param $campaignId
1172
  *
1173
  * @return null
1175
  */
1176
  public function getCampaignSummary($campaignId)
1177
  {
1178
+ $url = $this->_apiEndpoint . '/v2/campaigns/' . $campaignId
1179
+ . '/summary';
1180
 
1181
  $this->setUrl($url)
1182
  ->setVerb('GET');
1183
  $response = $this->execute();
1184
+ //log error
1185
+ if (isset($response->message)
1186
+ && ! in_array(
1187
+ $response->message, $this->exludeMessages
1188
+ )
1189
+ ) {
1190
+ $message = 'Get Campaign Summary ' . $response->message
1191
+ . ' ,url : ' . $url;
1192
+ Mage::helper('ddg')->log($message)
1193
  ->rayLog($response->message);
1194
  }
1195
 
1198
 
1199
  /**
1200
  * Deletes a piece of transactional data by key.
1201
+ *
1202
+ * @param $key
1203
  * @param string $collectionName
1204
+ *
1205
  * @return object
1206
  */
1207
+ public function deleteContactsTransactionalData($key,
1208
+ $collectionName = 'Orders'
1209
+ ) {
1210
+ $url = $this->_apiEndpoint . '/v2/contacts/transactional-data/'
1211
+ . $collectionName . '/' . $key;
1212
  $this->setUrl($url)
1213
  ->setVerb('DELETE');
1214
  $response = $this->execute();
1215
 
1216
+ if (isset($response->message)) {
1217
+ Mage::helper('ddg')->log(
1218
+ 'DELETE CONTACTS TRANSACTIONAL DATA : ' . $url . ' '
1219
+ . $response->message
1220
+ );
1221
+ }
1222
 
1223
  return $response;
1224
  }
1225
 
1226
  /**
1227
  * Adds a document to a campaign as an attachment.
1228
+ *
1229
  * @param $campaignId
1230
  * @param $data
1231
  *
1234
  */
1235
  public function postCampaignAttachments($campaignId, $data)
1236
  {
1237
+ $url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN
1238
+ . "/$campaignId/attachments";
1239
  $this->setURl($url)
1240
  ->setVerb('POST')
1241
  ->buildPostBody($data);
1242
  $result = $this->execute();
1243
 
1244
  if (isset($result->message)) {
1245
+ Mage::helper('ddg')->log(
1246
+ ' CAMPAIGN ATTACHMENT ' . $result->message
1247
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1248
  }
1249
 
1250
  return $result;
1254
  * get contact address books
1255
  *
1256
  * @param $contactId
1257
+ *
1258
  * @return object
1259
  * @throws Exception
1260
  */
1261
  public function getContactAddressBooks($contactId)
1262
  {
1263
+ $url = $this->_apiEndpoint . '/v2/contacts/' . $contactId
1264
+ . '/address-books';
1265
  $this->setUrl($url)
1266
  ->setVerb('GET');
1267
  $response = $this->execute();
1268
+ //log error
1269
+ if (isset($response->message)
1270
+ && ! in_array(
1271
+ $response->message, $this->exludeMessages
1272
+ )
1273
+ ) {
1274
+ $message = 'GET CONTACTS ADDRESS BOOKS contact: ' . $contactId
1275
+ . $response->message;
1276
  Mage::helper('ddg')->log($message)
1277
  ->rayLog($response->message);
1278
  }
1288
  */
1289
  public function getApiTemplateList()
1290
  {
1291
+ $url = $this->_apiEndpoint . self::REST_TEMPLATES;
1292
  $this->setUrl($url)
1293
  ->setVerb('GET');
1294
 
1295
+ $response = $this->execute();
1296
 
1297
+ //log error
1298
+ if (isset($response->message)
1299
+ && ! in_array(
1300
+ $response->message, $this->exludeMessages
1301
+ )
1302
+ ) {
1303
+ $message = 'GET API CONTACT LIST ' . $response->message;
1304
  Mage::helper('ddg')->log($message)
1305
+ ->rayLog($response->message);
1306
  }
1307
 
1308
  return $response;
1312
  * Gets a template by ID.
1313
  *
1314
  * @param $templateId
1315
+ *
1316
  * @return object
1317
  * @throws Exception
1318
  */
1319
  public function getApiTemplate($templateId)
1320
  {
1321
+ $url = $this->_apiEndpoint . self::REST_TEMPLATES . '/' . $templateId;
1322
  $this->setUrl($url)
1323
  ->setVerb('GET');
1324
 
1325
  $response = $this->execute();
1326
+ //log error
1327
+ if (isset($response->message)
1328
+ && ! in_array(
1329
+ $response->message, $this->exludeMessages
1330
+ )
1331
+ ) {
1332
+ $message = 'GET API CONTACT LIST ' . $response->message;
1333
  Mage::helper('ddg')->log($message)
1334
  ->rayLog($response->message);
1335
  }
1339
 
1340
  /**
1341
  * Adds multiple pieces of transactional data to account asynchronously, returning an identifier that can be used to check for import progress.
1342
+ *
1343
  * @param $collectionName
1344
  * @param $transactionalData
1345
+ *
1346
  * @return object
1347
  */
1348
+ public function postAccountTransactionalDataImport($transactionalData,
1349
+ $collectionName = 'Catalog_Default'
1350
+ ) {
1351
  $orders = array();
1352
  foreach ($transactionalData as $one) {
1353
  if (isset($one->id)) {
1354
  $orders[] = array(
1355
+ 'Key' => $one->id,
1356
  'ContactIdentifier' => 'account',
1357
+ 'Json' => json_encode($one->expose())
1358
  );
1359
  }
1360
  }
1361
+ $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
1362
+ . $collectionName;
1363
  $this->setURl($url)
1364
  ->setVerb('POST')
1365
  ->buildPostBody($orders);
1366
 
1367
  $response = $this->execute();
1368
+ //log error
1369
+ if (isset($response->message)
1370
+ && ! in_array(
1371
+ $response->message, $this->exludeMessages
1372
+ )
1373
+ ) {
1374
+ $message = ' SEND MULTI TRANSACTIONAL DATA TO ACCOUNT'
1375
+ . $response->message;
1376
  Mage::helper('ddg')->log($message)
1377
  ->rayLog($response->message);
1378
  }
1382
 
1383
  public function getCampaignsWithActivitySinceDate($dateTime)
1384
  {
1385
+ $url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS
1386
+ . '/with-activity-since/' . $dateTime;
1387
 
1388
  $this->setUrl($url)
1389
  ->setVerb('GET');
1390
 
1391
  $response = $this->execute();
1392
+ //log error
1393
+ if (isset($response->message)
1394
+ && ! in_array(
1395
+ $response->message, $this->exludeMessages
1396
+ )
1397
+ ) {
1398
+ $message = 'GET CAMPAIGNS WITH ACTIVITY SINCE DATE '
1399
+ . $response->message;
1400
  Mage::helper('ddg')->log($message)
1401
  ->rayLog($response->message);
1402
  }
1406
 
1407
  public function getCampaignActivityByContactId($campaignId, $contactId)
1408
  {
1409
+ $url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS . '/'
1410
+ . $campaignId . '/activities/' . $contactId;
1411
 
1412
  $this->setUrl($url)
1413
  ->setVerb('GET');
1414
 
1415
  $response = $this->execute();
1416
+ //log error
1417
+ if (isset($response->message)
1418
+ && ! in_array(
1419
+ $response->message, $this->exludeMessages
1420
+ )
1421
+ ) {
1422
+ $message = 'GET CAMPAIGN ACTIVITY BY CONTACT ID '
1423
+ . $response->message;
1424
  Mage::helper('ddg')->log($message)
1425
  ->rayLog($response->message);
1426
  }
1432
  * Gets the import status of a previously started contact import.
1433
  *
1434
  * @param $importId
1435
+ *
1436
  * @return object
1437
  */
1438
  public function getContactsImportByImportId($importId)
1442
  $this->setUrl($url)
1443
  ->setVerb('GET');
1444
 
1445
+ $response = $this->execute();
1446
  //log error
1447
+ if (isset($response->message)
1448
+ && ! in_array(
1449
+ $response->message, $this->exludeMessages
1450
+ )
1451
+ ) {
1452
  $message = 'GET CONTACTS IMPORT BY IMPORT ID ' . $response->message;
1453
  Mage::helper('ddg')->log($message)
1454
  ->rayLog($response->message);
1461
  * Gets the import status of a previously started transactional import.
1462
  *
1463
  * @param $importId
1464
+ *
1465
  * @return object
1466
  */
1467
  public function getContactsTransactionalDataImportByImportId($importId)
1468
  {
1469
+ $url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
1470
+ . $importId;
1471
 
1472
  $this->setUrl($url)
1473
  ->setVerb('GET');
1474
 
1475
+ $response = $this->execute();
1476
+ //log error
1477
+ if (isset($response->message)
1478
+ && ! in_array(
1479
+ $response->message, $this->exludeMessages
1480
+ )
1481
+ ) {
1482
+ $message = 'GET CONTACTS TRANSACTIONAL DATA IMPORT BY IMPORT ID '
1483
+ . $response->message;
1484
  Mage::helper('ddg')->log($message)
1485
  ->rayLog($response->message);
1486
  }
1492
  * get contact import report faults
1493
  *
1494
  * @param $id
1495
+ *
1496
  * @return bool|null
1497
  * @throws Exception
1498
  */
1499
  public function getContactImportReportFaults($id)
1500
  {
1501
+ $url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $id
1502
+ . '/report-faults';
1503
  $this->setUrl($url)
1504
  ->setVerb('GET');
1505
 
1507
  $response = $this->execute();
1508
 
1509
  //if string is JSON than there is a error message
1510
+ if (json_decode($response)) {
1511
  //log error
1512
+ if (isset($response->message)
1513
+ && ! in_array(
1514
+ $response->message, $this->exludeMessages
1515
+ )
1516
+ ) {
1517
+ $message = 'GET CONTACT IMPORT REPORT FAULTS: '
1518
+ . $response->message;
1519
  Mage::helper('ddg')->log($message)
1520
  ->rayLog($response->message);
1521
  }
1522
+
1523
  return false;
1524
  }
1525
 
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php CHANGED
@@ -2,105 +2,136 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Apiconnector_Contact
4
  {
 
5
  protected $_start;
6
  protected $_countCustomers = 0;
7
 
8
- /**
9
- * Contact sync.
10
- *
11
- * @return array
12
- */
13
- public function sync()
14
  {
15
  $result = array('success' => true, 'message' => '');
16
  /** @var Dotdigitalgroup_Email_Helper_Data $helper */
17
- $helper = Mage::helper('ddg');
18
  $this->_start = microtime(true);
19
  //resourse allocation
20
  $helper->allowResourceFullExecution();
21
  foreach (Mage::app()->getWebsites(true) as $website) {
22
- $enabled = Mage::helper('ddg')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $website);
23
- $sync = Mage::helper('ddg')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, $website);
 
 
 
 
 
 
24
  if ($enabled && $sync) {
25
 
26
- if (!$this->_countCustomers)
27
- $helper->log('---------- Start customer sync ----------');
28
- $numUpdated = $this->exportCustomersForWebsite($website);
29
- // show message for any number of customers
30
- if ($numUpdated)
31
- $result['message'] .= '</br>' . $website->getName() . ', updated customers = ' . $numUpdated;
 
 
 
32
  }
33
  }
34
- //sync proccessed
35
- if ($this->_countCustomers) {
36
- $message = 'Total time for sync : ' . gmdate( "H:i:s", microtime( true ) - $this->_start ) . ', Total updated = ' . $this->_countCustomers;
37
- $helper->log( $message );
38
- $message .= $result['message'];
39
- $result['message'] = $message;
40
- }
 
 
 
41
 
42
  return $result;
43
  }
44
 
45
- /**
46
- * Execute the contact sync for the website
47
- * number of customer synced.
48
- * @param Mage_Core_Model_Website $website
49
- *
50
- * @return int|void
51
- */
 
52
  public function exportCustomersForWebsite(Mage_Core_Model_Website $website)
53
  {
54
  $customers = $headers = $allMappedHash = array();
55
- $helper = Mage::helper('ddg');
56
- $pageSize = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT, $website);
 
 
 
57
 
58
  //skip if the mapping field is missing
59
- if ( !$helper->getCustomerAddressBook($website))
60
  return 0;
 
61
 
62
- $fileHelper = Mage::helper('ddg/file');
63
  $contactModel = Mage::getModel('ddg_automation/contact');
64
- $contacts = $contactModel->getContactsToImportForWebsite($website->getId(), $pageSize);
 
 
65
 
66
  // no contacts for this website
67
- if (!$contacts->getSize())
68
  return 0;
 
69
 
70
  //create customer filename
71
- $customersFile = strtolower($website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv');
 
 
72
  $helper->log('Customers file : ' . $customersFile);
73
 
74
  //get customer ids
75
  $customerIds = $contacts->getColumnValues('customer_id');
76
 
77
  //customer collection
78
- $customerCollection = $this->getCollection($customerIds, $website->getId());
 
 
79
 
80
  /**
81
  * HEADERS.
82
  */
83
- $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields($website);
84
- $headers = $mappedHash;
 
 
85
 
86
  //custom customer attributes
87
  $customAttributes = $helper->getCustomAttributes($website);
88
- if ($customAttributes){
89
- foreach ($customAttributes as $data) {
90
- $headers[] = $data['datafield'];
91
- $allMappedHash[$data['attribute']] = $data['datafield'];
92
- }
93
  }
94
  $headers[] = 'Email';
95
  $headers[] = 'EmailType';
96
- $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $headers);
 
 
97
  /**
98
  * END HEADERS.
99
  */
100
 
101
  //customer data
102
  foreach ($customerCollection as $customer) {
103
- $connectorCustomer = Mage::getModel('ddg_automation/apiconnector_customer', $mappedHash);
 
 
104
  $connectorCustomer->setCustomerData($customer);
105
  //count number of customers
106
  $customers[] = $customer->getId();
@@ -108,7 +139,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
108
  if ($connectorCustomer) {
109
  foreach ($customAttributes as $data) {
110
  $attribute = $data['attribute'];
111
- $value = $customer->getData($attribute);
112
  $connectorCustomer->setData($value);
113
  }
114
  }
@@ -117,116 +148,151 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
117
  $connectorCustomer->setData($customer->getEmail());
118
  $connectorCustomer->setData('Html');
119
  // save csv file data for customers
120
- $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $connectorCustomer->toCSVArray());
 
 
 
121
  //clear collection and free memory
122
  $customer->clearInstance();
123
  }
124
 
125
- $customerNum = count($customers);
126
- $helper->log('Website : ' . $website->getName() . ', customers = ' . $customerNum);
127
- $helper->log('---------------------------- execution time :' . gmdate("H:i:s", microtime(true) - $this->_start));
 
 
 
 
 
 
128
 
129
  if (is_file($fileHelper->getFilePath($customersFile))) {
130
  if ($customerNum > 0) {
131
  //register in queue with importer
132
- $check = Mage::getModel('ddg_automation/importer')->registerQueue(
133
- Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_CONTACT,
134
- '',
135
- Dotdigitalgroup_Email_Model_Importer::MODE_BULK,
136
- $website->getId(),
137
- $customersFile
138
- );
 
139
 
140
  //set imported
141
  if ($check) {
142
- Mage::getResourceModel('ddg_automation/contact')->update($customers);
 
 
143
  }
144
  }
145
  }
146
  $this->_countCustomers += $customerNum;
 
147
  return $customerNum;
148
  }
149
 
150
- /**
151
- * Sync a single contact.
152
- *
153
- * @param null $contactId
154
- *
155
- * @return mixed
156
- * @throws Mage_Core_Exception
157
- */
158
- public function syncContact($contactId = null)
159
  {
160
- if ($contactId)
161
- $contact = Mage::getModel('ddg_automation/contact')->load($contactId);
162
- else {
 
 
163
  $contact = Mage::registry('current_contact');
164
  }
165
- if (! $contact->getId()) {
166
- Mage::getSingleton('adminhtml/session')->addError('No contact found!');
 
 
 
167
  return false;
168
  }
169
 
170
  $websiteId = $contact->getWebsiteId();
171
- $website = Mage::app()->getWebsite($websiteId);
172
- $updated = 0;
173
  $customers = $headers = $allMappedHash = array();
174
- $helper = Mage::helper('ddg');
175
  $helper->log('---------- Start single customer sync ----------');
176
  //skip if the mapping field is missing
177
- if(!$helper->getCustomerAddressBook($website))
178
  return false;
 
179
  $fileHelper = Mage::helper('ddg/file');
180
 
181
  $customerId = $contact->getCustomerId();
182
- if (!$customerId) {
183
- Mage::getSingleton('adminhtml/session')->addError('Cannot manually sync guests!');
 
 
 
184
  return false;
185
  }
186
 
187
  //create customer filename
188
- $customersFile = strtolower($website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv');
 
 
189
  $helper->log('Customers file : ' . $customersFile);
190
 
191
  /**
192
  * HEADERS.
193
  */
194
- $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields($website);
195
- $headers = $mappedHash;
 
 
196
  //custom customer attributes
197
  $customAttributes = $helper->getCustomAttributes($website);
198
  foreach ($customAttributes as $data) {
199
- $headers[] = $data['datafield'];
200
  $allMappedHash[$data['attribute']] = $data['datafield'];
201
  }
202
 
203
  $headers[] = 'Email';
204
  $headers[] = 'EmailType';
205
- $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $headers);
 
 
206
  /**
207
  * END HEADERS.
208
  */
209
 
210
- $customerCollection = $this->getCollection(array($customerId), $website->getId());
 
 
211
 
212
  foreach ($customerCollection as $customer) {
213
  /**
214
  * DATA.
215
  */
216
- $connectorCustomer = Mage::getModel('ddg_automation/apiconnector_customer', $mappedHash);
 
 
217
  $connectorCustomer->setCustomerData($customer);
218
  //count number of customers
219
  $customers[] = $connectorCustomer;
220
  foreach ($customAttributes as $data) {
221
  $attribute = $data['attribute'];
222
- $value = $customer->getData($attribute);
223
  $connectorCustomer->setData($value);
224
  }
225
  //contact email and email type
226
  $connectorCustomer->setData($customer->getEmail());
227
  $connectorCustomer->setData('Html');
228
  // save csv file data for customers
229
- $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $connectorCustomer->toCSVArray());
 
 
 
230
 
231
  /**
232
  * END DATA.
@@ -239,72 +305,137 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
239
  //import contacts
240
  if ($updated > 0) {
241
  //register in queue with importer
242
- $check = Mage::getModel('ddg_automation/importer')->registerQueue(
243
- Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_CONTACT,
244
- '',
245
- Dotdigitalgroup_Email_Model_Importer::MODE_BULK,
246
- $website->getId(),
247
- $customersFile
248
- );
 
249
 
250
  //set imported
251
  if ($check) {
252
- Mage::getResourceModel('ddg_automation/contact')->update($customerId);
 
 
253
  }
254
  }
255
  }
 
256
  return $contact->getEmail();
257
  }
258
 
259
 
260
  /**
261
  * get customer collection
 
262
  * @param $customerIds
263
  * @param $websiteId
 
264
  * @return Mage_Eav_Model_Entity_Collection_Abstract
265
  * @throws Mage_Core_Exception
266
  */
267
  public function getCollection($customerIds, $websiteId = 0)
268
  {
269
- $customerCollection = Mage::getResourceModel('customer/customer_collection')
 
 
270
  ->addNameToSelect()
271
  ->addAttributeToSelect('*')
272
- ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
273
- ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
274
- ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')
275
- ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
276
- ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
277
- ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
278
- ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
279
- ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
280
- ->joinAttribute('shipping_country_code','customer_address/country_id', 'default_shipping', null, 'left')
281
- ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
282
- ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
283
- ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  ->addAttributeToFilter('entity_id', array('in' => $customerIds));
285
- $customer_log = Mage::getSingleton('core/resource')->getTableName('log_customer');
286
- $sales_flat_order_grid = Mage::getSingleton('core/resource')->getTableName('sales_flat_order_grid');
287
- $sales_flat_quote = Mage::getSingleton('core/resource')->getTableName('sales_flat_quote');
288
- $sales_flat_order = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
289
- $sales_flat_order_item = Mage::getSingleton('core/resource')->getTableName('sales_flat_order_item');
290
- $catalog_category_product_index = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
291
- $eav_attribute_option_value = Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value');
292
- $catalog_product_entity_int = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int');
293
- $eav_attribute = Mage::getSingleton('core/resource')->getTableName('eav_attribute');
 
 
 
 
 
 
 
 
 
 
 
294
 
295
 
296
  // get the last login date from the log_customer table
297
  $customerCollection->getSelect()->columns(
298
- array('last_logged_date' => new Zend_Db_Expr ("(SELECT login_at FROM $customer_log WHERE customer_id =e.entity_id ORDER BY log_id DESC LIMIT 1)")));
 
 
 
299
 
300
  // customer order information
301
- $alias = 'subselect';
302
- $statuses = Mage::helper('ddg')->getWebsiteConfig(
303
- Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS, $websiteId
 
304
  );
305
- $statuses = explode(',', $statuses);
306
- $subselect = Mage::getModel('Varien_Db_Select', Mage::getSingleton('core/resource')->getConnection('core_read'))
307
- ->from($sales_flat_order_grid, array(
 
 
 
 
308
  'customer_id as s_customer_id',
309
  'sum(grand_total) as total_spend',
310
  'count(*) as number_of_orders',
@@ -312,29 +443,36 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
312
  )
313
  )
314
  ->where("status in (?)", $statuses)
315
- ->group('customer_id')
316
- ;
317
 
318
  $columns = array(
319
- 'last_order_date' => new Zend_Db_Expr("(SELECT created_at FROM $sales_flat_order_grid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"),
320
- 'last_order_id' => new Zend_Db_Expr("(SELECT entity_id FROM $sales_flat_order_grid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"),
321
- 'last_increment_id' => new Zend_Db_Expr("(SELECT increment_id FROM $sales_flat_order_grid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"),
322
- 'last_quote_id' => new Zend_Db_Expr("(SELECT entity_id FROM $sales_flat_quote WHERE customer_id = e.entity_id ORDER BY created_at DESC LIMIT 1)"),
323
- 'first_category_id' => new Zend_Db_Expr(
 
 
 
 
 
 
 
 
324
  "(
325
- SELECT ccpi.category_id FROM $sales_flat_order as sfo
326
- left join $sales_flat_order_item as sfoi on sfoi.order_id = sfo.entity_id
327
- left join $catalog_category_product_index as ccpi on ccpi.product_id = sfoi.product_id
328
  WHERE sfo.customer_id = e.entity_id
329
  ORDER BY sfo.created_at ASC, sfoi.price DESC
330
  LIMIT 1
331
  )"
332
  ),
333
- 'last_category_id' => new Zend_Db_Expr(
334
  "(
335
- SELECT ccpi.category_id FROM $sales_flat_order as sfo
336
- left join $sales_flat_order_item as sfoi on sfoi.order_id = sfo.entity_id
337
- left join $catalog_category_product_index as ccpi on ccpi.product_id = sfoi.product_id
338
  WHERE sfo.customer_id = e.entity_id
339
  ORDER BY sfo.created_at DESC, sfoi.price DESC
340
  LIMIT 1
@@ -342,26 +480,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
342
  ),
343
  'product_id_for_first_brand' => new Zend_Db_Expr(
344
  "(
345
- SELECT sfoi.product_id FROM $sales_flat_order as sfo
346
- left join $sales_flat_order_item as sfoi on sfoi.order_id = sfo.entity_id
347
  WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
348
  ORDER BY sfo.created_at ASC, sfoi.price DESC
349
  LIMIT 1
350
  )"
351
  ),
352
- 'product_id_for_last_brand' => new Zend_Db_Expr(
353
  "(
354
- SELECT sfoi.product_id FROM $sales_flat_order as sfo
355
- left join $sales_flat_order_item as sfoi on sfoi.order_id = sfo.entity_id
356
  WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
357
  ORDER BY sfo.created_at DESC, sfoi.price DESC
358
  LIMIT 1
359
  )"
360
  ),
361
- 'week_day' => new Zend_Db_Expr(
362
  "(
363
  SELECT dayname(created_at) as week_day
364
- FROM $sales_flat_order
365
  WHERE customer_id = e.entity_id
366
  GROUP BY week_day
367
  HAVING COUNT(*) > 0
@@ -369,10 +507,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
369
  LIMIT 1
370
  )"
371
  ),
372
- 'month_day' => new Zend_Db_Expr(
373
  "(
374
  SELECT monthname(created_at) as month_day
375
- FROM $sales_flat_order
376
  WHERE customer_id = e.entity_id
377
  GROUP BY month_day
378
  HAVING COUNT(*) > 0
@@ -380,11 +518,11 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
380
  LIMIT 1
381
  )"
382
  ),
383
- 'most_category_id' => new Zend_Db_Expr(
384
  "(
385
- SELECT ccpi.category_id FROM $sales_flat_order as sfo
386
- LEFT JOIN $sales_flat_order_item as sfoi on sfoi.order_id = sfo.entity_id
387
- LEFT JOIN $catalog_category_product_index as ccpi on ccpi.product_id = sfoi.product_id
388
  WHERE sfo.customer_id = e.entity_id AND ccpi.category_id is not null
389
  GROUP BY category_id
390
  HAVING COUNT(sfoi.product_id) > 0
@@ -397,17 +535,18 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
397
  );
398
 
399
  $brand = Mage::helper('ddg')->getWebsiteConfig(
400
- Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE, $websiteId
 
401
  );
402
 
403
- if($brand){
404
  $columns['most_brand'] = new Zend_Db_Expr(
405
  "(
406
- SELECT eaov.value from $sales_flat_order sfo
407
- LEFT JOIN $sales_flat_order_item as sfoi on sfoi.order_id = sfo.entity_id
408
- LEFT JOIN $catalog_product_entity_int pei on pei.entity_id = sfoi.product_id
409
- LEFT JOIN $eav_attribute ea ON pei.attribute_id = ea.attribute_id
410
- LEFT JOIN $eav_attribute_option_value as eaov on pei.value = eaov.option_id
411
  WHERE sfo.customer_id = e.entity_id AND ea.attribute_code = '$brand' AND eaov.value is not null
412
  GROUP BY eaov.value
413
  HAVING count(*) > 0
@@ -420,7 +559,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
420
  $customerCollection->getSelect()->columns($columns);
421
 
422
  $customerCollection->getSelect()
423
- ->joinLeft(array($alias => $subselect), "{$alias}.s_customer_id = e.entity_id");
 
 
 
424
 
425
  return $customerCollection;
426
  }
2
 
3
  class Dotdigitalgroup_Email_Model_Apiconnector_Contact
4
  {
5
+
6
  protected $_start;
7
  protected $_countCustomers = 0;
8
 
9
+ /**
10
+ * Contact sync.
11
+ *
12
+ * @return array
13
+ */
14
+ public function sync()
15
  {
16
  $result = array('success' => true, 'message' => '');
17
  /** @var Dotdigitalgroup_Email_Helper_Data $helper */
18
+ $helper = Mage::helper('ddg');
19
  $this->_start = microtime(true);
20
  //resourse allocation
21
  $helper->allowResourceFullExecution();
22
  foreach (Mage::app()->getWebsites(true) as $website) {
23
+ $enabled = Mage::helper('ddg')->getWebsiteConfig(
24
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED,
25
+ $website
26
+ );
27
+ $sync = Mage::helper('ddg')->getWebsiteConfig(
28
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED,
29
+ $website
30
+ );
31
  if ($enabled && $sync) {
32
 
33
+ if ( ! $this->_countCustomers) {
34
+ $helper->log('---------- Start customer sync ----------');
35
+ }
36
+ $numUpdated = $this->exportCustomersForWebsite($website);
37
+ // show message for any number of customers
38
+ if ($numUpdated) {
39
+ $result['message'] .= '</br>' . $website->getName()
40
+ . ', updated customers = ' . $numUpdated;
41
+ }
42
  }
43
  }
44
+ //sync proccessed
45
+ if ($this->_countCustomers) {
46
+ $message = 'Total time for sync : ' . gmdate(
47
+ "H:i:s", microtime(true) - $this->_start
48
+ ) .
49
+ ', Total updated = ' . $this->_countCustomers;
50
+ $helper->log($message);
51
+ $message .= $result['message'];
52
+ $result['message'] = $message;
53
+ }
54
 
55
  return $result;
56
  }
57
 
58
+ /**
59
+ * Execute the contact sync for the website
60
+ * number of customer synced.
61
+ *
62
+ * @param Mage_Core_Model_Website $website
63
+ *
64
+ * @return int|void
65
+ */
66
  public function exportCustomersForWebsite(Mage_Core_Model_Website $website)
67
  {
68
  $customers = $headers = $allMappedHash = array();
69
+ $helper = Mage::helper('ddg');
70
+ $pageSize = $helper->getWebsiteConfig(
71
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT,
72
+ $website
73
+ );
74
 
75
  //skip if the mapping field is missing
76
+ if ( ! $helper->getCustomerAddressBook($website)) {
77
  return 0;
78
+ }
79
 
80
+ $fileHelper = Mage::helper('ddg/file');
81
  $contactModel = Mage::getModel('ddg_automation/contact');
82
+ $contacts = $contactModel->getContactsToImportForWebsite(
83
+ $website->getId(), $pageSize
84
+ );
85
 
86
  // no contacts for this website
87
+ if ( ! $contacts->getSize()) {
88
  return 0;
89
+ }
90
 
91
  //create customer filename
92
+ $customersFile = strtolower(
93
+ $website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv'
94
+ );
95
  $helper->log('Customers file : ' . $customersFile);
96
 
97
  //get customer ids
98
  $customerIds = $contacts->getColumnValues('customer_id');
99
 
100
  //customer collection
101
+ $customerCollection = $this->getCollection(
102
+ $customerIds, $website->getId()
103
+ );
104
 
105
  /**
106
  * HEADERS.
107
  */
108
+ $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields(
109
+ $website
110
+ );
111
+ $headers = $mappedHash;
112
 
113
  //custom customer attributes
114
  $customAttributes = $helper->getCustomAttributes($website);
115
+ if ($customAttributes) {
116
+ foreach ($customAttributes as $data) {
117
+ $headers[] = $data['datafield'];
118
+ $allMappedHash[$data['attribute']] = $data['datafield'];
119
+ }
120
  }
121
  $headers[] = 'Email';
122
  $headers[] = 'EmailType';
123
+ $fileHelper->outputCSV(
124
+ $fileHelper->getFilePath($customersFile), $headers
125
+ );
126
  /**
127
  * END HEADERS.
128
  */
129
 
130
  //customer data
131
  foreach ($customerCollection as $customer) {
132
+ $connectorCustomer = Mage::getModel(
133
+ 'ddg_automation/apiconnector_customer', $mappedHash
134
+ );
135
  $connectorCustomer->setCustomerData($customer);
136
  //count number of customers
137
  $customers[] = $customer->getId();
139
  if ($connectorCustomer) {
140
  foreach ($customAttributes as $data) {
141
  $attribute = $data['attribute'];
142
+ $value = $customer->getData($attribute);
143
  $connectorCustomer->setData($value);
144
  }
145
  }
148
  $connectorCustomer->setData($customer->getEmail());
149
  $connectorCustomer->setData('Html');
150
  // save csv file data for customers
151
+ $fileHelper->outputCSV(
152
+ $fileHelper->getFilePath($customersFile),
153
+ $connectorCustomer->toCSVArray()
154
+ );
155
  //clear collection and free memory
156
  $customer->clearInstance();
157
  }
158
 
159
+ $customerNum = count($customers);
160
+ $helper->log(
161
+ 'Website : ' . $website->getName() . ', customers = ' . $customerNum
162
+ );
163
+ $helper->log(
164
+ '---------------------------- execution time :' . gmdate(
165
+ "H:i:s", microtime(true) - $this->_start
166
+ )
167
+ );
168
 
169
  if (is_file($fileHelper->getFilePath($customersFile))) {
170
  if ($customerNum > 0) {
171
  //register in queue with importer
172
+ $check = Mage::getModel('ddg_automation/importer')
173
+ ->registerQueue(
174
+ Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_CONTACT,
175
+ '',
176
+ Dotdigitalgroup_Email_Model_Importer::MODE_BULK,
177
+ $website->getId(),
178
+ $customersFile
179
+ );
180
 
181
  //set imported
182
  if ($check) {
183
+ Mage::getResourceModel('ddg_automation/contact')->update(
184
+ $customers
185
+ );
186
  }
187
  }
188
  }
189
  $this->_countCustomers += $customerNum;
190
+
191
  return $customerNum;
192
  }
193
 
194
+ /**
195
+ * Sync a single contact.
196
+ *
197
+ * @param null $contactId
198
+ *
199
+ * @return mixed
200
+ * @throws Mage_Core_Exception
201
+ */
202
+ public function syncContact($contactId = null)
203
  {
204
+ if ($contactId) {
205
+ $contact = Mage::getModel('ddg_automation/contact')->load(
206
+ $contactId
207
+ );
208
+ } else {
209
  $contact = Mage::registry('current_contact');
210
  }
211
+ if ( ! $contact->getId()) {
212
+ Mage::getSingleton('adminhtml/session')->addError(
213
+ 'No contact found!'
214
+ );
215
+
216
  return false;
217
  }
218
 
219
  $websiteId = $contact->getWebsiteId();
220
+ $website = Mage::app()->getWebsite($websiteId);
221
+ $updated = 0;
222
  $customers = $headers = $allMappedHash = array();
223
+ $helper = Mage::helper('ddg');
224
  $helper->log('---------- Start single customer sync ----------');
225
  //skip if the mapping field is missing
226
+ if ( ! $helper->getCustomerAddressBook($website)) {
227
  return false;
228
+ }
229
  $fileHelper = Mage::helper('ddg/file');
230
 
231
  $customerId = $contact->getCustomerId();
232
+ if ( ! $customerId) {
233
+ Mage::getSingleton('adminhtml/session')->addError(
234
+ 'Cannot manually sync guests!'
235
+ );
236
+
237
  return false;
238
  }
239
 
240
  //create customer filename
241
+ $customersFile = strtolower(
242
+ $website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv'
243
+ );
244
  $helper->log('Customers file : ' . $customersFile);
245
 
246
  /**
247
  * HEADERS.
248
  */
249
+ $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields(
250
+ $website
251
+ );
252
+ $headers = $mappedHash;
253
  //custom customer attributes
254
  $customAttributes = $helper->getCustomAttributes($website);
255
  foreach ($customAttributes as $data) {
256
+ $headers[] = $data['datafield'];
257
  $allMappedHash[$data['attribute']] = $data['datafield'];
258
  }
259
 
260
  $headers[] = 'Email';
261
  $headers[] = 'EmailType';
262
+ $fileHelper->outputCSV(
263
+ $fileHelper->getFilePath($customersFile), $headers
264
+ );
265
  /**
266
  * END HEADERS.
267
  */
268
 
269
+ $customerCollection = $this->getCollection(
270
+ array($customerId), $website->getId()
271
+ );
272
 
273
  foreach ($customerCollection as $customer) {
274
  /**
275
  * DATA.
276
  */
277
+ $connectorCustomer = Mage::getModel(
278
+ 'ddg_automation/apiconnector_customer', $mappedHash
279
+ );
280
  $connectorCustomer->setCustomerData($customer);
281
  //count number of customers
282
  $customers[] = $connectorCustomer;
283
  foreach ($customAttributes as $data) {
284
  $attribute = $data['attribute'];
285
+ $value = $customer->getData($attribute);
286
  $connectorCustomer->setData($value);
287
  }
288
  //contact email and email type
289
  $connectorCustomer->setData($customer->getEmail());
290
  $connectorCustomer->setData('Html');
291
  // save csv file data for customers
292
+ $fileHelper->outputCSV(
293
+ $fileHelper->getFilePath($customersFile),
294
+ $connectorCustomer->toCSVArray()
295
+ );
296
 
297
  /**
298
  * END DATA.
305
  //import contacts
306
  if ($updated > 0) {
307
  //register in queue with importer
308
+ $check = Mage::getModel('ddg_automation/importer')
309
+ ->registerQueue(
310
+ Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_CONTACT,
311
+ '',
312
+ Dotdigitalgroup_Email_Model_Importer::MODE_BULK,
313
+ $website->getId(),
314
+ $customersFile
315
+ );
316
 
317
  //set imported
318
  if ($check) {
319
+ Mage::getResourceModel('ddg_automation/contact')->update(
320
+ $customerId
321
+ );
322
  }
323
  }
324
  }
325
+
326
  return $contact->getEmail();
327
  }
328
 
329
 
330
  /**
331
  * get customer collection
332
+ *
333
  * @param $customerIds
334
  * @param $websiteId
335
+ *
336
  * @return Mage_Eav_Model_Entity_Collection_Abstract
337
  * @throws Mage_Core_Exception
338
  */
339
  public function getCollection($customerIds, $websiteId = 0)
340
  {
341
+ $customerCollection = Mage::getResourceModel(
342
+ 'customer/customer_collection'
343
+ )
344
  ->addNameToSelect()
345
  ->addAttributeToSelect('*')
346
+ ->joinAttribute(
347
+ 'billing_street', 'customer_address/street', 'default_billing',
348
+ null, 'left'
349
+ )
350
+ ->joinAttribute(
351
+ 'billing_city', 'customer_address/city', 'default_billing',
352
+ null, 'left'
353
+ )
354
+ ->joinAttribute(
355
+ 'billing_country_code', 'customer_address/country_id',
356
+ 'default_billing', null, 'left'
357
+ )
358
+ ->joinAttribute(
359
+ 'billing_postcode', 'customer_address/postcode',
360
+ 'default_billing', null, 'left'
361
+ )
362
+ ->joinAttribute(
363
+ 'billing_telephone', 'customer_address/telephone',
364
+ 'default_billing', null, 'left'
365
+ )
366
+ ->joinAttribute(
367
+ 'billing_region', 'customer_address/region', 'default_billing',
368
+ null, 'left'
369
+ )
370
+ ->joinAttribute('billing_company', 'customer_address/company', 'default_billing', null, 'left')
371
+ ->joinAttribute(
372
+ 'shipping_street', 'customer_address/street',
373
+ 'default_shipping', null, 'left'
374
+ )
375
+ ->joinAttribute(
376
+ 'shipping_city', 'customer_address/city', 'default_shipping',
377
+ null, 'left'
378
+ )
379
+ ->joinAttribute(
380
+ 'shipping_country_code', 'customer_address/country_id',
381
+ 'default_shipping', null, 'left'
382
+ )
383
+ ->joinAttribute(
384
+ 'shipping_postcode', 'customer_address/postcode',
385
+ 'default_shipping', null, 'left'
386
+ )
387
+ ->joinAttribute(
388
+ 'shipping_telephone', 'customer_address/telephone',
389
+ 'default_shipping', null, 'left'
390
+ )
391
+ ->joinAttribute(
392
+ 'shipping_region', 'customer_address/region',
393
+ 'default_shipping', null, 'left'
394
+ )
395
+ ->joinAttribute('shipping_company', 'customer_address/company', 'default_shipping', null, 'left')
396
  ->addAttributeToFilter('entity_id', array('in' => $customerIds));
397
+ $customerLog = Mage::getSingleton('core/resource')
398
+ ->getTableName(
399
+ 'log_customer'
400
+ );
401
+ $salesFlatOrderGrid = Mage::getSingleton('core/resource')
402
+ ->getTableName('sales_flat_order_grid');
403
+ $salesFlatQuote = Mage::getSingleton('core/resource')
404
+ ->getTableName('sales_flat_quote');
405
+ $salesFlatOrder = Mage::getSingleton('core/resource')
406
+ ->getTableName('sales_flat_order');
407
+ $salesFlatOrderItem = Mage::getSingleton('core/resource')
408
+ ->getTableName('sales_flat_order_item');
409
+ $catalogCategoryProductIndex = Mage::getSingleton('core/resource')
410
+ ->getTableName('catalog_category_product');
411
+ $eavAttributeOptionValue = Mage::getSingleton('core/resource')
412
+ ->getTableName('eav_attribute_option_value');
413
+ $catalogProductEntityInt = Mage::getSingleton('core/resource')
414
+ ->getTableName('catalog_product_entity_int');
415
+ $eavAttribute = Mage::getSingleton('core/resource')
416
+ ->getTableName('eav_attribute');
417
 
418
 
419
  // get the last login date from the log_customer table
420
  $customerCollection->getSelect()->columns(
421
+ array('last_logged_date' => new Zend_Db_Expr(
422
+ "(SELECT login_at FROM $customerLog WHERE customer_id =e.entity_id ORDER BY log_id DESC LIMIT 1)"
423
+ ))
424
+ );
425
 
426
  // customer order information
427
+ $alias = 'subselect';
428
+ $statuses = Mage::helper('ddg')->getWebsiteConfig(
429
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
430
+ $websiteId
431
  );
432
+ $statuses = explode(',', $statuses);
433
+ $subselect = Mage::getModel(
434
+ 'Varien_Db_Select',
435
+ Mage::getSingleton('core/resource')->getConnection('core_read')
436
+ )
437
+ ->from(
438
+ $salesFlatOrderGrid, array(
439
  'customer_id as s_customer_id',
440
  'sum(grand_total) as total_spend',
441
  'count(*) as number_of_orders',
443
  )
444
  )
445
  ->where("status in (?)", $statuses)
446
+ ->group('customer_id');
 
447
 
448
  $columns = array(
449
+ 'last_order_date' => new Zend_Db_Expr(
450
+ "(SELECT created_at FROM $salesFlatOrderGrid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"
451
+ ),
452
+ 'last_order_id' => new Zend_Db_Expr(
453
+ "(SELECT entity_id FROM $salesFlatOrderGrid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"
454
+ ),
455
+ 'last_increment_id' => new Zend_Db_Expr(
456
+ "(SELECT increment_id FROM $salesFlatOrderGrid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"
457
+ ),
458
+ 'last_quote_id' => new Zend_Db_Expr(
459
+ "(SELECT entity_id FROM $salesFlatQuote WHERE customer_id = e.entity_id ORDER BY created_at DESC LIMIT 1)"
460
+ ),
461
+ 'first_category_id' => new Zend_Db_Expr(
462
  "(
463
+ SELECT ccpi.category_id FROM $salesFlatOrder as sfo
464
+ left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
465
+ left join $catalogCategoryProductIndex as ccpi on ccpi.product_id = sfoi.product_id
466
  WHERE sfo.customer_id = e.entity_id
467
  ORDER BY sfo.created_at ASC, sfoi.price DESC
468
  LIMIT 1
469
  )"
470
  ),
471
+ 'last_category_id' => new Zend_Db_Expr(
472
  "(
473
+ SELECT ccpi.category_id FROM $salesFlatOrder as sfo
474
+ left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
475
+ left join $catalogCategoryProductIndex as ccpi on ccpi.product_id = sfoi.product_id
476
  WHERE sfo.customer_id = e.entity_id
477
  ORDER BY sfo.created_at DESC, sfoi.price DESC
478
  LIMIT 1
480
  ),
481
  'product_id_for_first_brand' => new Zend_Db_Expr(
482
  "(
483
+ SELECT sfoi.product_id FROM $salesFlatOrder as sfo
484
+ left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
485
  WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
486
  ORDER BY sfo.created_at ASC, sfoi.price DESC
487
  LIMIT 1
488
  )"
489
  ),
490
+ 'product_id_for_last_brand' => new Zend_Db_Expr(
491
  "(
492
+ SELECT sfoi.product_id FROM $salesFlatOrder as sfo
493
+ left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
494
  WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
495
  ORDER BY sfo.created_at DESC, sfoi.price DESC
496
  LIMIT 1
497
  )"
498
  ),
499
+ 'week_day' => new Zend_Db_Expr(
500
  "(
501
  SELECT dayname(created_at) as week_day
502
+ FROM $salesFlatOrder
503
  WHERE customer_id = e.entity_id
504
  GROUP BY week_day
505
  HAVING COUNT(*) > 0
507
  LIMIT 1
508
  )"
509
  ),
510
+ 'month_day' => new Zend_Db_Expr(
511
  "(
512
  SELECT monthname(created_at) as month_day
513
+ FROM $salesFlatOrder
514
  WHERE customer_id = e.entity_id
515
  GROUP BY month_day
516
  HAVING COUNT(*) > 0
518
  LIMIT 1
519
  )"
520
  ),
521
+ 'most_category_id' => new Zend_Db_Expr(
522
  "(
523
+ SELECT ccpi.category_id FROM $salesFlatOrder as sfo
524
+ LEFT JOIN $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
525
+ LEFT JOIN $catalogCategoryProductIndex as ccpi on ccpi.product_id = sfoi.product_id
526
  WHERE sfo.customer_id = e.entity_id AND ccpi.category_id is not null
527
  GROUP BY category_id
528
  HAVING COUNT(sfoi.product_id) > 0
535
  );
536
 
537
  $brand = Mage::helper('ddg')->getWebsiteConfig(
538
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
539
+ $websiteId
540
  );
541
 
542
+ if ($brand) {
543
  $columns['most_brand'] = new Zend_Db_Expr(
544
  "(
545
+ SELECT eaov.value from $salesFlatOrder sfo
546
+ LEFT JOIN $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
547
+ LEFT JOIN $catalogProductEntityInt pei on pei.entity_id = sfoi.product_id
548
+ LEFT JOIN $eavAttribute ea ON pei.attribute_id = ea.attribute_id
549
+ LEFT JOIN $eavAttributeOptionValue as eaov on pei.value = eaov.option_id
550
  WHERE sfo.customer_id = e.entity_id AND ea.attribute_code = '$brand' AND eaov.value is not null
551
  GROUP BY eaov.value
552
  HAVING count(*) > 0
559
  $customerCollection->getSelect()->columns($columns);
560
 
561
  $customerCollection->getSelect()
562
+ ->joinLeft(
563
+ array($alias => $subselect),
564
+ "{$alias}.s_customer_id = e.entity_id"
565
+ );
566
 
567
  return $customerCollection;
568
  }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php CHANGED
@@ -7,40 +7,41 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
7
  public $customerData;
8
  public $reviewCollection;
9
 
10
- //enterprise reward
11
- public $reward;
12
 
13
  public $rewardCustomer;
14
  public $rewardLastSpent = "";
15
  public $rewardLastEarned = "";
16
  public $rewardExpiry = "";
17
 
18
- protected $_mapping_hash;
19
 
20
- protected $subscriber_status = array(
21
- Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => 'Subscribed',
22
- Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => 'Not Active',
23
- Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => 'Unsubscribed',
24
- Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => 'Unconfirmed'
25
- );
 
26
 
27
 
28
- /**
29
- * constructor, mapping hash to map.
30
- *
31
- * @param $mappingHash
32
- */
33
- public function __construct( $mappingHash)
34
- {
35
  $this->setMappigHash($mappingHash);
36
  }
37
 
38
- /**
39
- * Set key value data.
40
- *
41
- * @param $data
42
- */
43
- public function setData($data)
44
  {
45
  $this->customerData[] = $data;
46
  }
@@ -56,8 +57,9 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
56
  $this->setReviewCollection();
57
  $website = $customer->getStore()->getWebsite();
58
 
59
- if ($website && Mage::helper('ddg')->isSweetToothToGo($website))
60
  $this->setRewardCustomer($customer);
 
61
 
62
  foreach ($this->getMappingHash() as $key => $field) {
63
 
@@ -69,10 +71,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
69
  foreach ($exploded as $one) {
70
  $function .= ucfirst($one);
71
  }
72
- try{
73
- $value = call_user_func(array('self', $function));
 
 
74
  $this->customerData[$key] = $value;
75
- }catch (Exception $e){
76
  Mage::logException($e);
77
  }
78
  }
@@ -80,10 +84,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
80
 
81
  public function setReviewCollection()
82
  {
83
- $customer_id = $this->customer->getId();
84
- $collection = Mage::getModel('review/review')->getCollection()
85
- ->addCustomerFilter($customer_id)
86
- ->setOrder('review_id','DESC');
87
 
88
  $this->reviewCollection = $collection;
89
  }
@@ -93,12 +97,15 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
93
  return $this->reviewCollection->getSize();
94
  }
95
 
96
- public function getLastReviewDate(){
 
 
 
 
97
 
98
- if(count($this->reviewCollection)){
99
- $this->reviewCollection->getSelect()->limit(1);
100
- return $this->reviewCollection->getFirstItem()->getCreatedAt();
101
  }
 
102
  return '';
103
  }
104
 
@@ -110,349 +117,361 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
110
  public function setRewardCustomer(Mage_Customer_Model_Customer $customer)
111
  {
112
  //get tbt reward customer
113
- $tbt_reward = Mage::getModel('rewards/customer')->getRewardsCustomer($customer);
114
- $this->rewardCustomer = $tbt_reward;
 
 
 
115
 
116
  //get transfers collection from tbt reward. only active and order by last updated.
117
- $lastTransfers = $tbt_reward->getTransfers()
118
  ->selectOnlyActive()
119
- ->addOrder('last_update_ts', Varien_Data_Collection::SORT_ORDER_DESC);
 
 
120
 
121
  $spent = $earn = null;
122
 
123
- foreach($lastTransfers as $transfer) {
124
- // if transfer quantity is greater then 0 then this is last points earned date. keep checking until earn is not null
125
- if(is_null($earn) && $transfer->getQuantity() > 0){
126
- $earn = $transfer->getEffectiveStart();
127
- }
128
- // id transfer quantity is less then 0 then this is last points spent date. keep checking until spent is not null
129
- else if(is_null($spent) && $transfer->getQuantity() < 0) {
 
130
  $spent = $transfer->getEffectiveStart();
131
  }
132
  // break if both spent and earn are not null (a value has been assigned)
133
- if(!is_null($spent) && !is_null($earn)) {
134
  break;
135
  }
136
  }
137
 
138
  // if earn is not null (has a value) then assign the value to property
139
- if($earn)
140
  $this->rewardLastEarned = $earn;
 
141
  // if spent is not null (has a value) then assign the value to property
142
- if($spent)
143
  $this->rewardLastSpent = $spent;
 
144
 
145
- $tbt_expiry = Mage::getSingleton('rewards/expiry')
146
- ->getExpiryDate($tbt_reward);
147
 
148
  // if there is an expiry (has a value) then assign the value to property
149
- if($tbt_expiry)
150
- $this->rewardExpiry = $tbt_expiry;
 
151
  }
152
 
153
  /**
154
- * get customer id.
155
- *
156
- * @return mixed
157
- */
158
- public function getCustomerId()
159
  {
160
  return $this->customer->getId();
161
  }
162
 
163
- /**
164
- * get first name.
165
- *
166
- * @return mixed
167
- */
168
- public function getFirstname(){
 
169
  return $this->customer->getFirstname();
170
  }
171
 
172
- /**
173
- * get last name.
174
- *
175
- * @return mixed
176
- */
177
- public function getLastname()
178
  {
179
  return $this->customer->getLastname();
180
  }
181
 
182
- /**
183
- * get date of birth.
184
- *
185
- * @return mixed
186
- */
187
- public function getDob()
188
  {
189
  return $this->customer->getDob();
190
  }
191
 
192
- /**
193
- * get customer gender.
194
- *
195
- * @return bool|string
196
- */
197
- public function getGender()
198
  {
199
  return $this->_getCustomerGender();
200
  }
201
 
202
- /**
203
- * get customer prefix.
204
- *
205
- * @return mixed
206
- */
207
- public function getPrefix()
208
  {
209
  return $this->customer->getPrefix();
210
  }
211
 
212
- /**
213
- * get customer suffix.
214
- *
215
- * @return mixed
216
- */
217
- public function getSuffix()
218
  {
219
  return $this->customer->getSuffix();
220
  }
221
 
222
- /**
223
- * get website name.
224
- *
225
- * @return string
226
- */
227
- public function getWebsiteName()
228
  {
229
  return $this->_getWebsiteName();
230
  }
231
 
232
- /**
233
- * get store name.
234
- *
235
- * @return null|string
236
- */
237
- public function getStoreName()
238
  {
239
  return $this->_getStoreName();
240
  }
241
 
242
- /**
243
- * get customer created at date.
244
- *
245
- * @return mixed
246
- */
247
- public function getCreatedAt()
248
  {
249
  return $this->customer->getCreatedAt();
250
  }
251
 
252
- /**
253
- * get customer last logged in date.
254
- *
255
- * @return mixed
256
- */
257
- public function getLastLoggedDate()
258
  {
259
  return $this->customer->getLastLoggedDate();
260
  }
261
 
262
- /**
263
- * get cutomer group.
264
- *
265
- * @return string
266
- */
267
- public function getCustomerGroup()
268
  {
269
  return $this->_getCustomerGroup();
270
  }
271
 
272
- /**
273
- * get billing address line 1.
274
- *
275
- * @return string
276
- */
277
- public function getBillingAddress1()
278
  {
279
  return $this->_getStreet($this->customer->getBillingStreet(), 1);
280
  }
281
 
282
- /**
283
- * get billing address line 2.
284
- *
285
- * @return string
286
- */
287
- public function getBillingAddress2()
288
  {
289
  return $this->_getStreet($this->customer->getBillingStreet(), 2);
290
  }
291
 
292
- /**
293
- * get billing city.
294
- *
295
- * @return mixed
296
- */
297
- public function getBillingCity()
298
  {
299
  return $this->customer->getBillingCity();
300
  }
301
 
302
- /**
303
- * get billing country.
304
- *
305
- * @return mixed
306
- */
307
- public function getBillingCountry()
308
  {
309
  return $this->customer->getBillingCountryCode();
310
  }
311
 
312
- /**
313
- * get billing state.
314
- *
315
- * @return mixed
316
- */
317
- public function getBillingState()
318
  {
319
  return $this->customer->getBillingRegion();
320
  }
321
 
322
- /**
323
- * get billing postcode.
324
- *
325
- * @return mixed
326
- */
327
- public function getBillingPostcode()
328
  {
329
  return $this->customer->getBillingPostcode();
330
  }
331
 
332
- /**
333
- * get billing phone.
334
- *
335
- * @return mixed
336
- */
337
- public function getBillingTelephone()
338
  {
339
  return $this->customer->getBillingTelephone();
340
  }
341
 
342
- /**
343
- * get delivery address line 1.
344
- *
345
- * @return string
346
- */
347
- public function getDeliveryAddress1()
348
  {
349
  return $this->_getStreet($this->customer->getShippingStreet(), 1);
350
  }
351
 
352
- /**
353
- * get delivery addrss line 2.
354
- *
355
- * @return string
356
- */
357
- public function getDeliveryAddress2()
358
  {
359
  return $this->_getStreet($this->customer->getShippingStreet(), 2);
360
  }
361
 
362
- /**
363
- * get delivery city.
364
- *
365
- * @return mixed
366
- */
367
- public function getDeliveryCity()
368
  {
369
  return $this->customer->getShippingCity();
370
  }
371
 
372
- /**
373
- * get delivery country.
374
- *
375
- * @return mixed
376
- */
377
- public function getDeliveryCountry(){
 
378
  return $this->customer->getShippingCountryCode();
379
  }
380
 
381
- /**
382
- * get delivery state.
383
- *
384
- * @return mixed
385
- */
386
- public function getDeliveryState()
387
  {
388
  return $this->customer->getShippingRegion();
389
  }
390
 
391
- /**
392
- * get delivery postcode.
393
- *
394
- * @return mixed
395
- */
396
- public function getDeliveryPostcode()
397
  {
398
  return $this->customer->getShippingPostcode();
399
  }
400
 
401
- /**
402
- * get delivery phone.
403
- *
404
- * @return mixed
405
- */
406
- public function getDeliveryTelephone(){
 
407
  return $this->customer->getShippingTelephone();
408
  }
409
 
410
- /**
411
- * get numbser of orders.
412
- *
413
- * @return mixed
414
- */
415
- public function getNumberOfOrders()
416
  {
417
  return $this->customer->getNumberOfOrders();
418
  }
419
 
420
- /**
421
- * get average order value.
422
- *
423
- * @return mixed
424
- */
425
- public function getAverageOrderValue()
426
  {
427
  return $this->customer->getAverageOrderValue();
428
  }
429
 
430
- /**
431
- * get total spend.
432
- *
433
- * @return mixed
434
- */
435
- public function getTotalSpend()
436
  {
437
  return $this->customer->getTotalSpend();
438
  }
439
 
440
- /**
441
- * get last order date.
442
- *
443
- * @return mixed
444
- */
445
- public function getLastOrderDate()
446
  {
447
  return $this->customer->getLastOrderDate();
448
  }
449
 
450
- /**
451
- * get last order id.
452
- *
453
- * @return mixed
454
- */
455
- public function getLastOrderId()
456
  {
457
  return $this->customer->getLastOrderId();
458
  }
@@ -467,36 +486,35 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
467
  return $this->customer->getLastQuoteId();
468
  }
469
 
470
- /**
471
- * get cutomer id.
472
- *
473
- * @return mixed
474
- */
475
- public function getId()
476
  {
477
  return $this->customer->getId();
478
  }
479
 
480
- /**
481
- * get customer title.
482
- *
483
- * @return mixed
484
- */
485
- public function getTitle()
486
  {
487
  return $this->customer->getPrefix();
488
  }
489
 
490
- /**
491
- * get total refund value.
492
- *
493
- * @return float|int
494
- */
495
- public function getTotalRefund()
496
  {
497
- $orders = Mage::getResourceModel('sales/order_collection')
498
- ->addAttributeToFilter('customer_id', $this->customer->getId())
499
- ;
500
  $totalRefunded = 0;
501
  foreach ($orders as $order) {
502
  $refunded = $order->getTotalRefunded();
@@ -506,70 +524,77 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
506
  return $totalRefunded;
507
  }
508
 
509
- /**
510
- * export to CSV.
511
- *
512
- * @return mixed
513
- */
514
- public function toCSVArray()
515
  {
516
  $result = $this->customerData;
 
517
  return $result;
518
  }
519
 
520
- /**
521
- * customer gender.
522
- *
523
- * @return bool|string
524
- * @throws Mage_Core_Exception
525
- */
526
- protected function _getCustomerGender()
527
  {
528
  $genderId = $this->customer->getGender();
529
  if (is_numeric($genderId)) {
530
  $gender = Mage::getResourceModel('customer/customer')
531
  ->getAttribute('gender')
532
  ->getSource()
533
- ->getOptionText($genderId)
534
- ;
535
  return $gender;
536
  }
537
 
538
  return '';
539
  }
540
 
541
- protected function _getStreet($street, $line){
 
542
  $street = explode("\n", $street);
543
- if(isset($street[$line - 1]))
544
  return $street[$line - 1];
 
 
545
  return '';
546
  }
547
 
548
- protected function _getWebsiteName(){
 
549
  $websiteId = $this->customer->getWebsiteId();
550
- $website = Mage::app()->getWebsite($websiteId);
551
- if($website)
552
  return $website->getName();
 
553
 
554
  return '';
555
  }
556
 
557
- protected function _getStoreName()
558
  {
559
  $storeId = $this->customer->getStoreId();
560
- $store = Mage::app()->getStore($storeId);
561
- if($store)
562
  return $store->getName();
 
563
 
564
  return '';
565
  }
566
 
567
  /**
568
- * @param mixed $mapping_hash
569
  */
570
- public function setMappingHash($mapping_hash)
571
  {
572
- $this->_mapping_hash = $mapping_hash;
573
  }
574
 
575
  /**
@@ -577,37 +602,46 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
577
  */
578
  public function getMappingHash()
579
  {
580
- return $this->_mapping_hash;
581
  }
582
 
583
- protected function _getCustomerGroup(){
 
584
 
585
- $groupId = $this->customer->getGroupId();
586
- $group = Mage::getModel('customer/group')->load($groupId);
587
 
588
  if ($group->getId()) {
589
  return $group->getCode();
590
  }
 
591
  return '';
592
  }
593
 
594
- /**
595
- * mapping hash value.
596
- *
597
- * @param $value
598
- *
599
- * @return $this
600
- */
601
- public function setMappigHash($value)
602
  {
603
- $this->_mapping_hash = $value;
 
604
  return $this;
605
  }
606
 
607
  public function getRewardReferralUrl()
608
  {
609
- if(Mage::helper('ddg')->isSweetToothToGo($this->customer->getStore()->getWebsite()))
610
- return (string) Mage::helper('rewardsref/url')->getUrl($this->customer);
 
 
 
 
 
 
611
 
612
  return '';
613
  }
@@ -619,23 +653,33 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
619
 
620
  public function getRewardPointPending()
621
  {
622
- return $this->cleanString($this->rewardCustomer->getPendingPointsSummary());
 
 
623
  }
624
 
625
  public function getRewardPointPendingTime()
626
  {
627
- return $this->cleanString($this->rewardCustomer->getPendingTimePointsSummary());
 
 
628
  }
629
 
630
  public function getRewardPointOnHold()
631
  {
632
- return $this->cleanString($this->rewardCustomer->getOnHoldPointsSummary());
 
 
633
  }
634
 
635
  public function getRewardPointExpiration()
636
  {
637
- if($this->rewardExpiry != "")
638
- return Mage::getModel('core/date')->date('Y/m/d', strtotime($this->rewardExpiry));
 
 
 
 
639
  return $this->rewardExpiry;
640
  }
641
 
@@ -651,78 +695,100 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
651
 
652
  public function cleanString($string)
653
  {
654
- $cleanedString = preg_replace("/[^0-9]/","",$string);
655
- if($cleanedString != "")
656
- return (int) number_format($cleanedString, 0, '.', '');
 
 
657
  return 0;
658
  }
659
 
660
  public function getSubscriberStatus()
661
  {
662
- $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($this->customer);
663
- if($subscriber->getCustomerId())
664
- return $this->subscriber_status[$subscriber->getSubscriberStatus()];
 
 
 
665
  }
666
 
667
- /**
668
- * Reward points balance.
669
- * @return int
670
- */
671
- public function getRewardPoints() {
672
- if (!$this->reward)
673
- $this->_setReward();
 
 
 
674
 
675
- if($this->reward !== true){
676
  return $this->reward->getPointsBalance();
677
  }
 
678
  return '';
679
- }
680
 
681
- /**
682
- * Currency amount points.
683
- * @return mixed
684
- */
685
- public function getRewardAmount() {
686
- if (!$this->reward)
687
- $this->_setReward();
 
 
 
688
 
689
- if($this->reward !== true){
690
- return $this->reward->getCurrencyAmount();
691
  }
 
692
  return '';
693
- }
694
-
695
- /**
696
- * Expiration date to use the points.
697
- * @return string
698
- */
699
- public function getExpirationDate()
700
- {
701
- //set reward for later use
702
- if (!$this->reward)
703
- $this->_setReward();
704
-
705
- if($this->reward !== true){
 
 
706
  $expiredAt = $this->reward->getExpirationDate();
707
 
708
  if ($expiredAt) {
709
- $date = Mage::helper('core')->formatDate($expiredAt, 'short', true);
 
 
710
  } else {
711
  $date = '';
712
  }
 
713
  return $date;
714
  }
715
 
716
- return '';
717
- }
718
 
719
 
720
- protected function _setReward() {
721
- if (Mage::getModel('enterprise_reward/reward_history')){
722
- $collection = Mage::getModel('enterprise_reward/reward_history')->getCollection()
 
 
723
  ->addCustomerFilter($this->customer->getId())
724
  ->addWebsiteFilter($this->customer->getWebsiteId())
725
- ->setExpiryConfig(Mage::helper('enterprise_reward')->getExpiryConfig())
 
 
726
  ->addExpirationDate($this->customer->getWebsiteId())
727
  ->skipExpiredDuplicates()
728
  ->setDefaultOrder();
@@ -730,59 +796,66 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
730
  $item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
731
 
732
  $this->reward = $item;
733
- }
734
- else
735
  $this->reward = true;
736
- }
 
737
 
738
 
739
- /**
740
- * Customer segments id.
741
- * @return string
742
- */
743
- public function getCustomerSegments()
744
- {
 
745
  $collection = Mage::getModel('ddg_automation/contact')->getCollection()
746
  ->addFieldToFilter('customer_id', $this->getCustomerId())
747
  ->addFieldToFilter('website_id', $this->customer->getWebsiteId());
748
 
749
  $item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
750
 
751
- if ($item)
752
- return $item->getSegmentIds();
753
-
754
- return '';
755
- }
756
 
 
 
757
 
758
 
759
- /**
760
- * Last used reward points.
761
- * @return mixed
762
- */
763
- public function getLastUsedDate()
764
- {
 
765
  if (Mage::getModel('enterprise_reward/reward_history')) {
766
  //last used from the reward history based on the points delta used
767
- $collection = Mage::getModel('enterprise_reward/reward_history')->getCollection()
 
768
  ->addCustomerFilter($this->customer->getId())
769
  ->addWebsiteFilter($this->customer->getWebsiteId())
770
  ->addFieldToFilter('points_delta', array('lt' => 0))
771
  ->setDefaultOrder();
772
 
773
- $item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
 
774
  $lastUsed = $item->getCreatedAt();
775
 
776
  //for any valid date
777
- if ($lastUsed)
778
- return $date = Mage::helper('core')->formatDate($lastUsed, 'short', true);
 
 
 
779
  }
780
- return '';
781
- }
782
 
 
 
783
 
784
 
785
- /**
786
  * get most purchased category
787
  *
788
  * @return string
@@ -790,12 +863,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
790
  public function getMostPurCategory()
791
  {
792
  $id = $this->customer->getMostCategoryId();
793
- if($id){
794
  return Mage::getModel('catalog/category')
795
  ->load($id)
796
  ->setStoreId($this->customer->getStoreId())
797
  ->getName();
798
  }
 
799
  return "";
800
  }
801
 
@@ -807,8 +881,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
807
  public function getMostPurBrand()
808
  {
809
  $brand = $this->customer->getMostBrand();
810
- if($brand)
811
  return $brand;
 
 
812
  return "";
813
  }
814
 
@@ -820,8 +896,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
820
  public function getMostFreqPurDay()
821
  {
822
  $day = $this->customer->getWeekDay();
823
- if($day)
824
  return $day;
 
 
825
  return "";
826
  }
827
 
@@ -833,8 +911,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
833
  public function getMostFreqPurMon()
834
  {
835
  $month = $this->customer->getMonthDay();
836
- if($month)
837
  return $month;
 
 
838
  return "";
839
  }
840
 
@@ -846,12 +926,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
846
  public function getFirstCategoryPur()
847
  {
848
  $id = $this->customer->getFirstCategoryId();
849
- if($id){
850
  return Mage::getModel('catalog/category')
851
  ->load($id)
852
  ->setStoreId($this->customer->getStoreId())
853
  ->getName();
854
  }
 
855
  return "";
856
  }
857
 
@@ -863,12 +944,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
863
  public function getLastCategoryPur()
864
  {
865
  $id = $this->customer->getLastCategoryId();
866
- if($id){
867
  return Mage::getModel('catalog/category')
868
  ->setStoreId($this->customer->getStoreId())
869
  ->load($id)
870
  ->getName();
871
  }
 
872
  return "";
873
  }
874
 
@@ -880,6 +962,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
880
  public function getFirstBrandPur()
881
  {
882
  $id = $this->customer->getProductIdForFirstBrand();
 
883
  return $this->_getBrandValue($id);
884
  }
885
 
@@ -891,6 +974,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
891
  public function getLastBrandPur()
892
  {
893
  $id = $this->customer->getProductIdForLastBrand();
 
894
  return $this->_getBrandValue($id);
895
  }
896
 
@@ -900,14 +984,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
900
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
901
  $this->customer->getWebsiteId()
902
  );
903
- if($id && $attribute){
904
  $brand = Mage::getModel('catalog/product')
905
  ->setStoreId($this->customer->getStoreId())
906
  ->load($id)
907
  ->getAttributeText($attribute);
908
- if($brand)
909
  return $brand;
 
910
  }
 
911
  return "";
912
  }
913
 
@@ -920,4 +1006,24 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
920
  {
921
  return $this->customer->getLastIncrementId();
922
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
923
  }
7
  public $customerData;
8
  public $reviewCollection;
9
 
10
+ //enterprise reward
11
+ public $reward;
12
 
13
  public $rewardCustomer;
14
  public $rewardLastSpent = "";
15
  public $rewardLastEarned = "";
16
  public $rewardExpiry = "";
17
 
18
+ protected $_mappingHash;
19
 
20
+ public $subscriberStatus
21
+ = array(
22
+ Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => 'Subscribed',
23
+ Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => 'Not Active',
24
+ Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => 'Unsubscribed',
25
+ Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => 'Unconfirmed'
26
+ );
27
 
28
 
29
+ /**
30
+ * constructor, mapping hash to map.
31
+ *
32
+ * @param $mappingHash
33
+ */
34
+ public function __construct($mappingHash)
35
+ {
36
  $this->setMappigHash($mappingHash);
37
  }
38
 
39
+ /**
40
+ * Set key value data.
41
+ *
42
+ * @param $data
43
+ */
44
+ public function setData($data)
45
  {
46
  $this->customerData[] = $data;
47
  }
57
  $this->setReviewCollection();
58
  $website = $customer->getStore()->getWebsite();
59
 
60
+ if ($website && Mage::helper('ddg')->isSweetToothToGo($website)) {
61
  $this->setRewardCustomer($customer);
62
+ }
63
 
64
  foreach ($this->getMappingHash() as $key => $field) {
65
 
71
  foreach ($exploded as $one) {
72
  $function .= ucfirst($one);
73
  }
74
+ try {
75
+ $value = call_user_func(
76
+ array('self', $function)
77
+ );
78
  $this->customerData[$key] = $value;
79
+ } catch (Exception $e) {
80
  Mage::logException($e);
81
  }
82
  }
84
 
85
  public function setReviewCollection()
86
  {
87
+ $customerId = $this->customer->getId();
88
+ $collection = Mage::getModel('review/review')->getCollection()
89
+ ->addCustomerFilter($customerId)
90
+ ->setOrder('review_id', 'DESC');
91
 
92
  $this->reviewCollection = $collection;
93
  }
97
  return $this->reviewCollection->getSize();
98
  }
99
 
100
+ public function getLastReviewDate()
101
+ {
102
+
103
+ if (count($this->reviewCollection)) {
104
+ $this->reviewCollection->getSelect()->limit(1);
105
 
106
+ return $this->reviewCollection->getFirstItem()->getCreatedAt();
 
 
107
  }
108
+
109
  return '';
110
  }
111
 
117
  public function setRewardCustomer(Mage_Customer_Model_Customer $customer)
118
  {
119
  //get tbt reward customer
120
+ $tbtReward = Mage::getModel('rewards/customer')
121
+ ->getRewardsCustomer(
122
+ $customer
123
+ );
124
+ $this->rewardCustomer = $tbtReward;
125
 
126
  //get transfers collection from tbt reward. only active and order by last updated.
127
+ $lastTransfers = $tbtReward->getTransfers()
128
  ->selectOnlyActive()
129
+ ->addOrder(
130
+ 'last_update_ts', Varien_Data_Collection::SORT_ORDER_DESC
131
+ );
132
 
133
  $spent = $earn = null;
134
 
135
+ foreach ($lastTransfers as $transfer) {
136
+ // if transfer quantity is greater then 0 then this is last points earned date.
137
+ // keep checking until earn is not null
138
+ if (is_null($earn) && $transfer->getQuantity() > 0) {
139
+ $earn = $transfer->getEffectiveStart();
140
+ } else if (is_null($spent) && $transfer->getQuantity() < 0) {
141
+ // id transfer quantity is less then 0 then this is last points spent date.
142
+ // keep checking until spent is not null
143
  $spent = $transfer->getEffectiveStart();
144
  }
145
  // break if both spent and earn are not null (a value has been assigned)
146
+ if ( ! is_null($spent) && ! is_null($earn)) {
147
  break;
148
  }
149
  }
150
 
151
  // if earn is not null (has a value) then assign the value to property
152
+ if ($earn) {
153
  $this->rewardLastEarned = $earn;
154
+ }
155
  // if spent is not null (has a value) then assign the value to property
156
+ if ($spent) {
157
  $this->rewardLastSpent = $spent;
158
+ }
159
 
160
+ $tbtExpiry = Mage::getSingleton('rewards/expiry')
161
+ ->getExpiryDate($tbtReward);
162
 
163
  // if there is an expiry (has a value) then assign the value to property
164
+ if ($tbtExpiry) {
165
+ $this->rewardExpiry = $tbtExpiry;
166
+ }
167
  }
168
 
169
  /**
170
+ * get customer id.
171
+ *
172
+ * @return mixed
173
+ */
174
+ public function getCustomerId()
175
  {
176
  return $this->customer->getId();
177
  }
178
 
179
+ /**
180
+ * get first name.
181
+ *
182
+ * @return mixed
183
+ */
184
+ public function getFirstname()
185
+ {
186
  return $this->customer->getFirstname();
187
  }
188
 
189
+ /**
190
+ * get last name.
191
+ *
192
+ * @return mixed
193
+ */
194
+ public function getLastname()
195
  {
196
  return $this->customer->getLastname();
197
  }
198
 
199
+ /**
200
+ * get date of birth.
201
+ *
202
+ * @return mixed
203
+ */
204
+ public function getDob()
205
  {
206
  return $this->customer->getDob();
207
  }
208
 
209
+ /**
210
+ * get customer gender.
211
+ *
212
+ * @return bool|string
213
+ */
214
+ public function getGender()
215
  {
216
  return $this->_getCustomerGender();
217
  }
218
 
219
+ /**
220
+ * get customer prefix.
221
+ *
222
+ * @return mixed
223
+ */
224
+ public function getPrefix()
225
  {
226
  return $this->customer->getPrefix();
227
  }
228
 
229
+ /**
230
+ * get customer suffix.
231
+ *
232
+ * @return mixed
233
+ */
234
+ public function getSuffix()
235
  {
236
  return $this->customer->getSuffix();
237
  }
238
 
239
+ /**
240
+ * get website name.
241
+ *
242
+ * @return string
243
+ */
244
+ public function getWebsiteName()
245
  {
246
  return $this->_getWebsiteName();
247
  }
248
 
249
+ /**
250
+ * get store name.
251
+ *
252
+ * @return null|string
253
+ */
254
+ public function getStoreName()
255
  {
256
  return $this->_getStoreName();
257
  }
258
 
259
+ /**
260
+ * get customer created at date.
261
+ *
262
+ * @return mixed
263
+ */
264
+ public function getCreatedAt()
265
  {
266
  return $this->customer->getCreatedAt();
267
  }
268
 
269
+ /**
270
+ * get customer last logged in date.
271
+ *
272
+ * @return mixed
273
+ */
274
+ public function getLastLoggedDate()
275
  {
276
  return $this->customer->getLastLoggedDate();
277
  }
278
 
279
+ /**
280
+ * get cutomer group.
281
+ *
282
+ * @return string
283
+ */
284
+ public function getCustomerGroup()
285
  {
286
  return $this->_getCustomerGroup();
287
  }
288
 
289
+ /**
290
+ * get billing address line 1.
291
+ *
292
+ * @return string
293
+ */
294
+ public function getBillingAddress1()
295
  {
296
  return $this->_getStreet($this->customer->getBillingStreet(), 1);
297
  }
298
 
299
+ /**
300
+ * get billing address line 2.
301
+ *
302
+ * @return string
303
+ */
304
+ public function getBillingAddress2()
305
  {
306
  return $this->_getStreet($this->customer->getBillingStreet(), 2);
307
  }
308
 
309
+ /**
310
+ * get billing city.
311
+ *
312
+ * @return mixed
313
+ */
314
+ public function getBillingCity()
315
  {
316
  return $this->customer->getBillingCity();
317
  }
318
 
319
+ /**
320
+ * get billing country.
321
+ *
322
+ * @return mixed
323
+ */
324
+ public function getBillingCountry()
325
  {
326
  return $this->customer->getBillingCountryCode();
327
  }
328
 
329
+ /**
330
+ * get billing state.
331
+ *
332
+ * @return mixed
333
+ */
334
+ public function getBillingState()
335
  {
336
  return $this->customer->getBillingRegion();
337
  }
338
 
339
+ /**
340
+ * get billing postcode.
341
+ *
342
+ * @return mixed
343
+ */
344
+ public function getBillingPostcode()
345
  {
346
  return $this->customer->getBillingPostcode();
347
  }
348
 
349
+ /**
350
+ * get billing phone.
351
+ *
352
+ * @return mixed
353
+ */
354
+ public function getBillingTelephone()
355
  {
356
  return $this->customer->getBillingTelephone();
357
  }
358
 
359
+ /**
360
+ * get delivery address line 1.
361
+ *
362
+ * @return string
363
+ */
364
+ public function getDeliveryAddress1()
365
  {
366
  return $this->_getStreet($this->customer->getShippingStreet(), 1);
367
  }
368
 
369
+ /**
370
+ * get delivery addrss line 2.
371
+ *
372
+ * @return string
373
+ */
374
+ public function getDeliveryAddress2()
375
  {
376
  return $this->_getStreet($this->customer->getShippingStreet(), 2);
377
  }
378
 
379
+ /**
380
+ * get delivery city.
381
+ *
382
+ * @return mixed
383
+ */
384
+ public function getDeliveryCity()
385
  {
386
  return $this->customer->getShippingCity();
387
  }
388
 
389
+ /**
390
+ * get delivery country.
391
+ *
392
+ * @return mixed
393
+ */
394
+ public function getDeliveryCountry()
395
+ {
396
  return $this->customer->getShippingCountryCode();
397
  }
398
 
399
+ /**
400
+ * get delivery state.
401
+ *
402
+ * @return mixed
403
+ */
404
+ public function getDeliveryState()
405
  {
406
  return $this->customer->getShippingRegion();
407
  }
408
 
409
+ /**
410
+ * get delivery postcode.
411
+ *
412
+ * @return mixed
413
+ */
414
+ public function getDeliveryPostcode()
415
  {
416
  return $this->customer->getShippingPostcode();
417
  }
418
 
419
+ /**
420
+ * get delivery phone.
421
+ *
422
+ * @return mixed
423
+ */
424
+ public function getDeliveryTelephone()
425
+ {
426
  return $this->customer->getShippingTelephone();
427
  }
428
 
429
+ /**
430
+ * get numbser of orders.
431
+ *
432
+ * @return mixed
433
+ */
434
+ public function getNumberOfOrders()
435
  {
436
  return $this->customer->getNumberOfOrders();
437
  }
438
 
439
+ /**
440
+ * get average order value.
441
+ *
442
+ * @return mixed
443
+ */
444
+ public function getAverageOrderValue()
445
  {
446
  return $this->customer->getAverageOrderValue();
447
  }
448
 
449
+ /**
450
+ * get total spend.
451
+ *
452
+ * @return mixed
453
+ */
454
+ public function getTotalSpend()
455
  {
456
  return $this->customer->getTotalSpend();
457
  }
458
 
459
+ /**
460
+ * get last order date.
461
+ *
462
+ * @return mixed
463
+ */
464
+ public function getLastOrderDate()
465
  {
466
  return $this->customer->getLastOrderDate();
467
  }
468
 
469
+ /**
470
+ * get last order id.
471
+ *
472
+ * @return mixed
473
+ */
474
+ public function getLastOrderId()
475
  {
476
  return $this->customer->getLastOrderId();
477
  }
486
  return $this->customer->getLastQuoteId();
487
  }
488
 
489
+ /**
490
+ * get cutomer id.
491
+ *
492
+ * @return mixed
493
+ */
494
+ public function getId()
495
  {
496
  return $this->customer->getId();
497
  }
498
 
499
+ /**
500
+ * get customer title.
501
+ *
502
+ * @return mixed
503
+ */
504
+ public function getTitle()
505
  {
506
  return $this->customer->getPrefix();
507
  }
508
 
509
+ /**
510
+ * get total refund value.
511
+ *
512
+ * @return float|int
513
+ */
514
+ public function getTotalRefund()
515
  {
516
+ $orders = Mage::getResourceModel('sales/order_collection')
517
+ ->addAttributeToFilter('customer_id', $this->customer->getId());
 
518
  $totalRefunded = 0;
519
  foreach ($orders as $order) {
520
  $refunded = $order->getTotalRefunded();
524
  return $totalRefunded;
525
  }
526
 
527
+ /**
528
+ * export to CSV.
529
+ *
530
+ * @return mixed
531
+ */
532
+ public function toCSVArray()
533
  {
534
  $result = $this->customerData;
535
+
536
  return $result;
537
  }
538
 
539
+ /**
540
+ * customer gender.
541
+ *
542
+ * @return bool|string
543
+ * @throws Mage_Core_Exception
544
+ */
545
+ protected function _getCustomerGender()
546
  {
547
  $genderId = $this->customer->getGender();
548
  if (is_numeric($genderId)) {
549
  $gender = Mage::getResourceModel('customer/customer')
550
  ->getAttribute('gender')
551
  ->getSource()
552
+ ->getOptionText($genderId);
553
+
554
  return $gender;
555
  }
556
 
557
  return '';
558
  }
559
 
560
+ protected function _getStreet($street, $line)
561
+ {
562
  $street = explode("\n", $street);
563
+ if (isset($street[$line - 1])) {
564
  return $street[$line - 1];
565
+ }
566
+
567
  return '';
568
  }
569
 
570
+ protected function _getWebsiteName()
571
+ {
572
  $websiteId = $this->customer->getWebsiteId();
573
+ $website = Mage::app()->getWebsite($websiteId);
574
+ if ($website) {
575
  return $website->getName();
576
+ }
577
 
578
  return '';
579
  }
580
 
581
+ protected function _getStoreName()
582
  {
583
  $storeId = $this->customer->getStoreId();
584
+ $store = Mage::app()->getStore($storeId);
585
+ if ($store) {
586
  return $store->getName();
587
+ }
588
 
589
  return '';
590
  }
591
 
592
  /**
593
+ * @param mixed $mappingHash
594
  */
595
+ public function setMappingHash($mappingHash)
596
  {
597
+ $this->_mappingHash = $mappingHash;
598
  }
599
 
600
  /**
602
  */
603
  public function getMappingHash()
604
  {
605
+ return $this->_mappingHash;
606
  }
607
 
608
+ protected function _getCustomerGroup()
609
+ {
610
 
611
+ $groupId = $this->customer->getGroupId();
612
+ $group = Mage::getModel('customer/group')->load($groupId);
613
 
614
  if ($group->getId()) {
615
  return $group->getCode();
616
  }
617
+
618
  return '';
619
  }
620
 
621
+ /**
622
+ * mapping hash value.
623
+ *
624
+ * @param $value
625
+ *
626
+ * @return $this
627
+ */
628
+ public function setMappigHash($value)
629
  {
630
+ $this->_mappingHash = $value;
631
+
632
  return $this;
633
  }
634
 
635
  public function getRewardReferralUrl()
636
  {
637
+ if (Mage::helper('ddg')->isSweetToothToGo(
638
+ $this->customer->getStore()->getWebsite()
639
+ )
640
+ ) {
641
+ return (string)Mage::helper('rewardsref/url')->getUrl(
642
+ $this->customer
643
+ );
644
+ }
645
 
646
  return '';
647
  }
653
 
654
  public function getRewardPointPending()
655
  {
656
+ return $this->cleanString(
657
+ $this->rewardCustomer->getPendingPointsSummary()
658
+ );
659
  }
660
 
661
  public function getRewardPointPendingTime()
662
  {
663
+ return $this->cleanString(
664
+ $this->rewardCustomer->getPendingTimePointsSummary()
665
+ );
666
  }
667
 
668
  public function getRewardPointOnHold()
669
  {
670
+ return $this->cleanString(
671
+ $this->rewardCustomer->getOnHoldPointsSummary()
672
+ );
673
  }
674
 
675
  public function getRewardPointExpiration()
676
  {
677
+ if ($this->rewardExpiry != "") {
678
+ return Mage::getModel('core/date')->date(
679
+ 'Y/m/d', strtotime($this->rewardExpiry)
680
+ );
681
+ }
682
+
683
  return $this->rewardExpiry;
684
  }
685
 
695
 
696
  public function cleanString($string)
697
  {
698
+ $cleanedString = preg_replace("/[^0-9]/", "", $string);
699
+ if ($cleanedString != "") {
700
+ return (int)number_format($cleanedString, 0, '.', '');
701
+ }
702
+
703
  return 0;
704
  }
705
 
706
  public function getSubscriberStatus()
707
  {
708
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer(
709
+ $this->customer
710
+ );
711
+ if ($subscriber->getCustomerId()) {
712
+ return $this->subscriberStatus[$subscriber->getSubscriberStatus()];
713
+ }
714
  }
715
 
716
+ /**
717
+ * Reward points balance.
718
+ *
719
+ * @return int
720
+ */
721
+ public function getRewardPoints()
722
+ {
723
+ if ( ! $this->reward) {
724
+ $this->_setReward();
725
+ }
726
 
727
+ if ($this->reward !== true) {
728
  return $this->reward->getPointsBalance();
729
  }
730
+
731
  return '';
732
+ }
733
 
734
+ /**
735
+ * Currency amount points.
736
+ *
737
+ * @return mixed
738
+ */
739
+ public function getRewardAmount()
740
+ {
741
+ if ( ! $this->reward) {
742
+ $this->_setReward();
743
+ }
744
 
745
+ if ($this->reward !== true) {
746
+ return $this->reward->getCurrencyAmount();
747
  }
748
+
749
  return '';
750
+ }
751
+
752
+ /**
753
+ * Expiration date to use the points.
754
+ *
755
+ * @return string
756
+ */
757
+ public function getExpirationDate()
758
+ {
759
+ //set reward for later use
760
+ if ( ! $this->reward) {
761
+ $this->_setReward();
762
+ }
763
+
764
+ if ($this->reward !== true) {
765
  $expiredAt = $this->reward->getExpirationDate();
766
 
767
  if ($expiredAt) {
768
+ $date = Mage::helper('core')->formatDate(
769
+ $expiredAt, 'short', true
770
+ );
771
  } else {
772
  $date = '';
773
  }
774
+
775
  return $date;
776
  }
777
 
778
+ return '';
779
+ }
780
 
781
 
782
+ protected function _setReward()
783
+ {
784
+ if (Mage::getModel('enterprise_reward/reward_history')) {
785
+ $collection = Mage::getModel('enterprise_reward/reward_history')
786
+ ->getCollection()
787
  ->addCustomerFilter($this->customer->getId())
788
  ->addWebsiteFilter($this->customer->getWebsiteId())
789
+ ->setExpiryConfig(
790
+ Mage::helper('enterprise_reward')->getExpiryConfig()
791
+ )
792
  ->addExpirationDate($this->customer->getWebsiteId())
793
  ->skipExpiredDuplicates()
794
  ->setDefaultOrder();
796
  $item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
797
 
798
  $this->reward = $item;
799
+ } else {
 
800
  $this->reward = true;
801
+ }
802
+ }
803
 
804
 
805
+ /**
806
+ * Customer segments id.
807
+ *
808
+ * @return string
809
+ */
810
+ public function getCustomerSegments()
811
+ {
812
  $collection = Mage::getModel('ddg_automation/contact')->getCollection()
813
  ->addFieldToFilter('customer_id', $this->getCustomerId())
814
  ->addFieldToFilter('website_id', $this->customer->getWebsiteId());
815
 
816
  $item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
817
 
818
+ if ($item) {
819
+ return $item->getSegmentIds();
820
+ }
 
 
821
 
822
+ return '';
823
+ }
824
 
825
 
826
+ /**
827
+ * Last used reward points.
828
+ *
829
+ * @return mixed
830
+ */
831
+ public function getLastUsedDate()
832
+ {
833
  if (Mage::getModel('enterprise_reward/reward_history')) {
834
  //last used from the reward history based on the points delta used
835
+ $collection = Mage::getModel('enterprise_reward/reward_history')
836
+ ->getCollection()
837
  ->addCustomerFilter($this->customer->getId())
838
  ->addWebsiteFilter($this->customer->getWebsiteId())
839
  ->addFieldToFilter('points_delta', array('lt' => 0))
840
  ->setDefaultOrder();
841
 
842
+ $item = $collection->setPageSize(1)->setCurPage(1)
843
+ ->getFirstItem();
844
  $lastUsed = $item->getCreatedAt();
845
 
846
  //for any valid date
847
+ if ($lastUsed) {
848
+ return $date = Mage::helper('core')->formatDate(
849
+ $lastUsed, 'short', true
850
+ );
851
+ }
852
  }
 
 
853
 
854
+ return '';
855
+ }
856
 
857
 
858
+ /**
859
  * get most purchased category
860
  *
861
  * @return string
863
  public function getMostPurCategory()
864
  {
865
  $id = $this->customer->getMostCategoryId();
866
+ if ($id) {
867
  return Mage::getModel('catalog/category')
868
  ->load($id)
869
  ->setStoreId($this->customer->getStoreId())
870
  ->getName();
871
  }
872
+
873
  return "";
874
  }
875
 
881
  public function getMostPurBrand()
882
  {
883
  $brand = $this->customer->getMostBrand();
884
+ if ($brand) {
885
  return $brand;
886
+ }
887
+
888
  return "";
889
  }
890
 
896
  public function getMostFreqPurDay()
897
  {
898
  $day = $this->customer->getWeekDay();
899
+ if ($day) {
900
  return $day;
901
+ }
902
+
903
  return "";
904
  }
905
 
911
  public function getMostFreqPurMon()
912
  {
913
  $month = $this->customer->getMonthDay();
914
+ if ($month) {
915
  return $month;
916
+ }
917
+
918
  return "";
919
  }
920
 
926
  public function getFirstCategoryPur()
927
  {
928
  $id = $this->customer->getFirstCategoryId();
929
+ if ($id) {
930
  return Mage::getModel('catalog/category')
931
  ->load($id)
932
  ->setStoreId($this->customer->getStoreId())
933
  ->getName();
934
  }
935
+
936
  return "";
937
  }
938
 
944
  public function getLastCategoryPur()
945
  {
946
  $id = $this->customer->getLastCategoryId();
947
+ if ($id) {
948
  return Mage::getModel('catalog/category')
949
  ->setStoreId($this->customer->getStoreId())
950
  ->load($id)
951
  ->getName();
952
  }
953
+
954
  return "";
955
  }
956
 
962
  public function getFirstBrandPur()
963
  {
964
  $id = $this->customer->getProductIdForFirstBrand();
965
+
966
  return $this->_getBrandValue($id);
967
  }
968
 
974
  public function getLastBrandPur()
975
  {
976
  $id = $this->customer->getProductIdForLastBrand();
977
+
978
  return $this->_getBrandValue($id);
979
  }
980
 
984
  Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
985
  $this->customer->getWebsiteId()
986
  );
987
+ if ($id && $attribute) {
988
  $brand = Mage::getModel('catalog/product')
989
  ->setStoreId($this->customer->getStoreId())
990
  ->load($id)
991
  ->getAttributeText($attribute);
992
+ if ($brand) {
993
  return $brand;
994
+ }
995
  }
996
+
997
  return "";
998
  }
999
 
1006
  {
1007
  return $this->customer->getLastIncrementId();
1008
  }
1009
+
1010
+ /**
1011
+ * get billing company name
1012
+ *
1013
+ * @return mixed
1014
+ */
1015
+ public function getBillingCompany()
1016
+ {
1017
+ return $this->customer->getBillingCompany();
1018
+ }
1019
+
1020
+ /**
1021
+ * get shipping company name
1022
+ *
1023
+ * @return mixed
1024
+ */
1025
+ public function getDeliveryCompany()
1026
+ {
1027
+ return $this->customer->getShippingCompany();
1028
+ }
1029
  }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php CHANGED
@@ -1,6 +1,9 @@
1
  <?php
2
- class Dotdigitalgroup_Email_Model_Apiconnector_Test extends Dotdigitalgroup_Email_Model_Apiconnector_Client
 
 
3
  {
 
4
  /**
5
  * Validate apiuser on save.
6
  *
@@ -16,14 +19,22 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Test extends Dotdigitalgroup_Emai
16
  ->setApiPassword($apiPassword);
17
  $accountInfo = $this->getAccountInfo();
18
  if (isset($accountInfo->message)) {
19
- Mage::getSingleton('adminhtml/session')->addError($accountInfo->message);
20
- Mage::helper('ddg')->log('VALIDATION ERROR : ' . $accountInfo->message);
 
 
 
 
 
21
  return false;
22
  }
 
23
  return $accountInfo;
24
  }
 
25
  return false;
26
  }
 
27
  /**
28
  * Ajax validate api user.
29
  *
@@ -43,8 +54,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Test extends Dotdigitalgroup_Emai
43
  $message = 'API Username And Password Do Not Match!';
44
  Mage::helper('ddg')->log($message);
45
  }
 
46
  return $message;
47
  }
 
48
  return false;
49
  }
50
  }
1
  <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Test
4
+ extends Dotdigitalgroup_Email_Model_Apiconnector_Client
5
  {
6
+
7
  /**
8
  * Validate apiuser on save.
9
  *
19
  ->setApiPassword($apiPassword);
20
  $accountInfo = $this->getAccountInfo();
21
  if (isset($accountInfo->message)) {
22
+ Mage::getSingleton('adminhtml/session')->addError(
23
+ $accountInfo->message
24
+ );
25
+ Mage::helper('ddg')->log(
26
+ 'VALIDATION ERROR : ' . $accountInfo->message
27
+ );
28
+
29
  return false;
30
  }
31
+
32
  return $accountInfo;
33
  }
34
+
35
  return false;
36
  }
37
+
38
  /**
39
  * Ajax validate api user.
40
  *
54
  $message = 'API Username And Password Do Not Match!';
55
  Mage::helper('ddg')->log($message);
56
  }
57
+
58
  return $message;
59
  }
60
+
61
  return false;
62
  }
63
  }
app/code/community/Dotdigitalgroup/Email/Model/Automation.php CHANGED
@@ -2,223 +2,282 @@
2
 
3
  class Dotdigitalgroup_Email_Model_Automation extends Mage_Core_Model_Abstract
4
  {
5
- const AUTOMATION_TYPE_NEW_CUSTOMER = 'customer_automation';
6
- const AUTOMATION_TYPE_NEW_SUBSCRIBER = 'subscriber_automation';
7
- const AUTOMATION_TYPE_NEW_ORDER = 'order_automation';
8
- const AUTOMATION_TYPE_NEW_GUEST_ORDER = 'guest_order_automation';
9
- const AUTOMATION_TYPE_NEW_REVIEW = 'review_automation';
10
- const AUTOMATION_TYPE_NEW_WISHLIST = 'wishlist_automation';
11
- const AUTOMATION_STATUS_PENDING = 'pending';
12
- //automation enrolment limit
13
- public $limit = 100;
14
- public $email;
15
- public $typeId;
16
- public $websiteId;
17
- public $storeName;
18
- public $programId;
19
- public $programStatus = 'Active';
20
- public $programMessage;
21
- public $automationType;
22
- /**
23
- * constructor
24
- */
25
- public function _construct()
26
- {
27
- parent::_construct();
28
- $this->_init('ddg_automation/automation');
29
- }
30
- /**
31
- * @return $this|Mage_Core_Model_Abstract
32
- */
33
- protected function _beforeSave()
34
- {
35
- parent::_beforeSave();
36
- $now = Mage::getSingleton('core/date')->gmtDate();
37
- if ($this->isObjectNew()) {
38
- $this->setCreatedAt($now);
39
- } else {
40
- $this->setUpdatedAt($now);
41
- }
42
- return $this;
43
- }
44
 
45
- public function enrollment()
46
- {
47
- //automation statuses to filter
48
- $automationCollection = $this->getCollection()
49
- ->addFieldToSelect( 'automation_type' )
50
- ->addFieldToFilter( 'enrolment_status', self::AUTOMATION_STATUS_PENDING );
51
- $automationCollection->getSelect()->group( 'automation_type' );
52
- //active types
53
- $automationTypes = $automationCollection->getColumnValues( 'automation_type' );
54
- //send the campaign by each types
55
- foreach ( $automationTypes as $type ) {
56
- $contacts = array();
57
- //reset the collection
58
- $automationCollection->clear();
59
- $automationCollection = $this->getCollection()
60
- ->addFieldToFilter( 'enrolment_status', self::AUTOMATION_STATUS_PENDING )
61
- ->addFieldToFilter( 'automation_type', $type );
62
- //limit because of the each contact request to get the id
63
- $automationCollection->getSelect()->limit( $this->limit );
64
- foreach ( $automationCollection as $automation ) {
65
- $type = $automation->getAutomationType();
66
- //customerid, subscriberid, wishlistid..
67
- $email = $automation->getEmail();
68
- $this->typeId = $automation->getTypeId();
69
- $this->websiteId = $automation->getWebsiteId();
70
- $this->programId = $automation->getProgramId();
71
- $this->storeName = $automation->getStoreName();
72
- $contactId = Mage::helper( 'ddg' )->getContactId( $email, $this->websiteId );
73
- //contact id is valid, can update datafields
74
- if ( $contactId ) {
75
- //need to update datafields
76
- $this->updateDatafieldsByType( $this->automationType, $email );
77
- $contacts[ $automation->getId() ] = $contactId;
78
- } else {
79
- // the contact is suppressed or the request failed
80
- $automation->setEnrolmentStatus('Suppressed')->save();
81
- }
82
- }
83
- //only for subscribed contacts
84
- if ( ! empty( $contacts ) && $type != '' && $this->_checkCampignEnrolmentActive( $this->programId ) ) {
85
- $result = $this->sendContactsToAutomation( array_values( $contacts ) );
86
- //check for error message
87
- if ( isset( $result->message ) ) {
88
- $this->programStatus = 'Failed';
89
- $this->programMessage = $result->message;
90
- }
91
- //program is not active
92
- } elseif ( $this->programMessage == 'Error: ERROR_PROGRAM_NOT_ACTIVE ' ) {
93
- $this->programStatus = 'Deactivated';
94
- }
95
- //update contacts with the new status, and log the error message if failes
96
- $num = $this->getResource()->updateContacts($contacts, $this->programStatus, $this->programMessage);
97
- if ($num)
98
- Mage::helper('ddg')->log('Automation type : ' . $type . ', updated no : ' . $num);
99
- }
100
 
101
- }
102
- /**
103
- * update single contact datafields for this automation type.
104
- *
105
- * @param $type
106
- */
107
- public function updateDatafieldsByType($type, $email )
108
- {
109
- switch($type) {
110
- case self::AUTOMATION_TYPE_NEW_CUSTOMER :
111
- $this->_updateDefaultDatafields($email);
112
- break;
113
- case self::AUTOMATION_TYPE_NEW_SUBSCRIBER :
114
- $this->_updateDefaultDatafields($email);
115
- break;
116
- case self::AUTOMATION_TYPE_NEW_ORDER :
117
- $this->_updateNewOrderDatafields($email);
118
- break;
119
- case self::AUTOMATION_TYPE_NEW_GUEST_ORDER:
120
- $this->_updateNewOrderDatafields($email);
121
- break;
122
- case self::AUTOMATION_TYPE_NEW_REVIEW :
123
- $this->_updateNewOrderDatafields($email);
124
- break;
125
- case self::AUTOMATION_TYPE_NEW_WISHLIST:
126
- $this->_updateDefaultDatafields($email);
127
- break;
128
- default:
129
- $this->_updateDefaultDatafields($email);
130
- break;
131
- }
132
- }
133
- protected function _updateDefaultDatafields($email)
134
- {
135
- $website = Mage::app()->getWebsite($this->websiteId);
136
- Mage::helper('ddg')->updateDataFields($email, $website, $this->storeName);
137
- }
138
- protected function _updateNewOrderDatafields($email)
139
- {
140
- $website = Mage::app()->getWebsite($this->websiteId);
141
- $order = Mage::getModel('sales/order')->load($this->typeId);
142
- //data fields
143
- if($last_order_id = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID)){
144
- $data[] = array(
145
- 'Key' => $last_order_id,
146
- 'Value' => $order->getId()
147
- );
148
- }
149
- if($order_increment_id = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID)){
150
- $data[] = array(
151
- 'Key' => $order_increment_id,
152
- 'Value' => $order->getIncrementId()
153
- );
154
- }
155
- if($store_name = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME)){
156
- $data[] = array(
157
- 'Key' => $store_name,
158
- 'Value' => $this->storeName
159
- );
160
- }
161
- if($website_name = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME)){
162
- $data[] = array(
163
- 'Key' => $website_name,
164
- 'Value' => $website->getName()
165
- );
166
- }
167
- if($last_order_date = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE)){
168
- $data[] = array(
169
- 'Key' => $last_order_date,
170
- 'Value' => $order->getCreatedAt()
171
- );
172
- }
173
- if(($customer_id = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID)) && $order->getCustomerId()){
174
- $data[] = array(
175
- 'Key' => $customer_id,
176
- 'Value' => $order->getCustomerId()
177
- );
178
- }
179
- if(! empty($data)){
180
- //update data fields
181
- $client = Mage::helper('ddg')->getWebsiteApiClient($website);
182
- $client->updateContactDatafieldsByEmail($order->getCustomerEmail(), $data);
183
- }
184
- }
185
- /**
186
- * Program check if is valid and active.
187
- * @param $programId
188
- *
189
- * @return bool
190
- */
191
- protected function _checkCampignEnrolmentActive($programId)
192
- {
193
- //program is not set
194
- if (!$programId)
195
- return false;
196
- $client = Mage::helper('ddg')->getWebsiteApiClient($this->websiteId);
197
- $program = $client->getProgramById($programId);
198
- //program status
199
- if (isset($program->status))
200
- $this->programStatus = $program->status;
201
- if (isset($program->status) && $program->status == 'Active') {
202
- return true;
203
- }
204
- return false;
205
- }
206
- /**
207
- * Enrol contacts for a program.
208
- * @param $contacts
209
- *
210
- * @return null
211
- */
212
- public function sendContactsToAutomation($contacts)
213
- {
214
- $client = Mage::helper('ddg')->getWebsiteApiClient($this->websiteId);
215
- $data = array(
216
- 'Contacts' => $contacts,
217
- 'ProgramId' => $this->programId,
218
- 'AddressBooks' => array()
219
- );
220
- //api add contact to automation enrolment
221
- $result = $client->postProgramsEnrolments( $data );
222
- return $result;
223
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  class Dotdigitalgroup_Email_Model_Automation extends Mage_Core_Model_Abstract
4
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ const AUTOMATION_TYPE_NEW_CUSTOMER = 'customer_automation';
7
+ const AUTOMATION_TYPE_NEW_SUBSCRIBER = 'subscriber_automation';
8
+ const AUTOMATION_TYPE_NEW_ORDER = 'order_automation';
9
+ const AUTOMATION_TYPE_NEW_GUEST_ORDER = 'guest_order_automation';
10
+ const AUTOMATION_TYPE_NEW_REVIEW = 'review_automation';
11
+ const AUTOMATION_TYPE_NEW_WISHLIST = 'wishlist_automation';
12
+ const AUTOMATION_STATUS_PENDING = 'pending';
13
+ //automation enrolment limit
14
+ public $limit = 100;
15
+ public $email;
16
+ public $typeId;
17
+ public $websiteId;
18
+ public $storeName;
19
+ public $programId;
20
+ public $programStatus = 'Active';
21
+ public $programMessage;
22
+ public $automationType;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ /**
25
+ * constructor
26
+ */
27
+ public function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->_init('ddg_automation/automation');
31
+ }
32
+
33
+ /**
34
+ * @return $this|Mage_Core_Model_Abstract
35
+ */
36
+ protected function _beforeSave()
37
+ {
38
+ parent::_beforeSave();
39
+ $now = Mage::getSingleton('core/date')->gmtDate();
40
+ if ($this->isObjectNew()) {
41
+ $this->setCreatedAt($now);
42
+ } else {
43
+ $this->setUpdatedAt($now);
44
+ }
45
+
46
+ return $this;
47
+ }
48
+
49
+ public function enrollment()
50
+ {
51
+ //automation statuses to filter
52
+ $automationCollection = $this->getCollection()
53
+ ->addFieldToSelect('automation_type')
54
+ ->addFieldToFilter(
55
+ 'enrolment_status', self::AUTOMATION_STATUS_PENDING
56
+ );
57
+ $automationCollection->getSelect()->group('automation_type');
58
+ //active types
59
+ $automationTypes = $automationCollection->getColumnValues(
60
+ 'automation_type'
61
+ );
62
+ //send the campaign by each types
63
+ foreach ($automationTypes as $type) {
64
+ $contacts = array();
65
+ //reset the collection
66
+ $automationCollection->clear();
67
+ $automationCollection = $this->getCollection()
68
+ ->addFieldToFilter(
69
+ 'enrolment_status', self::AUTOMATION_STATUS_PENDING
70
+ )
71
+ ->addFieldToFilter('automation_type', $type);
72
+ //limit because of the each contact request to get the id
73
+ $automationCollection->getSelect()->limit($this->limit);
74
+ foreach ($automationCollection as $automation) {
75
+ $type = $automation->getAutomationType();
76
+ //customerid, subscriberid, wishlistid..
77
+ $email = $automation->getEmail();
78
+ $this->typeId = $automation->getTypeId();
79
+ $this->websiteId = $automation->getWebsiteId();
80
+ $this->programId = $automation->getProgramId();
81
+ $this->storeName = $automation->getStoreName();
82
+ $contactId = Mage::helper('ddg')->getContactId(
83
+ $email, $this->websiteId
84
+ );
85
+ //contact id is valid, can update datafields
86
+ if ($contactId) {
87
+ //need to update datafields
88
+ $this->updateDatafieldsByType(
89
+ $this->automationType, $email
90
+ );
91
+ $contacts[$automation->getId()] = $contactId;
92
+ } else {
93
+ // the contact is suppressed or the request failed
94
+ $automation->setEnrolmentStatus('Suppressed')->save();
95
+ }
96
+ }
97
+ //only for subscribed contacts
98
+ if ( ! empty($contacts) && $type != ''
99
+ && $this->_checkCampignEnrolmentActive($this->programId)
100
+ ) {
101
+ $result = $this->sendContactsToAutomation(
102
+ array_values($contacts)
103
+ );
104
+ //check for error message
105
+ if (isset($result->message)) {
106
+ $this->programStatus = 'Failed';
107
+ $this->programMessage = $result->message;
108
+ }
109
+ //program is not active
110
+ } elseif ($this->programMessage
111
+ == 'Error: ERROR_PROGRAM_NOT_ACTIVE '
112
+ ) {
113
+ $this->programStatus = 'Deactivated';
114
+ }
115
+ //update contacts with the new status, and log the error message if failes
116
+ $num = $this->getResource()->updateContacts(
117
+ $contacts, $this->programStatus, $this->programMessage
118
+ );
119
+ if ($num) {
120
+ Mage::helper('ddg')->log(
121
+ 'Automation type : ' . $type . ', updated no : ' . $num
122
+ );
123
+ }
124
+ }
125
+
126
+ }
127
+
128
+ /**
129
+ * update single contact datafields for this automation type.
130
+ *
131
+ * @param $type
132
+ */
133
+ public function updateDatafieldsByType($type, $email)
134
+ {
135
+ switch ($type) {
136
+ case self::AUTOMATION_TYPE_NEW_CUSTOMER :
137
+ $this->_updateDefaultDatafields($email);
138
+ break;
139
+ case self::AUTOMATION_TYPE_NEW_SUBSCRIBER :
140
+ $this->_updateDefaultDatafields($email);
141
+ break;
142
+ case self::AUTOMATION_TYPE_NEW_ORDER :
143
+ $this->_updateNewOrderDatafields();
144
+ break;
145
+ case self::AUTOMATION_TYPE_NEW_GUEST_ORDER:
146
+ $this->_updateNewOrderDatafields();
147
+ break;
148
+ case self::AUTOMATION_TYPE_NEW_REVIEW :
149
+ $this->_updateNewOrderDatafields();
150
+ break;
151
+ case self::AUTOMATION_TYPE_NEW_WISHLIST:
152
+ $this->_updateDefaultDatafields($email);
153
+ break;
154
+ default:
155
+ $this->_updateDefaultDatafields($email);
156
+ break;
157
+ }
158
+ }
159
+
160
+ protected function _updateDefaultDatafields($email)
161
+ {
162
+ $website = Mage::app()->getWebsite($this->websiteId);
163
+ Mage::helper('ddg')->updateDataFields(
164
+ $email, $website, $this->storeName
165
+ );
166
+ }
167
+
168
+ protected function _updateNewOrderDatafields()
169
+ {
170
+ $website = Mage::app()->getWebsite($this->websiteId);
171
+ $order = Mage::getModel('sales/order')->load($this->typeId);
172
+ //data fields
173
+ if ($lastOrderId = $website->getConfig(
174
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID
175
+ )
176
+ ) {
177
+ $data[] = array(
178
+ 'Key' => $lastOrderId,
179
+ 'Value' => $order->getId()
180
+ );
181
+ }
182
+ if ($orderIncrementId = $website->getConfig(
183
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID
184
+ )
185
+ ) {
186
+ $data[] = array(
187
+ 'Key' => $orderIncrementId,
188
+ 'Value' => $order->getIncrementId()
189
+ );
190
+ }
191
+ if ($storeName = $website->getConfig(
192
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
193
+ )
194
+ ) {
195
+ $data[] = array(
196
+ 'Key' => $storeName,
197
+ 'Value' => $this->storeName
198
+ );
199
+ }
200
+ if ($websiteName = $website->getConfig(
201
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
202
+ )
203
+ ) {
204
+ $data[] = array(
205
+ 'Key' => $websiteName,
206
+ 'Value' => $website->getName()
207
+ );
208
+ }
209
+ if ($lastOrderDate = $website->getConfig(
210
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE
211
+ )
212
+ ) {
213
+ $data[] = array(
214
+ 'Key' => $lastOrderDate,
215
+ 'Value' => $order->getCreatedAt()
216
+ );
217
+ }
218
+ if (($customerId = $website->getConfig(
219
+ Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID
220
+ ))
221
+ && $order->getCustomerId()
222
+ ) {
223
+ $data[] = array(
224
+ 'Key' => $customerId,
225
+ 'Value' => $order->getCustomerId()
226
+ );
227
+ }
228
+ if ( ! empty($data)) {
229
+ //update data fields
230
+ $client = Mage::helper('ddg')->g