EmailDirect_Integration - Version 1.2.8

Version Notes

Extension now has the ability to push over some shipping information along with the order.

Download this release

Release Info

Developer Magento Core Team
Extension EmailDirect_Integration
Version 1.2.8
Comparing to
See all releases


Version 1.2.8

Files changed (80) hide show
  1. app/code/local/EmailDirect/Integration/Block/Adminhtml/Customer/Edit/Tab/Memberactivity.php +73 -0
  2. app/code/local/EmailDirect/Integration/Block/Adminhtml/Memberactivity/Grid.php +101 -0
  3. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Account.php +20 -0
  4. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Fieldset/Hint.php +29 -0
  5. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Addressmapfields.php +22 -0
  6. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Button.php +119 -0
  7. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Common.php +79 -0
  8. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Mapfields.php +22 -0
  9. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Shippingmapfields.php +24 -0
  10. app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Convert/Profile/Export.php +99 -0
  11. app/code/local/EmailDirect/Integration/Block/Checkout/Subscribe.php +36 -0
  12. app/code/local/EmailDirect/Integration/Block/Customer/Account/Dashboard/Info.php +27 -0
  13. app/code/local/EmailDirect/Integration/Block/Customer/Account/Lists.php +193 -0
  14. app/code/local/EmailDirect/Integration/Block/Customer/Newsletter.php +17 -0
  15. app/code/local/EmailDirect/Integration/Block/Email/Order/Items.php +6 -0
  16. app/code/local/EmailDirect/Integration/Block/Email/Order/Items/Order/Default.php +59 -0
  17. app/code/local/EmailDirect/Integration/Block/Email/Order/Items/Order/Grouped.php +25 -0
  18. app/code/local/EmailDirect/Integration/Helper/Data.php +281 -0
  19. app/code/local/EmailDirect/Integration/Model/Custom/Collection.php +37 -0
  20. app/code/local/EmailDirect/Integration/Model/Observer.php +769 -0
  21. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Abandoned.php +31 -0
  22. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Abandonedlist.php +23 -0
  23. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Additionallist.php +26 -0
  24. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Checkoutsubscribe.php +19 -0
  25. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Export/Batch.php +24 -0
  26. app/code/local/EmailDirect/Integration/Model/System/Config/Source/List.php +30 -0
  27. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Maxtimes.php +20 -0
  28. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Publication.php +24 -0
  29. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Source.php +24 -0
  30. app/code/local/EmailDirect/Integration/Model/System/Config/Source/Time.php +20 -0
  31. app/code/local/EmailDirect/Integration/Model/Wrapper/Abandoned.php +35 -0
  32. app/code/local/EmailDirect/Integration/Model/Wrapper/Database.php +42 -0
  33. app/code/local/EmailDirect/Integration/Model/Wrapper/Execute.php +75 -0
  34. app/code/local/EmailDirect/Integration/Model/Wrapper/Ftp.php +17 -0
  35. app/code/local/EmailDirect/Integration/Model/Wrapper/Lists.php +63 -0
  36. app/code/local/EmailDirect/Integration/Model/Wrapper/Orders.php +91 -0
  37. app/code/local/EmailDirect/Integration/Model/Wrapper/Publications.php +42 -0
  38. app/code/local/EmailDirect/Integration/Model/Wrapper/Relays.php +66 -0
  39. app/code/local/EmailDirect/Integration/Model/Wrapper/Sources.php +31 -0
  40. app/code/local/EmailDirect/Integration/Model/Wrapper/Suscribers.php +165 -0
  41. app/code/local/EmailDirect/Integration/controllers/AbandonedController.php +150 -0
  42. app/code/local/EmailDirect/Integration/controllers/Admin/ExportController.php +208 -0
  43. app/code/local/EmailDirect/Integration/controllers/Customer/AccountController.php +113 -0
  44. app/code/local/EmailDirect/Integration/controllers/ExportController.php +11 -0
  45. app/code/local/EmailDirect/Integration/etc/adminhtml.xml +31 -0
  46. app/code/local/EmailDirect/Integration/etc/config.xml +252 -0
  47. app/code/local/EmailDirect/Integration/etc/system.xml +248 -0
  48. app/code/local/EmailDirect/Integration/sql/emaildirect_setup/mysql4-install-1.0.0.php +13 -0
  49. app/code/local/EmailDirect/Integration/sql/emaildirect_setup/mysql4-upgrade-1.0.13-1.0.14.php +12 -0
  50. app/code/local/EmailDirect/Integration/sql/emaildirect_setup/mysql4-upgrade-1.0.19-1.2.0.php +14 -0
  51. app/design/adminhtml/default/default/layout/emaildirect.xml +46 -0
  52. app/design/adminhtml/default/default/template/emaildirect/system/config/fieldset/hint.phtml +8 -0
  53. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/array.phtml +168 -0
  54. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/button.phtml +15 -0
  55. app/design/adminhtml/default/default/template/emaildirect/system/convert/profile/export.phtml +214 -0
  56. app/design/frontend/base/default/layout/emaildirect.xml +58 -0
  57. app/design/frontend/base/default/template/emaildirect/boxes/additionalNewsletter.phtml +17 -0
  58. app/design/frontend/base/default/template/emaildirect/boxes/additionalNewsletterBox.phtml +36 -0
  59. app/design/frontend/base/default/template/emaildirect/boxes/generalNewsletter.phtml +24 -0
  60. app/design/frontend/base/default/template/emaildirect/boxes/generalNewsletterBox.phtml +34 -0
  61. app/design/frontend/base/default/template/emaildirect/boxes/generalNewsletterMediumBox.phtml +22 -0
  62. app/design/frontend/base/default/template/emaildirect/checkout/subscribe.phtml +31 -0
  63. app/design/frontend/base/default/template/emaildirect/customer/account/dashboard/info.phtml +36 -0
  64. app/design/frontend/base/default/template/emaildirect/customer/account/lists.phtml +65 -0
  65. app/design/frontend/base/default/template/emaildirect/email/order/items.phtml +23 -0
  66. app/design/frontend/base/default/template/emaildirect/email/order/items/order/default.phtml +111 -0
  67. app/etc/modules/EmailDirect_Integration.xml +11 -0
  68. app/locale/en_US/template/email/newsletter_subscr_success_emaildirect.html +3 -0
  69. app/locale/en_US/template/email/newsletter_unsub_success_emaildirect.html +2 -0
  70. package.xml +18 -0
  71. skin/adminhtml/default/default/emaildirect/emaildirect-connected-ebizmarts-title.png +0 -0
  72. skin/adminhtml/default/default/emaildirect/emaildirect-section-background.png +0 -0
  73. skin/adminhtml/default/default/emaildirect/emaildirect-tab.png +0 -0
  74. skin/adminhtml/default/default/emaildirect/emaildirect.css +22 -0
  75. skin/adminhtml/default/default/emaildirect/emaildirect.js +1 -0
  76. skin/frontend/base/default/emaildirect/images/bkg_block-title.gif +0 -0
  77. skin/frontend/base/default/emaildirect/images/dotted_divider.gif +0 -0
  78. skin/frontend/base/default/emaildirect/images/emaildirect-tile.png +0 -0
  79. skin/frontend/base/default/emaildirect/images/i_block-subscribe.gif +0 -0
  80. skin/frontend/base/default/emaildirect/integration.js +20 -0
app/code/local/EmailDirect/Integration/Block/Adminhtml/Customer/Edit/Tab/Memberactivity.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_Customer_Edit_Tab_Memberactivity
4
+ extends EmailDirect_Integration_Block_Adminhtml_Memberactivity_Grid
5
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
+ {
7
+
8
+ /**
9
+ * Columns, that should be removed from grid
10
+ *
11
+ * @var array
12
+ */
13
+ protected $_columnsToRemove = array('visitor_session_id', 'protocol', 'customer_id');
14
+
15
+ public function __construct()
16
+ {
17
+ parent::__construct();
18
+ $this->setFilterVisibility(FALSE);
19
+ $this->setSaveParametersInSession(FALSE);
20
+ }
21
+
22
+ /**
23
+ * Defines after which tab, this tab should be rendered
24
+ *
25
+ * @return string
26
+ */
27
+ public function getAfter()
28
+ {
29
+ return 'orders';
30
+ }
31
+
32
+ /**
33
+ * Return Tab label
34
+ *
35
+ * @return string
36
+ */
37
+ public function getTabLabel()
38
+ {
39
+ return $this->__('EmailDirect List Member Activity');
40
+ }
41
+
42
+ /**
43
+ * Return Tab title
44
+ *
45
+ * @return string
46
+ */
47
+ public function getTabTitle()
48
+ {
49
+ return $this->__('EmailDirect List Member Activity');
50
+ }
51
+
52
+ /**
53
+ * Can show tab in tabs
54
+ *
55
+ * @return boolean
56
+ */
57
+ public function canShowTab()
58
+ {
59
+ $customer = Mage::registry('current_customer');
60
+ return (bool)$customer->getId();
61
+ }
62
+
63
+ /**
64
+ * Tab is hidden
65
+ *
66
+ * @return boolean
67
+ */
68
+ public function isHidden()
69
+ {
70
+ //TODO: Hide if MageMonkey is disabled
71
+ return false;
72
+ }
73
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/Memberactivity/Grid.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_Memberactivity_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('token_grid');
10
+ $this->setDefaultSort('id');
11
+ $this->setDefaultDir('DESC');
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $customer = Mage::registry('current_customer');
17
+ $email = $customer->getEmail();
18
+
19
+ $api = Mage::getSingleton('emaildirect/wrapper_suscribers', array('apikey' => Mage::helper('emaildirect')->getApiKey($customer->getStore())));
20
+ $activity = array();
21
+ // $lists = $api->listsForEmail($email);
22
+
23
+ $activityData = array();
24
+ $history = $api->suscriberHistory($email);
25
+ foreach($history->Actions->HistoryAction as $activity){
26
+ $act['action'] = $activity->Action;
27
+ $act['details'] = $activity->Details;
28
+ $act['timestamp'] = $activity->Date;
29
+ if(isset($activity->Links->Link)) {
30
+ $act['url'] = $activity->Links->Link;
31
+ }
32
+ $activityData[] = $act;
33
+ }
34
+
35
+
36
+
37
+ // if(is_array($lists)){
38
+ // foreach($lists as $list){
39
+ // $activity []= $api->listMemberActivity($list, $email);
40
+ // }
41
+ //
42
+ // if(!empty($activity)){
43
+ // foreach($activity as $act){
44
+ //
45
+ // if(empty($act['data'][0])){
46
+ // continue;
47
+ // }
48
+ //
49
+ // $activityData []= $act['data'];
50
+ // }
51
+ // }
52
+ // }
53
+
54
+ $collection = Mage::getModel('emaildirect/custom_collection', array($activityData));
55
+ $this->setCollection($collection);
56
+ return parent::_prepareCollection();
57
+ }
58
+
59
+ protected function _prepareColumns()
60
+ {
61
+
62
+ $this->addColumn('action', array(
63
+ 'header'=> Mage::helper('emaildirect')->__('Action'),
64
+ 'index' => 'action',
65
+ 'sortable' => false
66
+ ));
67
+ $this->addColumn('details', array(
68
+ 'header'=> Mage::helper('emaildirect')->__('Details'),
69
+ 'index' => 'details',
70
+ 'sortable' => false
71
+ ));
72
+ $this->addColumn('url', array(
73
+ 'header'=> Mage::helper('emaildirect')->__('Url'),
74
+ 'index' => 'url',
75
+ 'sortable' => false
76
+ ));
77
+ // $this->addColumn('bounce_type', array(
78
+ // 'header'=> Mage::helper('emaildirect')->__('Bounce Type'),
79
+ // 'index' => 'bounce_type',
80
+ // 'sortable' => false
81
+ // ));
82
+ // $this->addColumn('campaign_id', array(
83
+ // 'header'=> Mage::helper('emaildirect')->__('Campaign ID'),
84
+ // 'index' => 'campaign_id',
85
+ // 'sortable' => false
86
+ // ));
87
+ $this->addColumn('timestamp', array(
88
+ 'header'=> Mage::helper('emaildirect')->__('Timestamp'),
89
+ 'index' => 'timestamp',
90
+ 'sortable' => false
91
+ ));
92
+
93
+ return parent::_prepareColumns();
94
+ }
95
+
96
+ public function getRowUrl($row)
97
+ {
98
+ return false;
99
+ }
100
+
101
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Account.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Account
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $values = $element->getValues();
9
+
10
+ $html = '<ul class="checkboxes">';
11
+
12
+ foreach($values as $dat){
13
+ $html .= "<li>{$dat['label']}</li>";
14
+ }
15
+
16
+ $html .= '</ul>';
17
+
18
+ return $html;
19
+ }
20
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Fieldset/Hint.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Renderer for SagePay banner in System Configuration
5
+ * @author Ebizmart Team <info@ebizmarts.com>
6
+ */
7
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Fieldset_Hint
8
+ extends Mage_Adminhtml_Block_Abstract
9
+ implements Varien_Data_Form_Element_Renderer_Interface
10
+ {
11
+ protected $_template = 'emaildirect/system/config/fieldset/hint.phtml';
12
+
13
+ /**
14
+ * Render fieldset html
15
+ *
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return string
18
+ */
19
+ public function render(Varien_Data_Form_Element_Abstract $element)
20
+ {
21
+ return $this->toHtml();
22
+ }
23
+
24
+ public function getEmaildirectVersion()
25
+ {
26
+ return (string) Mage::getConfig()->getNode('modules/EmailDirect_Integration/version');
27
+ }
28
+
29
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Addressmapfields.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Addressmapfields extends EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Common
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ $this->addColumn('magento', array(
9
+ 'label' => Mage::helper('emaildirect')->__('Billing Address'),
10
+ 'style' => 'width:120px',
11
+ ));
12
+ $this->addColumn('emaildirect', array(
13
+ 'label' => Mage::helper('emaildirect')->__('Emaildirect'),
14
+ 'type' => 'options',
15
+ 'options' => Mage::helper('emaildirect')->getEmailDirectColumnOptions(),
16
+ 'style' => 'width:120px',
17
+ ));
18
+ $this->_addAfter = false;
19
+ $this->_addButtonLabel = Mage::helper('emaildirect')->__('Add field');
20
+ parent::__construct();
21
+ }
22
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Button.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Check if columns are defined, set template
7
+ *
8
+ */
9
+ public function __construct()
10
+ {
11
+ //echo "TTTTTTTTTTT";
12
+ parent::__construct();
13
+ $this->setTemplate('emaildirect/system/config/form/field/button.phtml');
14
+ }
15
+
16
+ /**
17
+ * Get the grid and scripts contents
18
+ *
19
+ * @param Varien_Data_Form_Element_Abstract $element
20
+ * @return string
21
+ */
22
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
23
+ {
24
+ $this->setElement($element);
25
+ $html = $this->_toHtml();
26
+ //$this->_arrayRowsCache = null; // doh, the object is used as singleton!
27
+ return $html;
28
+ }
29
+
30
+ /**
31
+ * Enter description here...
32
+ *
33
+ * @param Varien_Data_Form_Element_Abstract $element
34
+ * @return string
35
+ */
36
+ public function render(Varien_Data_Form_Element_Abstract $element)
37
+ {
38
+ $id = $element->getHtmlId();
39
+
40
+ $useContainerId = $element->getData('use_container_id');
41
+ $html = '<tr id="row_' . $id . '">'
42
+ . '<td class="label"><label for="'.$id.'">'.$element->getLabel().'</label></td>';
43
+
44
+ //$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
45
+ $isMultiple = $element->getExtType()==='multiple';
46
+
47
+ // replace [value] with [inherit]
48
+ $namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
49
+
50
+ $options = $element->getValues();
51
+
52
+ $addInheritCheckbox = false;
53
+ if ($element->getCanUseWebsiteValue()) {
54
+ $addInheritCheckbox = true;
55
+ $checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
56
+ }
57
+ elseif ($element->getCanUseDefaultValue()) {
58
+ $addInheritCheckbox = true;
59
+ $checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
60
+ }
61
+
62
+ if ($addInheritCheckbox) {
63
+ $inherit = $element->getInherit()==1 ? 'checked="checked"' : '';
64
+ if ($inherit) {
65
+ $element->setDisabled(true);
66
+ }
67
+ }
68
+
69
+ $html.= '<td class="value">';
70
+ $html.= $this->_getElementHtml($element);
71
+ if ($element->getComment()) {
72
+ $html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
73
+ }
74
+ $html.= '</td>';
75
+
76
+ if ($addInheritCheckbox) {
77
+
78
+ $defText = $element->getDefaultValue();
79
+ if ($options) {
80
+ $defTextArr = array();
81
+ foreach ($options as $k=>$v) {
82
+ if ($isMultiple) {
83
+ if (is_array($v['value']) && in_array($k, $v['value'])) {
84
+ $defTextArr[] = $v['label'];
85
+ }
86
+ } elseif ($v['value']==$defText) {
87
+ $defTextArr[] = $v['label'];
88
+ break;
89
+ }
90
+ }
91
+ $defText = join(', ', $defTextArr);
92
+ }
93
+
94
+ // default value
95
+ $html.= '<td class="use-default">';
96
+ //$html.= '<input id="'.$id.'_inherit" name="'.$namePrefix.'[inherit]" type="checkbox" value="1" class="input-checkbox config-inherit" '.$inherit.' onclick="$(\''.$id.'\').disabled = this.checked">';
97
+ $html.= '<input id="'.$id.'_inherit" name="'.$namePrefix.'[inherit]" type="checkbox" value="1" class="checkbox config-inherit" '.$inherit.' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> ';
98
+ $html.= '<label for="'.$id.'_inherit" class="inherit" title="'.htmlspecialchars($defText).'">'.$checkboxLabel.'</label>';
99
+ $html.= '</td>';
100
+ }
101
+
102
+ $html.= '<td class="scope-label">';
103
+ if ($element->getScope()) {
104
+ $html .= $element->getScopeLabel();
105
+ }
106
+ $html.= '</td>';
107
+
108
+ $html.= '<td class="">';
109
+ if ($element->getHint()) {
110
+ $html.= '<div class="hint" >';
111
+ $html.= '<div style="display: none;">' . $element->getHint() . '</div>';
112
+ $html.= '</div>';
113
+ }
114
+ $html.= '</td>';
115
+
116
+ $html.= '</tr>';
117
+ return $html;
118
+ }
119
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Common.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Common extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
4
+ {
5
+ /**
6
+ * Check if columns are defined, set template
7
+ *
8
+ */
9
+ public function __construct()
10
+ {
11
+
12
+ parent::__construct();
13
+ $this->setTemplate('emaildirect/system/config/form/field/array.phtml');
14
+
15
+ }
16
+ /**
17
+ * Add a column to array-grid
18
+ *
19
+ * @param string $name
20
+ * @param array $params
21
+ */
22
+ public function addColumn($name, $params)
23
+ {
24
+ $this->_columns[$name] = array(
25
+ 'label' => empty($params['label']) ? 'Column' : $params['label'],
26
+ 'size' => empty($params['size']) ? false : $params['size'],
27
+ 'style' => empty($params['style']) ? null : $params['style'],
28
+ 'class' => empty($params['class']) ? null : $params['class'],
29
+ 'type' => empty($params['type']) ? null : $params['type'],
30
+ 'options' => empty($params['options']) ? null : $params['options'],
31
+ 'renderer' => false,
32
+ );
33
+ if ((!empty($params['renderer'])) && ($params['renderer'] instanceof Mage_Core_Block_Abstract)) {
34
+ $this->_columns[$name]['renderer'] = $params['renderer'];
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Render array cell for prototypeJS template
40
+ *
41
+ * @param string $columnName
42
+ * @return string
43
+ */
44
+ protected function _renderCellTemplate($columnName)
45
+ {
46
+ if (empty($this->_columns[$columnName])) {
47
+ throw new Exception('Wrong column name specified.');
48
+ }
49
+ $column = $this->_columns[$columnName];
50
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
51
+
52
+ if ($column['renderer']) {
53
+ return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)
54
+ ->toHtml();
55
+ }
56
+
57
+ if ($column['type'] == 'options')
58
+ {
59
+ //$name = $this->getColumn()->getName() ? $this->getColumn()->getName() : $this->getColumn()->getId();
60
+ $html = '<select name="' . $inputName . '"class="' .
61
+ (isset($column['class']) ? $column['class'] : 'input-text') . '"'.
62
+ (isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '>';
63
+ //$value = $row->getData($this->getColumn()->getIndex());
64
+ foreach ($column['options'] as $val => $label){
65
+ //$selected = ( ($val == $value && (!is_null($value))) ? ' selected="selected"' : '' );
66
+ $html .= '<option #{_selected_' . $this->escapeHtml($val) . '} value="' . $this->escapeHtml($val) . '">';
67
+ $html .= $this->escapeHtml($label) . '</option>';
68
+ }
69
+ $html.='</select>';
70
+
71
+ return $html;
72
+ }
73
+
74
+ return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
75
+ ($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
76
+ (isset($column['class']) ? $column['class'] : 'input-text') . '"'.
77
+ (isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '/>';
78
+ }
79
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Mapfields.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Mapfields extends EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Common
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ $this->addColumn('magento', array(
9
+ 'label' => Mage::helper('emaildirect')->__('Customer'),
10
+ 'style' => 'width:120px',
11
+ ));
12
+ $this->addColumn('emaildirect', array(
13
+ 'label' => Mage::helper('emaildirect')->__('Emaildirect'),
14
+ 'style' => 'width:120px',
15
+ 'type' => 'options',
16
+ 'options' => Mage::helper('emaildirect')->getEmailDirectColumnOptions(),
17
+ ));
18
+ $this->_addAfter = false;
19
+ $this->_addButtonLabel = Mage::helper('emaildirect')->__('Add field');
20
+ parent::__construct();
21
+ }
22
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Shippingmapfields.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Shippingmapfields extends EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Common
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ $this->addColumn('magento', array(
9
+ 'label' => Mage::helper('emaildirect')->__('Shipping Field'),
10
+ 'type' => 'options',
11
+ 'options' => Mage::helper('emaildirect')->getShippingColumnOptions(),
12
+ 'style' => 'width:120px',
13
+ ));
14
+ $this->addColumn('emaildirect', array(
15
+ 'label' => Mage::helper('emaildirect')->__('Emaildirect'),
16
+ 'type' => 'options',
17
+ 'options' => Mage::helper('emaildirect')->getEmailDirectColumnOptions(),
18
+ 'style' => 'width:120px',
19
+ ));
20
+ $this->_addAfter = false;
21
+ $this->_addButtonLabel = Mage::helper('emaildirect')->__('Add field');
22
+ parent::__construct();
23
+ }
24
+ }
app/code/local/EmailDirect/Integration/Block/Adminhtml/System/Convert/Profile/Export.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Convert profiles run block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Emaildirect_Integration_Block_Adminhtml_System_Convert_Profile_Export extends Mage_Adminhtml_Block_Abstract
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->_init();
40
+ }
41
+ protected function _init()
42
+ {
43
+ $products = Mage::getModel('catalog/product')->getCollection();
44
+
45
+ if (Mage::helper('emaildirect')->exportConfig('include_disabled') == false)
46
+ $products->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
47
+
48
+ $importData = array_map('intval',$products->getAllIds());
49
+ $this->setBatchItemsCount(count($importData));
50
+
51
+ $this->setBatchConfig(
52
+ array(
53
+ 'styles' => array(
54
+ 'error' => array(
55
+ 'icon' => Mage::getDesign()->getSkinUrl('images/error_msg_icon.gif'),
56
+ 'bg' => '#FDD'
57
+ ),
58
+ 'message' => array(
59
+ 'icon' => Mage::getDesign()->getSkinUrl('images/fam_bullet_success.gif'),
60
+ 'bg' => '#DDF'
61
+ ),
62
+ 'loader' => Mage::getDesign()->getSkinUrl('images/ajax-loader.gif')
63
+ ),
64
+ 'template' => '<li style="#{style}" id="#{id}">'
65
+ . '<img id="#{id}_img" src="#{image}" class="v-middle" style="margin-right:5px"/>'
66
+ . '<span id="#{id}_status" class="text">#{text}</span>'
67
+ . '</li>',
68
+ 'text' => $this->__('Processed <strong>%s%% %s/%d</strong> records', '#{percent}', '#{updated}', $this->getBatchItemsCount()),
69
+ 'uploadText' => $this->__('Sending file to Emaildirect...'),
70
+ 'successText' => $this->__('Exported <strong>%s</strong> records', '#{updated}')
71
+ )
72
+ );
73
+
74
+ $this->setImportData($importData);
75
+
76
+ if (Mage::helper('emaildirect')->exportConfig('send_to_emaildirect') == true)
77
+ $this->setUploadStatus('true');
78
+ else
79
+ $this->setUploadStatus('false');
80
+ $this->setBatchSize(Mage::helper('emaildirect')->exportConfig('batch'));
81
+ }
82
+
83
+ public function getBatchConfigJson()
84
+ {
85
+ return Mage::helper('core')->jsonEncode(
86
+ $this->getBatchConfig()
87
+ );
88
+ }
89
+
90
+ public function jsonEncode($source)
91
+ {
92
+ return Mage::helper('core')->jsonEncode($source);
93
+ }
94
+
95
+ public function getFormKey()
96
+ {
97
+ return Mage::getSingleton('core/session')->getFormKey();
98
+ }
99
+ }
app/code/local/EmailDirect/Integration/Block/Checkout/Subscribe.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Checkout_Subscribe extends Mage_Core_Block_Template
4
+ {
5
+
6
+ /**
7
+ * Render block HTML
8
+ *
9
+ * @return string
10
+ */
11
+ protected function _toHtml()
12
+ {
13
+ $alreadySubscribed = Mage::getModel('newsletter/subscriber')
14
+ ->loadByEmail($this->getQuote()->getCustomerEmail())
15
+ ->isSubscribed();
16
+
17
+ if ( !$this->helper('emaildirect')->canCheckoutSubscribe() OR
18
+ $alreadySubscribed ) {
19
+ return '';
20
+ }
21
+
22
+ return parent::_toHtml();
23
+ }
24
+
25
+ public function getQuote()
26
+ {
27
+ return Mage::getSingleton('checkout/session')
28
+ ->getQuote();
29
+ }
30
+
31
+ public function checkStatus()
32
+ {
33
+ return (int)$this->helper('emaildirect')->config('checkout_subscribe');
34
+ }
35
+
36
+ }
app/code/local/EmailDirect/Integration/Block/Customer/Account/Dashboard/Info.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Customer_Account_Dashboard_Info extends Mage_Customer_Block_Account_Dashboard_Info
4
+ {
5
+ public function IsSubscribed($email)
6
+ {
7
+ $rc = Mage::getSingleton('emaildirect/wrapper_suscribers')->getProperties($email);
8
+ $lists = array();
9
+
10
+ $abandonedID = Mage::helper('emaildirect')->config('abandonedpublication');
11
+
12
+ if($rc->Publications->Publication && $rc->Publications->Publication->PublicationID != $abandonedID) {
13
+ $lists[]=(string)$rc->Publications->Publication->Name;
14
+ }
15
+ $abandonedID = Mage::helper('emaildirect')->config('abandonedlist');
16
+
17
+ foreach($rc->Lists->List as $i) {
18
+ if($i->ListID != $abandonedID) {
19
+ $lists[]=(string)$i->Name;
20
+ }
21
+ }
22
+ return $lists;
23
+
24
+ // return $this->getSubscriptionObject()->isSubscribed();
25
+ }
26
+
27
+ }
app/code/local/EmailDirect/Integration/Block/Customer/Account/Lists.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Emaildirect_Integration_Block_Customer_Account_Lists extends Mage_Core_Block_Template
4
+ {
5
+
6
+ protected $_lists = array();
7
+ protected $_info = array();
8
+ protected $_myLists = array();
9
+ protected $_generalList = array();
10
+ protected $_form;
11
+ protected $_allLists = array();
12
+ protected $_publications = array();
13
+
14
+ public function getAllLists()
15
+ {
16
+ $listData = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
17
+ $options = array();
18
+ foreach($listData as $list)
19
+ {
20
+ if($list['active'])
21
+ $options[] = array(
22
+ 'id' => $list['id'],
23
+ 'name' => $list['name']);
24
+ }
25
+ $this->_allLists = $options;
26
+ return $options;
27
+ }
28
+
29
+ public function getGeneralList()
30
+ {
31
+ $general = $this->helper('emaildirect')->config('publication');
32
+ // foreach($this->_allLists as $list) {
33
+ // if($list['id']==$general) {
34
+ // $rc = array('id' => $list['id'], 'name' => $list['name']);
35
+ // break;
36
+ // }
37
+ // }
38
+ $rc = Mage::getSingleton('emaildirect/wrapper_publications')->getPublication($general);
39
+ return array('id' =>(int) $rc->PublicationID,'name'=> (string)$rc->Name);
40
+ }
41
+
42
+
43
+ /**
44
+ * Get additional lists data
45
+ *
46
+ * @return array
47
+ */
48
+ public function getLists()
49
+ {
50
+ $additionalLists = $this->helper('emaildirect')->config('additional_lists');
51
+ $activelists = explode(",",$additionalLists);
52
+ $this->getAllLists();
53
+
54
+ if($additionalLists){
55
+ $lists = $this->_allLists;
56
+ $options = array();
57
+ foreach($lists as $list)
58
+ {
59
+ if(in_array($list['id'],$activelists))
60
+ $this->_lists [] = array(
61
+ 'id' => $list['id'],
62
+ 'name' => $list['name']);
63
+ }
64
+
65
+ }
66
+ return $this->_lists;
67
+ }
68
+
69
+ /**
70
+ * Getter for class property
71
+ *
72
+ * @return array
73
+ */
74
+ public function getSubscribedLists()
75
+ {
76
+ $properties = Mage::getSingleton('emaildirect/wrapper_suscribers')->getProperties($this->_getEmail());
77
+ $rc = array();
78
+ $publications = array();
79
+ foreach($properties->Lists->List as $list)
80
+ {
81
+ $rc [] = (int)$list->ListID;
82
+ }
83
+ $this->_myLists = $rc;
84
+ foreach($properties->Publications->Publication as $publication)
85
+ {
86
+ $this->_publications[] = (int) $publication->PublicationID;
87
+ }
88
+ return $this->_myLists;
89
+ }
90
+
91
+ /**
92
+ * Utility to generate HTML name for element
93
+ * @param string $list
94
+ * @param string $group
95
+ * @param bool $multiple
96
+ * @return string
97
+ */
98
+ protected function _htmlGroupName($list, $group = NULL, $multiple = FALSE)
99
+ {
100
+ $htmlName = "list[{$list['id']}]";
101
+
102
+ if(!is_null($group)){
103
+ $htmlName .= "[{$group['id']}]";
104
+ }
105
+
106
+ if(TRUE === $multiple){
107
+ $htmlName .= '[]';
108
+ }
109
+
110
+ return $htmlName;
111
+ }
112
+
113
+ /**
114
+ * Form getter/instantiation
115
+ *
116
+ * @return Varien_Data_Form
117
+ */
118
+ public function getForm()
119
+ {
120
+ if ($this->_form instanceof Varien_Data_Form) {
121
+ return $this->_form;
122
+ }
123
+ $form = new Varien_Data_Form();
124
+ return $form;
125
+ }
126
+
127
+
128
+ /**
129
+ * Retrieve email from Customer object in session
130
+ *
131
+ * @return string Email address
132
+ */
133
+ protected function _getEmail()
134
+ {
135
+ return $this->helper('customer')->getCustomer()->getEmail();
136
+ }
137
+
138
+ /**
139
+ * Return HTML code for list <label> with checkbox, checked if subscribed, otherwise not
140
+ *
141
+ * @param array $list List data from
142
+ * @return string HTML code
143
+ */
144
+ public function listLabel($generalList,$list)
145
+ {
146
+ $myLists = $this->_myLists;
147
+
148
+ $checkbox = new Varien_Data_Form_Element_Checkbox;
149
+ $checkbox->setForm($this->getForm());
150
+ $checkbox->setHtmlId('list-' . $list['id']);
151
+ if(!in_array($generalList['id'],$this->_publications)) {
152
+ $checkbox->setChecked(false);
153
+ $checkbox->setData('disabled',true);
154
+ }
155
+ else {
156
+ $checkbox->setChecked((bool)(is_array($myLists) && in_array($list['id'], $myLists)));
157
+ }
158
+ $checkbox->setTitle( ($checkbox->getChecked() ? $this->__('Click to unsubscribe from this list.') : $this->__('Click to subscribe to this list.')) );
159
+ $checkbox->setLabel($list['name']);
160
+
161
+ $hname = $this->_htmlGroupName($list);
162
+ $checkbox->setName($hname . '[subscribed]');
163
+
164
+ $checkbox->setValue($list['id']);
165
+ $checkbox->setClass('emaildirect-list-subscriber');
166
+
167
+
168
+ return $checkbox->getLabelHtml() . $checkbox->getElementHtml();
169
+ }
170
+ public function publicationLabel($list)
171
+ {
172
+ $myLists = $this->_myLists;
173
+
174
+ $checkbox = new Varien_Data_Form_Element_Checkbox;
175
+ $checkbox->setForm($this->getForm());
176
+ $checkbox->setHtmlId('publication-' . $list['id']);
177
+ $checkbox->setChecked(in_array($list['id'],$this->_publications));
178
+ // $checkbox->setChecked((bool)(is_array($myLists) && in_array($list['id'], $myLists)));
179
+ $checkbox->setTitle( ($checkbox->getChecked() ? $this->__('Click to unsubscribe from this list.') : $this->__('Click to subscribe to this list.')) );
180
+ $checkbox->setLabel($list['name']);
181
+
182
+ // $hname = $this->_htmlGroupName($list);
183
+ $hname = 'publication';
184
+ $checkbox->setName($hname . '[subscribed]');
185
+
186
+ $checkbox->setValue($list['id']);
187
+ $checkbox->setClass('emaildirect-publication-subscriber');
188
+
189
+
190
+ return $checkbox->getLabelHtml() . $checkbox->getElementHtml();
191
+ }
192
+
193
+ }
app/code/local/EmailDirect/Integration/Block/Customer/Newsletter.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 15, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Block_Customer_Newsletter extends Mage_Customer_Block_Newsletter {
9
+
10
+ public function isEmailDirectEnabled($store) {
11
+ // Mage::log(__METHOD__);
12
+ return true;
13
+ }
14
+ public function getSubscribedAdditionalLists() {
15
+ // Mage::log(__METHOD__);
16
+ }
17
+ }
app/code/local/EmailDirect/Integration/Block/Email/Order/Items.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Email_Order_Items extends Mage_Sales_Block_Items_Abstract
4
+ {
5
+
6
+ }
app/code/local/EmailDirect/Integration/Block/Email/Order/Items/Order/Default.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Email_Order_Items_Order_Default extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * Retrieve current order model instance
7
+ *
8
+ * @return Mage_Sales_Model_Order
9
+ */
10
+ public function getOrder()
11
+ {
12
+ return $this->getItem()->getOrder();
13
+ }
14
+
15
+ public function getItemOptions()
16
+ {
17
+ $result = array();
18
+ if ($options = $this->getItem()->getProductOptions()) {
19
+ if (isset($options['options'])) {
20
+ $result = array_merge($result, $options['options']);
21
+ }
22
+ if (isset($options['additional_options'])) {
23
+ $result = array_merge($result, $options['additional_options']);
24
+ }
25
+ if (isset($options['attributes_info'])) {
26
+ $result = array_merge($result, $options['attributes_info']);
27
+ }
28
+ }
29
+
30
+ return $result;
31
+ }
32
+
33
+ public function getValueHtml($value)
34
+ {
35
+ if (is_array($value)) {
36
+ return sprintf('%d', $value['qty']) . ' x ' . $this->htmlEscape($value['title']) . " " . $this->getItem()->getOrder()->formatPrice($value['price']);
37
+ } else {
38
+ return $this->htmlEscape($value);
39
+ }
40
+ }
41
+
42
+ public function getSku($item)
43
+ {
44
+ if ($item->getProductOptionByCode('simple_sku'))
45
+ return $item->getProductOptionByCode('simple_sku');
46
+ else
47
+ return $item->getSku();
48
+ }
49
+
50
+ /**
51
+ * Return product additional information block
52
+ *
53
+ * @return Mage_Core_Block_Abstract
54
+ */
55
+ public function getProductAdditionalInformationBlock()
56
+ {
57
+ return $this->getLayout()->getBlock('additional.product.info');
58
+ }
59
+ }
app/code/local/EmailDirect/Integration/Block/Email/Order/Items/Order/Grouped.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Email_Email_Items_Order_Grouped extends Mage_Sales_Block_Order_Email_Items_Order_Default
4
+ {
5
+ /**
6
+ * Prepare item html
7
+ *
8
+ * This method uses renderer for real product type
9
+ *
10
+ * @return string
11
+ */
12
+ protected function _toHtml()
13
+ { if ($this->getItem()->getOrderItem()) {
14
+ $item = $this->getItem()->getOrderItem();
15
+ } else {
16
+ $item = $this->getItem();
17
+ }
18
+ if ($productType = $item->getRealProductType()) {
19
+ $renderer = $this->getRenderedBlock()->getItemRenderer($productType);
20
+ $renderer->setItem($this->getItem());
21
+ return $renderer->toHtml();
22
+ }
23
+ return parent::_toHtml();
24
+ }
25
+ }
app/code/local/EmailDirect/Integration/Helper/Data.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Oct 26, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+
11
+ public function debugLog($data)
12
+ {
13
+ if ($this->config('debug'))
14
+ {
15
+ Mage::log($data,null,'emaildirect.log');
16
+ }
17
+ }
18
+
19
+ public function getExportFileName($name,$full = true)
20
+ {
21
+ $filename = "{$name}.csv";
22
+ // get name from config page?
23
+ if ($full)
24
+ return Mage::getBaseDir('export').'/' . $filename;
25
+
26
+ return $filename;
27
+ }
28
+
29
+ public function getApiKey($store = null)
30
+ {
31
+ if(is_null($store)){
32
+ $key = $this->config('apikey');
33
+ }else{
34
+ $curstore = Mage::app()->getStore();
35
+ Mage::app()->setCurrentStore($store);
36
+ $key = $this->config('apikey', $store);
37
+ Mage::app()->setCurrentStore($curstore);
38
+ }
39
+
40
+ return $key;
41
+ }
42
+
43
+ private function _config($value,$section, $store = null)
44
+ {
45
+ if (is_null($store))
46
+ {
47
+ $store = Mage::app()->getStore();
48
+
49
+ $configscope = Mage::app()->getRequest()->getParam('store');
50
+
51
+ if ($configscope)
52
+ $store = $configscope;
53
+ }
54
+
55
+ $realvalue = Mage::getStoreConfig("emaildirect/{$section}/{$value}", $store);
56
+
57
+ return $realvalue;
58
+ }
59
+
60
+ public function config($value, $store = null)
61
+ {
62
+ return $this->_config($value,'general',$store);
63
+ }
64
+
65
+ public function exportConfig($value, $store = null)
66
+ {
67
+ return $this->_config($value,'export',$store);
68
+ }
69
+
70
+ public function getEmailDirectColumnOptions()
71
+ {
72
+ $columns = Mage::getSingleton('emaildirect/wrapper_database')->getAllColumns();
73
+
74
+ $options = array();
75
+
76
+ foreach ($columns as $column)
77
+ {
78
+ if ($column->IsCustom == 'true')
79
+ {
80
+ $key = (string)$column->ColumnName;
81
+
82
+ $options[$key] = $key;
83
+ }
84
+ }
85
+
86
+ return $options;
87
+ }
88
+
89
+ public function getShippingColumnOptions()
90
+ {
91
+ $options = array('shipping_code' => 'Shipping Code', 'shipping_description' => 'Shipping Description', 'carrier_code' => 'Tracking Carrier Code', 'title' => 'Tracking Title', 'number' => 'Tracking Number');
92
+
93
+ return $options;
94
+ }
95
+
96
+ public function getDefaultList($storeId)
97
+ {
98
+ $curstore = Mage::app()->getStore();
99
+ Mage::app()->setCurrentStore($storeId);
100
+ $list = $this->config('list', $storeId);
101
+ Mage::app()->setCurrentStore($curstore);
102
+ return $list;
103
+ }
104
+ public function getDefaultPublication($storeId)
105
+ {
106
+ $curstore = Mage::app()->getStore();
107
+ Mage::app()->setCurrentStore($storeId);
108
+ $publication = $this->config('publication', $storeId);
109
+ Mage::app()->setCurrentStore($curstore);
110
+ return $publication;
111
+ }
112
+
113
+ public function getMergeVars($customer, $includeEmail = FALSE)
114
+ {
115
+ $merge_vars = array();
116
+ $maps = unserialize( $this->config('map_fields', $customer->getStoreId()) );
117
+
118
+ if($maps)
119
+ {
120
+ $this->processMap($merge_vars, $maps, $customer);
121
+ }
122
+
123
+ $address_maps = unserialize( $this->config('address_fields', $customer->getStoreId()) );
124
+
125
+ // Process address
126
+ if ($address_maps)
127
+ {
128
+ $address = $customer->getBillingAddress();
129
+ if ($address)
130
+ {
131
+ $this->processMap($merge_vars, $address_maps, $address);
132
+ }
133
+ }
134
+
135
+ return $merge_vars;
136
+ }
137
+
138
+ private function getTrackingData($order)
139
+ {
140
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
141
+ ->setOrderFilter($order)
142
+ ->load();
143
+ foreach($shipmentCollection as $_shipment)
144
+ {
145
+ foreach($_shipment->getAllTracks() as $tracknum)
146
+ {
147
+ return $tracknum->getData();
148
+ }
149
+ }
150
+
151
+ return null;
152
+ }
153
+
154
+ private function getShippingData($order)
155
+ {
156
+ $data = array();
157
+
158
+ $data['shipping_code'] = $order->getData('shipping_method');
159
+ $data['shipping_description'] = $order->getData('shipping_description');
160
+
161
+ $track_data = $this->getTrackingData($order);
162
+
163
+ if ($track_data != null)
164
+ {
165
+ $data['carrier_code'] = $track_data['carrier_code'];
166
+ $data['title'] = $track_data['title'];
167
+ $data['number'] = $track_data['number'];
168
+ }
169
+
170
+ $shipping_data = new Varien_Object();
171
+
172
+ $shipping_data->setData($data);
173
+
174
+ return $shipping_data;
175
+ }
176
+
177
+ public function getOrderMergeVars(&$merge_vars, $order)
178
+ {
179
+ $this->debugLog('getOrderMergeVars');
180
+ $maps = unserialize( $this->config('shipping_fields', $order->getStoreId()) );
181
+
182
+ if($maps)
183
+ {
184
+ $this->debugLog('MAPS:');
185
+ $this->debugLog($maps);
186
+ $shipping_data = $this->getShippingData($order);
187
+
188
+ $this->debugLog('Shipping Data');
189
+ $this->debugLog($shipping_data);
190
+
191
+ $this->processMap($merge_vars, $maps, $shipping_data);
192
+ }
193
+
194
+ return $merge_vars;
195
+ }
196
+
197
+ private function processMap(&$merge_vars,$maps, $data)
198
+ {
199
+ $request = Mage::app()->getRequest();
200
+
201
+ foreach($maps as $map)
202
+ {
203
+ $customAtt = $map['magento'];
204
+ $emaildirectTag = $key = $map['emaildirect'];
205
+
206
+ if($emaildirectTag && $customAtt)
207
+ {
208
+ switch ($customAtt)
209
+ {
210
+ case 'state_code':
211
+ {
212
+ $region_id = $data->getData('region_id');
213
+
214
+ $region = Mage::getModel('directory/region')->load($region_id);
215
+
216
+ if (!$region)
217
+ continue;
218
+
219
+ $state_code = $region->getCode();
220
+
221
+ $merge_vars[$key] = $state_code;
222
+ }
223
+ break;
224
+ case 'date_of_purchase':
225
+ $last_order = Mage::getResourceModel('sales/order_collection')
226
+ ->addFieldToFilter('customer_id', $data->getId())
227
+ ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
228
+ ->setOrder('created_at', 'desc')
229
+ ->getFirstItem();
230
+
231
+ if ( $last_order->getId() )
232
+ {
233
+ $merge_vars[$key] = Mage::helper('core')->formatDate($last_order->getCreatedAt());
234
+ }
235
+
236
+ break;
237
+ default:
238
+
239
+ if( ($value = (string)$data->getData(strtolower($customAtt)))
240
+ OR ($value = (string)$request->getPost(strtolower($customAtt))) )
241
+ {
242
+ $merge_vars[$key] = $value;
243
+ }
244
+
245
+ break;
246
+ }
247
+
248
+ }
249
+ }
250
+ }
251
+
252
+ public function canCheckoutSubscribe()
253
+ {
254
+ return (bool)($this->config('checkout_subscribe') != 0);
255
+ // return Mage::getStoreConfigFlag('emaildirect/general/checkout_subscribe');
256
+ }
257
+ public function canEdirect()
258
+ {
259
+ return (bool)((int)$this->config('active') !== 0);
260
+ }
261
+
262
+ public function registerGuestCustomer($order)
263
+ {
264
+ if( Mage::registry('ed_guest_customer') ){
265
+ return;
266
+ }
267
+
268
+ $customer = new Varien_Object;
269
+
270
+ $customer->setId(time());
271
+ $customer->setEmail($order->getBillingAddress()->getEmail());
272
+ $customer->setStoreId($order->getStoreId());
273
+ $customer->setFirstname($order->getBillingAddress()->getFirstname());
274
+ $customer->setLastname($order->getBillingAddress()->getLastname());
275
+ $customer->setPrimaryBillingAddress($order->getBillingAddress());
276
+ $customer->setPrimaryShippingAddress($order->getShippingAddress());
277
+ Mage::register('ed_guest_customer', $customer, TRUE);
278
+
279
+ }
280
+
281
+ }
app/code/local/EmailDirect/Integration/Model/Custom/Collection.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_Custom_Collection
4
+ extends Varien_Data_Collection
5
+ {
6
+
7
+ protected $_toload = NULL;
8
+
9
+ public function __construct(array $data)
10
+ {
11
+ $data = current($data);
12
+
13
+ if( empty($data) ){
14
+ return parent::__construct();
15
+ }
16
+
17
+ $this->_toload = $data;
18
+
19
+ return parent::__construct();
20
+ }
21
+ public function load($printQuery = false, $logQuery = false)
22
+ {
23
+ if($this->isLoaded() || is_null($this->_toload)){
24
+ return $this;
25
+ }
26
+
27
+ foreach ($this->_toload as $row) {
28
+ $item = new Varien_Object;
29
+ $item->addData($row);
30
+ $this->addItem($item);
31
+ }
32
+
33
+ $this->_setIsLoaded();
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/local/EmailDirect/Integration/Model/Observer.php ADDED
@@ -0,0 +1,769 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Nov 28, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Observer
9
+ {
10
+ const ABANDONED_SETUP_PATH = 'emaildirect/general/abandonedsetup';
11
+ const ABANDONED_SETUP_VERSION = 'emaildirect/general/setup_version';
12
+
13
+ private function getVersion()
14
+ {
15
+ return (string) Mage::getConfig()->getNode('modules/EmailDirect_Integration/version');
16
+ }
17
+
18
+ /**
19
+ * Handle Subscriber object saving process
20
+ */
21
+ public function handleSubscriber(Varien_Event_Observer $observer)
22
+ {
23
+ $subscriber = $observer->getEvent()->getSubscriber();
24
+ $subscriber->setImportMode(false);
25
+
26
+ $email = $subscriber->getSubscriberEmail();
27
+ $listId = Mage::helper('emaildirect')->getDefaultPublication($subscriber->getStoreId());
28
+ $isConfirmNeed = (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_CONFIRMATION_FLAG, $subscriber->getStoreId()) == 1) ? TRUE : FALSE;
29
+
30
+ //New subscriber, just add
31
+ if( $subscriber->isObjectNew() ){
32
+
33
+ if( TRUE === $isConfirmNeed ){
34
+ $subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED);
35
+ if( !Mage::helper('customer')->isLoggedIn() && Mage::registry('ed_guest_customer')) {
36
+ $guestCustomer = Mage::registry('ed_guest_customer');
37
+ $subscriber->setFirstname($guestCustomer->getFirstname());
38
+ $subscriber->setLastname($guestCustomer->getLastname());
39
+ Mage::unregister('ed_guest_customer');
40
+ $subscriber->save();
41
+ }
42
+ }
43
+ else {
44
+ $subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
45
+ $mergeVars = $this->_mergeVars($subscriber);
46
+ Mage::getSingleton('emaildirect/wrapper_suscribers')
47
+ ->suscriberAdd($email,$mergeVars);
48
+ }
49
+ }else{
50
+ $status = (int)$subscriber->getData('subscriber_status');
51
+
52
+ $oldSubscriber = Mage::getModel('newsletter/subscriber')
53
+ ->load($subscriber->getId());
54
+ $oldstatus = (int)$oldSubscriber->getOrigData('subscriber_status');
55
+ if($oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED && $status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
56
+ $subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
57
+ $mergeVars = $this->_mergeVars($subscriber);
58
+ Mage::getSingleton('emaildirect/wrapper_suscribers')
59
+ ->suscriberAdd($email,$mergeVars);
60
+ }
61
+ elseif( $status !== $oldstatus ){ //Status change
62
+ //Unsubscribe customer
63
+ if($status == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED){
64
+ Mage::getSingleton('emaildirect/wrapper_publications')
65
+ ->unsubscribe($listId, $email);
66
+ }else if($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED){
67
+ if( $oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE || $oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED ){
68
+ Mage::getSingleton('emaildirect/wrapper_publications')
69
+ ->subscribe($listId, $email);
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Handle Subscriber deletion from Magento, unsubcribes email
78
+ * and sends the delete_member flag so the subscriber gets deleted.
79
+ */
80
+ public function handleSubscriberDeletion(Varien_Event_Observer $observer)
81
+ {
82
+ $subscriber = $observer->getEvent()->getSubscriber();
83
+ $subscriber->setImportMode(TRUE);
84
+
85
+ $listId = Mage::helper('emaildirect')->getDefaultList($subscriber->getStoreId());
86
+ }
87
+
88
+ private function addDatabaseField($data)
89
+ {
90
+ $name = $data['name'];
91
+ $type = $data['type'];
92
+
93
+ if (!Mage::getSingleton('emaildirect/wrapper_database')->exists($name))
94
+ {
95
+ if (isset($data['size']))
96
+ $rc = Mage::getSingleton('emaildirect/wrapper_database')->add($name,$type,$data['size']);
97
+ else
98
+ $rc = Mage::getSingleton('emaildirect/wrapper_database')->add($name,$type);
99
+
100
+ if(isset($rc->ErrorCode) && $rc->ErrorCode != 233)
101
+ {
102
+ Mage::helper('emaildirect')->debugLog("Error adding {$name} field");
103
+ Mage::helper('emaildirect')->debugLog($rc);
104
+ Mage::throwException("Error adding {$name} field");
105
+ }
106
+
107
+ if (!Mage::getSingleton('emaildirect/wrapper_database')->exists($name))
108
+ {
109
+ Mage::helper('emaildirect')->debugLog("Error creating {$name} field");
110
+ Mage::helper('emaildirect')->debugLog($rc);
111
+ Mage::throwException("Error creating {$name} field");
112
+ }
113
+ }
114
+ }
115
+
116
+ private function addMultiFields($prefix = "", $count = null)
117
+ {
118
+ if ($count == null)
119
+ $count = Mage::helper('emaildirect')->config('product_fields');
120
+
121
+ for ($i = 1; $i <= $count; $i++)
122
+ {
123
+ $multi_fields = array(
124
+ array('name' => "{$prefix}ProductName{$i}",
125
+ 'type' => 'Text',
126
+ 'size' => '200'),
127
+ array('name' => "{$prefix}SKU{$i}",
128
+ 'type' => 'Text',
129
+ 'size' => '50'),
130
+ array('name' => "{$prefix}URL{$i}",
131
+ 'type' => 'Text',
132
+ 'size' => '200'),
133
+ array('name' => "{$prefix}Image{$i}",
134
+ 'type' => 'Text',
135
+ 'size' => '200'),
136
+ array('name' => "{$prefix}Description{$i}",
137
+ 'type' => 'Text',
138
+ 'size' => '200'),
139
+ array('name' => "{$prefix}Cost{$i}",
140
+ 'type' => 'Text',
141
+ 'size' => '20')
142
+ );
143
+
144
+ Mage::helper('emaildirect')->debugLog("Multi Field:");
145
+ Mage::helper('emaildirect')->debugLog($multi_fields);
146
+
147
+ foreach ($multi_fields as $data)
148
+ {
149
+ $this->addDatabaseField($data);
150
+
151
+ }
152
+ }
153
+ }
154
+
155
+ private function verifyAbandonedFields()
156
+ {
157
+ Mage::helper('emaildirect')->debugLog("verifyAbandonedFields Start");
158
+ $fields = array(
159
+ array('name' => 'AbandonedDate',
160
+ 'type' => 'Date'),
161
+ array('name' => 'AbandonedUrl',
162
+ 'type' => 'Text',
163
+ 'size' => '1000')
164
+ );
165
+
166
+ foreach ($fields as $data)
167
+ {
168
+ $this->addDatabaseField($data);
169
+ }
170
+
171
+ $this->addMultiFields("AB");
172
+
173
+ // Save version so we know if we are up to date or not
174
+ Mage::getConfig()->saveConfig(self::ABANDONED_SETUP_PATH, 1,"default","default");
175
+ Mage::getConfig()->saveConfig(self::ABANDONED_SETUP_VERSION, $this->getVersion(),"default","default");
176
+ Mage::helper('emaildirect')->debugLog("verifyAbandonedFields End");
177
+ }
178
+
179
+ private function verifyProductFields()
180
+ {
181
+ $fields = array(
182
+ array('name' => 'LastOrderNumber',
183
+ 'type' => 'Text',
184
+ 'size' => '30'),
185
+ array('name' => 'LastPurchaseDate',
186
+ 'type' => 'Date'),
187
+ array('name' => 'LastPurchaseTotal',
188
+ 'type' => 'Text',
189
+ 'size' => '20')
190
+ );
191
+
192
+ foreach ($fields as $data)
193
+ {
194
+ $this->addDatabaseField($data);
195
+ }
196
+
197
+ $this->addMultiFields();
198
+
199
+ $this->addMultiFields("Related", Mage::helper('emaildirect')->config('related_fields'));
200
+ }
201
+
202
+ public function saveConfig(Varien_Event_Observer $observer)
203
+ {
204
+ $store = is_null($observer->getEvent()->getStore()) ? 'default': $observer->getEvent()->getStore();
205
+ $post = Mage::app()->getRequest()->getPost();
206
+ $apiKey = isset($post['groups']['general']['fields']['apikey']['value']) ? $post['groups']['general']['fields']['apikey']['value'] : Mage::helper('emaildirect')->config('apikey');
207
+ if(!$apiKey){
208
+ return $observer;
209
+ }
210
+
211
+ $source = isset($post['groups']['general']['fields']['source']['value']) ? $post['groups']['general']['fields']['source']['value'] : Mage::helper('emaildirect')->config('source');
212
+
213
+ if($source == '') {
214
+ $source = "Magento";
215
+ $config = new Mage_Core_Model_Config();
216
+ $config->saveConfig('emaildirect/general/source',$source,"default",$store);
217
+ Mage::getConfig()->cleanCache();
218
+ }
219
+ //check if the source exist
220
+ $sources = Mage::getSingleton('emaildirect/wrapper_sources')->getSources();
221
+ $found = false;
222
+ foreach($sources as $item)
223
+ {
224
+ if($item['name']==$source) {
225
+ $found = true;
226
+ $sourceid = $item['id'];
227
+ // Mage::log($item);
228
+ break;
229
+ }
230
+ }
231
+
232
+ if(!$found) {
233
+ $rc = Mage::getSingleton('emaildirect/wrapper_sources')->addSource($source);
234
+ if(!isset($rc->SourceID)) {
235
+ Mage::throwException("Error adding source");
236
+ }
237
+ else {
238
+ $config = new Mage_Core_Model_Config();
239
+ $config->saveConfig('emaildirect/general/sourceid',$rc->SourceID,"default",$store);
240
+ Mage::getConfig()->cleanCache();
241
+ }
242
+ }
243
+ else {
244
+ $config = new Mage_Core_Model_Config();
245
+ $config->saveConfig('emaildirect/general/sourceid',$sourceid,"default",$store);
246
+ Mage::getConfig()->cleanCache();
247
+ }
248
+
249
+ if (isset($post['groups']['general']['fields']['save_latest_order']['value']) && $post['groups']['general']['fields']['save_latest_order']['value'] == true)
250
+ {
251
+ $this->verifyProductFields();
252
+ }
253
+
254
+ //add the custom fields for abandoned cart
255
+ $this->verifyAbandonedFields();
256
+ }
257
+
258
+ public function _mergeVars($object = NULL, $includeEmail = FALSE)
259
+ {
260
+ //Initialize as GUEST customer
261
+ $customer = new Varien_Object;
262
+
263
+ $regCustomer = Mage::registry('current_customer');
264
+ $guestCustomer = Mage::registry('ed_guest_customer');
265
+
266
+ if( Mage::helper('customer')->isLoggedIn() ){
267
+ $customer = Mage::helper('customer')->getCustomer();
268
+ }elseif($regCustomer){
269
+ $customer = $regCustomer;
270
+ }elseif($guestCustomer){
271
+ $customer = $guestCustomer;
272
+ }else{
273
+ /*if(is_null($object)){
274
+ $customer->setEmail($object->getSubscriberEmail())
275
+ ->setStoreId($object->getStoreId());
276
+ }else{
277
+ $customer = $object;
278
+ }*/
279
+ $customer = $object;
280
+ }
281
+
282
+ $address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
283
+ if ($address)
284
+ $customer->setBillingAddress($address);
285
+
286
+ $mergeVars = Mage::helper('emaildirect')->getMergeVars($customer, $includeEmail);
287
+
288
+ return $mergeVars;
289
+ }
290
+
291
+ private function addMergeItem($item, $pos, $mergeVars, $prefix = "")
292
+ {
293
+ $name = "";
294
+ $sku = "";
295
+ $url = "";
296
+ $image = "";
297
+ $cost = "";
298
+ $description = "";
299
+
300
+ if ($item != null)
301
+ {
302
+ $product_id = 0;
303
+
304
+ if (is_string($item))
305
+ $product_id = $item;
306
+ else
307
+ $product_id = $item->getProduct()->getId();
308
+
309
+ $product = Mage::getModel('catalog/product')->load($product_id);
310
+
311
+ if ($product != null)
312
+ {
313
+ $name = $product->getName();
314
+ $sku = $product->getSku();
315
+ $url = $product->getProductUrl();
316
+
317
+ if ($product->getImage() != 'no_selection')
318
+ $image = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
319
+
320
+ if (is_string($item))
321
+ $cost = $product->getPrice();
322
+ else
323
+ $cost = $item->getPrice();
324
+
325
+ $cost = number_format($cost, 2, '.', '');
326
+ $description = $product->getShortDescription();
327
+ }
328
+ }
329
+
330
+ $mergeVars["{$prefix}ProductName{$pos}"] = $name;
331
+ $mergeVars["{$prefix}SKU{$pos}"] = $sku;
332
+ $mergeVars["{$prefix}URL{$pos}"] = $url;
333
+ $mergeVars["{$prefix}Image{$pos}"] = $image;
334
+
335
+ $mergeVars["{$prefix}Cost{$pos}"] = $cost;
336
+ $mergeVars["{$prefix}Description{$pos}"] = $description;
337
+
338
+ return $mergeVars;
339
+ }
340
+
341
+ private function getRelatedOrderItems($quote, $mergeVars)
342
+ {
343
+ $prefix = "Related";
344
+
345
+ $max_count = Mage::helper('emaildirect')->config('related_fields');
346
+
347
+ $id_list = array();
348
+
349
+ foreach($quote->getAllItems() as $item)
350
+ {
351
+ $id_list[] = $item->getProduct()->getId();
352
+ }
353
+
354
+ $collection = Mage::getModel('catalog/product_link')
355
+ ->getCollection()
356
+ ->addFieldToFilter('product_id', array('in' => $id_list))
357
+ ->addFieldToFilter('link_type_id','1')
358
+ ->setPageSize($max_count);
359
+
360
+ $related_products = $collection->getData();
361
+
362
+ $count = 0;
363
+
364
+ foreach ($related_products as $rp)
365
+ {
366
+ $count++;
367
+
368
+ if ($count > $max_count)
369
+ break;
370
+
371
+ $mergeVars = $this->addMergeItem($rp['linked_product_id'], $count, $mergeVars, $prefix);
372
+ }
373
+
374
+ while ($count < $max_count)
375
+ {
376
+ $count++;
377
+ $mergeVars = $this->addMergeItem(null, $count, $mergeVars, $prefix);
378
+ }
379
+
380
+ return $mergeVars;
381
+ }
382
+
383
+ private function getMergeOrderItems($quote, $mergeVars, $prefix = "")
384
+ {
385
+ $max_count = Mage::helper('emaildirect')->config('product_fields');
386
+
387
+ $count = 0;
388
+
389
+ foreach($quote->getAllItems() as $item)
390
+ {
391
+ $count++;
392
+
393
+ if ($count > $max_count)
394
+ break;
395
+
396
+ $mergeVars = $this->addMergeItem($item, $count, $mergeVars, $prefix);
397
+ }
398
+
399
+ while ($count < $max_count)
400
+ {
401
+ $count++;
402
+ $mergeVars = $this->addMergeItem(null, $count, $mergeVars, $prefix);
403
+ }
404
+
405
+ return $mergeVars;
406
+ }
407
+
408
+ public function updateCustomer(Varien_Event_Observer $observer)
409
+ {
410
+ $store = Mage::app()->getStore()->getId();
411
+ $customer = $observer->getEvent()->getCustomer();
412
+
413
+ $mergeVars = $this->_mergeVars($customer, TRUE);
414
+
415
+ $api = Mage::getSingleton('emaildirect/wrapper_suscribers');
416
+
417
+ $oldEmail = $customer->getOrigData('email');
418
+ $email = $customer->getEmail();
419
+ if($oldEmail == '') {
420
+ $api->suscriberAdd($email,$mergeVars);
421
+ }
422
+ elseif($oldEmail != $email)
423
+ {
424
+ $api->mailModify($oldEmail,$email);
425
+ $api->suscriberAdd($email,$mergeVars);
426
+ }
427
+
428
+ return $observer;
429
+ }
430
+
431
+ public function registerCheckoutSubscribe(Varien_Event_Observer $observer)
432
+ {
433
+ if(!Mage::helper('emaildirect')->canEdirect()){
434
+ return;
435
+ }
436
+ $subscribe = Mage::app()->getRequest()->getPost('emaildirect_subscribe');
437
+
438
+ if(!is_null($subscribe)){
439
+ Mage::getSingleton('core/session')->setEmaildirectCheckout($subscribe);
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Subscribe customer to Newsletter if flag on session is present
445
+ */
446
+ public function registerCheckoutSuccess(Varien_Event_Observer $observer)
447
+ {
448
+ if(!Mage::helper('emaildirect')->canEdirect()){
449
+ return;
450
+ }
451
+ $sessionFlag = Mage::getSingleton('core/session')->getEmaildirectCheckout(TRUE);
452
+ if($sessionFlag){
453
+ $orderId = (int)current($observer->getEvent()->getOrderIds());
454
+
455
+ if($orderId){
456
+ $order = Mage::getModel('sales/order')->load($orderId);
457
+ if( $order->getId() ){
458
+
459
+ //Guest Checkout
460
+ if( (int)$order->getCustomerGroupId() === Mage_Customer_Model_Group::NOT_LOGGED_IN_ID ){
461
+ Mage::helper('emaildirect')->registerGuestCustomer($order);
462
+ }
463
+
464
+ $subscriber = Mage::getModel('newsletter/subscriber')
465
+ ->subscribe($order->getCustomerEmail());
466
+ }
467
+ }
468
+ }
469
+ }
470
+ public function orderSaveAfter(Varien_Event_Observer $observer)
471
+ {
472
+ $sendit = Mage::helper('emaildirect')->config('sendorder');
473
+
474
+ if ($sendit)
475
+ {
476
+ $order = $observer->getEvent()->getOrder();
477
+ if($order->getState() === Mage_Sales_Model_Order::STATE_COMPLETE)
478
+ {
479
+ $email = $order->getCustomerEmail();
480
+
481
+ if ($order->getData('customer_is_guest'))
482
+ {
483
+ $customer = new Varien_Object;
484
+
485
+ $customer->setData('email',$email);
486
+ $customer->setData('firstname',$order->getData('customer_firstname'));
487
+ $customer->setData('lastname',$order->getData('customer_lastname'));
488
+ $customer->setData('store_id',$order->getStoreId());
489
+
490
+ $customer->setBillingAddress($order->getBillingAddress());
491
+ }
492
+ else
493
+ {
494
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
495
+ $address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
496
+ $customer->setBillingAddress($address);
497
+ }
498
+
499
+ $mergeVars = Mage::helper('emaildirect')->getMergeVars($customer, true);
500
+ $mergeVars = Mage::helper('emaildirect')->getOrderMergeVars($mergeVars,$order);
501
+
502
+ if (Mage::helper('emaildirect')->config('save_latest_order'))
503
+ {
504
+ $this->checkProductFields();
505
+ $this->checkAbandonedFields(true);
506
+
507
+ $mergeVars['LastOrderNumber'] = $order->getIncrementId();
508
+ $mergeVars['LastPurchaseDate'] = $order->getData('created_at');
509
+ $mergeVars['LastPurchaseTotal'] = number_format($order->getData('total_paid'), 2, '.', '');
510
+
511
+ $mergeVars = $this->getMergeOrderItems($order, $mergeVars);
512
+ $mergeVars = $this->getRelatedOrderItems($order, $mergeVars);
513
+ }
514
+
515
+ Mage::helper('emaildirect')->debugLog("MERGE VARS:");
516
+ Mage::helper('emaildirect')->debugLog($mergeVars);
517
+
518
+ Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($email,$order, $mergeVars);
519
+ }
520
+ }
521
+ return $observer;
522
+ }
523
+
524
+ // START ABANDONED CRON
525
+ private function getAbandonedTime()
526
+ {
527
+ $time = Mage::helper('emaildirect')->config('abandonedtime');
528
+ $time *= 60; // Adjust to seconds.
529
+
530
+ $date = date(Mage::getModel('core/date')->gmtTimestamp());
531
+
532
+ $date = $date - $time;
533
+
534
+ return date("Y-m-d H:i:s", $date);
535
+ }
536
+
537
+ private function getLastOrder($quote)
538
+ {
539
+ Mage::helper('emaildirect')->debugLog("Get Last Order");
540
+ $customer_id = $quote->getData('customer_id');
541
+
542
+ Mage::helper('emaildirect')->debugLog("Customer ID: {$customer_id}");
543
+
544
+ $orders = Mage::getResourceModel('sales/order_collection')
545
+ ->addFieldToSelect('*')
546
+ ->addFieldToFilter('customer_id', $customer_id)
547
+ ->addAttributeToSort('created_at', 'DESC')
548
+ ->setPageSize(1);
549
+
550
+ Mage::helper('emaildirect')->debugLog("Order Count: " . $orders->getSize());
551
+ if ($orders->getSize() <= 0)
552
+ return null;
553
+
554
+ Mage::helper('emaildirect')->debugLog("Order Found");
555
+ $order = $orders->getFirstItem();
556
+
557
+ return $order;
558
+ }
559
+
560
+ private function processAbandoned($quote)
561
+ {
562
+ //$customer = $quote->getCustomer();
563
+ $email = $quote->getCustomerEmail();
564
+
565
+ $abandonedDate = $quote->getUpdatedAt();
566
+
567
+ //$mergeVars = Mage::helper('emaildirect')->getMergeVars($customer, true);
568
+ $mergeVars = array();
569
+
570
+ $mergeVars['FirstName'] = $quote->getData('customer_firstname');
571
+ $mergeVars['LastName'] = $quote->getData('customer_lastname');
572
+
573
+ $mergeVars['AbandonedDate'] = $abandonedDate;
574
+ $mergeVars['AbandonedUrl'] = $quote->getEmaildirectAbandonedUrl();
575
+
576
+ $mergeVars = $this->getMergeOrderItems($quote, $mergeVars, "AB");
577
+
578
+ $order = $this->getLastOrder($quote);
579
+
580
+ if ($order != null)
581
+ {
582
+ $mergeVars = Mage::helper('emaildirect')->getOrderMergeVars($mergeVars,$order);
583
+ }
584
+
585
+ Mage::helper('emaildirect')->debugLog("Check Save Lastest");
586
+ if (Mage::helper('emaildirect')->config('save_latest_order'))
587
+ {
588
+ Mage::helper('emaildirect')->debugLog("Get Order");
589
+
590
+ if ($order != null)
591
+ {
592
+ Mage::helper('emaildirect')->debugLog("Order Found");
593
+ $mergeVars['LastOrderNumber'] = $order->getIncrementId();
594
+ $mergeVars['LastPurchaseDate'] = $order->getData('created_at');
595
+ $mergeVars['LastPurchaseTotal'] = number_format($order->getData('total_paid'), 2, '.', '');
596
+
597
+ $mergeVars = $this->getMergeOrderItems($order, $mergeVars);
598
+ $mergeVars = $this->getRelatedOrderItems($order, $mergeVars);
599
+ }
600
+
601
+ Mage::helper('emaildirect')->debugLog("Finish Save Latest");
602
+ }
603
+
604
+ $xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$mergeVars);
605
+
606
+ // Set the abandoned date so we don't process this again.
607
+ $quote->setEmaildirectAbandonedDate($quote->getUpdatedAt());
608
+ $quote->save();
609
+
610
+ return $xml;
611
+ }
612
+
613
+ private function checkAbandonedFields()
614
+ {
615
+ $version = $this->getVersion();
616
+
617
+ $setup_version = Mage::helper('emaildirect')->config('setup_version');
618
+
619
+ if ($setup_version == NULL || (version_compare($setup_version, $version) < 0))
620
+ $this->verifyAbandonedFields();
621
+ }
622
+
623
+ private function checkProductFields()
624
+ {
625
+ if (!Mage::helper('emaildirect')->config('save_latest_order'))
626
+ return;
627
+
628
+ $version = $this->getVersion();
629
+
630
+ $setup_version = Mage::helper('emaildirect')->config('setup_version');
631
+
632
+ if ($setup_version == NULL || (version_compare($setup_version, $version) < 0))
633
+ $this->verifyProductFields();
634
+ }
635
+
636
+ public function abandonedCartsProcessor()
637
+ {
638
+ Mage::helper('emaildirect')->debugLog("Abandoned Carts Processor Start");
639
+
640
+ $sendit = Mage::helper('emaildirect')->config('sendabandoned');
641
+ $setup = Mage::helper('emaildirect')->config('abandonedsetup');
642
+
643
+ if (!$sendit)
644
+ {
645
+ Mage::helper('emaildirect')->debugLog("Skipping... SendIt = False");
646
+ return;
647
+ }
648
+
649
+ if (!$setup)
650
+ {
651
+ Mage::helper('emaildirect')->debugLog("Skipping... Not Setup");
652
+ return;
653
+ }
654
+
655
+ $this->checkProductFields();
656
+ $this->checkAbandonedFields();
657
+
658
+ $check_date = $this->getAbandonedTime();
659
+
660
+ Mage::helper('emaildirect')->debugLog("Check Date: {$check_date}");
661
+
662
+ // Get abandoned collection
663
+ $collection = Mage::getResourceModel('reports/quote_collection');
664
+
665
+ $collection->addFieldToFilter('items_count', array('neq' => '0'))
666
+ ->addFieldToFilter('main_table.is_active', '1')
667
+ ->setOrder('updated_at');
668
+
669
+ $collection->addFieldToFilter('main_table.updated_at', array('lt' => $check_date));
670
+ $collection->addFieldToFilter('main_table.emaildirect_abandoned_date', array('null' => true));
671
+ $collection->addFieldToFilter('main_table.emaildirect_abandoned_url', array('notnull' => true));
672
+ $collection->addFieldToFilter('main_table.customer_email', array('notnull' => true));
673
+
674
+ Mage::helper('emaildirect')->debugLog("SQL: " . $collection->getSelect()->__toString());
675
+
676
+ $subscribers = false;
677
+
678
+ $xml = "<Subscribers>";
679
+
680
+ // Get the data for each abandoned cart
681
+ foreach ($collection as $quote)
682
+ {
683
+ $xml .= $this->processAbandoned($quote);
684
+ $subscribers = true;
685
+ }
686
+
687
+ $xml .= "</Subscribers>";
688
+
689
+ if (!$subscribers)
690
+ {
691
+ Mage::helper('emaildirect')->debugLog("Exiting... No Carts Found");
692
+ return; // No abandoned carts found
693
+ }
694
+
695
+ Mage::helper('emaildirect')->debugLog("Subscriber Xml:");
696
+ Mage::helper('emaildirect')->debugLog($xml);
697
+
698
+ Mage::helper('emaildirect')->debugLog("Sending Abandoned Carts");
699
+ // Send them all at once
700
+ $rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
701
+
702
+ Mage::helper('emaildirect')->debugLog("Results:");
703
+ Mage::helper('emaildirect')->debugLog($rc);
704
+
705
+ Mage::helper('emaildirect')->debugLog("Abandoned Carts Processor End");
706
+ }
707
+ // END ABANDONED CRON
708
+
709
+ // START QUOTE SAVE AFTER
710
+ private function getAbandonedUrl($quote)
711
+ {
712
+ // We are using comma separated lists for the ID's and Quantities so that it takes up less
713
+ // space when we generate the Querystring
714
+
715
+ $ids = "";
716
+ $qtys = "";
717
+
718
+ foreach($quote->getAllItems() as $item)
719
+ {
720
+ if ($ids != "")
721
+ {
722
+ $ids .= ",";
723
+ $qtys .= ",";
724
+ }
725
+
726
+ $product = $item->getProduct();
727
+
728
+ $ids .= $product->getId();
729
+ $qtys .= $item->getQty();
730
+ }
731
+
732
+ $url_data = array("quote" => $quote->getId(), "id" => $ids, "qty" => $qtys);
733
+
734
+ $url = base64_encode(serialize($url_data));
735
+
736
+ $url = Mage::getUrl('emaildirect/abandoned/restore',array('_secure'=>true)) . "?cart={$url}";
737
+
738
+ return $url;
739
+ }
740
+
741
+ public function quoteSaveAfter(Varien_Event_Observer $observer)
742
+ {
743
+ Mage::helper('emaildirect')->debugLog("Quote Save After Start");
744
+ $quote = $observer->getEvent()->getQuote();
745
+
746
+ if (trim($quote->getEmaildirectAbandonedDate()))
747
+ {
748
+ Mage::helper('emaildirect')->debugLog("Skipping... Already sent.");
749
+ return;
750
+ }
751
+
752
+ $url = $this->getAbandonedUrl($quote);
753
+
754
+ Mage::helper('emaildirect')->debugLog("Abandoned Url: {$url}");
755
+
756
+ if ($quote->getEmaildirectAbandonedUrl() == $url)
757
+ {
758
+ Mage::helper('emaildirect')->debugLog("Skipping... Abandoned Url is up to date.");
759
+ return;
760
+ }
761
+
762
+ Mage::helper('emaildirect')->debugLog("Saving Quote.");
763
+ // Re-save quote with new URL
764
+ $quote->setEmaildirectAbandonedUrl($url);
765
+ $quote->save();
766
+ Mage::helper('emaildirect')->debugLog("Quote Save After End");
767
+ }
768
+ // END QUOTE SAVE AFTER
769
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Abandoned.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_System_Config_Source_Abandoned
4
+ {
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value' => 0, 'label' => Mage::helper('emaildirect')->__('Do not send through Magento')),
14
+ array('value' => 1, 'label' => Mage::helper('emaildirect')->__('1 Day')),
15
+ array('value' => 2, 'label' => Mage::helper('emaildirect')->__('2 Days')),
16
+ array('value' => 3, 'label' => Mage::helper('emaildirect')->__('3 Days')),
17
+ array('value' => 4, 'label' => Mage::helper('emaildirect')->__('4 Days')),
18
+ array('value' => 5, 'label' => Mage::helper('emaildirect')->__('5 Days')),
19
+ array('value' => 6, 'label' => Mage::helper('emaildirect')->__('6 Days')),
20
+ array('value' => 7, 'label' => Mage::helper('emaildirect')->__('7 Days')),
21
+ array('value' => 8, 'label' => Mage::helper('emaildirect')->__('8 Days')),
22
+ array('value' => 9, 'label' => Mage::helper('emaildirect')->__('9 Days')),
23
+ array('value' => 10, 'label' => Mage::helper('emaildirect')->__('10 Days')),
24
+ array('value' => 11, 'label' => Mage::helper('emaildirect')->__('11 Days')),
25
+ array('value' => 12, 'label' => Mage::helper('emaildirect')->__('12 Days')),
26
+ array('value' => 13, 'label' => Mage::helper('emaildirect')->__('13 Days')),
27
+ array('value' => 14, 'label' => Mage::helper('emaildirect')->__('14 Days')),
28
+ array('value' => 15, 'label' => Mage::helper('emaildirect')->__('15 Days')),
29
+ );
30
+ }
31
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Abandonedlist.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_System_Config_Source_Abandonedlist
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $options = array();
8
+
9
+ $options[] = array(
10
+ 'value' => -1,
11
+ 'label' => "-- SELECT LIST --");
12
+
13
+ $lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
14
+ foreach($lists as $list)
15
+ {
16
+ if($list['active'])
17
+ $options[] = array(
18
+ 'value' => $list['id'],
19
+ 'label' => $list['name']);
20
+ }
21
+ return $options;
22
+ }
23
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Additionallist.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Nov 25, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_System_Config_Source_Additionallist
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ $options = array();
13
+
14
+ // $ws = Mage::getModel('emaildirect/wrapper_lists');
15
+ // $lists = $ws->getLists();
16
+ $lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
17
+ foreach($lists as $list)
18
+ {
19
+ if($list['active'])
20
+ $options[] = array(
21
+ 'value' => $list['id'],
22
+ 'label' => $list['name']);
23
+ }
24
+ return $options;
25
+ }
26
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Checkoutsubscribe.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_System_Config_Source_Checkoutsubscribe
4
+ {
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value' => 1, 'label' => Mage::helper('emaildirect')->__('Enabled - Checked by default')),
14
+ array('value' => 2, 'label' => Mage::helper('emaildirect')->__('Enabled - Not Checked by default')),
15
+ array('value' => 3, 'label' => Mage::helper('emaildirect')->__('Enabled - Force subscription')),
16
+ array('value' => 0, 'label' => Mage::helper('emaildirect')->__('-- Disabled --'))
17
+ );
18
+ }
19
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Export/Batch.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_System_Config_Source_Export_Batch
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ $options = array(
13
+ array('value' => 1,'label' => "1"),
14
+ array('value' => 5,'label' => "5"),
15
+ array('value' => 10,'label' => "10"),
16
+ array('value' => 25,'label' => "25"),
17
+ array('value' => 50,'label' => "50"),
18
+ array('value' => 100,'label' => "100"),
19
+ array('value' => 250,'label' => "250")
20
+ );
21
+
22
+ return $options;
23
+ }
24
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/List.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Nov 25, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_System_Config_Source_List
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ $options = array();
13
+ $options[] = array (
14
+ 'value' => -1,
15
+ 'label' => '--select--',
16
+ );
17
+
18
+ // $ws = Mage::getModel('emaildirect/wrapper_lists');
19
+ // $lists = $ws->getLists();
20
+ $lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
21
+ foreach($lists as $list)
22
+ {
23
+ if($list['active'])
24
+ $options[] = array(
25
+ 'value' => $list['id'],
26
+ 'label' => $list['name']);
27
+ }
28
+ return $options;
29
+ }
30
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Maxtimes.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_System_Config_Source_Maxtimes
4
+ {
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value' => 1, 'label' => Mage::helper('emaildirect')->__('1 Times')),
14
+ array('value' => 2, 'label' => Mage::helper('emaildirect')->__('2 Times')),
15
+ array('value' => 3, 'label' => Mage::helper('emaildirect')->__('3 Times')),
16
+ array('value' => 4, 'label' => Mage::helper('emaildirect')->__('4 Times')),
17
+ array('value' => 5, 'label' => Mage::helper('emaildirect')->__('5 Times')),
18
+ );
19
+ }
20
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Publication.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_System_Config_Source_Publication
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ $options = array();
13
+
14
+ $publications = Mage::getSingleton('emaildirect/wrapper_publications')->getPublications();
15
+ foreach($publications as $publication)
16
+ {
17
+ if($publication['active'])
18
+ $options[] = array(
19
+ 'value' => $publication['id'],
20
+ 'label' => $publication['name']);
21
+ }
22
+ return $options;
23
+ }
24
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Source.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_System_Config_Source_Source
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ $options = array();
13
+
14
+ $sources = Mage::getSingleton('emaildirect/wrapper_sources')->getSources();
15
+ foreach($sources as $source)
16
+ {
17
+ if($source['active'])
18
+ $options[] = array(
19
+ 'value' => $source['id'],
20
+ 'label' => $source['name']);
21
+ }
22
+ return $options;
23
+ }
24
+ }
app/code/local/EmailDirect/Integration/Model/System/Config/Source/Time.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_System_Config_Source_Time
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ $options = array(
13
+ array('value' => 15,'label' => "15 Minutes"),
14
+ array('value' => 30,'label' => "30 Minutes"),
15
+ array('value' => 45,'label' => "45 Minutes"),
16
+ array('value' => 60,'label' => "60 Minutes"));
17
+
18
+ return $options;
19
+ }
20
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Abandoned.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmailDirect_Integration_Model_Wrapper_Abandoned
3
+ {
4
+ public function sendSubscribers($xml)
5
+ {
6
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("abandoned","","",$xml,false);
7
+ return $rc;
8
+ }
9
+
10
+ public function getOneSubscriber($mail,$mergeVars)
11
+ {
12
+ $sourceid = Mage::helper('emaildirect')->config('sourceid');
13
+ $publicationid = Mage::helper('emaildirect')->config('abandonedpublication');
14
+ $listid = Mage::helper('emaildirect')->config('abandonedlist');
15
+
16
+ $data = "<CustomFields>";
17
+ foreach($mergeVars as $key => $value)
18
+ {
19
+ $data .= "<CustomField><FieldName>{$key}</FieldName><Value><![CDATA[{$value}]]></Value></CustomField>";
20
+ }
21
+ $data .= "</CustomFields>";
22
+
23
+ $list_data = "";
24
+
25
+ if ($listid != -1)
26
+ $list_data = "<Lists><int>$listid</int></Lists>";
27
+
28
+ $xml = "<Subscriber><EmailAddress>{$mail}</EmailAddress>{$data}<SourceID>{$sourceid}</SourceID>";
29
+ $xml .= "<Publications><int>{$publicationid}</int></Publications>{$list_data}<Force>true</Force></Subscriber>";
30
+
31
+ //Mage::log($xml,null,"1_quote.log");
32
+
33
+ return $xml;
34
+ }
35
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Database.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_Wrapper_Database
4
+ {
5
+ public function add($name,$type,$size=0)
6
+ {
7
+ $xml = "<DatabaseColumnAdd>";
8
+ $xml .= "<ColumnName><![CDATA[$name]]></ColumnName>";
9
+ $xml .= "<ColumnType><![CDATA[$type]]></ColumnType>";
10
+ if($size) {
11
+ $xml .= "<ColumnSize><![CDATA[$size]]></ColumnSize>";
12
+ }
13
+ $xml .= "</DatabaseColumnAdd>";
14
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("database","","",$xml,false);
15
+
16
+ return $rc;
17
+ }
18
+
19
+ public function get($name)
20
+ {
21
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("database",$name,"",null,false);
22
+
23
+ return $rc;
24
+ }
25
+
26
+ public function getAllColumns()
27
+ {
28
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("database","","",null,false);
29
+
30
+ return $rc;
31
+ }
32
+
33
+ public function exists($name)
34
+ {
35
+ $column = $this->get($name);
36
+
37
+ if (isset($column->ErrorCode) && $column->ErrorCode == 234)
38
+ return false;
39
+
40
+ return true;
41
+ }
42
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Execute.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Oct 31, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Wrapper_Execute
9
+ {
10
+ private $apiKey = null;
11
+
12
+
13
+ public function sendCommand($command,$subcommand = null, $id= null,$xmldata=null,$put = false)
14
+ {
15
+ if(!$this->apiKey) {
16
+ $this->_getApiKey();
17
+ }
18
+ //Mage::log("Send data: ".$xmldata);
19
+ $URL = Mage::getStoreConfig('emaildirect/general/urls/accesspoint');
20
+ $urlsuffix = Mage::getStoreConfig('emaildirect/general/urls/'.$command);
21
+ $URL .= $urlsuffix;
22
+ if($id) {
23
+ $URL .= "/$id";
24
+ }
25
+ if($subcommand) {
26
+ $URL .= "/$subcommand";
27
+ }
28
+ $header = array('Content-Type: text/xml','ApiKey: '.$this->apiKey,'Accept: application/xml');
29
+ $ch = curl_init($URL);
30
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
31
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
32
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
33
+ curl_setopt($ch, CURLOPT_HEADER, true);
34
+ curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
35
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
36
+ if($put) {
37
+ $putString = stripslashes($xmldata);
38
+ $putData = tmpfile();
39
+ fwrite($putData, $putString);
40
+ fseek($putData, 0);
41
+ curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
42
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
43
+ curl_setopt($ch, CURLOPT_PUT, true);
44
+ curl_setopt($ch, CURLOPT_INFILE, $putData);
45
+ curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString));
46
+ }
47
+ else {
48
+ curl_setopt($ch, CURLOPT_POST, 0);
49
+ if($xmldata) {
50
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);
51
+ }
52
+ }
53
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
54
+ $output = curl_exec($ch);
55
+ //Mage::log("Received data: ".$output);
56
+ curl_close($ch);
57
+ $start = strpos($output,'<?xml',true);
58
+ if(!$start) {
59
+ $start = strpos($output,'<Response>',true);
60
+ }
61
+ $strxml = substr($output,$start);
62
+ try {
63
+ $xml = simplexml_load_string($strxml);
64
+ }
65
+ catch(Exception $e) {
66
+ Mage::throwException($e->getMessage());
67
+ }
68
+ return $xml;
69
+ }
70
+ private function _getApiKey()
71
+ {
72
+ $path = 'emaildirect/general/apikey';
73
+ $this->apiKey = Mage::getStoreConfig($path);
74
+ }
75
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Ftp.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_Wrapper_Ftp
4
+ {
5
+ public function upload($url,$name, $folder = "importFiles")
6
+ {
7
+ $xml = "<FileUpload>";
8
+ $xml .= "<URL>{$url}</URL>";
9
+ $xml .= "<FileName>{$name}</FileName>";
10
+ $xml .= "<FolderPath>{$folder}</FolderPath>";
11
+ $xml .= "</FileUpload>";
12
+
13
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("ftp","","",$xml,false);
14
+
15
+ return $rc;
16
+ }
17
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Lists.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Nov 14, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Wrapper_Lists
9
+ {
10
+ public function __construct($args)
11
+ {
12
+ $storeId = isset($args['store']) ? $args['store'] : null;
13
+ $apikey = (!isset($args['apikey']) ? Mage::helper('emaildirect')->getApiKey($storeId) : $args['apikey']);
14
+
15
+ }
16
+
17
+ public function getLists()
18
+ {
19
+ $lists = array();
20
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('lists');
21
+ foreach($rc->List as $list)
22
+ {
23
+ $newlist = array('id' => (int)$list->ListID,
24
+ 'name' => (string)$list->Name,
25
+ 'members' => (int)$list->ActiveMembers,
26
+ 'active' => (boolean)$list->IsActive
27
+ );
28
+ $lists[] = $newlist;
29
+ }
30
+ return $lists;
31
+ }
32
+
33
+ public function listUnsubscribe($listId, $email)
34
+ {
35
+ $xml = "<Subscribers><EmailAddress>$email</EmailAddress></Subscribers>";
36
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('lists','RemoveEmails',$listId,$xml);
37
+ if(isset($rc->ErrorCode))
38
+ {
39
+ Mage::getSingleton('customer/session')->addError((string)$rc->Message);
40
+ Mage::throwException((string)$rc->Message);
41
+ }
42
+ elseif((int)$rc->ContactsSubmitted != (int)$rc->Successes) {
43
+ Mage::getSingleton('customer/session')->addError((string)$rc->Failures->Failure->Message);
44
+ Mage::throwException((string)$rc->Failures->Failure->Message);
45
+ }
46
+ }
47
+
48
+ public function listSubscribe($listId, $email)
49
+ {
50
+ // ask if the customer is a subscriber
51
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('subscribers',null,$email,null);
52
+ // if already a subscriber
53
+ if(isset($rc->EmailID)) {
54
+ // Mage::log("only subscribe");
55
+ $xml = "<Subscribers><EmailAddress>$email</EmailAddress></Subscribers>";
56
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('lists','AddEmails',$listId,$xml);
57
+ }
58
+ else {
59
+ // Mage::log("add subscriber and subscribe to list");
60
+
61
+ }
62
+ }
63
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Orders.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_Wrapper_Orders
4
+ {
5
+
6
+ public function getOrderXml($order, $email = null)
7
+ {
8
+ $prefix = Mage::helper('emaildirect')->config('prefix');
9
+
10
+ $date = $order->getCreatedAt();
11
+ $orderNum = $prefix.$order->getIncrementId();
12
+
13
+ $items = $order->getAllItems();
14
+
15
+ $xml = "<Order>";
16
+ if ($email != null)
17
+ $xml .= "<EmailAddress><![CDATA[{$email}]]></EmailAddress>";
18
+ $xml .= "<PurchaseDate>{$date}</PurchaseDate>";
19
+ $xml .= "<OrderNumber>{$orderNum}</OrderNumber>";
20
+ if(is_array($items))
21
+ {
22
+ $xml .= "<Items>";
23
+ foreach($items as $item)
24
+ {
25
+ if ($item->getParentItemId() != null)
26
+ continue;
27
+
28
+ $qty = (int)$item->getQtyOrdered();
29
+ $xml .= "<OrderItem>";
30
+ $name = $item->getName();
31
+ $xml .= "<ProductName><![CDATA[$name]]></ProductName>";
32
+ $sku = $item->getSku();
33
+ $xml .= "<SKU><![CDATA[{$sku}]]></SKU>";
34
+
35
+ $xml .= "<Quantity>{$qty}</Quantity>";
36
+ $price = $item->getPrice();
37
+ $xml .= "<UnitPrice>{$price}</UnitPrice>";
38
+ $weight = $item->getWeight();
39
+ $xml .= "<Weight>{$weight}</Weight>";
40
+ $status = 'Completed';
41
+ $xml .= "<Status>{$status}</Status>";
42
+ $xml .= "</OrderItem>";
43
+
44
+ }
45
+ $xml .= "</Items>";
46
+ }
47
+ $xml .= "</Order>";
48
+
49
+ return $xml;
50
+ }
51
+
52
+ public function addSubscriberOrder($mail,$order, $mergeVars,$uselist = TRUE)
53
+ {
54
+ $store = Mage::app()->getStore();
55
+ $sourceid = Mage::helper('emaildirect')->config('sourceid',$store->getId());
56
+ $publicationid = Mage::helper('emaildirect')->config('publication',$store->getId());
57
+
58
+ if($uselist)
59
+ $listid = Mage::helper('emaildirect')->config('list',$store->getId());
60
+ else
61
+ $listid = -1;
62
+
63
+ $data = "<CustomFields>";
64
+ foreach($mergeVars as $key => $value)
65
+ {
66
+ $data .= "<CustomField><FieldName>{$key}</FieldName><Value><![CDATA[{$value}]]></Value></CustomField>";
67
+ }
68
+ $data .= "</CustomFields>";
69
+
70
+ $list_data = "";
71
+
72
+ if ($listid != -1)
73
+ $list_data = "<Lists><int>{$listid}</int></Lists>";
74
+
75
+ $order_data = "<Orders>" . $this->getOrderXml($order) . "</Orders>";
76
+
77
+ $xml = "<Subscriber><EmailAddress>{$mail}</EmailAddress>{$data}<SourceID>{$sourceid}</SourceID>{$order_data}<Publications><int>{$publicationid}</int></Publications>{$list_data}<Force>true</Force></Subscriber>";
78
+
79
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","","",$xml,false);
80
+
81
+ return $rc;
82
+ }
83
+
84
+ public function addOrder($order)
85
+ {
86
+ $xml = $this->getOrderXml($order, $order->getCustomerEmail());
87
+
88
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("orders","","",$xml,false);
89
+ return $rc;
90
+ }
91
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Publications.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Wrapper_Publications
9
+ {
10
+ public function getPublications()
11
+ {
12
+ $publications = array();
13
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('publications');
14
+ foreach($rc->Publication as $publication)
15
+ {
16
+ $newpublication = array('id' => (int)$publication->PublicationID,
17
+ 'name' => (string)$publication->Name,
18
+ 'members' => (int)$publication->ActiveMembers,
19
+ 'active' => (boolean)$publication->IsActive
20
+ );
21
+ $publications[] = $newpublication;
22
+ }
23
+ return $publications;
24
+ }
25
+ public function subscribe($id, $email)
26
+ {
27
+ $xml = "<Subscribers><EmailAddress>$email</EmailAddress></Subscribers>";
28
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('publications','AddEmails',$id,$xml);
29
+ return $rc;
30
+ }
31
+ public function unsubscribe($id,$email)
32
+ {
33
+ $xml = "<Subscribers><EmailAddress>$email</EmailAddress></Subscribers>";
34
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('publications','RemoveEmails',$id,$xml);
35
+ return $rc;
36
+ }
37
+ public function getPublication($id) {
38
+ $xml = "";
39
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('publications','',$id,$xml);
40
+ return $rc;
41
+ }
42
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Relays.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 22, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Wrapper_Relays
9
+ {
10
+ public function addCategory($name)
11
+ {
12
+ $categoryId = $this->getCategory($name);
13
+ if($categoryId) {
14
+ return $categoryId;
15
+ }
16
+ $xml = "<string>$name</string>";
17
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("relays","","",$xml,false);
18
+ if(isset($rc->RelaySendCategory->RelaySendCategoryID)) {
19
+ return $rc->RelaySendCategory->RelaySendCategoryID;
20
+ }
21
+ else {
22
+ return 0;
23
+ }
24
+ }
25
+ public function getCategory($name)
26
+ {
27
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("relays","","",null);
28
+ foreach($rc->Category as $category) {
29
+ if($category->Name == $name) {
30
+ return $category->RelaySendCategoryID;
31
+ }
32
+ }
33
+ return false;
34
+ }
35
+
36
+ public function sendMail($senderName,$senderEmail,$toEmail,$toName,$subject,$text)
37
+ {
38
+ $relayId = Mage::Helper('emaildirect')->config('relayid');
39
+ // $text = htmlentities($text);
40
+
41
+ if(is_array($toEmail)) {
42
+ $auxemail = implode(",",$toEmail);
43
+ }
44
+ else {
45
+ $auxemail = $toEmail;
46
+ }
47
+ if(is_array($toName)) {
48
+ $auxname = implode(",",$toName);
49
+ }
50
+ else {
51
+ $auxname = $toName;
52
+ }
53
+
54
+ // $xml = "<RelaySend><ToEmail>$toEmail</ToEmail><ToName>$toName</ToName><FromName>$senderName</FromName><FromEmail>$senderEmail</FromEmail><Subject>$subject</Subject><HTML>$text</HTML><Text>$text</Text></RelaySend>";
55
+ //// $xml = "<RelaySend><ToEmail><![CDATA[$auxemail]]></ToEmail><ToName><![CDATA[$auxname]]></ToName><FromName><![CDATA[$senderName]]></FromName><FromEmail><![CDATA[$senderEmail]]></FromEmail><Subject><![CDATA[$subject]]></Subject><HTML><![CDATA[$text]]></HTML></RelaySend>";
56
+ //// if(Mage::registry('track')==1) {
57
+ $replace = '<br><img src="[Link_Impression]" width="5" height="5" \></body>';
58
+ $textmail = preg_replace("/\<\/body\>/",$replace,$text);
59
+ $xml = "<RelaySend><ToEmail><![CDATA[$auxemail]]></ToEmail><TrackLinks>true</TrackLinks><Force>true</Force><ToName><![CDATA[$auxname]]></ToName><FromName><![CDATA[$senderName]]></FromName><FromEmail><![CDATA[$senderEmail]]></FromEmail><Subject><![CDATA[$subject]]></Subject><HTML><![CDATA[$textmail]]></HTML></RelaySend>";
60
+ //// }
61
+ //// else {
62
+ //// $xml = "<RelaySend><ToEmail><![CDATA[$auxemail]]></ToEmail><ToName><![CDATA[$auxname]]></ToName><FromName><![CDATA[$senderName]]></FromName><FromEmail><![CDATA[$senderEmail]]></FromEmail><Subject><![CDATA[$subject]]></Subject><HTML><![CDATA[$text]]></HTML></RelaySend>";
63
+ //// }
64
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("relays","",$relayId,$xml);
65
+ }
66
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Sources.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Wrapper_Sources
9
+ {
10
+ public function getSources()
11
+ {
12
+ $sources = array();
13
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('sources');
14
+ foreach($rc->Source as $source)
15
+ {
16
+ $newsource = array('id' => (int)$source->SourceID,
17
+ 'name' => (string)$source->Name,
18
+ 'members' => (int)$source->ActiveMembers,
19
+ 'active' => (boolean)$source->IsActive
20
+ );
21
+ $sources[] = $newsource;
22
+ }
23
+ return $sources;
24
+ }
25
+ public function addSource($name)
26
+ {
27
+ $xml = "<Source><Name>$name</Name><Description>$name</Description></Source>";
28
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('sources',"",null,$xml,false);
29
+ return $rc;
30
+ }
31
+ }
app/code/local/EmailDirect/Integration/Model/Wrapper/Suscribers.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Nov 29, 2011
4
+ *
5
+ * To change the template for this generated file go to
6
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
7
+ */
8
+ class EmailDirect_Integration_Model_Wrapper_Suscribers
9
+ {
10
+ public function suscriberModify($mail,$mergeVars)
11
+ {
12
+ $sourceid = Mage::helper('emaildirect')->config('sourceid'); //Mage::getStoreConfig('emaildirect/general/sourceid');
13
+ $publicationid = Mage::helper('emaildirect')->config('publication'); //Mage::getStoreConfig('emaildirect/general/publication');
14
+ $listid = Mage::helper('emaildirect')->config('list');
15
+ $data = "<CustomFields>";
16
+ foreach($mergeVars as $key => $value)
17
+ {
18
+ $data .= "<CustomField><FieldName>$key</FieldName><Value><![CDATA[$value]]></Value></CustomField>";
19
+ }
20
+ $data .= "</CustomFields>";
21
+ if($listid != -1) {
22
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<SourceID>$sourceid</SourceID><Publications><int>$publicationid</int></Publications><Lists><int>$listid</int></Lists></Subscriber>";
23
+ }
24
+ else {
25
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<SourceID>$sourceid</SourceID><Publications><int>$publicationid</int></Publications></Subscriber>";
26
+ }
27
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","",$mail,$xml,true);
28
+ if(isset($rc->ErrorCode)) {
29
+ return FALSE;
30
+ }
31
+ return TRUE;
32
+ }
33
+ public function suscriberAdd($mail,$mergeVars,$uselist = TRUE)
34
+ {
35
+ $store = Mage::app()->getStore();
36
+ $sourceid = Mage::helper('emaildirect')->config('sourceid',$store->getId());
37
+ $publicationid = Mage::helper('emaildirect')->config('publication',$store->getId());
38
+ if($uselist) {
39
+ $listid = Mage::helper('emaildirect')->config('list',$store->getId());
40
+ }
41
+ else {
42
+ $listid = -1;
43
+ }
44
+ $data = "<CustomFields>";
45
+ foreach($mergeVars as $key => $value)
46
+ {
47
+ $data .= "<CustomField><FieldName>$key</FieldName><Value><![CDATA[$value]]></Value></CustomField>";
48
+ }
49
+ $data .= "</CustomFields>";
50
+ if($listid != -1) {
51
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<SourceID>$sourceid</SourceID><Publications><int>$publicationid</int></Publications><Lists><int>$listid</int></Lists><Force>true</Force></Subscriber>";
52
+ }
53
+ else {
54
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<SourceID>$sourceid</SourceID><Publications><int>$publicationid</int></Publications><Force>true</Force></Subscriber>";
55
+ }
56
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","","",$xml,false);
57
+ }
58
+
59
+ public function modifyAddress($mail,$address)
60
+ {
61
+ // Mage::log($address);
62
+ $streets = $address->getStreet();
63
+ $street = $streets[0];
64
+ if(isset($streets[1])) {
65
+ $street .= " ".$streets[1];
66
+ }
67
+ $zip = $address->getPostcode();
68
+ $city = $address->getCity();
69
+ $state = $address->getRegion();
70
+ $phone = $address->getTelephone();
71
+ $data = "<CustomFields>";
72
+ $data .= "<CustomField><FieldName>Address</FieldName><Value><![CDATA[$street]]></Value></CustomField>";
73
+ $data .= "<CustomField><FieldName>Zip</FieldName><Value><![CDATA[$zip]]></Value></CustomField>";
74
+ $data .= "<CustomField><FieldName>City</FieldName><Value><![CDATA[$city]]></Value></CustomField>";
75
+ $data .= "<CustomField><FieldName>State</FieldName><Value><![CDATA[$state]]></Value></CustomField>";
76
+ $data .= "<CustomField><FieldName>Phone</FieldName><Value><![CDATA[$phone]]></Value></CustomField>";
77
+ $data .= "</CustomFields>";
78
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<Force>true</Force></Subscriber>";
79
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","","",$xml,false);
80
+ }
81
+
82
+ // Not used
83
+ public function abandonedAdd($mail,$mergeVars)
84
+ {
85
+ $sourceid = Mage::helper('emaildirect')->config('sourceid');
86
+ $publicationid = Mage::helper('emaildirect')->config('abandonedpublication');
87
+ $listid = Mage::helper('emaildirect')->config('abandonedlist');
88
+ $data = "<CustomFields>";
89
+ foreach($mergeVars as $key => $value)
90
+ {
91
+ $data .= "<CustomField><FieldName>$key</FieldName><Value><![CDATA[$value]]></Value></CustomField>";
92
+ }
93
+ $data .= "</CustomFields>";
94
+ if($listid != -1) {
95
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<SourceID>$sourceid</SourceID><Publications><int>$publicationid</int></Publications><Lists><int>$listid</int></Lists><Force>true</Force></Subscriber>";
96
+ }
97
+ else {
98
+ $xml = "<Subscriber><EmailAddress>$mail</EmailAddress>$data<SourceID>$sourceid</SourceID><Publications><int>$publicationid</int></Publications><Force>true</Force></Subscriber>";
99
+ }
100
+
101
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","","",$xml,false);
102
+ }
103
+
104
+
105
+ private function fixBouncedMail($oldmail,$newmail)
106
+ {
107
+ $xml = "<Subscriber><EmailAddress>$oldmail</EmailAddress><Force>true</Force></Subscriber>";
108
+
109
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","","",$xml, false);
110
+
111
+ if(isset($rc->ErrorCode))
112
+ {
113
+ Mage::getSingleton('customer/session')->addError((string)$rc->Message);
114
+ Mage::throwException((string)$rc->Message);
115
+ }
116
+
117
+ $xml = "<Subscriber><EmailAddress>$newmail</EmailAddress></Subscriber>";
118
+
119
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","ChangeEmail",$oldmail,$xml);
120
+
121
+ if(isset($rc->ErrorCode))
122
+ {
123
+ Mage::getSingleton('customer/session')->addError((string)$rc->Message);
124
+ Mage::throwException((string)$rc->Message);
125
+ }
126
+ }
127
+
128
+ public function mailModify($oldmail,$newmail)
129
+ {
130
+ $xml = "<Subscriber><EmailAddress>$newmail</EmailAddress></Subscriber>";
131
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","ChangeEmail",$oldmail,$xml);
132
+ if(isset($rc->ErrorCode))
133
+ {
134
+ if ($rc->ErrorCode == 202)
135
+ {
136
+ $this->fixBouncedMail($oldmail, $newmail);
137
+ }
138
+ else
139
+ {
140
+ Mage::getSingleton('customer/session')->addError((string)$rc->Message);
141
+ Mage::throwException((string)$rc->Message);
142
+ }
143
+ }
144
+ }
145
+ public function listsForEmail($email)
146
+ {
147
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","Properties",$email);
148
+ // Mage::log($rc);
149
+ // foreach($rc->Lists->List as $list)
150
+ // {
151
+ //
152
+ // }
153
+ return array();
154
+ }
155
+ public function suscriberHistory($mail)
156
+ {
157
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","History",$mail);
158
+ return $rc;
159
+ }
160
+ public function getProperties($mail)
161
+ {
162
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","Properties",$mail);
163
+ return $rc;
164
+ }
165
+ }
app/code/local/EmailDirect/Integration/controllers/AbandonedController.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmailDirect_Integration_AbandonedController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function testAction()
5
+ {
6
+ $order = Mage::getModel('sales/order')->load(56);
7
+
8
+ Zend_debug::dump($order->getData());
9
+
10
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
11
+ ->setOrderFilter($order)
12
+ ->load();
13
+ foreach($shipmentCollection as $_shipment)
14
+ {
15
+ Zend_debug::dump($_shipment->getData());
16
+ foreach($_shipment->getAllTracks() as $tracknum)
17
+ {
18
+ Zend_debug::dump($tracknum->getData());
19
+ }
20
+ }
21
+
22
+ //$method = $order->getPayment()->getMethodInstance();
23
+
24
+ //Zend_debug::dump($order->getPayment()->getData());
25
+ //Zend_debug::dump($order->getPayment()->getAdditionalInformation());
26
+ //Zend_debug::dump($order->getPayment()->getMethodInstance()->getPaymentInfo());
27
+
28
+
29
+ }
30
+
31
+ public function restoreAction()
32
+ {
33
+ $coded_cart = Mage::app()->getRequest()->getParam('cart');
34
+
35
+ $cart_data = unserialize(base64_decode($coded_cart));
36
+
37
+ $this->clearCart($cart_data['quote']);
38
+ $this->restoreCartItems($cart_data);
39
+
40
+ $this->_redirect("checkout/cart");
41
+ }
42
+
43
+ private function restoreCartItems($cart_data)
44
+ {
45
+ $id_list = explode(",",$cart_data['id']);
46
+ $qty_list = explode(",",$cart_data['qty']);
47
+
48
+ $quote = $this->getQuote();
49
+
50
+ foreach ($id_list as $key => $item_id)
51
+ {
52
+ $qty = $qty_list[$key];
53
+
54
+ $this->addItemToCart($item_id, $qty);
55
+ }
56
+
57
+ // update our totals, save.
58
+ $quote->getBillingAddress();
59
+ $quote->collectTotals();
60
+ $quote->save();
61
+
62
+ $this->getCheckout()->setQuoteId($quote->getId());
63
+ }
64
+
65
+ private function addItemToCart($id, $qty)
66
+ {
67
+ $product = Mage::getModel('catalog/product')->load($id);
68
+
69
+ if (!$product->getId())
70
+ {
71
+ //echo "Failed to load product";
72
+ return false;
73
+ }
74
+
75
+ $data = array(
76
+ 'qty' => $qty,
77
+ 'options' => array()
78
+ );
79
+
80
+ $quote = $this->getQuote();
81
+
82
+ try
83
+ {
84
+ // add the product to our quote
85
+ $quote->addProductAdvanced($product , new Varien_Object($data));
86
+
87
+ return true;
88
+ }
89
+ catch (Exception $e)
90
+ {
91
+ //Zend_Debug::dump($e->getMessage());
92
+ Mage::logException($e);
93
+ return false;
94
+ }
95
+ }
96
+
97
+ private function removeOldQuote($original_quote_id)
98
+ {
99
+ $quote = Mage::getModel('sales/quote')->load($original_quote_id);
100
+
101
+ if ($quote->getId() == $original_quote_id)
102
+ {
103
+ $quote->delete();
104
+ }
105
+ }
106
+
107
+ private function clearCart($original_quote_id)
108
+ {
109
+ $customer_session = Mage::getSingleton('customer/session');
110
+
111
+ $checkout = $this->getCheckout();
112
+
113
+ $checkout->clear(); // clear donations
114
+
115
+ $quote = $this->getQuote();
116
+
117
+ // Check to see if we need to remove the quote
118
+ // if they aren't logged in then we will need to otherwise when they login the items won't match
119
+ if ($quote->getId() != $original_quote_id)
120
+ {
121
+ $this->removeOldQuote($original_quote_id);
122
+ }
123
+
124
+ foreach ($quote->getItemsCollection() as $item)
125
+ {
126
+ $item->isDeleted(true);
127
+ }
128
+
129
+ $quote->getBillingAddress();
130
+ $quote->getShippingAddress();
131
+ $quote->getPayment();
132
+ $quote->setEmailDirectAbandonedDate(null);
133
+
134
+ $customer = $customer_session->getCustomer();
135
+ if ($customer)
136
+ $quote->assignCustomer($customer);
137
+
138
+ $quote->save();
139
+ }
140
+
141
+ private function getQuote()
142
+ {
143
+ return Mage::getSingleton('checkout/session')->getQuote();
144
+ }
145
+
146
+ private function getCheckout()
147
+ {
148
+ return Mage::getSingleton('checkout/session');
149
+ }
150
+ }
app/code/local/EmailDirect/Integration/controllers/Admin/ExportController.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Emaildirect_Integration_Admin_ExportController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected $_min_category_level = 2;
6
+
7
+
8
+ private function setConfigValue($name)
9
+ {
10
+ $old_value = Mage::helper('emaildirect')->exportConfig($name);
11
+
12
+ $new_value = $this->getRequest()->getParam($name);
13
+
14
+ if ($new_value != '' && $new_value != $old_value)
15
+ {
16
+ Mage::getConfig()->saveConfig("emaildirect/export/{$name}", $new_value,"default","default");
17
+ return true;
18
+ }
19
+
20
+ return false;
21
+ }
22
+
23
+ private function setConfiguration()
24
+ {
25
+ $config_options = array('send_to_emaildirect','include_disabled');
26
+
27
+ $changed = false;
28
+
29
+ foreach ($config_options as $option)
30
+ {
31
+ if ($this->setConfigValue($option))
32
+ $changed = true;
33
+ }
34
+
35
+ if ($changed)
36
+ {
37
+ Mage::getConfig()->cleanCache();
38
+ Mage::getConfig()->reinit();
39
+ Mage::app()->reinitStores();
40
+ }
41
+ }
42
+
43
+ public function runAction()
44
+ {
45
+ // Update export configuration options if changed before button click
46
+ $this->setConfiguration();
47
+
48
+ $this->loadLayout();
49
+ $this->renderLayout();
50
+ }
51
+
52
+ private function getCategoryPath($category)
53
+ {
54
+ $name = "";
55
+
56
+ while ($category->parent_id != 0 && $category->level >= $this->_min_category_level)
57
+ {
58
+ if ($name != "")
59
+ $name = $category->getName() . "/{$name}";
60
+ else
61
+ $name = $category->getName();
62
+
63
+ $category = $category->getParentCategory();
64
+ }
65
+
66
+ return $name;
67
+ }
68
+
69
+ private function getProductData($id)
70
+ {
71
+ $product = Mage::getModel('catalog/product')->load($id);
72
+
73
+ $product_data = array($product->getName(), $product->getSku());
74
+
75
+ $product_categories = $product->getCategoryCollection()->exportToArray();
76
+
77
+ $category_data = array();
78
+
79
+ foreach($product_categories as $cat)
80
+ {
81
+ $category = Mage::getModel('catalog/category')->load($cat['entity_id']);
82
+
83
+ $category_data[] = $this->getCategoryPath($category);
84
+ }
85
+
86
+ if (count($category_data) > 0)
87
+ $product_data[] = implode(",",$category_data);
88
+ else
89
+ $product_data[] = "";
90
+
91
+ return $product_data;
92
+ }
93
+
94
+ private function saveRow($fields,$name)
95
+ {
96
+ $file = Mage::helper('emaildirect')->getExportFileName($name);
97
+
98
+ if (file_exists($file))
99
+ {
100
+ $fp = fopen($file, 'a');
101
+ }
102
+ else
103
+ {
104
+ $header_fields = array('Product Name','SKU','Root Category');
105
+
106
+ $fp = fopen($file, 'w');
107
+ fputcsv($fp, $header_fields, ',','"');
108
+ }
109
+
110
+ fputcsv($fp, $fields, ',','"');
111
+
112
+ fclose($fp);
113
+ }
114
+
115
+ private function getMinCategoryLevel()
116
+ {
117
+ $roots = Mage::getModel('catalog/category')->load(1)->getChildren();
118
+
119
+ if (strpos($roots,',') === FALSE)
120
+ return 2;
121
+ return 1;
122
+ }
123
+
124
+ public function batchRunAction()
125
+ {
126
+ $this->_min_category_level = $this->getMinCategoryLevel();
127
+
128
+ if ($this->getRequest()->isPost())
129
+ {
130
+ $product_id = $this->getRequest()->getPost('id', 0);
131
+ $file_name = $this->getRequest()->getPost('filename', 0);
132
+
133
+ //Mage::log($product_id,null,'1_export.log');
134
+
135
+ if (is_array($product_id))
136
+ {
137
+ foreach ($product_id as $id)
138
+ {
139
+ $csv_data = $this->getProductData($id);
140
+
141
+ $this->saveRow($csv_data,"emaildirect_products_{$file_name}");
142
+ }
143
+
144
+ $result = array(
145
+ 'savedRows' => count($product_id),
146
+ 'errors' => array()
147
+ );
148
+ }
149
+ else
150
+ {
151
+ $csv_data = $this->getProductData($product_id);
152
+
153
+ $this->saveRow($csv_data,"emaildirect_products_{$file_name}");
154
+
155
+
156
+ $result = array(
157
+ 'savedRows' => 1,
158
+ 'errors' => array()
159
+ );
160
+ }
161
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
162
+ }
163
+ }
164
+
165
+ public function downloadAction()
166
+ {
167
+ $file_name = "emaildirect_products_" . $this->getRequest()->getParam('filename');
168
+ $file = Mage::helper('emaildirect')->getExportFileName($file_name);
169
+
170
+ $this->_prepareDownloadResponse(Mage::helper('emaildirect')->getExportFileName($file_name,false), file_get_contents($file));
171
+ }
172
+
173
+ public function batchFinishAction()
174
+ {
175
+ if ($this->getRequest()->isPost())
176
+ {
177
+ $file_name = $this->getRequest()->getPost('filename', 0);
178
+
179
+ $url = $this->getUrl('*/*/download') . "filename/{$file_name}";
180
+
181
+ $result = array(
182
+ 'download_link' => $url,
183
+ );
184
+
185
+ if (Mage::helper('emaildirect')->exportConfig('send_to_emaildirect') == true)
186
+ {
187
+ $ed_url = $this->getUrl('emaildirect/export/download') . "filename/{$file_name}";
188
+ $api = Mage::getSingleton('emaildirect/wrapper_ftp');
189
+ $rc = $api->upload($ed_url,"magento_products_{$file_name}.csv");
190
+
191
+ //Mage::log($rc,null,'1_export.log');
192
+
193
+ if (isset($rc->ErrorCode))
194
+ {
195
+ $result['error'] = "EmailDirect Error: (" . (string) $rc->ErrorCode . "): " . (string)$rc->Message;
196
+ }
197
+ }
198
+
199
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
200
+ }
201
+
202
+ }
203
+ /*
204
+ protected function _isAllowed()
205
+ {
206
+ return Mage::getSingleton('admin/session')->isAllowed('admin/system/convert/profiles');
207
+ }*/
208
+ }
app/code/local/EmailDirect/Integration/controllers/Customer/AccountController.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ /**
6
+ * Action predispatch
7
+ *
8
+ * Check customer authentication for some actions
9
+ */
10
+ public function preDispatch()
11
+ {
12
+ parent::preDispatch();
13
+
14
+ if (!$this->getRequest()->isDispatched()) {
15
+ return;
16
+ }
17
+
18
+ if (!$this->_getCustomerSession()->authenticate($this)) {
19
+ $this->setFlag('', 'no-dispatch', true);
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Retrieve customer session model object
25
+ *
26
+ * @return Mage_Customer_Model_Session
27
+ */
28
+ protected function _getCustomerSession()
29
+ {
30
+ return Mage::getSingleton('customer/session');
31
+ }
32
+
33
+ /**
34
+ * Display data
35
+ */
36
+ public function indexAction()
37
+ {
38
+ $this->loadLayout();
39
+ $this->_initLayoutMessages('customer/session');
40
+
41
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Newsletter Subscription'));
42
+ $this->renderLayout();
43
+ }
44
+
45
+ public function saveadditionalAction()
46
+ {
47
+ // Mage::log(__METHOD__);
48
+ $customerSession = Mage::getSingleton('customer/session');
49
+
50
+ if($this->getRequest()->isPost()){
51
+
52
+ //<state> param is an html serialized field containing the default form state
53
+ //before submission, we need to parse it as a request in order to save it to $odata and process it
54
+ parse_str($this->getRequest()->getPost('state'), $odata);
55
+
56
+ $curlists = (TRUE === array_key_exists('list', $odata)) ? $odata['list'] : array();
57
+ $lists = $this->getRequest()->getPost('list', array());
58
+ $customer = Mage::helper('customer')->getCustomer();
59
+ $email = $customer->getEmail();
60
+
61
+ // Manage the main publication and subscription
62
+ $publication = (TRUE === array_key_exists('publication', $odata)) ? $odata['publication'] : array();
63
+ $pub_selection = $this->getRequest()->getPost('publication', array());
64
+ $general = Mage::helper('emaildirect')->config('publication');
65
+
66
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
67
+ $subscriber->setImportMode(false);
68
+ $rc = Mage::getSingleton('emaildirect/wrapper_publications')->getPublication($general);
69
+ $subscriber->setListName((string)$rc->Name);
70
+
71
+
72
+
73
+ if(!$pub_selection) {
74
+ Mage::getSingleton('emaildirect/wrapper_publications')->unsubscribe($general,$email);
75
+ $subscriber->unsubscribe();
76
+ // unsuscribe for all the lists
77
+ foreach($curlists as $listId => $list){
78
+ Mage::getSingleton('emaildirect/wrapper_lists')->listUnsubscribe($listId, $email);
79
+ }
80
+ $this->_redirect('*/*/index');
81
+ }
82
+ elseif($publication != $pub_selection) {
83
+ if($subscriber->isObjectNew()) {
84
+ $mergeVars = Mage::getModel('emaildirect/observer')->_mergeVars($subscriber);
85
+ Mage::getSingleton('emaildirect/wrapper_suscribers')
86
+ ->suscriberAdd($email,$mergeVars);
87
+ }
88
+ else {
89
+ Mage::getSingleton('emaildirect/wrapper_publications')->subscribe($general,$email);
90
+ }
91
+ $subscriber->subscribe($email);
92
+ }
93
+ if( !empty($curlists) ){
94
+ foreach($curlists as $listId => $list){
95
+ if(FALSE === array_key_exists($listId, $lists)){
96
+ Mage::getSingleton('emaildirect/wrapper_lists')->listUnsubscribe($listId, $email);
97
+ }
98
+ }
99
+ }
100
+ //Subscribe to new lists
101
+ $subscribe = array_diff_key($lists, $curlists);
102
+ if( !empty($subscribe) ){
103
+ foreach($subscribe as $listId => $slist){
104
+ Mage::getSingleton('emaildirect/wrapper_lists')->listSubscribe($listId, $email);
105
+ }
106
+
107
+ }
108
+
109
+ }
110
+
111
+ $this->_redirect('*/*/index');
112
+ }
113
+ }
app/code/local/EmailDirect/Integration/controllers/ExportController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmailDirect_Integration_ExportController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function downloadAction()
5
+ {
6
+ $file_name = "emaildirect_products_" . $this->getRequest()->getParam('filename');
7
+ $file = Mage::helper('emaildirect')->getExportFileName($file_name);
8
+
9
+ $this->_prepareDownloadResponse(Mage::helper('emaildirect')->getExportFileName($file_name,false), file_get_contents($file));
10
+ }
11
+ }
app/code/local/EmailDirect/Integration/etc/adminhtml.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <emaildirect translate="title" module="emaildirect">
12
+ <title>EmailDirect Configuration</title>
13
+ </emaildirect>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ <translate>
23
+ <modules>
24
+ <EmailDirect_Integration>
25
+ <files>
26
+ <default>EmailDirect_Integration.csv</default>
27
+ </files>
28
+ </EmailDirect_Integration>
29
+ </modules>
30
+ </translate>
31
+ </config>
app/code/local/EmailDirect/Integration/etc/config.xml ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <EmailDirect_Integration>
5
+ <version>1.2.8</version>
6
+ </EmailDirect_Integration>
7
+ </modules>
8
+ <global>
9
+ <events>
10
+ <newsletter_subscriber_save_before>
11
+ <observers>
12
+ <emaildirect_subscribe_observer>
13
+ <class>emaildirect/observer</class>
14
+ <method>handleSubscriber</method>
15
+ </emaildirect_subscribe_observer>
16
+ </observers>
17
+ </newsletter_subscriber_save_before>
18
+ <newsletter_subscriber_delete_after>
19
+ <observers>
20
+ <emaildirect_subscribe_delete_observer>
21
+ <class>emaildirect/observer</class>
22
+ <method>handleSubscriberDeletion</method>
23
+ </emaildirect_subscribe_delete_observer>
24
+ </observers>
25
+ </newsletter_subscriber_delete_after>
26
+ <customer_save_after>
27
+ <observers>
28
+ <emaildirect_update_customer>
29
+ <class>emaildirect/observer</class>
30
+ <method>updateCustomer</method>
31
+ </emaildirect_update_customer>
32
+ </observers>
33
+ </customer_save_after>
34
+ <sales_order_save_after>
35
+ <observers>
36
+ <emaildirect_order_save_after>
37
+ <class>emaildirect/observer</class>
38
+ <method>orderSaveAfter</method>
39
+ </emaildirect_order_save_after>
40
+ </observers>
41
+ </sales_order_save_after>
42
+ <sales_quote_save_after>
43
+ <observers>
44
+ <emaildirect_quote_save_after>
45
+ <class>emaildirect/observer</class>
46
+ <method>quoteSaveAfter</method>
47
+ </emaildirect_quote_save_after>
48
+ </observers>
49
+ </sales_quote_save_after>
50
+ </events>
51
+ <models>
52
+ <emaildirect>
53
+ <class>EmailDirect_Integration_Model</class>
54
+ <resourceModel>emaildirect_mysql4</resourceModel>
55
+ </emaildirect>
56
+ <emaildirect_mysql4>
57
+ <class>EmailDirect_Integration_Model_Mysql4</class>
58
+ <entities>
59
+ <apidebug><table>emaildirect_api_debug</table></apidebug>
60
+ </entities>
61
+ </emaildirect_mysql4>
62
+ </models>
63
+ <resources>
64
+ <emaildirect_setup>
65
+ <setup>
66
+ <module>EmailDirect_Integration</module>
67
+ </setup>
68
+ <connection>
69
+ <use>core_setup</use>
70
+ </connection>
71
+ </emaildirect_setup>
72
+ <emaildirect_write>
73
+ <connection>
74
+ <use>core_write</use>
75
+ </connection>
76
+ </emaildirect_write>
77
+ <emaildirect_read>
78
+ <connection>
79
+ <use>core_read</use>
80
+ </connection>
81
+ </emaildirect_read>
82
+ </resources>
83
+ <blocks>
84
+ <emaildirect>
85
+ <class>EmailDirect_Integration_Block</class>
86
+ </emaildirect>
87
+ </blocks>
88
+ <helpers>
89
+ <emaildirect>
90
+ <class>EmailDirect_Integration_Helper</class>
91
+ </emaildirect>
92
+ </helpers>
93
+ <template>
94
+ <email>
95
+ <newsletter_subscription_success_email_template translate="label" module="emaildirect">
96
+ <label>Newsletter subscription success</label>
97
+ <file>newsletter_subscr_success_emaildirect.html</file>
98
+ <type>html</type>
99
+ </newsletter_subscription_success_email_template>
100
+ <newsletter_subscription_un_email_template translate="label" module="emaildirect">
101
+ <label>Newsletter unsubscription success</label>
102
+ <file>newsletter_unsub_success_emaildirect.html</file>
103
+ <type>html</type>
104
+ </newsletter_subscription_un_email_template>
105
+ </email>
106
+ </template>
107
+ </global>
108
+ <frontend>
109
+ <translate>
110
+ <modules>
111
+ <EmailDirect_Integration>
112
+ <files>
113
+ <default>EmailDirect_Integration.csv</default>
114
+ </files>
115
+ </EmailDirect_Integration>
116
+ </modules>
117
+ </translate>
118
+ <routers>
119
+ <emaildirect>
120
+ <use>standard</use>
121
+ <args>
122
+ <module>EmailDirect_Integration</module>
123
+ <frontName>emaildirect</frontName>
124
+ </args>
125
+ </emaildirect>
126
+ </routers>
127
+ <layout>
128
+ <updates>
129
+ <emaildirect>
130
+ <file>emaildirect.xml</file>
131
+ </emaildirect>
132
+ </updates>
133
+ </layout>
134
+ <events>
135
+ <controller_action_postdispatch_checkout_onepage_saveOrder>
136
+ <observers>
137
+ <emaildirect_subscribe_checkout>
138
+ <class>emaildirect/observer</class>
139
+ <method>registerCheckoutSubscribe</method>
140
+ </emaildirect_subscribe_checkout>
141
+ </observers>
142
+ </controller_action_postdispatch_checkout_onepage_saveOrder>
143
+ <checkout_onepage_controller_success_action>
144
+ <observers>
145
+ <emaildirect_subscribe_checkoutsuccess>
146
+ <class>emaildirect/observer</class>
147
+ <method>registerCheckoutSuccess</method>
148
+ </emaildirect_subscribe_checkoutsuccess>
149
+ </observers>
150
+ </checkout_onepage_controller_success_action>
151
+ <sales_order_place_after>
152
+ <observers>
153
+ <emaildirect_sendorder>
154
+ <class>emaildirect/observer</class>
155
+ <method>orderSaveAfter</method>
156
+ </emaildirect_sendorder>
157
+ </observers>
158
+ </sales_order_place_after>
159
+ </events>
160
+ </frontend>
161
+ <admin>
162
+ <routers>
163
+ <emaildirect>
164
+ <use>admin</use>
165
+ <args>
166
+ <module>Emaildirect_Integration</module>
167
+ <frontName>emaildirect</frontName>
168
+ </args>
169
+ </emaildirect>
170
+ </routers>
171
+ </admin>
172
+ <adminhtml>
173
+ <layout>
174
+ <updates>
175
+ <emaildirect>
176
+ <file>emaildirect.xml</file>
177
+ </emaildirect>
178
+ </updates>
179
+ </layout>
180
+ <translate>
181
+ <modules>
182
+ <EmailDirect_Integration>
183
+ <files>
184
+ <default>EmailDirect_Integration.csv</default>
185
+ </files>
186
+ </EmailDirect_Integration>
187
+ </modules>
188
+ </translate>
189
+ <events>
190
+ <admin_system_config_changed_section_emaildirect>
191
+ <observers>
192
+ <emaildirect_save_config>
193
+ <class>emaildirect/observer</class>
194
+ <method>saveConfig</method>
195
+ </emaildirect_save_config>
196
+ </observers>
197
+ </admin_system_config_changed_section_emaildirect>
198
+ </events>
199
+ </adminhtml>
200
+ <default>
201
+ <emaildirect>
202
+ <general>
203
+ <urls>
204
+ <accesspoint>https://rest.emaildirect.com/v1/</accesspoint>
205
+ <lists>Lists</lists>
206
+ <subscribers>Subscribers</subscribers>
207
+ <sources>Sources</sources>
208
+ <publications>Publications</publications>
209
+ <products>Products</products>
210
+ <categories>ProductCategories</categories>
211
+ <orders>Orders</orders>
212
+ <database>Database</database>
213
+ <abandoned>Import/AddOrUpdate</abandoned>
214
+ <ftp>FTP</ftp>
215
+ </urls>
216
+ <active>0</active>
217
+ <sourceid>0</sourceid>
218
+ <source>Magento</source>
219
+ <max_times>1</max_times>
220
+ <list>-1</list>
221
+ <address_fields><![CDATA[a:5:{s:2:"a1";a:2:{s:7:"magento";s:6:"street";s:11:"emaildirect";s:7:"Address";}s:2:"a2";a:2:{s:7:"magento";s:4:"city";s:11:"emaildirect";s:4:"City";}s:2:"a3";a:2:{s:7:"magento";s:10:"state_code";s:11:"emaildirect";s:5:"State";}s:2:"a4";a:2:{s:7:"magento";s:8:"postcode";s:11:"emaildirect";s:3:"Zip";}s:2:"a5";a:2:{s:7:"magento";s:9:"telephone";s:11:"emaildirect";s:5:"Phone";}}]]></address_fields>
222
+ <map_fields><![CDATA[a:2:{i:0;a:2:{s:7:"magento";s:9:"firstname";s:11:"emaildirect";s:9:"FirstName";}i:1;a:2:{s:7:"magento";s:8:"lastname";s:11:"emaildirect";s:8:"LastName";}}]]></map_fields>
223
+ <abandonedtime>30</abandonedtime>
224
+ <abandonedlist>-1</abandonedlist>
225
+ <sendabandoned>0</sendabandoned>
226
+ <abandonedsetup>0</abandonedsetup>
227
+ <debug>0</debug>
228
+ <save_latest_order>0</save_latest_order>
229
+ <product_fields>3</product_fields>
230
+ <related_fields>2</related_fields>
231
+ </general>
232
+ <export>
233
+ <send_to_emaildirect>1</send_to_emaildirect>
234
+ <include_disabled>1</include_disabled>
235
+ <batch>100</batch>
236
+ </export>
237
+ </emaildirect>
238
+ </default>
239
+ <crontab>
240
+ <jobs>
241
+ <emaildirect_integration>
242
+ <schedule>
243
+ <cron_expr>0 */1 * * *</cron_expr>
244
+ <!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
245
+ </schedule>
246
+ <run>
247
+ <model>emaildirect/observer::abandonedCartsProcessor</model>
248
+ </run>
249
+ </emaildirect_integration>
250
+ </jobs>
251
+ </crontab>
252
+ </config>
app/code/local/EmailDirect/Integration/etc/system.xml ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <emaildirect translate="label" module="emaildirect">
5
+ <class>emaildirect-section</class>
6
+ <label>EmailDirect Configuration</label>
7
+ <header_css>emaildirect-header</header_css>
8
+ <tab>customer</tab>
9
+ <sort_order>404</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <groups>
14
+ <hint>
15
+ <frontend_model>emaildirect/adminhtml_system_config_fieldset_hint</frontend_model>
16
+ <sort_order>0</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ </hint>
21
+ <general translate="label comment">
22
+ <label>General</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>660</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <abandoned_email_template translate="label">
30
+ <label>Email Template</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_email_template</source_model>
33
+ <sort_order>3</sort_order>
34
+ <show_in_default>0</show_in_default>
35
+ <show_in_website>0</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ </abandoned_email_template>
38
+ <active translate="label">
39
+ <label>Enabled</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>10</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </active>
47
+ <apikey translate="label comment">
48
+ <label>API Key</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>20</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>0</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <comment>Enter your EmailDirect API Key here</comment>
55
+ </apikey>
56
+ <publication translate="label comment">
57
+ <label>Publication</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>emaildirect/system_config_source_publication</source_model>
60
+ <sort_order>24</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>0</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ <can_be_empty>1</can_be_empty>
65
+ <comment>This is the Publication that emails will be subscribed to and is required</comment>
66
+ </publication>
67
+ <additional_lists translate="label comment">
68
+ <label>Additional Lists</label>
69
+ <frontend_type>multiselect</frontend_type>
70
+ <source_model>emaildirect/system_config_source_additionallist</source_model>
71
+ <sort_order>35</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>0</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <can_be_empty>1</can_be_empty>
76
+ <comment>Choose one or more Lists to allow your subscribers more options when subscribing. Not required</comment>
77
+ </additional_lists>
78
+
79
+ <source translate="label comment">
80
+ <label>Source</label>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>42</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>0</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ <can_be_empty>0</can_be_empty>
87
+ <comment><![CDATA[This is the main source used with the Magento General Subscription.<br> If you leave this field blank <b>Magento</b> is used]]></comment>
88
+ </source>
89
+ <address_fields translate="label comment">
90
+ <label>Address Fields Mapping</label>
91
+ <frontend_model>emaildirect/adminhtml_system_config_form_field_addressmapfields</frontend_model>
92
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
93
+ <sort_order>72</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>0</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </address_fields>
98
+ <map_fields translate="label comment">
99
+ <label>Customer Fields Mapping</label>
100
+ <frontend_model>emaildirect/adminhtml_system_config_form_field_mapfields</frontend_model>
101
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
102
+ <sort_order>70</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>0</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </map_fields>
107
+
108
+ <shipping_fields translate="label comment">
109
+ <label>Shipping Fields Mapping</label>
110
+ <frontend_model>emaildirect/adminhtml_system_config_form_field_shippingmapfields</frontend_model>
111
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
112
+ <sort_order>75</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>0</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </shipping_fields>
117
+
118
+ <checkout_subscribe translate="label comment">
119
+ <label>Subscribe On Checkout</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>emaildirect/system_config_source_checkoutsubscribe</source_model>
122
+ <sort_order>80</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>0</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ <comment>Show Newsletter Subscribe checkbox in the last Checkout Step (Order Review)</comment>
127
+ </checkout_subscribe>
128
+ <sendorder translate="label">
129
+ <label>Send orders to EmailDirect</label>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>adminhtml/system_config_source_yesno</source_model>
132
+ <sort_order>85</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ <comment>Sends all completed orders to EmailDirect Purchase Behavior for detailed reporting, filtering and targeting</comment>
137
+ </sendorder>
138
+ <save_latest_order translate="label">
139
+ <label>Save Latest Order Information</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>adminhtml/system_config_source_yesno</source_model>
142
+ <sort_order>86</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ <comment>Save information from the latest order along with the first 3 products from that order</comment>
147
+ </save_latest_order>
148
+ <sendabandoned translate="label">
149
+ <label>Add Abandoned Carts To EmailDirect</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_yesno</source_model>
152
+ <sort_order>90</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ <comment>This will add any abandoned shopping carts to the EmailDirect database with AbandonedDate and AbandonedURL database fields. These fields can be used with Workflows to time your own Abandoned Shopping Cart emails or send a series of emails. This allows for complete customization of the email.</comment>
157
+ </sendabandoned>
158
+ <abandonedtime translate="label comment">
159
+ <label>Abandoned Time</label>
160
+ <frontend_type>select</frontend_type>
161
+ <source_model>emaildirect/system_config_source_time</source_model>
162
+ <sort_order>100</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ <comment>How long before a cart is considered abandoned?</comment>
167
+ </abandonedtime>
168
+ <abandonedpublication translate="label comment">
169
+ <label>Abandoned Publication</label>
170
+ <frontend_type>select</frontend_type>
171
+ <source_model>emaildirect/system_config_source_publication</source_model>
172
+ <sort_order>110</sort_order>
173
+ <show_in_default>1</show_in_default>
174
+ <show_in_website>1</show_in_website>
175
+ <show_in_store>1</show_in_store>
176
+ <can_be_empty>1</can_be_empty>
177
+ <comment>This is the Publication that you will put abandoned shoppers into</comment>
178
+ </abandonedpublication>
179
+ <abandonedlist translate="label comment">
180
+ <label>Abandoned List</label>
181
+ <frontend_type>select</frontend_type>
182
+ <source_model>emaildirect/system_config_source_abandonedlist</source_model>
183
+ <sort_order>120</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ <can_be_empty>1</can_be_empty>
188
+ <comment>This is the List that you will put abandoned shoppers into. Not Required.</comment>
189
+ </abandonedlist>
190
+
191
+ </fields>
192
+ </general>
193
+ <export translate="label comment">
194
+ <label>Export Options</label>
195
+ <frontend_type>text</frontend_type>
196
+ <sort_order>670</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ <expanded>1</expanded>
201
+ <fields>
202
+ <send_to_emaildirect translate="label">
203
+ <label>Send File to Emaildirect</label>
204
+ <frontend_type>select</frontend_type>
205
+ <source_model>adminhtml/system_config_source_yesno</source_model>
206
+ <sort_order>10</sort_order>
207
+ <show_in_default>1</show_in_default>
208
+ <show_in_website>1</show_in_website>
209
+ <show_in_store>1</show_in_store>
210
+ <comment>This will add the category file to your EmailDirect account FTP. In your EmailDirect account go to Purchase Behavior, Orders, Import Order File and choose 'Select From FTP' to complete the import process.</comment>
211
+ </send_to_emaildirect>
212
+ <include_disabled translate="label">
213
+ <label>Include disabled Products?</label>
214
+ <frontend_type>select</frontend_type>
215
+ <source_model>adminhtml/system_config_source_yesno</source_model>
216
+ <sort_order>20</sort_order>
217
+ <show_in_default>1</show_in_default>
218
+ <show_in_website>1</show_in_website>
219
+ <show_in_store>1</show_in_store>
220
+ </include_disabled>
221
+ <batch translate="label comment">
222
+ <label>Batch Size</label>
223
+ <frontend_type>select</frontend_type>
224
+ <source_model>emaildirect/system_config_source_export_batch</source_model>
225
+ <sort_order>20</sort_order>
226
+ <show_in_default>0</show_in_default>
227
+ <show_in_website>0</show_in_website>
228
+ <show_in_store>0</show_in_store>
229
+ <comment>Number of Products to Export at a time (SAVE CONFIG BEFORE EXPORTING)</comment>
230
+ </batch>
231
+ <export_button>
232
+ <label>Export Products</label>
233
+ <!--<frontend_type>select</frontend_type>-->
234
+ <frontend_model>emaildirect/adminhtml_system_config_form_field_button</frontend_model>
235
+
236
+ <sort_order>130</sort_order>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <show_in_store>1</show_in_store>
240
+ <can_be_empty>1</can_be_empty>
241
+ <comment>Export Orders to CSV and send the CSV file to Emaildirect (opens in new window)</comment>
242
+ </export_button>
243
+ </fields>
244
+ </export>
245
+ </groups>
246
+ </emaildirect>
247
+ </sections>
248
+ </config>
app/code/local/EmailDirect/Integration/sql/emaildirect_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE `{$this->getTable('sales_flat_quote')}`
10
+ add column emaildirect_counter int(5) default '0'
11
+ ");
12
+
13
+ $installer->endSetup();
app/code/local/EmailDirect/Integration/sql/emaildirect_setup/mysql4-upgrade-1.0.13-1.0.14.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ ALTER TABLE {$this->getTable('newsletter_subscriber')}
8
+ ADD firstname varchar(255) NOT NULL default '',
9
+ ADD lastname varchar(255) NOT NULL default ''
10
+ ");
11
+
12
+ $installer->endSetup();
app/code/local/EmailDirect/Integration/sql/emaildirect_setup/mysql4-upgrade-1.0.19-1.2.0.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE `{$this->getTable('sales_flat_quote')}`
10
+ add column emaildirect_abandoned_date TIMESTAMP NULL,
11
+ add column emaildirect_abandoned_url Text NULL
12
+ ");
13
+
14
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/emaildirect.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_system_config_edit>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
6
+ </reference>
7
+ </adminhtml_system_config_edit>
8
+
9
+ <emaildirect_adminhtml_ctemplate_edit>
10
+ <reference name="head">
11
+ <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
12
+ <action method="addItem"><type>skin_js</type><name>emaildirect/emaildirect.js</name></action>
13
+ </reference>
14
+ </emaildirect_adminhtml_ctemplate_edit>
15
+
16
+ <emaildirect_adminhtml_ctemplate_new>
17
+ <reference name="head">
18
+ <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
19
+ <action method="addItem"><type>skin_js</type><name>emaildirect/emaildirect.js</name></action>
20
+ </reference>
21
+ </emaildirect_adminhtml_ctemplate_new>
22
+
23
+ <!--adminhtml_customer_edit>
24
+ <reference name="customer_edit_tabs">
25
+ <action method="addTab">
26
+ <name>customer_edit_tab_emaildirect_memberactivity</name>
27
+ <block>emaildirect/adminhtml_customer_edit_tab_memberactivity</block>
28
+ </action>
29
+ </reference>
30
+ </adminhtml_customer_edit-->
31
+
32
+ <emaildirect_admin_export_run>
33
+ <remove name="root"/>
34
+ <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
35
+ <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
36
+ <action method="addJs"><script>prototype/prototype.js</script></action>
37
+ <action method="addJs"><script>prototype/validation.js</script></action>
38
+ <action method="addJs"><script>varien/js.js</script></action>
39
+ <action method="addJs"><script>mage/translate.js</script></action>
40
+ <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
41
+ </block>
42
+ <block type="emaildirect/adminhtml_system_convert_profile_export" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
43
+ </block>
44
+ </emaildirect_admin_export_run>
45
+
46
+ </layout>
app/design/adminhtml/default/default/template/emaildirect/system/config/fieldset/hint.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ ?>
3
+ <div class="emaildirect-notice">
4
+ <h4>
5
+ <?php echo Mage::helper('emaildirect')->__('<strong style="color:#EA7601;">EmailDirect Integration v%s </strong> ', $this->getEmaildirectVersion())?>
6
+ </h4>
7
+ </div>
8
+
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/array.phtml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+
28
+ <?php
29
+ $_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
30
+
31
+ $_colspan = 2;
32
+ if (!$this->_addAfter) {
33
+ $_colspan -= 1;
34
+ }
35
+ $_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
36
+ ?>
37
+
38
+ <div class="grid" id="grid<?php echo $_htmlId ?>">
39
+ <table cellpadding="0" cellspacing="0" class="border">
40
+ <tbody>
41
+
42
+ <tr class="headings" id="headings<?php echo $_htmlId ?>">
43
+ <?php foreach ($this->_columns as $columnName => $column):?>
44
+ <th><?php echo $column['label'] ?></th>
45
+ <?php endforeach;?>
46
+ <th <?php echo $_colspan?>></th>
47
+ </tr>
48
+
49
+ <tr id="addRow<?php echo $_htmlId ?>">
50
+ <td colspan="<?php echo count($this->_columns) ?>"></td>
51
+ <td <?php echo $_colspan?>>
52
+ <button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>">
53
+ <span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
54
+ </button>
55
+ </td>
56
+ </tr>
57
+
58
+ </tbody>
59
+ </table>
60
+ <input type="hidden" name="<?php echo $this->getElement()->getName() ?>[__empty]" value="" />
61
+ </div>
62
+ <div id="empty<?php echo $_htmlId ?>">
63
+ <button style="" onclick="" class="scalable add" type="button" id="emptyAddBtn<?php echo $_htmlId ?>">
64
+ <span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
65
+ </button>
66
+ </div>
67
+
68
+ <script type="text/javascript">
69
+ //<![CDATA[
70
+ // create row creator
71
+ var arrayRow<?php echo $_htmlId ?> = {
72
+ // define row prototypeJS template
73
+ template : new Template(
74
+ '<tr id="#{_id}">'
75
+ <?php foreach ($this->_columns as $columnName => $column):?>
76
+ +'<td>'
77
+ +'<?php echo $this->_renderCellTemplate($columnName)?>'
78
+ +'<\/td>'
79
+ <?php endforeach;?>
80
+ <?php if ($this->_addAfter):?>
81
+ +'<td><button onclick="" class="scalable add" type="button" id="addAfterBtn#{_id}"><span><span><span><?php echo Mage::helper('adminhtml')->__('Add after') ?><\/span><\/span><\/span><\/button><\/td>'
82
+ <?php endif;?>
83
+ +'<td><button onclick="arrayRow<?php echo $_htmlId ?>.del(\'#{_id}\')" class="scalable delete" type="button"><span><span><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/span><\/span><\/button><\/td>'
84
+ +'<\/tr>'
85
+ ),
86
+
87
+ rowsCount : 0,
88
+
89
+ add : function(templateData, insertAfterId)
90
+ {
91
+ // generate default template data
92
+ if ('' == templateData) {
93
+ var d = new Date();
94
+ var templateData = {
95
+ <?php foreach ($this->_columns as $columnName => $column):?>
96
+ <?php echo $columnName ?> : '',
97
+ <?php endforeach;?>
98
+ _id : '_' + d.getTime() + '_' + d.getMilliseconds()
99
+ };
100
+ }
101
+
102
+ // insert before last row
103
+ if ('' == insertAfterId) {
104
+ Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
105
+ }
106
+ // insert after specified row
107
+ else {
108
+ Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
109
+ }
110
+
111
+ <?php if ($this->_addAfter):?>
112
+ Event.observe('addAfterBtn' + templateData._id, 'click', this.add.bind(this, '', templateData._id));
113
+ <?php endif;?>
114
+
115
+ this.rowsCount += 1;
116
+ },
117
+
118
+ del : function(rowId)
119
+ {
120
+ $(rowId).remove();
121
+ this.rowsCount -= 1;
122
+ if (0 == this.rowsCount) {
123
+ this.showButtonOnly();
124
+ }
125
+ },
126
+
127
+ showButtonOnly : function()
128
+ {
129
+ $('grid<?php echo $_htmlId ?>').hide();
130
+ $('empty<?php echo $_htmlId ?>').show();
131
+ }
132
+ }
133
+
134
+ // bind add action to "Add" button in last row
135
+ Event.observe('addToEndBtn<?php echo $_htmlId ?>', 'click', arrayRow<?php echo $_htmlId ?>.add.bind(arrayRow<?php echo $_htmlId ?>, '', ''));
136
+
137
+ // add existing rows
138
+ <?php
139
+ $_addAfterId = "headings{$_htmlId}";
140
+ foreach ($this->getArrayRows() as $_rowId => $_row) {
141
+
142
+ $_row['_selected_' . $_row['emaildirect']] = "selected=\"selected\"";
143
+ $_row['_selected_' . $_row['magento']] = "selected=\"selected\"";
144
+
145
+ echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
146
+ $_addAfterId = $_rowId;
147
+ }
148
+ ?>
149
+
150
+ // initialize standalone button
151
+ $('empty<?php echo $_htmlId ?>').hide();
152
+ Event.observe('emptyAddBtn<?php echo $_htmlId ?>', 'click', function () {
153
+ $('grid<?php echo $_htmlId ?>').show();
154
+ $('empty<?php echo $_htmlId ?>').hide();
155
+ arrayRow<?php echo $_htmlId ?>.add('', '');
156
+ });
157
+
158
+ // if no rows, hide grid and show button only
159
+ <?php if (!$this->getArrayRows()):?>
160
+ arrayRow<?php echo $_htmlId ?>.showButtonOnly();
161
+ <?php endif;?>
162
+
163
+ // toggle the grid, if element is disabled (depending on scope)
164
+ <?php if ($this->getElement()->getDisabled()):?>
165
+ toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
166
+ <?php endif;?>
167
+ //]]>
168
+ </script>
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/button.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--<button id='emaildirect_export' onClick="window.open('<?php echo $this->getUrl("emaildirect/admin_export/run/"); ?>'); return false;">Export</button>-->
2
+ <button id='emaildirect_export' onClick="test(); return false;">Export</button>
3
+ <script type='text/javascript'>
4
+ function test()
5
+ {
6
+ var form = $('config_edit_form');
7
+ var send_to_ed = form['groups[export][fields][send_to_emaildirect][value]'];
8
+ var include_disabled = form['groups[export][fields][include_disabled][value]'];
9
+ var url = '<?php echo $this->getUrl("emaildirect/admin_export/run/"); ?>';
10
+
11
+ url += 'send_to_emaildirect/' + $(send_to_ed).getValue() + '/include_disabled/' + $(include_disabled).getValue() + '/';
12
+
13
+ window.open(url);
14
+ }
15
+ </script>
app/design/adminhtml/default/default/template/emaildirect/system/convert/profile/export.phtml ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //echo $this->getUrl("*/*/download",array('filename' => 'test123'));
4
+ ?>
5
+ <style type="text/css" >
6
+ ul { list-style-type:none; padding:0; margin:0; }
7
+ li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 13px sans-serif; }
8
+ img { margin-right:5px; }
9
+ </style>
10
+ <script type="text/javascript">
11
+ var FORM_KEY = "<?php echo $this->getFormKey();?>";
12
+ </script>
13
+ <ul>
14
+ <li>
15
+ <img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif')?>" class="v-middle" style="margin-right:5px"/>
16
+ <?php echo $this->__("Starting EmailDirect Export...");?>
17
+ </li>
18
+ <li style="background-color:#FFD;">
19
+ <img src="<?php echo $this->getSkinUrl('images/fam_bullet_error.gif');?>" class="v-middle" style="margin-right:5px"/>
20
+ <?php echo $this->__("Warning: Please do not close the window during export process!");?>
21
+
22
+ </li>
23
+ </ul>
24
+ <ul id="profileRows">
25
+ <li id="liFinished" style="display:none;">
26
+ <img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif');?>" class="v-middle" style="margin-right:5px"/>
27
+ <?php echo $this->__("Finished Export!.");?>
28
+ <span id='download_link'>
29
+
30
+ </span>
31
+ </li>
32
+ </ul>
33
+ <?php $this->getBatchModel() ?>
34
+ <?php $importData = $this->getImportData();?>
35
+ <script type="text/javascript">
36
+ var d = new Date();
37
+ var countOfStartedProfiles = 0;
38
+ var filename = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + "T" + d.getHours() + "_" + d.getMinutes();
39
+ var countOfUpdated = 0;
40
+ var countOfError = 0;
41
+ var importData = <?php echo $this->jsonEncode($importData);?>;
42
+ var totalRecords = <?php echo $this->getBatchItemsCount();?>;
43
+ var config = <?php echo $this->getBatchConfigJson();?>;
44
+ var group = <?php echo $this->getBatchSize() ?>;
45
+ var upload_ed = <?php echo $this->getUploadStatus() ?>;
46
+ </script>
47
+ <script type="text/javascript">
48
+
49
+ function execImportData()
50
+ {
51
+ if (importData.length == 0)
52
+ {
53
+ // Finished
54
+ $("updatedRows_img").src = config.styles.message.icon;
55
+ $("updatedRows").style.backgroundColor = config.styles.message.bg;
56
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
57
+ style: "background-color:"+config.styles.message.bg,
58
+ image: config.styles.message.icon,
59
+ text: config.tplSccTxt.evaluate({updated:(countOfUpdated-countOfError)}),
60
+ id: "updatedFinish"
61
+ })});
62
+
63
+ if (upload_ed)
64
+ {
65
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
66
+ style: "background-color:"+config.styles.message.bg,
67
+ image: config.styles.message.icon,
68
+ text: config.tplUploading.evaluate(),
69
+ id: "uploadingFinish"
70
+ })});
71
+ }
72
+
73
+ if ($("liBeforeFinish"))
74
+ {
75
+ Element.insert($("liFinished"), {before: $("liBeforeFinish")});
76
+ $("liBeforeFinish").show();
77
+ }
78
+
79
+ new Ajax.Request("<?php echo $this->getUrl('*/*/batchFinish');?>", {
80
+ method: "post",
81
+ parameters: {filename: filename, form_key: FORM_KEY},
82
+ onComplete: function(transport)
83
+ {
84
+ if (transport.responseText.isJSON())
85
+ {
86
+ var response = transport.responseText.evalJSON();
87
+
88
+ Element.insert($("download_link"), {bottom: "<a href='" + response.download_link + "'>Download File</a>"});
89
+ if (response.error)
90
+ {
91
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
92
+ style: "background-color:"+config.styles.error.bg,
93
+ image: config.styles.error.icon,
94
+ text: response.error.escapeHTML(),
95
+ id: "error-finish"
96
+ })});
97
+ }
98
+ }
99
+
100
+ if ($("before-finish-wait-img"))
101
+ $("before-finish-wait-img").hide();
102
+
103
+ $('liFinished').show();
104
+ }
105
+ });
106
+ }
107
+ else
108
+ {
109
+ if (group > 1)
110
+ {
111
+ var ids = [];
112
+ for (var i = 0; i < group; i++)
113
+ {
114
+ ids.push(importData.shift());
115
+
116
+ if (importData.length == 0)
117
+ break;
118
+ }
119
+
120
+ sendImportData(ids,"id[]");
121
+
122
+ }
123
+ else
124
+ {
125
+ sendImportData(importData.shift(),"id");
126
+ }
127
+ }
128
+ }
129
+
130
+ function sendImportData(id,id_name)
131
+ {
132
+ var data = {}
133
+ var updated = 1;
134
+
135
+ data[id_name] = id;
136
+
137
+ if (typeof(id) != 'number')
138
+ updated = id.length;
139
+
140
+ if (!config.tpl)
141
+ {
142
+ config.tpl = new Template(config.template);
143
+ config.tplTxt = new Template(config.text);
144
+ config.tplSccTxt = new Template(config.successText);
145
+ config.tplUploading = new Template(config.uploadText);
146
+ }
147
+ if (!$("updatedRows"))
148
+ {
149
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
150
+ style: "background-color: #FFD;",
151
+ image: config.styles.loader,
152
+ text: config.tplTxt.evaluate({updated:countOfUpdated, percent:getPercent()}),
153
+ id: "updatedRows"
154
+ })});
155
+ }
156
+ countOfStartedProfiles++;
157
+
158
+ if (!data.form_key)
159
+ data.form_key = FORM_KEY;
160
+
161
+ data.filename = filename;
162
+
163
+ new Ajax.Request("<?php echo $this->getUrl("*/*/batchRun/");?>", {
164
+ method: "post",
165
+ parameters: data,
166
+ onSuccess: function(transport)
167
+ {
168
+ countOfStartedProfiles --;
169
+ countOfUpdated += updated;
170
+ if (transport.responseText.isJSON())
171
+ addProfileRow(transport.responseText.evalJSON());
172
+ else
173
+ {
174
+ Element.insert($("updatedRows"), {before: config.tpl.evaluate({
175
+ style: "background-color: "+config.styles.error.bg,
176
+ image: config.styles.error.icon,
177
+ text: transport.responseText.escapeHTML(),
178
+ id: "error-" + countOfStartedProfiles
179
+ })
180
+ });
181
+ countOfError ++;
182
+ }
183
+ execImportData();
184
+ }
185
+ });
186
+ }
187
+
188
+ function getPercent()
189
+ {
190
+ return Math.ceil((countOfUpdated/totalRecords)*1000)/10;
191
+ }
192
+
193
+ function addProfileRow(data)
194
+ {
195
+ if (data.errors.length > 0)
196
+ {
197
+ for (var i=0, length=data.errors.length; i<length; i++)
198
+ {
199
+ Element.insert($("updatedRows"), {before: config.tpl.evaluate({
200
+ style: "background-color:"+config.styles.error.bg,
201
+ image: config.styles.error.icon,
202
+ text: data.errors[i],
203
+ id: "id-" + (countOfUpdated + i + 1)
204
+ })});
205
+ countOfError ++;
206
+ }
207
+ }
208
+ $("updatedRows_status").update(config.tplTxt.evaluate({updated:countOfUpdated, percent:getPercent()}));
209
+ }
210
+ </script>
211
+
212
+ <script type="text/javascript">
213
+ execImportData();
214
+ </script>
app/design/frontend/base/default/layout/emaildirect.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <checkout_onepage_review>
5
+ <reference name="checkout.onepage.review.info.items.after">
6
+ <block type="emaildirect/checkout_subscribe" name="emaildirect.subscribe" template="emaildirect/checkout/subscribe.phtml" />
7
+ </reference>
8
+ </checkout_onepage_review>
9
+
10
+ <emaildirect_email_order_items>
11
+ <block type="emaildirect/email_order_items" name="items" template="emaildirect/email/order/items.phtml">
12
+ <action method="addItemRender"><type>default</type><block>emaildirect/email_order_items_order_default</block><template>emaildirect/email/order/items/order/default.phtml</template></action>
13
+ <action method="addItemRender"><type>grouped</type><block>emaildirect/email_order_items_order_grouped</block><template>emaildirect/email/order/items/order/default.phtml</template></action>
14
+ </block>
15
+ <block type="core/text_list" name="additional.product.info" />
16
+ </emaildirect_email_order_items>
17
+
18
+ <!-- Customer -->
19
+ <customer_account>
20
+ <reference name="head">
21
+ <action method="addItem"><type>skin_js</type><name>emaildirect/integration.js</name><params/></action>
22
+ </reference>
23
+ <reference name="customer_account_navigation">
24
+ <action method="addLink" ifconfig="emaildirect/general/active" translate="label" module="emaildirect">
25
+ <name>emaildirect</name>
26
+ <path>emaildirect/customer_account/index</path>
27
+ <label>Newsletter Subscriptions</label>
28
+ </action>
29
+ </reference>
30
+ </customer_account>
31
+ <customer_account_index>
32
+ <reference name="my.account.wrapper">
33
+ <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">
34
+ <block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
35
+ <block type="core/template" name="customer_account_dashboard_top" as="top" />
36
+ <block type="emaildirect/customer_account_dashboard_info" name="emaildirect.customer_account_dashboard_info" as="info" template="emaildirect/customer/account/dashboard/info.phtml"/>
37
+ <block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
38
+ <block type="customer/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
39
+ </block>
40
+ </reference>
41
+ </customer_account_index>
42
+
43
+ <emaildirect_customer_account_index>
44
+ <label>Customer My Account Emaildirect</label>
45
+ <update handle="customer_account"/>
46
+ <!--reference name="head">
47
+ <action method="addCss"><stylesheet>magemonkey/magemonkey.css</stylesheet></action>
48
+ </reference-->
49
+ <reference name="my.account.wrapper">
50
+ <block type="emaildirect/customer_account_lists" name="emaildirect_additionallists" template="emaildirect/customer/account/lists.phtml" />
51
+ <block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml"/>
52
+ </reference>
53
+ </emaildirect_customer_account_index>
54
+ <!-- Customer -->
55
+
56
+
57
+
58
+ </layout>
app/design/frontend/base/default/template/emaildirect/boxes/additionalNewsletter.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo "toy aca"; ?>
2
+ <?php if($this->isEmailDirectEnabled($this->getCustomer()->getStoreId())): ?>
3
+ <?php if($this->getSubscribedAdditionalLists()): ?>
4
+ <div class="box-title">
5
+ <h3><?php echo $this->__('Additional Newsletters Lists') ?></h3>
6
+ </div>
7
+ <div class="box-content">
8
+ <?php foreach ($this->getSubscribedAdditionalLists() as $_list): ?>
9
+ <?php if($_list->getIsSubscribed()): ?>
10
+ <p style="margin-bottom:0px;"><?php echo $this->htmlEscape($_list->getName()) ?></p>
11
+ <?php endif; ?>
12
+ <?php endforeach;?>
13
+ </div>
14
+ <?php endif;?>
15
+ <img alt="Powered By EmailDirect" src="<?php echo $this->getSkinUrl('emaildirect/images/mailchimp_tile.png') ?>" style="float:right;"/>
16
+ <?php endif;?>
17
+
app/design/frontend/base/default/template/emaildirect/boxes/additionalNewsletterBox.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $store = $this->getCustomer()->getStoreId();?>
2
+ <?php if($this->isMailChimpProEnabled($store)): ?>
3
+ <?php if($this->getAdditionalLists($store)): ?>
4
+ <div class="subscribed-additional">
5
+ <form action="<?php echo $this->getFormMultiActionUrl() ?>" method="post" id="form-validate">
6
+ <input type="hidden" name="additional" id="additional" value="1" />
7
+ <?php echo $this->getBlockHtml('formkey')?>
8
+ <div class="page-title">
9
+ <h1><?php echo $this->__('Additional Newsletters Lists') ?></h1>
10
+ </div>
11
+ <fieldset id="additionalFieldset">
12
+ <ul class="form-list">
13
+ <?php foreach ($this->getAdditionalLists($store) as $_list): ?>
14
+ <li class="control">
15
+ <?php $inputId = 'list['.$_list->getListId().']'; ?>
16
+ <?php $fieldsetId = 'additionalFieldset'.$_list->getListId() ;?>
17
+ <input onclick="unCheckGroups('<?php echo $fieldsetId; ?>')" type="checkbox" value="<?php echo $_list->getIsSubscribed()?>" <?php if($_list->getIsSubscribed()) echo 'checked="checked"'; ?> name="<?php echo $inputId; ?>" id="<?php echo $inputId; ?>" title="<?php echo $this->__('Is Subscribed') ?>" class="checkbox" />
18
+ <label for="subscription"><?php echo $this->htmlEscape($_list->getName()) ?></label>
19
+ <?php if($this->getGroups($_list->getListId(),null)): ?>
20
+ <fieldset id="<?php echo $fieldsetId; ?>">
21
+ <?php echo $this->getGroupInputs($_list->getListId(),$this->getCustomer()->getStoreId(),true); ?>
22
+ </fieldset>
23
+ <?php endif; ?>
24
+ </li>
25
+ <?php endforeach; ?>
26
+ </ul>
27
+ <div class="buttons-set">
28
+ <?php /*<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>*/ ?>
29
+ <button type="submit" title="<?php echo $this->__('Update Additional Lists') ?>" class="form-button right" ><span><span><?php echo $this->__('Update Additional Lists') ?></span></span></button>
30
+ </div>
31
+ <img alt="Powered By MailChimp" src="<?php echo $this->getSkinUrl('mailchimppro/images/mailchimp_tile.gif') ?>" class="poweredByMailchimp"/>
32
+ </fieldset>
33
+ </form>
34
+ </div>
35
+ <?php endif;?>
36
+ <?php endif;?>
app/design/frontend/base/default/template/emaildirect/boxes/generalNewsletter.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php $store = $this->getCustomer()->getStoreId();?>
3
+
4
+ <?php if($this->isEmailDirectEnabled($store)): ?>
5
+
6
+ <input type="hidden" name="is_general" id="is_general" value="1" />
7
+
8
+ <?php if($this->getGroups(null,$store)): ?>
9
+ <fieldset id="generalFieldset" >
10
+ <?php echo $this->getGroupInputs(null,$store,false); ?>
11
+ <script type="text/javascript">
12
+ var id = ($('subscription'))? $('subscription'): $('is_subscribed');
13
+ Mailchimppro.general.initialize(id,'generalFieldset');
14
+ </script>
15
+ </fieldset>
16
+ <?php endif; ?>
17
+
18
+ <?php if($this->isForcedToRegisterSubscribe()): ?>
19
+ <script type="text/javascript">
20
+ Mailchimppro.general.hide('is_subscribed');
21
+ </script>
22
+ <?php endif; ?>
23
+
24
+ <?php endif; ?>
app/design/frontend/base/default/template/emaildirect/boxes/generalNewsletterBox.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php if($this->canShowSmallBox()): ?>
3
+ <div class="block block-subscribe">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
6
+ </div>
7
+ <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
8
+ <?php echo $this->getBlockHtml('formkey')?>
9
+ <div class="block-content">
10
+ <label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
11
+ <div class="input-box">
12
+ <?php $customModel = Mage::getSingleton('customer/session'); ?>
13
+ <?php if($customModel->isLoggedIn()): ?>
14
+ <input type="hidden" name="email" id="newsletter" value="<?php echo $customModel->getCustomer()->getEmail();?>"/>
15
+ <input type="checkbox" name="is_subscribed" id="subscription" value="1" title="<?php echo $this->__('General Subscription') ?>"<?php if($this->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" /><label for="subscription"><?php echo $this->__('General Subscription') ?></label>
16
+ <?php else: ?>
17
+ <input type="text" name="email" id="newsletter" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" />
18
+ <input type="hidden" name="is_subscribed" id="is_subscribed" value="1" />
19
+ <?php endif; ?>
20
+ </div>
21
+ <?php echo $this->getChildHtml('generalNewsletter') ?>
22
+ <div class="actions">
23
+ <button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
24
+ <img alt="Powered By MailChimp" src="<?php echo $this->getSkinUrl('mailchimppro/images/mailchimp_tile.gif') ?>" style="float:right;"/>
25
+ </div>
26
+ </div>
27
+ </form>
28
+ <script type="text/javascript">
29
+ //<![CDATA[
30
+ var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
31
+ //]]>
32
+ </script>
33
+ </div>
34
+ <?php endif;?>
app/design/frontend/base/default/template/emaildirect/boxes/generalNewsletterMediumBox.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php if($this->canShowMediumBox() && !$this->isForcedToSubscribeCheckout()): ?>
3
+ <div class="block block-subscribe">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
9
+ <br/>
10
+ <ul class="form-list">
11
+ <li class="control">
12
+ <input type="checkbox" name="is_subscribed" id="subscription" value="1" title="<?php echo $this->__('General Subscription') ?>"<?php if($this->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
13
+ <label for="subscription"><?php echo $this->__('General Subscription') ?></label>
14
+ </li>
15
+ <?php echo $this->getChildHtml('generalNewsletter'); ?>
16
+ </ul>
17
+ <div class="actions">
18
+ <img alt="Powered By MailChimp" src="<?php echo $this->getSkinUrl('mailchimppro/images/mailchimp_tile.gif') ?>" style="float:right;"/>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <?php endif;?>
app/design/frontend/base/default/template/emaildirect/checkout/subscribe.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $check = $this->checkStatus();
3
+ $auto = (($check === 1) OR ($check === 3));
4
+ ?>
5
+ <script type="text/javascript">
6
+ addSubscribeToPost = function (element){
7
+
8
+ if( $('emaildirect-subscribe') ){
9
+ $('emaildirect-subscribe').remove();
10
+ }
11
+
12
+ if(element.checked){
13
+ var inputer = new Element('input', { name: "emaildirect_subscribe", id: "emaildirect-subscribe", value: "1", type: "hidden" });
14
+ try {
15
+ Element.insert( Form.findFirstElement(payment.form), inputer);
16
+ } catch(notelem) {
17
+ $("co-payment-form").insert(inputer);
18
+ }
19
+
20
+ }
21
+
22
+ }
23
+ </script>
24
+ <div class="buttons-set"<?php if($check === 3): ?> style="display:none;"<?php endif;?>>
25
+ <input<?php if($auto): ?> checked="checked"<?php endif;?> type="checkbox" onchange="addSubscribeToPost(this);" name="emaildirect_trigger" id="emaildirect-trigger" value="1" title="<?php echo $this->htmlEscape($this->__('Sign Up for Newsletter')) ?>" class="checkbox" />
26
+ <label for="emaildirect-trigger"><?php echo $this->htmlEscape($this->__('Sign Up for Newsletter')) ?></label>
27
+ </div>
28
+
29
+ <script type="text/javascript">
30
+ addSubscribeToPost($('emaildirect-trigger'));
31
+ </script>
app/design/frontend/base/default/template/emaildirect/customer/account/dashboard/info.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="col2-set">
2
+ <div class="col-1">
3
+ <div class="box">
4
+ <div class="box-title">
5
+ <h3><?php echo $this->__('Contact Information') ?></h3>
6
+ <a href="<?php echo $this->getUrl('customer/account/edit') ?>"><?php echo $this->__('Edit') ?></a>
7
+ </div>
8
+ <div class="box-content">
9
+ <p>
10
+ <?php echo $this->htmlEscape($this->getCustomer()->getName()) ?><br />
11
+ <?php echo $this->htmlEscape($this->getCustomer()->getEmail()) ?><br />
12
+ <a href="<?php echo $this->getChangePasswordUrl() ?>"><?php echo $this->__('Change Password') ?></a>
13
+ </p>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ <?php if( $this->isNewsletterEnabled() ): ?>
18
+ <div class="col-2">
19
+ <div class="box">
20
+ <div class="box-title">
21
+ <h3><?php echo $this->__('Newsletters') ?></h3>
22
+ <a href="<?php echo $this->getUrl('newsletter/manage') ?>"><?php echo $this->__('Edit') ?></a>
23
+ </div>
24
+ <div class="box-content">
25
+ <p>
26
+ <?php if( $lists = $this->IsSubscribed($this->getCustomer()->getEmail())): ?>
27
+ <?php echo $this->__("You are currently subscribed to these newsletters: ".implode(",",$lists)) ?>
28
+ <?php else: ?>
29
+ <?php echo $this->__('You are currently not subscribed to any newsletter.') ?>
30
+ <?php endif; ?>
31
+ </p>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <?php endif; ?>
36
+ </div>
app/design/frontend/base/default/template/emaildirect/customer/account/lists.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $lists = $this->getLists();
4
+ $myLists = $this->getSubscribedLists();
5
+ $generalList = $this->getGeneralList();
6
+
7
+ ?>
8
+ <div class="page-title">
9
+ <h1><?php echo $this->__('Newsletter Subscription'); ?></h1>
10
+ </div>
11
+ <form action="<?php echo $this->getUrl('emaildirect/customer_account/saveadditional'); ?>" name="emaildirect_additional" id="emaildirect-additional" method="post">
12
+ <div class="fieldset">
13
+ <?php echo $this->getBlockHtml('formkey'); ?>
14
+ <ul class="emaildirect-additional-lists">
15
+ <!-- General Subscription -->
16
+ <li class="listdata"><?php echo 'General Subscription : '.$this->publicationLabel($generalList); ?>
17
+ <!-- General Subscription -->
18
+ <!-- Additional Lists -->
19
+ <?php
20
+ foreach($lists as $list):
21
+ //$igroups = $list['interest_groupings'];
22
+ ?>
23
+
24
+ <li class="listdata"><?php echo $this->listLabel($generalList,$list); ?>
25
+ </li>
26
+
27
+ <?php endforeach; ?>
28
+ <!-- Additional Lists -->
29
+
30
+ </ul>
31
+ </div>
32
+ <input type="hidden" name="state" value="" id="form-state" />
33
+ <div class="buttons-set">
34
+ <button type="submit" title="<?php echo $this->__('Save') ?>" class="button"><span><span><?php echo $this->__('Save') ?></span></span></button>
35
+ </div>
36
+ </form>
37
+ <script type="text/javascript">
38
+ document.observe("dom:loaded", function() {
39
+ removeManageNewsletter();
40
+ $$('.emaildirect-publication-subscriber').first().observe('change', function(){
41
+ var groupings = $$('.emaildirect-list-subscriber');
42
+
43
+ if(groupings){
44
+ if(this.checked){
45
+ groupings.each(function(index, item){
46
+
47
+ if(this.value != index.value){
48
+ index.removeAttribute('disabled');
49
+ }
50
+
51
+ }.bind(this));
52
+ }else{
53
+ groupings.each(function(index, item){
54
+ if(this.value != index.value){
55
+ index.writeAttribute('disabled', 'disabled');
56
+ }
57
+
58
+ }.bind(this));
59
+ }
60
+ }
61
+ });
62
+ $('form-state').writeAttribute('value', $('emaildirect-additional').serialize());
63
+
64
+ });
65
+ </script>
app/design/frontend/base/default/template/emaildirect/email/order/items.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_quote = $this->getQuote() ?>
2
+ <table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
3
+ <thead>
4
+ <tr>
5
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item') ?></th>
6
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Sku') ?></th>
7
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Qty') ?></th>
8
+ <th align="right" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <?php $i=0; foreach ($_quote->getAllItems() as $_item): ?>
13
+ <?php if($_item->getParentItem()) continue; else $i++; ?>
14
+ <tbody<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
15
+ <?php echo $this->getItemHtml($_item) ?>
16
+ </tbody>
17
+ <?php endforeach; ?>
18
+
19
+ <tbody>
20
+ <?php //echo $this->getChildHtml('order_totals') ?>
21
+ </tbody>
22
+ </table>
23
+
app/design/frontend/base/default/template/emaildirect/email/order/items/order/default.phtml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_item = $this->getItem() ?>
2
+ <?php $_quote = $this->getItem()->getQuote() ?>
3
+ <tr>
4
+ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
5
+ <strong style="font-size:11px;"><?php echo $this->htmlEscape($_item->getName()) ?></strong>
6
+ <?php if ($this->getItemOptions()): ?>
7
+ <dl style="margin:0; padding:0;">
8
+ <?php foreach ($this->getItemOptions() as $option): ?>
9
+ <dt><strong><em><?php echo $option['label'] ?></em></strong></dt>
10
+ <dd style="margin:0; padding:0 0 0 9px;">
11
+ <?php echo nl2br($this->escapeHtml($option['value'])) ?>
12
+ </dd>
13
+ <?php endforeach; ?>
14
+ </dl>
15
+ <?php endif; ?>
16
+ <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
17
+ <?php if ($addInfoBlock) :?>
18
+ <?php echo $addInfoBlock->setItem($_item)->toHtml(); ?>
19
+ <?php endif; ?>
20
+ <?php echo $this->escapeHtml($_item->getDescription()) ?>
21
+ </td>
22
+ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $this->htmlEscape($this->getSku($_item)) ?></td>
23
+ <td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getQtyOrdered()*1 ?></td>
24
+ <td align="right" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
25
+ <?php if ($this->helper('tax')->displaySalesPriceExclTax($_quote->getStoreId()) || $this->helper('tax')->displaySalesBothPrices($_quote->getStore())): ?>
26
+ <?php if ($this->helper('tax')->displaySalesBothPrices($_quote->getStoreId())): ?>
27
+ <span class="label"><?php echo Mage::helper('tax')->__('Excl. Tax'); ?>:</span>
28
+ <?php endif; ?>
29
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'email', $_quote->getStore())): ?>
30
+ <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
31
+ <?php //echo $_quote->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
32
+ <?php else: ?>
33
+ <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_item->getRowTotal()) ?>
34
+ <?php endif; ?>
35
+
36
+
37
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
38
+ <br />
39
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'email', $_quote->getStore())): ?>
40
+ <small>
41
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
42
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount'],true,true); ?></span><br />
43
+ <?php endforeach; ?>
44
+ </small>
45
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_quote->getStoreId())): ?>
46
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
47
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
48
+ <?php endforeach; ?>
49
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'email', $_quote->getStoreId())): ?>
50
+ <small>
51
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
52
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?></span><br />
53
+ <?php endforeach; ?>
54
+ </small>
55
+ <?php endif; ?>
56
+
57
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_quote->getStore())): ?>
58
+ <br />
59
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
60
+ <?php endif; ?>
61
+ <?php endif; ?>
62
+ <?php endif; ?>
63
+
64
+
65
+ <?php if ($this->helper('tax')->displaySalesPriceInclTax($_quote->getStoreId()) || $this->helper('tax')->displaySalesBothPrices($_quote->getStoreId())): ?>
66
+ <?php if ($this->helper('tax')->displaySalesBothPrices($_quote->getStoreId())): ?>
67
+ <br /><span class="label"><?php echo Mage::helper('tax')->__('Incl. Tax'); ?>:</span>
68
+ <?php endif; ?>
69
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
70
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'email', $_quote->getStoreId())): ?>
71
+ <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
72
+ <?php else: ?>
73
+ <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_incl-$_item->getWeeeTaxRowDisposition()) ?>
74
+ <?php endif; ?>
75
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
76
+ <br />
77
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'email', $_quote->getStore())): ?>
78
+ <small>
79
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
80
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount'],true,true); ?></span><br />
81
+ <?php endforeach; ?>
82
+ </small>
83
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_quote->getStoreId())): ?>
84
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
85
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
86
+ <?php endforeach; ?>
87
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'email', $_quote->getStoreId())): ?>
88
+ <small>
89
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
90
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?></span><br />
91
+ <?php endforeach; ?>
92
+ </small>
93
+ <?php endif; ?>
94
+
95
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_quote->getStoreId())): ?>
96
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo Mage::app()->getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
97
+ <?php endif; ?>
98
+ <?php endif; ?>
99
+ <?php endif; ?>
100
+ </td>
101
+ </tr>
102
+ <?php if ($_item->getGiftMessageId() && $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_item->getGiftMessageId())): ?>
103
+ <tr>
104
+ <td colspan="4" style=" border-bottom:2px solid #CCCCCC; padding:3px 9px;">
105
+ <strong style="color:#444444; font-size:11px;"><?php echo $this->__('Gift Message') ?></strong>
106
+ <?php echo $this->__('From:'); ?> <?php echo $this->htmlEscape($_giftMessage->getSender()) ?><br />
107
+ <?php echo $this->__('To:'); ?> <?php echo $this->htmlEscape($_giftMessage->getRecipient()) ?><br />
108
+ <strong><?php echo $this->__('Message:'); ?></strong><br /><?php echo $this->htmlEscape($_giftMessage->getMessage()) ?>
109
+ </td>
110
+ </tr>
111
+ <?php endif; ?>
app/etc/modules/EmailDirect_Integration.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <EmailDirect_Integration>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ <depends>
7
+ <Mage_Newsletter />
8
+ </depends>
9
+ </EmailDirect_Integration>
10
+ </modules>
11
+ </config>
app/locale/en_US/template/email/newsletter_subscr_success_emaildirect.html ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <!--@subject Newsletter subscription success @-->
2
+
3
+ Newsletter subscription success to {{var subscriber.getListName()}}
app/locale/en_US/template/email/newsletter_unsub_success_emaildirect.html ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <!--@subject Newsletter unsubscription success @-->
2
+ Newsletter unsubscription success to {{var subscriber.getListName()}}
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>EmailDirect_Integration</name>
4
+ <version>1.2.8</version>
5
+ <stability>stable</stability>
6
+ <license>GNU</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>EmailDirect integration for magento</summary>
10
+ <description>EmailDirect integration for magento</description>
11
+ <notes>Extension now has the ability to push over some shipping information along with the order.</notes>
12
+ <authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
13
+ <date>2013-04-03</date>
14
+ <time>18:55:35</time>
15
+ <contents><target name="magelocal"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Memberactivity.php" hash="02dd48c236fcaeeaaf112b6cbf173942"/></dir></dir></dir><dir name="Memberactivity"><file name="Grid.php" hash="c8b6d5b867078f56dc17112eccb8a2ca"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="c1723aa50546d11d8e4644bc93905acd"/></dir><dir name="Form"><dir name="Field"><file name="Addressmapfields.php" hash="be908f92dac6d326f5c2defd81a0ec1b"/><file name="Button.php" hash="5eeebb8654eb102d1e0c86792b0f4d41"/><file name="Common.php" hash="2fd2afd99ec1dd3e90f023c8664b66d3"/><file name="Mapfields.php" hash="7c1b30bf71e73af7603a64832abf02d2"/><file name="Shippingmapfields.php" hash="13f478f1794275543e52a6684690edaa"/></dir></dir><file name="Account.php" hash="3289f9687d16f1df81ea8cb5dbaebc99"/></dir><dir name="Convert"><dir name="Profile"><file name="Export.php" hash="a1c7cb8c788062a2e2bde92599bf2919"/></dir></dir></dir></dir><dir name="Checkout"><file name="Subscribe.php" hash="e79060600f511308acf6c802be4ade3f"/></dir><dir name="Customer"><dir name="Account"><dir name="Dashboard"><file name="Info.php" hash="61aec01f715bb1fa96e9d57ea839fc18"/></dir><file name="Lists.php" hash="fd043743461c6e6278a0476be1f0017d"/></dir><file name="Newsletter.php" hash="99614d12c08728454ac373db1f2370d8"/></dir><dir name="Email"><dir name="Order"><dir name="Items"><dir name="Order"><file name="Default.php" hash="8d70e1810d6f9ffabc026f1477f9ea9b"/><file name="Grouped.php" hash="c6f7a34722d4dc6e17afb83fe572d164"/></dir></dir><file name="Items.php" hash="771dd865fae0ad4954d8efda93cb9389"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="9e3ed1a0087b2bb4871c65a6e8a1fee8"/></dir><dir name="Model"><dir name="Custom"><file name="Collection.php" hash="36cac586b65ea06208b2f419f2472fed"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="15452ded72243a699df5d844d55be03e"/></dir><file name="Abandoned.php" hash="7d8090a39de7dbfa1da0bf91906cf051"/><file name="Abandonedlist.php" hash="02579b2052e51c08f43944272504d418"/><file name="Additionallist.php" hash="2cef8c52aa96496bc21991ddff498ee1"/><file name="Checkoutsubscribe.php" hash="f61bf1d4d07950735c6a8979ef973ae0"/><file name="List.php" hash="4dee4e09bde8fc59abb95e097683c0aa"/><file name="Maxtimes.php" hash="a9596823d86d198ac04aebda7f0f7cd8"/><file name="Publication.php" hash="9e70e04ca599a7d808416c17e028df2c"/><file name="Source.php" hash="1d744b9d98b2f6a72c051f76307b4207"/><file name="Time.php" hash="86c0f7c207ada9a0544d024aacfd9940"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="36596e0163463e4c4dbcf241a345512c"/><file name="Database.php" hash="299e97253a66306c092f6df725a1840d"/><file name="Execute.php" hash="d8c0a2946540396790369de027e24994"/><file name="Ftp.php" hash="13d4214335e36a1174e5c53bdaafd743"/><file name="Lists.php" hash="1b6b799138cecbf22739d72259232b90"/><file name="Orders.php" hash="30033851fb047e526c63e44726a0e33c"/><file name="Publications.php" hash="1908c314209f9cb3d1c6b265cf07bbdd"/><file name="Relays.php" hash="b8d5b394582c65846f0da75133ea2732"/><file name="Sources.php" hash="569e1a953b3fc5611e12be95de35555f"/><file name="Suscribers.php" hash="e86874c31f4afc28e710d82380348d7f"/></dir><file name="Observer.php" hash="5d5b684d8baed6b40bc9459351ba9109"/></dir><dir name="controllers"><dir name="Admin"><file name="ExportController.php" hash="d23ab90df4910a7ae4f9c5c491e8fd33"/></dir><dir name="Customer"><file name="AccountController.php" hash="e53818ca3db2df13d16cb9419799ede0"/></dir><file name="AbandonedController.php" hash="c0569a81b853d6153e487549a0a67002"/><file name="ExportController.php" hash="d34f5f1842db64f5eb1f18b4938c8c29"/></dir><dir name="etc"><file name="adminhtml.xml" hash="896c10d8a3f932346e7d301052b1b6a6"/><file name="config.xml" hash="f8366802e8fa3a2549165ea249f20ae6"/><file name="system.xml" hash="ad884626b4d1eae73beecdbb8d0ea869"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-1.0.0.php" hash="a1e6c6e6bb0653698171c7c6dd7d53a1"/><file name="mysql4-upgrade-1.0.13-1.0.14.php" hash="7891e513c4c01931c0c5ee00585c2f34"/><file name="mysql4-upgrade-1.0.19-1.2.0.php" hash="194ac6c94dd8433c4a3227ff7ffd4708"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-connected-ebizmarts-title.png" hash="faf3858f23eafe3a89cce144fef6bd2a"/><file name="emaildirect-section-background.png" hash="c205ce454fe63280d7d7dd74428b7ea4"/><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="db1abaa6a68523af8049781757852af9"/><file name="emaildirect.js" hash="ce03dd6f51ea529fc4acdc5116f4e030"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="bkg_block-title.gif" hash="f8c1f130ad69464fe7aff2f589b2ec75"/><file name="dotted_divider.gif" hash="260ebae91ffb1b7c663906b29a069925"/><file name="emaildirect-tile.png" hash="86a0ed36169ab9691480fc995ab674a8"/><file name="i_block-subscribe.gif" hash="9e5fee06a543742045118a95f2debcb8"/></dir><file name="integration.js" hash="d8c8d5bf0ddb4f6ead23bec8a2814475"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="b6304e77a394a5756fb0e8260282f0d0"/></dir><dir name="template"><dir name="emaildirect"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="da6adeef06766bbaada93244607bef73"/></dir><dir name="form"><dir name="field"><file name="array.phtml" hash="d6af9f840f4dda9c73d106e167ec1bc6"/><file name="button.phtml" hash="74e83344fc8ce6a4bc480828dcf0fd0b"/></dir></dir></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="86339d17e83bd8dcc2a268b3ace3d9e7"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="0a9d6391a114efc879cd0a4690bfc980"/></dir><dir name="template"><dir name="emaildirect"><dir name="boxes"><file name="additionalNewsletter.phtml" hash="0f9d1b59ea045aae31710451f39695f4"/><file name="additionalNewsletterBox.phtml" hash="441b952761083466eaf931e5f7590694"/><file name="generalNewsletter.phtml" hash="fe109f8490e235b98da9d823a5d34ab7"/><file name="generalNewsletterBox.phtml" hash="d98f4fe4582134c0c00cb51490abfbf4"/><file name="generalNewsletterMediumBox.phtml" hash="db51750f55d41dae4b36ec47bc3a0931"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="cfc5c70f68327277616cc6d08cdb2fc8"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="ccebdd94f03c03368f6b33780e68875b"/></dir><file name="lists.phtml" hash="c808667ec668455b39c76dfd400b2abb"/></dir></dir><dir name="email"><dir name="order"><dir name="items"><dir name="order"><file name="default.phtml" hash="2d65f3d02b9baa08969d68f2a2cca348"/></dir></dir><file name="items.phtml" hash="e6b15e6460010c5acae66017d177bfb9"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="newsletter_subscr_success_emaildirect.html" hash="f6afb69d207bbc3f8920e7a72ac9dd07"/><file name="newsletter_unsub_success_emaildirect.html" hash="bd9f97e8f5485180d4420097b5200ef4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EmailDirect_Integration.xml" hash="2d2666e6d9cd8d40a4974d5e242721d6"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/adminhtml/default/default/emaildirect/emaildirect-connected-ebizmarts-title.png ADDED
Binary file
skin/adminhtml/default/default/emaildirect/emaildirect-section-background.png ADDED
Binary file
skin/adminhtml/default/default/emaildirect/emaildirect-tab.png ADDED
Binary file
skin/adminhtml/default/default/emaildirect/emaildirect.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ul.tabs a.emaildirect-section:hover { background-color:#D8E6E6; background-image:url(images/tabs_link_over_bg.gif); }
2
+
3
+ ul.tabs a.emaildirect-section,
4
+ ul.tabs a.emaildirect-section:hover {border-bottom:none; padding:0.5em 0.5em 0 1.5em; text-indent:-9999px;}
5
+
6
+ ul.tabs a.emaildirect-section span,
7
+ ul.tabs a.emaildirect-section:hover span { background:url(emaildirect-tab.png) no-repeat 0 0; overflow:hidden; padding:0; width:120px; height:24px;}
8
+
9
+ ul.tabs a.emaildirect-section.active, ul.tabs a.emaildirect-section.active:hover {background-color: white;}
10
+
11
+ h3.emaildirect-header { background:url(emaildirect-tab.png) no-repeat 0 0; height: 24px; overflow:hidden; padding:0; width:120px; text-indent:-9999px; }
12
+
13
+ /*h3.mailchimp-header { background:url(emaildirect-connected-ebizmarts-title.png) no-repeat 0 0; height: 64px; overflow:hidden; padding:0; width:200px; text-indent:-9999px; }*/
14
+
15
+ fieldset#emaildirect_general {background:url(emaildirect-section-background.png) no-repeat right top; }
16
+
17
+ div.emaildirect-notice{
18
+ background:#EAF0EE;
19
+ border:1px solid #CCCCCC;
20
+ margin-bottom:10px;
21
+ padding:11px 0 0 10px;
22
+ }
skin/adminhtml/default/default/emaildirect/emaildirect.js ADDED
@@ -0,0 +1 @@
 
1
+ //Place EmailDirect Javascript here
skin/frontend/base/default/emaildirect/images/bkg_block-title.gif ADDED
Binary file
skin/frontend/base/default/emaildirect/images/dotted_divider.gif ADDED
Binary file
skin/frontend/base/default/emaildirect/images/emaildirect-tile.png ADDED
Binary file
skin/frontend/base/default/emaildirect/images/i_block-subscribe.gif ADDED
Binary file
skin/frontend/base/default/emaildirect/integration.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ removeManageNewsletter = function(){
2
+ var newsletter = $$('div.block-content ul li a[href*="newsletter/manage"]');
3
+ if(newsletter.length){
4
+ newsletter.first().up().remove();
5
+ }
6
+ }
7
+
8
+ document.observe("dom:loaded", function() {
9
+
10
+ var emaildirectEnabled = $$('div.block-content ul li a[href*="emaildirect/customer_account/index"]');
11
+
12
+ if(emaildirectEnabled.length){
13
+ removeManageNewsletter();
14
+ var editLink = $$('div.my-account a[href*="newsletter/manage"]');
15
+ if(editLink.length){
16
+ editLink.first().writeAttribute('href', emaildirectEnabled.first().readAttribute('href'));
17
+ }
18
+ }
19
+
20
+ });