EmailDirect_Integration - Version 2.0.17

Version Notes

Store identifier (name, ID or code) is now included in custom fields. This will allow you to associate customers with specific stores in a multi-store environment.

Cron can now be accessed by a URL for situations when traditional Cron setups fail.

Troubleshooting page can now view system and exception log files to aid in troubleshooting.

Download this release

Release Info

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


Code changes from version 2.0.16 to 2.0.17

Files changed (42) hide show
  1. app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned.php +1 -1
  2. app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details.php +14 -14
  3. app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Cron/Url/Info.php +69 -0
  4. app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Info.php +21 -21
  5. app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Log.php +45 -31
  6. app/code/community/EmailDirect/Integration/Helper/Abandoned.php +160 -168
  7. app/code/community/EmailDirect/Integration/Helper/Data.php +824 -774
  8. app/code/community/EmailDirect/Integration/Helper/Fields.php +2 -0
  9. app/code/community/EmailDirect/Integration/Helper/Troubleshooting.php +718 -711
  10. app/code/community/EmailDirect/Integration/Model/Abandoned/Observer.php +4 -1
  11. app/code/community/EmailDirect/Integration/Model/System/Config/Source/Store.php +27 -0
  12. app/code/community/EmailDirect/Integration/controllers/AbandonedController.php +274 -261
  13. app/code/community/EmailDirect/Integration/controllers/Admin/DiagnosticController.php +0 -491
  14. app/code/community/EmailDirect/Integration/controllers/Admin/TroubleshootingController.php +0 -208
  15. app/code/community/EmailDirect/Integration/controllers/{Admin → Adminhtml/EmailDirect}/AbandonedController.php +1 -1
  16. app/code/community/EmailDirect/Integration/controllers/Adminhtml/EmailDirect/DiagnosticController.php +489 -0
  17. app/code/community/EmailDirect/Integration/controllers/{Admin → Adminhtml/EmailDirect}/ExportController.php +2 -2
  18. app/code/community/EmailDirect/Integration/controllers/Adminhtml/EmailDirect/TroubleshootingController.php +244 -0
  19. app/code/community/EmailDirect/Integration/controllers/CronController.php +25 -0
  20. app/code/community/EmailDirect/Integration/etc/adminhtml.xml +2 -2
  21. app/code/community/EmailDirect/Integration/etc/config.xml +325 -323
  22. app/code/community/EmailDirect/Integration/etc/system.xml +148 -70
  23. app/design/adminhtml/default/default/layout/emaildirect.xml +94 -94
  24. app/design/adminhtml/default/default/template/emaildirect/diagnostics.phtml +16 -16
  25. app/design/adminhtml/default/default/template/emaildirect/system/config/fieldset/hint.phtml +2 -2
  26. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/api.phtml +11 -11
  27. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/cron/url/info.phtml +16 -0
  28. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/diagnostics.phtml +3 -3
  29. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/date_range.phtml +21 -21
  30. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/orders.phtml +2 -2
  31. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/products.phtml +2 -2
  32. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/info.phtml +1 -1
  33. app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/logging.phtml +6 -10
  34. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/status.phtml +20 -20
  35. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/cron.phtml +2 -2
  36. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/download.phtml +1 -1
  37. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/help.phtml +1 -1
  38. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/log.phtml +103 -55
  39. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/settings.phtml +1 -1
  40. app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/submit.phtml +1 -1
  41. package.xml +8 -6
  42. skin/adminhtml/default/default/emaildirect/emaildirect.css +9 -0
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned.php CHANGED
@@ -34,7 +34,7 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned extends Mage_Adminhtml_B
34
  $data = Mage::helper('emaildirect')->getCronLastRun(0,'cron_last_run');
35
 
36
  if ($data['class'] == 'ab_ng')
37
- $url = Mage::helper('emaildirect')->getAdminUrl("ed_integration/admin_troubleshooting/index",array('active_tab' => 'trouble_cron'));
38
  Mage::getSingleton('adminhtml/session')->addWarning("There appears to be a problem with your cron settings. Please make sure that cron is running so that Abandoned Carts can be processed. Click <a href='{$url}'>here</a> for more information.");
39
 
40
  parent::__construct();
34
  $data = Mage::helper('emaildirect')->getCronLastRun(0,'cron_last_run');
35
 
36
  if ($data['class'] == 'ab_ng')
37
+ $url = Mage::helper('emaildirect')->getAdminUrl("adminhtml/emaildirect_troubleshooting/index",array('active_tab' => 'trouble_cron'));
38
  Mage::getSingleton('adminhtml/session')->addWarning("There appears to be a problem with your cron settings. Please make sure that cron is running so that Abandoned Carts can be processed. Click <a href='{$url}'>here</a> for more information.");
39
 
40
  parent::__construct();
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details.php CHANGED
@@ -10,7 +10,7 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details extends Mage_Adm
10
  $this->_mode = 'details';
11
 
12
  parent::__construct();
13
-
14
  if (!$this->isGuestCustomer())
15
  {
16
  $this->_addButton('view_customer', array(
@@ -18,39 +18,39 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details extends Mage_Adm
18
  'onclick' => 'setLocation(\'' . $this->getUrl('adminhtml/customer/edit', array('id'=> $this->getCustomerId(), 'active_tab'=>'cart')) . '\')',
19
  ), 0);
20
  }
21
-
22
  $this->_removeButton('delete');
23
  $this->_removeButton('reset');
24
  $this->_removeButton('save');
25
  $this->setId('abandoned_details');
26
  }
27
-
28
  public function getCustomerId()
29
  {
30
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
31
-
32
  return $abandoned_cart->getCustomerId();
33
  }
34
-
35
  public function isGuestCustomer()
36
  {
37
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
38
-
39
  return $abandoned_cart->getCustomerGroupId() == 0;
40
  }
41
 
42
  public function getHeaderText()
43
  {
44
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
45
-
46
  $name = "";
47
  $additional = "";
48
-
49
  if ($abandoned_cart->getCustomerGroupId() == 0)
50
  {
51
  // Guest
52
  $email = $abandoned_cart->getEmail();
53
-
54
  $additional = "Guest Customer ({$email})";
55
  }
56
  else
@@ -59,9 +59,9 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details extends Mage_Adm
59
  $name = $abandoned_cart->getCustomerFirstname() . " " . $abandoned_cart->getCustomerLastname();
60
  $additional = "{$name} ({$email})";
61
  }
62
-
63
  $date = Mage::helper('core')->formatTime($abandoned_cart->getUpdatedAt(), 'medium', true);
64
-
65
  return Mage::helper('emaildirect')->__('Abandoned Cart - ' . $additional . " - Abandoned On: " . $date);
66
  }
67
 
@@ -69,12 +69,12 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details extends Mage_Adm
69
  {
70
  return parent::getUrl($params, $params2);
71
  }
72
-
73
  public function getDownloadUrl()
74
  {
75
- return $this->getUrl('ed_integration/admin_troubleshooting/download/');
76
  }
77
-
78
  public function getBackUrl()
79
  {
80
  return Mage::helper('emaildirect')->getAdminUrl('*/*/index');
10
  $this->_mode = 'details';
11
 
12
  parent::__construct();
13
+
14
  if (!$this->isGuestCustomer())
15
  {
16
  $this->_addButton('view_customer', array(
18
  'onclick' => 'setLocation(\'' . $this->getUrl('adminhtml/customer/edit', array('id'=> $this->getCustomerId(), 'active_tab'=>'cart')) . '\')',
19
  ), 0);
20
  }
21
+
22
  $this->_removeButton('delete');
23
  $this->_removeButton('reset');
24
  $this->_removeButton('save');
25
  $this->setId('abandoned_details');
26
  }
27
+
28
  public function getCustomerId()
29
  {
30
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
31
+
32
  return $abandoned_cart->getCustomerId();
33
  }
34
+
35
  public function isGuestCustomer()
36
  {
37
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
38
+
39
  return $abandoned_cart->getCustomerGroupId() == 0;
40
  }
41
 
42
  public function getHeaderText()
43
  {
44
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
45
+
46
  $name = "";
47
  $additional = "";
48
+
49
  if ($abandoned_cart->getCustomerGroupId() == 0)
50
  {
51
  // Guest
52
  $email = $abandoned_cart->getEmail();
53
+
54
  $additional = "Guest Customer ({$email})";
55
  }
56
  else
59
  $name = $abandoned_cart->getCustomerFirstname() . " " . $abandoned_cart->getCustomerLastname();
60
  $additional = "{$name} ({$email})";
61
  }
62
+
63
  $date = Mage::helper('core')->formatTime($abandoned_cart->getUpdatedAt(), 'medium', true);
64
+
65
  return Mage::helper('emaildirect')->__('Abandoned Cart - ' . $additional . " - Abandoned On: " . $date);
66
  }
67
 
69
  {
70
  return parent::getUrl($params, $params2);
71
  }
72
+
73
  public function getDownloadUrl()
74
  {
75
+ return $this->getUrl('adminhtml/emaildirect_troubleshooting/download/');
76
  }
77
+
78
  public function getBackUrl()
79
  {
80
  return Mage::helper('emaildirect')->getAdminUrl('*/*/index');
app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Cron/Url/Info.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Cron_Url_Info extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ private $_helper = null;
6
+ private $_logger = null;
7
+ private $_status = null;
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setTemplate('emaildirect/system/config/form/field/cron/url/info.phtml');
13
+ $this->_helper = Mage::helper('emaildirect');
14
+ $this->_logger = Mage::helper('emaildirect/troubleshooting');
15
+ }
16
+
17
+ public function render(Varien_Data_Form_Element_Abstract $element)
18
+ {
19
+ $this->setElement($element);
20
+ $useContainerId = $element->getData('use_container_id');
21
+ return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5">%s</td></tr>',
22
+ $element->getHtmlId(), $this->_toHtml()
23
+ );
24
+ }
25
+
26
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
27
+ {
28
+ $this->setElement($element);
29
+ $html = $this->_toHtml();
30
+ return $html;
31
+ }
32
+
33
+ public function getCronPassword()
34
+ {
35
+ return $this->_helper->config('cron_url_password');
36
+ }
37
+
38
+ public function getCronUrl($process = null, $password = null)
39
+ {
40
+ $params = array();
41
+
42
+ if ($process != null) {
43
+ $params['process'] = $process;
44
+ }
45
+
46
+ if ($password != null) {
47
+ $params['password'] = $password;
48
+ }
49
+
50
+ return Mage::getUrl('emaildirect/cron/run', $params);
51
+ }
52
+
53
+ public function getProcessOptions()
54
+ {
55
+ $password = $this->getCronPassword();
56
+
57
+ $options = array(
58
+ array('label' => "Abandoned Carts", 'param' => 'abandoned'),
59
+ array('label' => "Orders", 'param' => 'orders')
60
+ );
61
+
62
+ foreach ($options as &$option) {
63
+ $option['url'] = $this->getCronUrl($option['param'],$password);
64
+ }
65
+
66
+ return $options;
67
+
68
+ }
69
+ }
app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Info.php CHANGED
@@ -2,25 +2,25 @@
2
 
3
  class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Info extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
- private $_helper = null;
6
 
7
- public function __construct()
8
- {
9
- parent::__construct();
10
- $this->setTemplate('emaildirect/system/config/form/field/info.phtml');
11
- $this->_helper = Mage::helper('emaildirect');
12
- }
13
-
14
- public function render(Varien_Data_Form_Element_Abstract $element)
15
- {
16
- $useContainerId = $element->getData('use_container_id');
17
- return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5">%s</td></tr>',
18
- $element->getHtmlId(), $this->_toHtml()
19
- );
20
- }
21
-
22
- public function isWebsiteConfig()
23
- {
24
- return $this->_helper->isWebsiteConfig();
25
- }
26
- }
2
 
3
  class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Info extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
+ private $_helper = null;
6
 
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setTemplate('emaildirect/system/config/form/field/info.phtml');
11
+ $this->_helper = Mage::helper('emaildirect');
12
+ }
13
+
14
+ public function render(Varien_Data_Form_Element_Abstract $element)
15
+ {
16
+ $useContainerId = $element->getData('use_container_id');
17
+ return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5">%s</td></tr>',
18
+ $element->getHtmlId(), $this->_toHtml()
19
+ );
20
+ }
21
+
22
+ public function isWebsiteConfig()
23
+ {
24
+ return $this->_helper->isWebsiteConfig();
25
+ }
26
+ }
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Log.php CHANGED
@@ -4,35 +4,49 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Log
4
  extends Mage_Adminhtml_Block_Template
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
7
-
8
- public function getTabLabel()
9
- {
10
- return Mage::helper('emaildirect')->__('Log File');
11
- }
12
-
13
- public function getTabTitle()
14
- {
15
- return Mage::helper('emaildirect')->__('Log file');
16
- }
17
-
18
- public function canShowTab()
19
- {
20
- return true;
21
- }
22
-
23
- public function isHidden()
24
- {
25
- return false;
26
- }
27
-
28
- public function __construct()
29
- {
30
- parent::__construct();
31
- $this->setTemplate('emaildirect/troubleshooting/view/tab/log.phtml');
32
- }
33
-
34
- public function getLogFile()
35
- {
36
- return Mage::helper('emaildirect/troubleshooting')->getLogFileContents();
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
4
  extends Mage_Adminhtml_Block_Template
5
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
  {
7
+
8
+ public function getTabLabel()
9
+ {
10
+ return Mage::helper('emaildirect')->__('Log File');
11
+ }
12
+
13
+ public function getTabTitle()
14
+ {
15
+ return Mage::helper('emaildirect')->__('Log file');
16
+ }
17
+
18
+ public function canShowTab()
19
+ {
20
+ return true;
21
+ }
22
+
23
+ public function isHidden()
24
+ {
25
+ return false;
26
+ }
27
+
28
+ public function __construct()
29
+ {
30
+ parent::__construct();
31
+ $this->setTemplate('emaildirect/troubleshooting/view/tab/log.phtml');
32
+ }
33
+
34
+ public function getLogFile()
35
+ {
36
+ return Mage::helper('emaildirect/troubleshooting')->getLogFileContents();
37
+ }
38
+
39
+ public function getLogFiles()
40
+ {
41
+ return array(
42
+ Mage::helper('emaildirect/troubleshooting')->getLogFileName(),
43
+ "exception.log",
44
+ "system.log"
45
+ );
46
+ }
47
+
48
+ public function getSelectedLog()
49
+ {
50
+ return Mage::helper('emaildirect/troubleshooting')->getLogFileName();
51
+ }
52
  }
app/code/community/EmailDirect/Integration/Helper/Abandoned.php CHANGED
@@ -2,175 +2,167 @@
2
 
3
  class EmailDirect_Integration_Helper_Abandoned extends EmailDirect_Integration_Helper_Data
4
  {
5
- private $_sequences = null;
6
- private $_current_sequence = 0;
7
- private $_sequence_enabled = false;
8
- private $_sequence_field = "";
9
-
10
- public function getAbandonedUrl($quote)
11
  {
12
  // We are using comma separated lists for the ID's and Quantities so that it takes up less
13
  // space when we generate the Querystring
14
-
15
- $item_data = array();
16
-
17
- $this->debug("Get Abandoned URL");
18
-
19
- foreach ($quote->getAllItems() as $item)
20
- {
21
- $product = $this->getProduct($item);
22
- $parent_id = $item->getParentItemId();
23
- $item_id = $item->getId();
24
-
25
- if ($parent_id != null)
26
- {
27
- $item_data[$parent_id]['option'] = $product->getId();
28
- }
29
- else
30
- {
31
- $item_data[$item_id]['product_id'] = $product->getId();
32
- $item_data[$item_id]['qty'] = $item->getQty();
33
-
34
- if ($item->getProductType() == 'grouped')
35
- {
36
- $option = $item->getOptionByCode('product_type');
37
- if ($option)
38
- {
39
- $product = $option->getProduct();
40
- $item_data[$item_id]['option'] = $product->getId();
41
- }
42
- }
43
- else if ($item->getProductType() == 'bundle')
44
- {
45
- $option = $item->getOptionByCode('info_buyRequest');
46
-
47
- if ($option)
48
- {
49
- $data = unserialize($option->getValue());
50
-
51
- $bundle_option = "";
52
-
53
- foreach ($data['bundle_option'] as $id => $value)
54
- {
55
- if ($bundle_option != "")
56
- $bundle_option .= "-";
57
-
58
- $bundle_option .= "{$id}=";
59
-
60
- if (is_array($value))
61
- {
62
- $bundle_option .= implode(":",$value);
63
- }
64
- else
65
- {
66
- $qty = $data['bundle_option_qty'][$id];
67
- $bundle_option .= "{$value}~{$qty}";
68
- }
69
- }
70
- $item_data[$item_id]['bundle_option'] = $bundle_option;
71
- }
72
- }
73
- }
74
- }
75
-
76
- $ids = "";
77
- $qtys = "";
78
-
79
- $this->debug("Item Data:");
80
- $this->debug($item_data);
81
-
82
- foreach ($item_data as $item)
83
- {
84
- if ($ids != "")
85
- {
86
- $ids .= ",";
87
- $qtys .= ",";
88
- }
89
-
90
- $ids .= $item['product_id'];
91
- $qtys .= $item['qty'];
92
-
93
- if (isset($item['bundle_option']))
94
- $ids .= "|{$item['bundle_option']}";
95
- else if (isset($item['option']))
96
- $ids .= "|{$item['option']}";
97
- }
98
-
99
- $url_data = array("quote" => $quote->getId(), "id" => $ids, "qty" => $qtys);
100
-
101
- //$this->logAndDebug($url_data, "Abandoned Url Data");
102
- $this->debug("URL Data:");
103
- $this->debug($url_data);
104
-
105
- $url = base64_encode(serialize($url_data));
106
-
107
- $url = Mage::getUrl('emaildirect/abandoned/restore',array('_secure'=>true)) . "?cart={$url}";
108
-
109
- $this->debug("URL:");
110
- $this->debug($url);
111
-
112
  return $url;
113
- }
114
-
115
- public function getLastOrder($quote)
116
- {
117
- $this->logAndDebug("Get Last Order");
118
- $customer_id = $quote->getData('customer_id');
119
-
120
- $this->logAndDebug("Customer ID: {$customer_id}");
121
-
122
- $orders = Mage::getResourceModel('sales/order_collection')
123
- ->addFieldToSelect('*')
124
- ->addFieldToFilter('customer_id', $customer_id)
125
- ->addAttributeToSort('created_at', 'DESC')
126
- ->setPageSize(1);
127
-
128
- $this->logAndDebug("Order Count: " . $orders->getSize());
129
- if ($orders->getSize() <= 0)
130
- {
131
- $this->logAndDebug("No Orders Found");
132
- return null;
133
- }
134
-
135
- $this->logAndDebug("Order Found");
136
- $order = $orders->getFirstItem();
137
-
138
- return $order;
139
- }
140
-
141
- public function addSequence(&$merge_vars)
142
- {
143
- if (!$this->_sequence_enabled)
144
- return;
145
-
146
- if (!isset($this->_sequences[$this->_current_sequence]))
147
- $this->_current_sequence = 0;
148
-
149
- $merge_vars[$this->_sequence_field] = $this->_sequences[$this->_current_sequence++];
150
- }
151
-
152
- public function setupSequence()
153
- {
154
- $this->_sequence_enabled = $this->config('abandonedsequence_enabled');
155
-
156
- if (!$this->_sequence_enabled)
157
- return;
158
-
159
- $sequences = str_replace("\r\n","\n",$this->config('abandonedsequence_options'));
160
- $this->_current_sequence = $this->config('abandonedsequence_current');
161
-
162
- if (!is_numeric($this->_current_sequence))
163
- $this->_current_sequence = 0;
164
-
165
- $this->_sequences = explode("\n",$sequences);
166
- $this->_sequence_field = $this->config('abandonedsequence_field');
167
- }
168
-
169
- public function saveCurrentSequence()
170
- {
171
- if (!$this->_sequence_enabled)
172
- return;
173
-
174
- $this->updateConfig('abandonedsequence_current',$this->_current_sequence);
175
- }
176
- }
 
 
 
 
 
2
 
3
  class EmailDirect_Integration_Helper_Abandoned extends EmailDirect_Integration_Helper_Data
4
  {
5
+ private $_sequences = null;
6
+ private $_current_sequence = 0;
7
+ private $_sequence_enabled = false;
8
+ private $_sequence_field = "";
9
+
10
+ public function getAbandonedUrl($quote)
11
  {
12
  // We are using comma separated lists for the ID's and Quantities so that it takes up less
13
  // space when we generate the Querystring
14
+
15
+ $item_data = array();
16
+
17
+ $this->debug("Get Abandoned URL");
18
+
19
+ foreach ($quote->getAllItems() as $item) {
20
+ $product = $this->getProduct($item);
21
+ $parent_id = $item->getParentItemId();
22
+ $item_id = $item->getId();
23
+
24
+ if ($parent_id != null) {
25
+ $item_data[$parent_id]['option'] = $product->getId();
26
+ } else {
27
+ $item_data[$item_id]['product_id'] = $product->getId();
28
+ $item_data[$item_id]['qty'] = $item->getQty();
29
+
30
+ if ($item->getProductType() == 'grouped') {
31
+ $option = $item->getOptionByCode('product_type');
32
+ if ($option) {
33
+ $product = $option->getProduct();
34
+ $item_data[$item_id]['option'] = $product->getId();
35
+ }
36
+ } else if ($item->getProductType() == 'bundle') {
37
+ $option = $item->getOptionByCode('info_buyRequest');
38
+
39
+ if ($option) {
40
+ $data = unserialize($option->getValue());
41
+
42
+ $bundle_option = "";
43
+
44
+ foreach ($data['bundle_option'] as $id => $value) {
45
+ if ($bundle_option != "") {
46
+ $bundle_option .= "-";
47
+ }
48
+
49
+ $bundle_option .= "{$id}=";
50
+
51
+ if (is_array($value)) {
52
+ $bundle_option .= implode(":",$value);
53
+ } else {
54
+ $qty = $data['bundle_option_qty'][$id];
55
+ $bundle_option .= "{$value}~{$qty}";
56
+ }
57
+ }
58
+ $item_data[$item_id]['bundle_option'] = $bundle_option;
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ $ids = "";
65
+ $qtys = "";
66
+
67
+ $this->debug("Item Data:");
68
+ $this->debug($item_data);
69
+
70
+ foreach ($item_data as $item) {
71
+ if ($ids != "") {
72
+ $ids .= ",";
73
+ $qtys .= ",";
74
+ }
75
+
76
+ $ids .= $item['product_id'];
77
+ $qtys .= $item['qty'];
78
+
79
+ if (isset($item['bundle_option'])) {
80
+ $ids .= "|{$item['bundle_option']}";
81
+ } else if (isset($item['option'])) {
82
+ $ids .= "|{$item['option']}";
83
+ }
84
+ }
85
+
86
+ $url_data = array("quote" => $quote->getId(), "id" => $ids, "qty" => $qtys);
87
+
88
+ //$this->logAndDebug($url_data, "Abandoned Url Data");
89
+ $this->debug("URL Data:");
90
+ $this->debug($url_data);
91
+
92
+ $url = base64_encode(serialize($url_data));
93
+
94
+ $url = Mage::getUrl('emaildirect/abandoned/restore',array('_secure' => true, 'cart' => $url));
95
+
96
+ $this->debug("URL:");
97
+ $this->debug($url);
98
+
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  return $url;
100
+ }
101
+
102
+ public function getLastOrder($quote)
103
+ {
104
+ $this->logAndDebug("Get Last Order");
105
+ $customer_id = $quote->getData('customer_id');
106
+
107
+ $this->logAndDebug("Customer ID: {$customer_id}");
108
+
109
+ $orders = Mage::getResourceModel('sales/order_collection')
110
+ ->addFieldToSelect('*')
111
+ ->addFieldToFilter('customer_id', $customer_id)
112
+ ->addAttributeToSort('created_at', 'DESC')
113
+ ->setPageSize(1);
114
+
115
+ $this->logAndDebug("Order Count: " . $orders->getSize());
116
+
117
+ if ($orders->getSize() <= 0) {
118
+ $this->logAndDebug("No Orders Found");
119
+ return null;
120
+ }
121
+
122
+ $this->logAndDebug("Order Found");
123
+ $order = $orders->getFirstItem();
124
+
125
+ return $order;
126
+ }
127
+
128
+ public function addSequence(&$merge_vars)
129
+ {
130
+ if (!$this->_sequence_enabled) {
131
+ return;
132
+ }
133
+
134
+ if (!isset($this->_sequences[$this->_current_sequence])) {
135
+ $this->_current_sequence = 0;
136
+ }
137
+
138
+ $merge_vars[$this->_sequence_field] = $this->_sequences[$this->_current_sequence++];
139
+ }
140
+
141
+ public function setupSequence()
142
+ {
143
+ $this->_sequence_enabled = $this->config('abandonedsequence_enabled');
144
+
145
+ if (!$this->_sequence_enabled) {
146
+ return;
147
+ }
148
+
149
+ $sequences = str_replace("\r\n","\n",$this->config('abandonedsequence_options'));
150
+ $this->_current_sequence = $this->config('abandonedsequence_current');
151
+
152
+ if (!is_numeric($this->_current_sequence)) {
153
+ $this->_current_sequence = 0;
154
+ }
155
+
156
+ $this->_sequences = explode("\n",$sequences);
157
+ $this->_sequence_field = $this->config('abandonedsequence_field');
158
+ }
159
+
160
+ public function saveCurrentSequence()
161
+ {
162
+ if (!$this->_sequence_enabled) {
163
+ return;
164
+ }
165
+
166
+ $this->updateConfig('abandonedsequence_current',$this->_current_sequence);
167
+ }
168
+ }
app/code/community/EmailDirect/Integration/Helper/Data.php CHANGED
@@ -2,36 +2,36 @@
2
 
3
  class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
- const DATE_FORMAT = "Y-m-d H:i:s";
6
 
7
- const DISABLED_REASON_PREFIX = "Skipping";
8
 
9
- protected $_logger = null;
10
 
11
- public function __construct()
12
- {
13
- $this->_logger = Mage::helper('emaildirect/troubleshooting');
14
- }
15
 
16
- protected function logAndDebug($data)
17
- {
18
- $this->_logger->logAndDebug($data);
19
- }
20
 
21
  public function log($data)
22
  {
23
  $this->_logger->log($data);
24
  }
25
 
26
- protected function debug($data)
27
- {
28
- $this->_logger->debug($data);
29
- }
30
 
31
- protected function debugHeader($data, $level = 2)
32
- {
33
- $this->_logger->debugHeader($data, $level);
34
- }
35
 
36
  public function getCronNotRunMinutes()
37
  {
@@ -43,927 +43,977 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
43
  return round(abs(time() - strtotime($date)) / 60,0);
44
  }
45
 
46
- public function getMergeVars($customer)
47
- {
48
- $merge_vars = array();
49
- $maps = unserialize( $this->config('map_fields', $customer->getStoreId()) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- if ($maps)
52
- {
53
- $this->debug("Customer Field Mapping");
54
- $this->processMap($merge_vars, $maps, $customer);
55
- }
56
 
57
- $address_maps = unserialize( $this->config('address_fields', $customer->getStoreId()) );
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- // Process address
60
- if ($address_maps)
61
- {
62
- $address = $customer->getBillingAddress();
63
- if ($address)
64
- {
65
- $this->debug("Address Field Mapping");
66
- $this->processMap($merge_vars, $address_maps, $address);
67
- }
68
- }
69
 
70
- return $merge_vars;
71
- }
72
 
73
- protected function processMap(&$merge_vars,$maps, $data)
74
  {
75
- $request = Mage::app()->getRequest();
76
-
77
- $this->debug("Mappings");
78
- $this->debug($maps);
79
-
80
- $this->debug("Map Data");
81
- $this->debug($data);
82
-
83
- foreach ($maps as $map)
84
- {
85
- // Make sure we have values for both
86
- if (!isset($map['magento']) || !isset($map['emaildirect']))
87
- continue;
88
-
89
- $custom_field = $map['magento'];
90
- $emaildirect_field = $map['emaildirect'];
91
-
92
- if ($emaildirect_field && $custom_field)
93
- {
94
- switch ($custom_field)
95
- {
96
- case 'state_code':
97
- {
98
- $region_id = $data->getData('region_id');
99
-
100
- if (!$region_id)
101
- continue;
102
-
103
- $region = Mage::getModel('directory/region')->load($region_id);
104
-
105
- if (!$region)
106
- continue;
107
-
108
- $state_code = $region->getCode();
109
-
110
- if ($state_code != "")
111
- $merge_vars[$emaildirect_field] = $state_code;
112
- } break;
113
- default:
114
- {
115
- if (($value = (string)$data->getData(strtolower($custom_field))) || ($value = (string)$request->getPost(strtolower($custom_field))))
116
- $merge_vars[$emaildirect_field] = $value;
117
- } break;
118
- }
119
- }
120
- }
121
- }
122
-
123
- protected function getProduct($item)
124
- {
125
- if (get_class($item) == "Varien_Object") {
126
- return $item->getProduct();
127
- }
128
-
129
- $product_id = $item->getProductId();
130
-
131
- if (!$product_id)
132
- return null;
133
-
134
- $product = Mage::getModel('catalog/product')->load($product_id);
135
-
136
- if ($product == null || !$product->getId())
137
- return null;
138
-
139
- return $product;
140
- }
141
-
142
- // Used to restore configurable products to the cart
143
- public function getConfigurableOptions($product, $simple_product_id)
144
- {
145
- $type_instance = $product->getTypeInstance(true);
146
- $child_products = $type_instance->getUsedProducts(null, $product);
147
- $attrbutes = $type_instance->getUsedProductAttributes($product);
148
-
149
- $super_attrbutes = array();
150
-
151
- foreach ($child_products as $child)
152
- {
153
- if ($child->getId() == $simple_product_id)
154
- {
155
- foreach ($attrbutes as $attribute)
156
- {
157
- $super_attrbutes[$attribute->getAttributeId()] = $child->getData($attribute->getAttributeCode());
158
- }
159
- }
160
- }
161
-
162
- return $super_attrbutes;
163
- }
164
-
165
- public function getStoreId($code)
166
- {
167
- if ($code == null)
168
- return 0;
169
-
170
- try
171
- {
172
- $store = Mage::getModel("core/store")->load($code);
173
- return $store->getId();
174
- }
175
- catch (Exception $e)
176
- {
177
- return 0;
178
- }
179
- }
180
-
181
- public function getAdminStore()
182
- {
183
- $code = Mage::app()->getRequest()->getParam('store');
184
-
185
- return $this->getStoreId($code);
186
- }
187
-
188
- public function getUrlParams()
189
- {
190
- $param_options = array('store','group','website');
191
-
192
- $request = Mage::app()->getRequest();
193
-
194
- foreach ($param_options as $param)
195
- {
196
- if ($request->getParam($param) != null)
197
- return array($param => $request->getParam($param));
198
- }
199
-
200
- return array();
201
- }
202
-
203
- public function forceSubscribe()
204
- {
205
- $option = (int)$this->config('checkout_subscribe');
206
-
207
- // Force subscribe on
208
- if ($option == 3)
209
- return true;
210
-
211
- return false;
212
- }
213
-
214
- public function getOrderExportCollection($from, $to, $include, $store = null)
215
- {
216
- $from_date = Mage::getModel('core/date')->gmtDate(null,strtotime($from)); // 2010-05-11 15:00:00
217
-
218
- $to_date = Mage::getModel('core/date')->gmtDate(null,strtotime($to)); // 2010-05-11 15:00:00
219
-
220
- $orders = Mage::getModel('sales/order')->getCollection()
221
- ->addAttributeToFilter('created_at', array('from' => $from_date, 'to' => $to_date));
222
-
223
- $mode = $this->config('send_field');
224
-
225
- if ($mode == 'state')
226
- {
227
- $states = Mage::helper('emaildirect')->config('send_states');
228
- $state_list = explode(",",$states);
229
- $orders->addAttributeToFilter('state', array('in' => $state_list));
230
- }
231
- else
232
- {
233
- $statuses = Mage::helper('emaildirect')->config('send_statuses');
234
- $status_list = explode(",",$statuses);
235
- $orders->addAttributeToFilter('status', array('in' => $status_list));
236
- }
237
-
238
- if ($store != null && $store != 0)
239
- $orders->addAttributeToFilter('store_id', array('eq' => $store));
240
-
241
- if (!$include)
242
- {
243
- $orders->getSelect()->joinLeft(array('ed_or' => Mage::getSingleton('core/resource')->getTableName("emaildirect/order")),"ed_or.order_id=main_table.entity_id",array(
244
- 'date_sent' => "date_sent"
245
- ));
246
- $orders->getSelect()->where('`ed_or`.`date_sent` IS NULL');
247
- }
248
-
249
- return $orders;
250
- }
251
-
252
- public function getProductExportCollection($include = false, $store = null)
253
- {
254
- $products = Mage::getModel('catalog/product')->getCollection();
255
-
256
- if ($include == false)
257
- $products->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
258
-
259
- if ($store != null && $store != 0)
260
- $products->addStoreFilter($store);
261
 
262
- return $products;
263
- }
 
 
 
264
 
265
- public function formatSize($size)
266
- {
267
- try
268
- {
269
- if ($size == 0 || $size == null || $size == "")
270
- return "0 b";
271
 
272
- $unit = array('b','kb','mb','gb','tb','pb');
 
273
 
274
- $numeric_size = @round($size/pow(1024,($i=$size?floor(log($size,1024)):0)),2);
275
 
276
- if (!isset($unit[$i]))
277
- return "Unknown";
278
 
279
- return "{$numeric_size} {$unit[$i]}";
280
- }
281
- catch (Exception $e)
282
- {
283
- $this->_logger->logException($e);
284
- return "Unknown";
285
- }
286
- }
287
 
288
- public function getDuration($timeline, $zero = false)
289
- {
290
- $periods = array('day' => 86400, 'hour' => 3600, 'minute' => 60);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
- $ret = "";
 
293
 
294
- foreach($periods as $name => $seconds)
295
- {
296
- $num = floor($timeline / $seconds);
 
297
 
298
- if ($num > 0 || ($num == 0 && $zero == true))
299
- {
300
- $timeline -= ($num * $seconds);
301
- $ret .= $num.' '.$name.(($num > 1 || $num == 0) ? 's' : '').' ';
302
- }
303
- }
 
 
 
 
304
 
305
- return trim($ret);
306
- }
 
307
 
308
- public function timeElapsed2string($time)
309
- {
310
- if ($time == "")
311
- return "";
312
 
313
- if (is_string($time))
314
- $time = strtotime($time);
 
315
 
316
- $timeline = time() - $time;
317
 
318
- return $this->getDuration($timeline);
319
- }
 
 
 
320
 
321
- public function getExportFileName($name,$full = true)
322
- {
323
- $filename = "{$name}.csv";
324
 
325
- if ($full)
326
- return Mage::getBaseDir('export').'/' . $filename;
 
327
 
328
- return $filename;
329
- }
 
330
 
331
- public function getApiKey($store = null)
332
- {
333
- return $this->config('apikey',$store);
334
- }
335
 
336
- public function isWebsiteConfig()
337
- {
338
- $request = Mage::app()->getRequest();
339
 
340
- if ($request->getParam('website') && !$request->getParam('store'))
341
- return true;
342
 
343
- return false;
344
- }
345
 
346
- public function updateConfig($path, $value, $store = 0, $base_path = 'general')
347
- {
348
- $scope = "stores";
349
 
350
- if ($store == null)
351
- $store = $this->getCurrentStore();
 
 
 
 
 
 
 
 
 
 
352
 
353
- if ($store == 0)
354
- $scope = "default";
355
 
356
- $config = Mage::getConfig();
357
- $config->saveConfig("emaildirect/{$base_path}/{$path}",$value,$scope,$store);
358
- $config->cleanCache();
359
- }
 
 
 
360
 
361
- public function deleteConfig($path, $store = 0, $base_path = 'general')
362
- {
363
- $scope = "stores";
364
 
365
- if ($store == null)
366
- $store = $this->getCurrentStore();
 
367
 
368
- if ($store == 0)
369
- $scope = "default";
370
 
371
- $config = Mage::getConfig();
372
- $config->deleteConfig("emaildirect/{$base_path}/{$path}",$scope,$store);
373
- $config->cleanCache();
374
- }
375
 
376
- public function resetCurrentStore()
377
- {
378
- $this->_current_store = null;
379
- }
380
 
381
- public function getCurrentStore()
382
- {
383
- $store = Mage::app()->getStore()->getId();
384
- $config_store = Mage::app()->getRequest()->getParam('store');
385
- $on_config = $this->onConfigPage();
 
386
 
387
- if ($config_store && $on_config)
388
- $store = $config_store;
389
- //else if (!is_null($this->_current_store))
390
- // $store = $this->_current_store;
391
 
392
- if (is_string($store))
393
- return $this->getStoreId($store);
394
 
395
- return $store;
396
- }
397
 
398
- private function _config($value, $section, $store = null)
399
- {
400
- if (is_null($store))
401
- $store = $this->getCurrentStore();
 
 
 
 
402
 
403
- //echo "emaildirect/{$section}/{$value}";
 
 
404
 
405
- $realvalue = Mage::getStoreConfig("emaildirect/{$section}/{$value}", $store);
406
 
407
- return $realvalue;
408
- }
 
409
 
410
- public function config($value, $store = null)
411
- {
412
- return $this->_config($value,'general',$store);
413
- }
 
 
414
 
415
- public function exportConfig($value, $store = null)
416
- {
417
- return $this->_config($value,'export',$store);
418
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
 
420
- public function troubleConfig($value, $store = null)
421
- {
422
- return $this->_config($value,'troubleshooting',$store);
423
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
 
425
  public function getEmailDirectColumnOptions()
426
  {
427
- $columns = Mage::getSingleton('emaildirect/wrapper_database')->getAllColumns();
428
 
429
- $custom_fields = Mage::helper('emaildirect/fields')->getCustomFields(true);
430
 
431
- $invalid_columns = array();
432
 
433
- foreach ($custom_fields as $cf)
434
- {
435
- $invalid_columns[] = $cf['name'];
436
- }
437
 
438
- $options = array();
439
 
440
- if (!isset($columns))
441
- return $options;
442
 
443
- foreach ($columns as $column)
444
- {
445
- if ($column->IsCustom == 'true' && !in_array((string)$column->ColumnName,$invalid_columns))
446
- {
447
- $key = (string)$column->ColumnName;
448
 
449
- $options[$key] = $key;
450
- }
451
- }
452
 
453
- return $options;
454
- }
455
 
456
- public function getShippingColumnOptions()
457
  {
458
- $options = array(
459
- 'shipping_code' => 'Shipping Code',
460
- 'shipping_description' => 'Shipping Description',
461
- 'carrier_code' => 'Tracking Carrier Code',
462
- 'title' => 'Tracking Title',
463
- 'number' => 'Tracking Number');
464
-
465
- return $options;
466
  }
467
 
468
- public function getDefaultPublication($storeId)
469
- {
470
- return $this->config('publication', $storeId);
471
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
 
473
- public function isSignupTest()
474
- {
475
- return Mage::app()->getRequest()->getParam('signup_test') == "true";
476
- }
 
 
477
 
478
- public function canCapture()
479
- {
480
- if (!$this->canEdirect())
481
- return false;
482
 
483
- if ((bool)($this->config('capture_enabled') != 0) && !Mage::helper('customer')->isLoggedIn())
484
- return true;
 
 
485
 
486
- return false;
487
- }
488
 
489
- public function canSendWishlist()
490
- {
491
- if (!$this->canEdirect())
492
- return false;
493
 
494
- if (Mage::helper('customer')->isLoggedIn() && (bool)($this->config('wishlist_enabled') != 0))
495
- return true;
 
 
496
 
497
- return false;
498
- }
499
 
500
- public function canSendLastLogin()
501
- {
502
- if (!$this->canEdirect())
503
- return false;
504
 
505
- if (Mage::helper('customer')->isLoggedIn() && (bool)($this->config('lastlogin_enabled') != 0))
506
- return true;
507
 
508
- return false;
509
- }
510
 
511
- public function isSignupEnabled()
512
- {
513
- if (!$this->canEdirect())
514
- return false;
 
 
515
 
516
- if ((bool)($this->config('signup_enabled') == 0) || (bool)($this->config('signup_activated') == 0))
517
- return false;
518
 
519
- return true;
520
- }
521
 
522
- public function canShowSignup()
523
- {
524
- if ($this->isSignupTest())
525
- return true;
526
 
527
- if (!$this->isSignupEnabled())
528
- return false;
529
 
530
- $last_closed = Mage::getModel('core/cookie')->get('ed_signup');
 
 
 
531
 
532
- $recurrence = $this->config('signup_recurrence');
 
533
 
534
- if ($last_closed == "")
535
- return true;
536
 
537
- switch ($recurrence)
538
- {
539
- case "once": return false;
540
- default:
541
- $last_closed = strtotime("+{$recurrence}",$last_closed); break;
542
- }
543
 
544
- if ($last_closed > time())
545
- return false;
 
546
 
547
- return true;
548
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
 
550
- public function canCheckoutSubscribe()
551
- {
552
- if (!$this->canEdirect())
553
- return false;
554
 
555
- return (bool)($this->config('checkout_subscribe') != 0);
556
- }
557
 
558
- public function canEdirect()
559
- {
560
- // Necessary?
561
- //Mage::helper('core')->isModuleOutputEnabled('EmailDirect_Integration');
562
 
563
- $active = $this->config('active');
564
- $setup = $this->config('setup');
 
 
 
565
 
566
- if ($active && $setup)
567
- return true;
 
568
 
569
- return $this->onConfigPage();
570
- }
 
 
 
571
 
572
- public function onConfigPage()
573
- {
574
- $controller = Mage::app()->getRequest()->getControllerName();
575
 
576
- if ($controller == 'system_config')
577
- return true;
578
 
579
- return false;
580
- }
581
 
582
- public function registerGuestCustomer($order)
583
- {
584
- if (Mage::registry('ed_guest_customer'))
585
- return;
586
 
587
- $customer = new Varien_Object;
588
 
589
- $customer->setId(time());
590
- $customer->setEmail($order->getBillingAddress()->getEmail());
591
- $customer->setStoreId($order->getStoreId());
592
- $customer->setFirstname($order->getBillingAddress()->getFirstname());
593
- $customer->setLastname($order->getBillingAddress()->getLastname());
594
- $customer->setPrimaryBillingAddress($order->getBillingAddress());
595
- $customer->setPrimaryShippingAddress($order->getShippingAddress());
596
- Mage::register('ed_guest_customer', $customer, TRUE);
597
- }
598
 
599
- public function getFullStoreName($store)
600
- {
601
- if ($store == null)
602
- return "Unknown";
603
 
604
- $store_name = "";
605
 
606
- if ($website = $store->getWebsite())
607
- $store_name .= $website->getName() . " - ";
 
 
608
 
609
- if ($group = $store->getGroup())
610
- $store_name .= $group->getName() . " - ";
 
 
 
 
 
 
 
 
 
611
 
612
- $store_name .= $store->getName();
 
613
 
614
- return $store_name;
615
- }
 
 
616
 
617
- public function getFullStoreNameById($store_id)
618
- {
619
- $store = Mage::getModel('core/store')->load($store_id);
620
 
621
- return $this->getFullStoreName($store);
622
- }
623
 
624
- public function getAbandonedStatus($helpLink = true)
625
- {
626
- $stores = Mage::app()->getStores();
627
 
628
- $abandoned_status = array(
629
- 'enabled' => false,
630
- 'cron_last_run' => $this->getCronLastRunHtml($helpLink),
631
- 'stores' => array()
632
- );
633
 
634
- foreach ($stores as $store)
635
- {
636
- $data = array();
 
637
 
638
- $data['id'] = $store->getId();
639
- $data['name'] = $this->getFullStoreName($store);
640
- $data['enabled'] = $this->getAbandonedEnabled($store->getId());
641
- if ($data['enabled'])
642
- $abandoned_status['enabled'] = true;
643
 
644
- $data['last_run'] = $this->getAbandonedLastRunhtml($store->getId());
 
 
 
645
 
646
- $abandoned_status['stores'][] = $data;
647
- }
 
 
 
648
 
649
- return $abandoned_status;
650
- }
651
 
652
- public function getCronLastRun($store = null, $config = 'abandoned_last_run')
653
- {
654
- $last_run = $this->config($config, $store);
655
 
656
- $data = array();
 
657
 
658
- if ($last_run != null)
659
- {
660
- $data['last_run'] = $last_run;
 
 
661
 
662
- $minutes = round(abs(time() - strtotime($last_run)) / 60,0);
 
663
 
664
- $data['minutes'] = $minutes;
 
665
 
666
- if ($minutes > $this->getCronNotRunMinutes())
667
- $data['class'] = 'ab_ng';
668
- else
669
- $data['class'] = 'ab_ok';
 
670
 
671
- $data['last_run_display'] = Mage::helper('core')->formatTime($last_run, 'long', true);
672
- $data['time_elapsed'] = $this->timeElapsed2string($last_run);
673
- }
674
- else
675
- {
676
- $data['last_run'] = 'NEVER';
677
- $data['minutes'] = -1;
678
- $data['last_run_display'] = 'NEVER';
679
- $data['time_elapsed'] = "";
680
- $data['class'] = 'ab_ng';
681
- }
682
 
683
- return $data;
684
- }
685
 
686
- private function getLastRunHtml($store = null, $config = 'abandoned_last_run', $helpLink = true)
687
- {
688
- $data = $this->getCronLastRun($store,$config);
689
- $warning_img = "";
690
 
691
- if ($data['class'] == "ab_ng" && $helpLink)
692
- $warning_img = "<a href='" . $this->getAdminUrl("ed_integration/admin_troubleshooting/index") . "#abandoned_carts' target='_blank'><img src='" . Mage::getDesign()->getSkinUrl('images/warning_msg_icon.gif') . "' class='cron_warning' /></a>";
693
 
694
- $time_elapsed = "";
 
695
 
696
- if ($data['time_elapsed'] != '')
697
- $time_elapsed = "({$data['time_elapsed']})";
 
 
698
 
699
- return "<span class='{$data['class']}'>{$data['last_run_display']} {$time_elapsed}</span>{$warning_img}";
700
- }
701
 
702
- public function getAbandonedLastRunHtml($store = null)
703
- {
704
- return $this->getLastRunHtml($store);
705
- }
706
 
707
- public function getCronLastRunHtml($helpLink = true)
708
- {
709
- return $this->getLastRunHtml(0, 'cron_last_run', $helpLink);
710
- }
711
 
712
- public function getAdminUrlParams($params = array())
713
- {
714
- $request = Mage::app()->getRequest();
715
- $url_params = array('website','store');
716
 
717
- foreach ($url_params as $up)
718
- {
719
- if ($request->getParam($up))
720
- $params[$up] = $request->getParam($up);
721
- }
722
 
723
- return $params;
724
- }
 
725
 
726
- public function getAdminUrl($url, $params = array())
727
- {
728
- $params = $this->getAdminUrlParams($params);
729
 
730
- return Mage::helper("adminhtml")->getUrl($url, $params);
731
- }
732
 
733
- public function getOrdersEnabled()
734
- {
735
- $active = $this->config('active');
736
- $setup = $this->config('setup');
737
- $sendit = $this->config('sendorder');
738
 
739
- if (!$sendit || !$setup || !$active)
740
- return false;
 
741
 
742
- return true;
743
- }
744
 
745
- public function getBatchEnabled()
746
- {
747
- $active = $this->config('active');
748
- $setup = $this->config('setup');
749
- $batch = $this->config('batch_enabled');
750
 
751
- if (!$batch || !$setup || !$active)
752
- return false;
753
 
754
- return true;
755
- }
 
756
 
757
- public function getBatchOnly()
758
- {
759
- $batch_only = $this->config('batch_only');
760
 
761
- if (!$batch_only)
762
- return false;
763
 
764
- return true;
765
- }
 
 
 
 
766
 
767
- public function getDisabledReason()
768
- {
769
- if (!$this->config('active'))
770
- return "EmailDirect Module is Disabled.";
771
 
772
- if (!$this->config('setup'))
773
- return "EmailDirect Module is not configured with a valid API Key.";
774
 
775
- return "";
776
- }
 
777
 
778
- public function getOrdersDisabledReason()
779
- {
780
- $base = $this->getDisabledReason();
781
 
782
- if ($base != "")
783
- return $base;
784
 
785
- return "Sending Orders is disabled.";
786
- }
787
 
788
- public function getWishlistDisabledReason()
789
- {
790
- $base = $this->getDisabledReason();
791
 
792
- if ($base != "")
793
- return $base;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
794
 
795
- if (!Mage::helper('customer')->isLoggedIn())
796
- return "Customer not logged in";
 
 
 
 
 
 
 
 
 
 
797
 
798
- return "Wishlist is disabled.";
799
- }
800
 
801
- public function getLastLoginDisabledReason()
802
- {
803
- $base = $this->getDisabledReason();
804
 
805
- if ($base != "")
806
- return $base;
 
 
 
 
807
 
808
- //if (!Mage::helper('customer')->isLoggedIn())
809
- //return "Customer not logged in";
810
 
811
- return "Last Login is disabled.";
812
- }
813
 
814
- public function getBatchDisabledReason()
815
- {
816
- $base = $this->getDisabledReason();
817
 
818
- if ($base != "")
819
- return $base;
 
820
 
821
- return "Sending Orders in batch is disabled.";
822
- }
 
 
823
 
824
- public function getAbandonedEnabled($store = null)
825
- {
826
- $active = $this->config('active', $store);
827
- $setup = $this->config('setup', $store);
828
- $sendit = $this->config('sendabandoned', $store);
829
- $abandoned_setup = $this->config('abandonedsetup', $store);
830
 
831
- if (!$sendit || !$setup || !$active || !$abandoned_setup)
832
- return false;
833
 
834
- return true;
835
- }
836
 
837
- public function getAbandonedDisabledReason()
838
- {
839
- $base = $this->getDisabledReason();
 
 
 
 
 
 
840
 
841
- if ($base != "")
842
- return $base;
843
 
844
- if (!$this->config('abandonedsetup'))
845
- return "Abandoned Cart Processing Not Setup.";
 
 
846
 
847
- return "Sending Abandoned Carts is Disabled";
848
- }
 
 
 
 
849
 
850
- // Newsletter
 
 
 
851
 
852
- private function getSubscriberData($data, $email)
853
- {
854
- $properties = Mage::getSingleton('emaildirect/wrapper_subscribers')->getProperties($email);
855
- $pub_count = 0;
856
- $list_count = 0;
857
- $publication_subscribed = false;
858
 
859
- if (!isset($properties->Publications->Publication))
860
- return $data;
861
 
862
- foreach($properties->Publications->Publication as $publication)
863
- {
864
- if ((int) $publication->PublicationID == $data['publication']['id'])
865
- {
866
- $data['publication']['subscribed'] = true;
867
- $publication_subscribed = true;
868
- $pub_count++;
869
- }
870
- }
871
-
872
- $data['count'] = $pub_count;
873
-
874
- // Disable the lists if the publication is not subscribed
875
- if (!$publication_subscribed)
876
- {
877
- foreach ($data['lists'] as $list_id => $list)
878
- {
879
- $data['lists'][$list_id]['disabled'] = true;
880
- }
881
- $data['list_count'] = 0;
882
- return $data;
883
- }
884
-
885
- if (!isset($properties->Lists->List))
886
- return $data;
887
-
888
- foreach($properties->Lists->List as $list)
889
- {
890
- $list_id = (int)$list->ListID;
891
-
892
- if (isset($data['lists'][$list_id]))
893
- {
894
- $data['lists'][$list_id]['subscribed'] = true;
895
- $list_count++;
896
- }
897
- }
898
-
899
- $data['count'] = $pub_count + $list_count;
900
- $data['list_count'] = $list_count;
901
-
902
- return $data;
903
- }
904
-
905
- private function getPublication()
906
- {
907
- $general = $this->config('publication');
908
-
909
- $rc = Mage::getSingleton('emaildirect/wrapper_publications')->getPublication($general);
910
- return array('id' =>(int) $rc->PublicationID,'name'=> (string)$rc->Name, 'subscribed' => false, 'disabled' => false);
911
- }
912
-
913
- private function getLists()
914
- {
915
- $list_data = array();
916
- $additional_lists = $this->config('additional_lists');
917
-
918
- if ($additional_lists == "")
919
- return $list_data;
920
-
921
- $active_lists = explode(",",$additional_lists);
922
-
923
- $all_lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
924
-
925
- foreach($all_lists as $list)
926
- {
927
- if (in_array($list['id'],$active_lists))
928
- $list_data[$list['id']] = array(
929
- 'id' => $list['id'],
930
- 'name' => $list['name'],
931
- 'subscribed' => false,
932
- 'disabled' => false);
933
- }
934
-
935
- return $list_data;
936
- }
937
-
938
- public function getSubscriptions($email)
939
- {
940
- $this->_logger->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CUSTOMER);
941
- $this->_logger->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
942
-
943
- $data = array(
944
- 'publication' => array('id' => -1,'name' => 'Unknown', 'subscribed' => false, 'disabled' => true),
945
- 'lists' => array(),
946
- 'count' => 0,
947
- 'list_count' => 0
948
- );
949
-
950
- try
951
- {
952
- $data['publication'] = $this->getPublication();
953
- $data['lists'] = $this->getLists();
954
-
955
- $data = $this->getSubscriberData($data, $email);
956
-
957
- $this->_logger->resetLogLevel();
958
-
959
- return $data;
960
- }
961
- catch (Exception $e)
962
- {
963
- Mage::logException($e);
964
- $this->_logger->logException($e);
965
- $this->_logger->resetLogLevel();
966
- return $data;
967
- }
968
- }
969
  }
2
 
3
  class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
+ const DATE_FORMAT = "Y-m-d H:i:s";
6
 
7
+ const DISABLED_REASON_PREFIX = "Skipping";
8
 
9
+ protected $_logger = null;
10
 
11
+ public function __construct()
12
+ {
13
+ $this->_logger = Mage::helper('emaildirect/troubleshooting');
14
+ }
15
 
16
+ protected function logAndDebug($data)
17
+ {
18
+ $this->_logger->logAndDebug($data);
19
+ }
20
 
21
  public function log($data)
22
  {
23
  $this->_logger->log($data);
24
  }
25
 
26
+ protected function debug($data)
27
+ {
28
+ $this->_logger->debug($data);
29
+ }
30
 
31
+ protected function debugHeader($data, $level = 2)
32
+ {
33
+ $this->_logger->debugHeader($data, $level);
34
+ }
35
 
36
  public function getCronNotRunMinutes()
37
  {
43
  return round(abs(time() - strtotime($date)) / 60,0);
44
  }
45
 
46
+ public function getStoreMap($merge_vars, $store = null)
47
+ {
48
+ if ($store == null) {
49
+ $store = Mage::app()->getStore();
50
+ }
51
+
52
+ $store_config = Mage::helper('emaildirect')->config('store_send_type');
53
+
54
+ $store_value = $store->getId();
55
+
56
+ switch ($store_config) {
57
+ case "name": $store_value = $store->getName(); break;
58
+ case "code": $store_value = $store->getCode(); break;
59
+ }
60
+
61
+ $merge_vars["Store"] = $store_value;
62
+
63
+ return $merge_vars;
64
+ }
65
+
66
+ public function getMergeVars($customer)
67
+ {
68
+ $merge_vars = array();
69
+
70
+ $maps = unserialize( $this->config('map_fields', $customer->getStoreId()) );
71
 
72
+ if ($maps)
73
+ {
74
+ $this->debug("Customer Field Mapping");
75
+ $this->processMap($merge_vars, $maps, $customer);
76
+ }
77
 
78
+ $address_maps = unserialize( $this->config('address_fields', $customer->getStoreId()) );
79
+
80
+ // Process address
81
+ if ($address_maps)
82
+ {
83
+ $address = $customer->getBillingAddress();
84
+ if ($address)
85
+ {
86
+ $this->debug("Address Field Mapping");
87
+ $this->processMap($merge_vars, $address_maps, $address);
88
+ }
89
+ }
90
 
91
+ $merge_vars = $this->getStoreMap($merge_vars);
 
 
 
 
 
 
 
 
 
92
 
93
+ return $merge_vars;
94
+ }
95
 
96
+ protected function processMap(&$merge_vars,$maps, $data)
97
  {
98
+ $request = Mage::app()->getRequest();
99
+
100
+ $this->debug("Mappings");
101
+ $this->debug($maps);
102
+
103
+ $this->debug("Map Data");
104
+ $this->debug($data);
105
+
106
+ foreach ($maps as $map)
107
+ {
108
+ // Make sure we have values for both
109
+ if (!isset($map['magento']) || !isset($map['emaildirect']))
110
+ continue;
111
+
112
+ $custom_field = $map['magento'];
113
+ $emaildirect_field = $map['emaildirect'];
114
+
115
+ if ($emaildirect_field && $custom_field)
116
+ {
117
+ switch ($custom_field)
118
+ {
119
+ case 'state_code':
120
+ {
121
+ $region_id = $data->getData('region_id');
122
+
123
+ if (!$region_id)
124
+ continue;
125
+
126
+ $region = Mage::getModel('directory/region')->load($region_id);
127
+
128
+ if (!$region)
129
+ continue;
130
+
131
+ $state_code = $region->getCode();
132
+
133
+ if ($state_code != "")
134
+ $merge_vars[$emaildirect_field] = $state_code;
135
+ } break;
136
+ default:
137
+ {
138
+ $value = (string)$data->getData(strtolower($custom_field));
139
+
140
+ if ($value === null) {
141
+ $value = (string)$request->getPost(strtolower($custom_field));
142
+ }
143
+
144
+ if ($value !== null) {
145
+ $merge_vars[$emaildirect_field] = $value;
146
+ }
147
+ } break;
148
+ }
149
+ }
150
+ }
151
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
+ protected function getProduct($item)
154
+ {
155
+ if (get_class($item) == "Varien_Object") {
156
+ return $item->getProduct();
157
+ }
158
 
159
+ $product_id = $item->getProductId();
 
 
 
 
 
160
 
161
+ if (!$product_id)
162
+ return null;
163
 
164
+ $product = Mage::getModel('catalog/product')->load($product_id);
165
 
166
+ if ($product == null || !$product->getId())
167
+ return null;
168
 
169
+ return $product;
170
+ }
 
 
 
 
 
 
171
 
172
+ // Used to restore configurable products to the cart
173
+ public function getConfigurableOptions($product, $simple_product_id)
174
+ {
175
+ $type_instance = $product->getTypeInstance(true);
176
+ $child_products = $type_instance->getUsedProducts(null, $product);
177
+ $attrbutes = $type_instance->getUsedProductAttributes($product);
178
+
179
+ $super_attrbutes = array();
180
+
181
+ foreach ($child_products as $child)
182
+ {
183
+ if ($child->getId() == $simple_product_id)
184
+ {
185
+ foreach ($attrbutes as $attribute)
186
+ {
187
+ $super_attrbutes[$attribute->getAttributeId()] = $child->getData($attribute->getAttributeCode());
188
+ }
189
+ }
190
+ }
191
 
192
+ return $super_attrbutes;
193
+ }
194
 
195
+ public function getStoreId($code)
196
+ {
197
+ if ($code == null)
198
+ return 0;
199
 
200
+ try
201
+ {
202
+ $store = Mage::getModel("core/store")->load($code);
203
+ return $store->getId();
204
+ }
205
+ catch (Exception $e)
206
+ {
207
+ return 0;
208
+ }
209
+ }
210
 
211
+ public function getAdminStore()
212
+ {
213
+ $code = Mage::app()->getRequest()->getParam('store');
214
 
215
+ return $this->getStoreId($code);
216
+ }
 
 
217
 
218
+ public function getUrlParams()
219
+ {
220
+ $param_options = array('store','group','website');
221
 
222
+ $request = Mage::app()->getRequest();
223
 
224
+ foreach ($param_options as $param)
225
+ {
226
+ if ($request->getParam($param) != null)
227
+ return array($param => $request->getParam($param));
228
+ }
229
 
230
+ return array();
231
+ }
 
232
 
233
+ public function forceSubscribe()
234
+ {
235
+ $option = (int)$this->config('checkout_subscribe');
236
 
237
+ // Force subscribe on
238
+ if ($option == 3)
239
+ return true;
240
 
241
+ return false;
242
+ }
 
 
243
 
244
+ public function getOrderExportCollection($from, $to, $include, $store = null)
245
+ {
246
+ $from_date = Mage::getModel('core/date')->gmtDate(null,strtotime($from)); // 2010-05-11 15:00:00
247
 
248
+ $to_date = Mage::getModel('core/date')->gmtDate(null,strtotime($to)); // 2010-05-11 15:00:00
 
249
 
250
+ $orders = Mage::getModel('sales/order')->getCollection()
251
+ ->addAttributeToFilter('created_at', array('from' => $from_date, 'to' => $to_date));
252
 
253
+ $mode = $this->config('send_field');
 
 
254
 
255
+ if ($mode == 'state')
256
+ {
257
+ $states = Mage::helper('emaildirect')->config('send_states');
258
+ $state_list = explode(",",$states);
259
+ $orders->addAttributeToFilter('state', array('in' => $state_list));
260
+ }
261
+ else
262
+ {
263
+ $statuses = Mage::helper('emaildirect')->config('send_statuses');
264
+ $status_list = explode(",",$statuses);
265
+ $orders->addAttributeToFilter('status', array('in' => $status_list));
266
+ }
267
 
268
+ if ($store != null && $store != 0)
269
+ $orders->addAttributeToFilter('store_id', array('eq' => $store));
270
 
271
+ if (!$include)
272
+ {
273
+ $orders->getSelect()->joinLeft(array('ed_or' => Mage::getSingleton('core/resource')->getTableName("emaildirect/order")),"ed_or.order_id=main_table.entity_id",array(
274
+ 'date_sent' => "date_sent"
275
+ ));
276
+ $orders->getSelect()->where('`ed_or`.`date_sent` IS NULL');
277
+ }
278
 
279
+ return $orders;
280
+ }
 
281
 
282
+ public function getProductExportCollection($include = false, $store = null)
283
+ {
284
+ $products = Mage::getModel('catalog/product')->getCollection();
285
 
286
+ if ($include == false)
287
+ $products->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
288
 
289
+ if ($store != null && $store != 0)
290
+ $products->addStoreFilter($store);
 
 
291
 
292
+ return $products;
293
+ }
 
 
294
 
295
+ public function formatSize($size)
296
+ {
297
+ try
298
+ {
299
+ if ($size == 0 || $size == null || $size == "")
300
+ return "0 b";
301
 
302
+ $unit = array('b','kb','mb','gb','tb','pb');
 
 
 
303
 
304
+ $numeric_size = @round($size/pow(1024,($i=$size?floor(log($size,1024)):0)),2);
 
305
 
306
+ if (!isset($unit[$i]))
307
+ return "Unknown";
308
 
309
+ return "{$numeric_size} {$unit[$i]}";
310
+ }
311
+ catch (Exception $e)
312
+ {
313
+ $this->_logger->logException($e);
314
+ return "Unknown";
315
+ }
316
+ }
317
 
318
+ public function getDuration($timeline, $zero = false)
319
+ {
320
+ $periods = array('day' => 86400, 'hour' => 3600, 'minute' => 60);
321
 
322
+ $ret = "";
323
 
324
+ foreach($periods as $name => $seconds)
325
+ {
326
+ $num = floor($timeline / $seconds);
327
 
328
+ if ($num > 0 || ($num == 0 && $zero == true))
329
+ {
330
+ $timeline -= ($num * $seconds);
331
+ $ret .= $num.' '.$name.(($num > 1 || $num == 0) ? 's' : '').' ';
332
+ }
333
+ }
334
 
335
+ return trim($ret);
336
+ }
337
+
338
+ public function timeElapsed2string($time)
339
+ {
340
+ if ($time == "")
341
+ return "";
342
+
343
+ if (is_string($time))
344
+ $time = strtotime($time);
345
+
346
+ $timeline = time() - $time;
347
+
348
+ return $this->getDuration($timeline);
349
+ }
350
+
351
+ public function getExportFileName($name,$full = true)
352
+ {
353
+ $filename = "{$name}.csv";
354
+
355
+ if ($full)
356
+ return Mage::getBaseDir('export').'/' . $filename;
357
+
358
+ return $filename;
359
+ }
360
+
361
+ public function getApiKey($store = null)
362
+ {
363
+ return $this->config('apikey',$store);
364
+ }
365
+
366
+ public function isWebsiteConfig()
367
+ {
368
+ $request = Mage::app()->getRequest();
369
+
370
+ if ($request->getParam('website') && !$request->getParam('store'))
371
+ return true;
372
+
373
+ return false;
374
+ }
375
+
376
+ public function updateConfig($path, $value, $store = 0, $base_path = 'general')
377
+ {
378
+ $scope = "stores";
379
+
380
+ if ($store == null)
381
+ $store = $this->getCurrentStore();
382
+
383
+ if ($store == 0)
384
+ $scope = "default";
385
+
386
+ $config = Mage::getConfig();
387
+ $config->saveConfig("emaildirect/{$base_path}/{$path}",$value,$scope,$store);
388
+ $config->cleanCache();
389
+ }
390
+
391
+ public function deleteConfig($path, $store = 0, $base_path = 'general')
392
+ {
393
+ $scope = "stores";
394
+
395
+ if ($store == null)
396
+ $store = $this->getCurrentStore();
397
+
398
+ if ($store == 0)
399
+ $scope = "default";
400
+
401
+ $config = Mage::getConfig();
402
+ $config->deleteConfig("emaildirect/{$base_path}/{$path}",$scope,$store);
403
+ $config->cleanCache();
404
+ }
405
+
406
+ public function resetCurrentStore()
407
+ {
408
+ $this->_current_store = null;
409
+ }
410
+
411
+ public function getCurrentStore()
412
+ {
413
+ $store = Mage::app()->getStore()->getId();
414
+ $config_store = Mage::app()->getRequest()->getParam('store');
415
+ $on_config = $this->onConfigPage();
416
+
417
+ if ($config_store && $on_config)
418
+ $store = $config_store;
419
+ //else if (!is_null($this->_current_store))
420
+ // $store = $this->_current_store;
421
 
422
+ if (is_string($store))
423
+ return $this->getStoreId($store);
424
+
425
+ return $store;
426
+ }
427
+
428
+ private function _config($value, $section, $store = null)
429
+ {
430
+ if (is_null($store))
431
+ $store = $this->getCurrentStore();
432
+
433
+ //echo "emaildirect/{$section}/{$value}";
434
+
435
+ $realvalue = Mage::getStoreConfig("emaildirect/{$section}/{$value}", $store);
436
+
437
+ return $realvalue;
438
+ }
439
+
440
+ public function config($value, $store = null)
441
+ {
442
+ return $this->_config($value,'general',$store);
443
+ }
444
+
445
+ public function exportConfig($value, $store = null)
446
+ {
447
+ return $this->_config($value,'export',$store);
448
+ }
449
+
450
+ public function troubleConfig($value, $store = null)
451
+ {
452
+ return $this->_config($value,'troubleshooting',$store);
453
+ }
454
 
455
  public function getEmailDirectColumnOptions()
456
  {
457
+ $columns = Mage::getSingleton('emaildirect/wrapper_database')->getAllColumns();
458
 
459
+ $custom_fields = Mage::helper('emaildirect/fields')->getCustomFields(true);
460
 
461
+ $invalid_columns = array();
462
 
463
+ foreach ($custom_fields as $cf)
464
+ {
465
+ $invalid_columns[] = $cf['name'];
466
+ }
467
 
468
+ $options = array();
469
 
470
+ if (!isset($columns))
471
+ return $options;
472
 
473
+ foreach ($columns as $column)
474
+ {
475
+ if ($column->IsCustom == 'true' && !in_array((string)$column->ColumnName,$invalid_columns))
476
+ {
477
+ $key = (string)$column->ColumnName;
478
 
479
+ $options[$key] = $key;
480
+ }
481
+ }
482
 
483
+ return $options;
484
+ }
485
 
486
+ public function getShippingColumnOptions()
487
  {
488
+ $options = array(
489
+ 'shipping_code' => 'Shipping Code',
490
+ 'shipping_description' => 'Shipping Description',
491
+ 'carrier_code' => 'Tracking Carrier Code',
492
+ 'title' => 'Tracking Title',
493
+ 'number' => 'Tracking Number');
494
+
495
+ return $options;
496
  }
497
 
498
+ public function getDefaultPublication($storeId)
499
+ {
500
+ return $this->config('publication', $storeId);
501
+ }
502
+
503
+ public function isSignupTest()
504
+ {
505
+ return Mage::app()->getRequest()->getParam('signup_test') == "true";
506
+ }
507
+
508
+ public function canCapture()
509
+ {
510
+ if (!$this->canEdirect())
511
+ return false;
512
+
513
+ if ((bool)($this->config('capture_enabled') != 0) && !Mage::helper('customer')->isLoggedIn())
514
+ return true;
515
+
516
+ return false;
517
+ }
518
+
519
+ public function canSendWishlist()
520
+ {
521
+ if (!$this->canEdirect())
522
+ return false;
523
+
524
+ if (Mage::helper('customer')->isLoggedIn() && (bool)($this->config('wishlist_enabled') != 0))
525
+ return true;
526
+
527
+ return false;
528
+ }
529
+
530
+ public function canSendLastLogin()
531
+ {
532
+ if (!$this->canEdirect())
533
+ return false;
534
+
535
+ if (Mage::helper('customer')->isLoggedIn() && (bool)($this->config('lastlogin_enabled') != 0))
536
+ return true;
537
+
538
+ return false;
539
+ }
540
+
541
+ public function isCronUrlEnabled()
542
+ {
543
+ if (!$this->canEdirect()) {
544
+ return false;
545
+ }
546
+
547
+ if ((bool)($this->config('cron_url_enabled') == 0)) {
548
+ return false;
549
+ }
550
 
551
+ if ($this->config('cron_url_password_enabled') == 1) {
552
+ $password = Mage::app()->getRequest()->getParam('password');
553
+ if ($password != $this->config('cron_url_password')) {
554
+ return false;
555
+ }
556
+ }
557
 
558
+ return true;
559
+ }
 
 
560
 
561
+ public function isSignupEnabled()
562
+ {
563
+ if (!$this->canEdirect())
564
+ return false;
565
 
566
+ if ((bool)($this->config('signup_enabled') == 0) || (bool)($this->config('signup_activated') == 0))
567
+ return false;
568
 
569
+ return true;
570
+ }
 
 
571
 
572
+ public function canShowSignup()
573
+ {
574
+ if ($this->isSignupTest())
575
+ return true;
576
 
577
+ if (!$this->isSignupEnabled())
578
+ return false;
579
 
580
+ $last_closed = Mage::getModel('core/cookie')->get('ed_signup');
 
 
 
581
 
582
+ $recurrence = $this->config('signup_recurrence');
 
583
 
584
+ if ($last_closed == "")
585
+ return true;
586
 
587
+ switch ($recurrence)
588
+ {
589
+ case "once": return false;
590
+ default:
591
+ $last_closed = strtotime("+{$recurrence}",$last_closed); break;
592
+ }
593
 
594
+ if ($last_closed > time())
595
+ return false;
596
 
597
+ return true;
598
+ }
599
 
600
+ public function canCheckoutSubscribe()
601
+ {
602
+ if (!$this->canEdirect())
603
+ return false;
604
 
605
+ return (bool)($this->config('checkout_subscribe') != 0);
606
+ }
607
 
608
+ public function canEdirect()
609
+ {
610
+ // Necessary?
611
+ //Mage::helper('core')->isModuleOutputEnabled('EmailDirect_Integration');
612
 
613
+ $active = $this->config('active');
614
+ $setup = $this->config('setup');
615
 
616
+ if ($active && $setup)
617
+ return true;
618
 
619
+ return $this->onConfigPage();
620
+ }
 
 
 
 
621
 
622
+ public function onConfigPage()
623
+ {
624
+ $controller = Mage::app()->getRequest()->getControllerName();
625
 
626
+ if ($controller == 'system_config')
627
+ return true;
628
+
629
+ return false;
630
+ }
631
+
632
+ public function registerGuestCustomer($order)
633
+ {
634
+ if (Mage::registry('ed_guest_customer'))
635
+ return;
636
+
637
+ $customer = new Varien_Object;
638
+
639
+ $customer->setId(time());
640
+ $customer->setEmail($order->getBillingAddress()->getEmail());
641
+ $customer->setStoreId($order->getStoreId());
642
+ $customer->setFirstname($order->getBillingAddress()->getFirstname());
643
+ $customer->setLastname($order->getBillingAddress()->getLastname());
644
+ $customer->setPrimaryBillingAddress($order->getBillingAddress());
645
+ $customer->setPrimaryShippingAddress($order->getShippingAddress());
646
+ Mage::register('ed_guest_customer', $customer, TRUE);
647
+ }
648
+
649
+ public function getFullStoreName($store)
650
+ {
651
+ if ($store == null)
652
+ return "Unknown";
653
+
654
+ $store_name = "";
655
+
656
+ if ($website = $store->getWebsite())
657
+ $store_name .= $website->getName() . " - ";
658
+
659
+ if ($group = $store->getGroup())
660
+ $store_name .= $group->getName() . " - ";
661
+
662
+ $store_name .= $store->getName();
663
+
664
+ return $store_name;
665
+ }
666
 
667
+ public function getFullStoreNameById($store_id)
668
+ {
669
+ $store = Mage::getModel('core/store')->load($store_id);
 
670
 
671
+ return $this->getFullStoreName($store);
672
+ }
673
 
674
+ public function getAbandonedStatus($helpLink = true)
675
+ {
676
+ $stores = Mage::app()->getStores();
 
677
 
678
+ $abandoned_status = array(
679
+ 'enabled' => false,
680
+ 'cron_last_run' => $this->getCronLastRunHtml($helpLink),
681
+ 'stores' => array()
682
+ );
683
 
684
+ foreach ($stores as $store)
685
+ {
686
+ $data = array();
687
 
688
+ $data['id'] = $store->getId();
689
+ $data['name'] = $this->getFullStoreName($store);
690
+ $data['enabled'] = $this->getAbandonedEnabled($store->getId());
691
+ if ($data['enabled'])
692
+ $abandoned_status['enabled'] = true;
693
 
694
+ $data['last_run'] = $this->getAbandonedLastRunhtml($store->getId());
 
 
695
 
696
+ $abandoned_status['stores'][] = $data;
697
+ }
698
 
699
+ return $abandoned_status;
700
+ }
701
 
702
+ public function getCronLastRun($store = null, $config = 'abandoned_last_run')
703
+ {
704
+ $last_run = $this->config($config, $store);
 
705
 
706
+ $data = array();
707
 
708
+ if ($last_run != null)
709
+ {
710
+ $data['last_run'] = $last_run;
 
 
 
 
 
 
711
 
712
+ $minutes = round(abs(time() - strtotime($last_run)) / 60,0);
 
 
 
713
 
714
+ $data['minutes'] = $minutes;
715
 
716
+ if ($minutes > $this->getCronNotRunMinutes())
717
+ $data['class'] = 'ab_ng';
718
+ else
719
+ $data['class'] = 'ab_ok';
720
 
721
+ $data['last_run_display'] = Mage::helper('core')->formatTime($last_run, 'long', true);
722
+ $data['time_elapsed'] = $this->timeElapsed2string($last_run);
723
+ }
724
+ else
725
+ {
726
+ $data['last_run'] = 'NEVER';
727
+ $data['minutes'] = -1;
728
+ $data['last_run_display'] = 'NEVER';
729
+ $data['time_elapsed'] = "";
730
+ $data['class'] = 'ab_ng';
731
+ }
732
 
733
+ return $data;
734
+ }
735
 
736
+ private function getLastRunHtml($store = null, $config = 'abandoned_last_run', $helpLink = true)
737
+ {
738
+ $data = $this->getCronLastRun($store,$config);
739
+ $warning_img = "";
740
 
741
+ if ($data['class'] == "ab_ng" && $helpLink)
742
+ $warning_img = "<a href='" . $this->getAdminUrl("adminhtml/emaildirect_troubleshooting/index") . "#abandoned_carts' target='_blank'><img src='" . Mage::getDesign()->getSkinUrl('images/warning_msg_icon.gif') . "' class='cron_warning' /></a>";
 
743
 
744
+ $time_elapsed = "";
 
745
 
746
+ if ($data['time_elapsed'] != '')
747
+ $time_elapsed = "({$data['time_elapsed']})";
 
748
 
749
+ return "<span class='{$data['class']}'>{$data['last_run_display']} {$time_elapsed}</span>{$warning_img}";
750
+ }
 
 
 
751
 
752
+ public function getAbandonedLastRunHtml($store = null)
753
+ {
754
+ return $this->getLastRunHtml($store);
755
+ }
756
 
757
+ public function getCronLastRunHtml($helpLink = true)
758
+ {
759
+ return $this->getLastRunHtml(0, 'cron_last_run', $helpLink);
760
+ }
 
761
 
762
+ public function getAdminUrlParams($params = array())
763
+ {
764
+ $request = Mage::app()->getRequest();
765
+ $url_params = array('website','store');
766
 
767
+ foreach ($url_params as $up)
768
+ {
769
+ if ($request->getParam($up))
770
+ $params[$up] = $request->getParam($up);
771
+ }
772
 
773
+ return $params;
774
+ }
775
 
776
+ public function getAdminUrl($url, $params = array())
777
+ {
778
+ $params = $this->getAdminUrlParams($params);
779
 
780
+ return Mage::helper("adminhtml")->getUrl($url, $params);
781
+ }
782
 
783
+ public function getOrdersEnabled()
784
+ {
785
+ $active = $this->config('active');
786
+ $setup = $this->config('setup');
787
+ $sendit = $this->config('sendorder');
788
 
789
+ if (!$sendit || !$setup || !$active)
790
+ return false;
791
 
792
+ return true;
793
+ }
794
 
795
+ public function getBatchEnabled()
796
+ {
797
+ $active = $this->config('active');
798
+ $setup = $this->config('setup');
799
+ $batch = $this->config('batch_enabled');
800
 
801
+ if (!$batch || !$setup || !$active)
802
+ return false;
 
 
 
 
 
 
 
 
 
803
 
804
+ return true;
805
+ }
806
 
807
+ public function getBatchOnly()
808
+ {
809
+ $batch_only = $this->config('batch_only');
 
810
 
811
+ if (!$batch_only)
812
+ return false;
813
 
814
+ return true;
815
+ }
816
 
817
+ public function getDisabledReason()
818
+ {
819
+ if (!$this->config('active'))
820
+ return "EmailDirect Module is Disabled.";
821
 
822
+ if (!$this->config('setup'))
823
+ return "EmailDirect Module is not configured with a valid API Key.";
824
 
825
+ return "";
826
+ }
 
 
827
 
828
+ public function getOrdersDisabledReason()
829
+ {
830
+ $base = $this->getDisabledReason();
 
831
 
832
+ if ($base != "")
833
+ return $base;
 
 
834
 
835
+ return "Sending Orders is disabled.";
836
+ }
 
 
 
837
 
838
+ public function getWishlistDisabledReason()
839
+ {
840
+ $base = $this->getDisabledReason();
841
 
842
+ if ($base != "")
843
+ return $base;
 
844
 
845
+ if (!Mage::helper('customer')->isLoggedIn())
846
+ return "Customer not logged in";
847
 
848
+ return "Wishlist is disabled.";
849
+ }
 
 
 
850
 
851
+ public function getLastLoginDisabledReason()
852
+ {
853
+ $base = $this->getDisabledReason();
854
 
855
+ if ($base != "")
856
+ return $base;
857
 
858
+ //if (!Mage::helper('customer')->isLoggedIn())
859
+ //return "Customer not logged in";
 
 
 
860
 
861
+ return "Last Login is disabled.";
862
+ }
863
 
864
+ public function getBatchDisabledReason()
865
+ {
866
+ $base = $this->getDisabledReason();
867
 
868
+ if ($base != "")
869
+ return $base;
 
870
 
871
+ return "Sending Orders in batch is disabled.";
872
+ }
873
 
874
+ public function getAbandonedEnabled($store = null)
875
+ {
876
+ $active = $this->config('active', $store);
877
+ $setup = $this->config('setup', $store);
878
+ $sendit = $this->config('sendabandoned', $store);
879
+ $abandoned_setup = $this->config('abandonedsetup', $store);
880
 
881
+ if (!$sendit || !$setup || !$active || !$abandoned_setup)
882
+ return false;
 
 
883
 
884
+ return true;
885
+ }
886
 
887
+ public function getAbandonedDisabledReason()
888
+ {
889
+ $base = $this->getDisabledReason();
890
 
891
+ if ($base != "")
892
+ return $base;
 
893
 
894
+ if (!$this->config('abandonedsetup'))
895
+ return "Abandoned Cart Processing Not Setup.";
896
 
897
+ return "Sending Abandoned Carts is Disabled";
898
+ }
899
 
900
+ // Newsletter
 
 
901
 
902
+ private function getSubscriberData($data, $email)
903
+ {
904
+ $properties = Mage::getSingleton('emaildirect/wrapper_subscribers')->getProperties($email);
905
+ $pub_count = 0;
906
+ $list_count = 0;
907
+ $publication_subscribed = false;
908
+
909
+ if (!isset($properties->Publications->Publication))
910
+ return $data;
911
+
912
+ foreach($properties->Publications->Publication as $publication)
913
+ {
914
+ if ((int) $publication->PublicationID == $data['publication']['id'])
915
+ {
916
+ $data['publication']['subscribed'] = true;
917
+ $publication_subscribed = true;
918
+ $pub_count++;
919
+ }
920
+ }
921
 
922
+ $data['count'] = $pub_count;
923
+
924
+ // Disable the lists if the publication is not subscribed
925
+ if (!$publication_subscribed)
926
+ {
927
+ foreach ($data['lists'] as $list_id => $list)
928
+ {
929
+ $data['lists'][$list_id]['disabled'] = true;
930
+ }
931
+ $data['list_count'] = 0;
932
+ return $data;
933
+ }
934
 
935
+ if (!isset($properties->Lists->List))
936
+ return $data;
937
 
938
+ foreach($properties->Lists->List as $list)
939
+ {
940
+ $list_id = (int)$list->ListID;
941
 
942
+ if (isset($data['lists'][$list_id]))
943
+ {
944
+ $data['lists'][$list_id]['subscribed'] = true;
945
+ $list_count++;
946
+ }
947
+ }
948
 
949
+ $data['count'] = $pub_count + $list_count;
950
+ $data['list_count'] = $list_count;
951
 
952
+ return $data;
953
+ }
954
 
955
+ private function getPublication()
956
+ {
957
+ $general = $this->config('publication');
958
 
959
+ $rc = Mage::getSingleton('emaildirect/wrapper_publications')->getPublication($general);
960
+ return array('id' =>(int) $rc->PublicationID,'name'=> (string)$rc->Name, 'subscribed' => false, 'disabled' => false);
961
+ }
962
 
963
+ private function getLists()
964
+ {
965
+ $list_data = array();
966
+ $additional_lists = $this->config('additional_lists');
967
 
968
+ if ($additional_lists == "")
969
+ return $list_data;
 
 
 
 
970
 
971
+ $active_lists = explode(",",$additional_lists);
 
972
 
973
+ $all_lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
 
974
 
975
+ foreach($all_lists as $list)
976
+ {
977
+ if (in_array($list['id'],$active_lists))
978
+ $list_data[$list['id']] = array(
979
+ 'id' => $list['id'],
980
+ 'name' => $list['name'],
981
+ 'subscribed' => false,
982
+ 'disabled' => false);
983
+ }
984
 
985
+ return $list_data;
986
+ }
987
 
988
+ public function getSubscriptions($email)
989
+ {
990
+ $this->_logger->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CUSTOMER);
991
+ $this->_logger->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
992
 
993
+ $data = array(
994
+ 'publication' => array('id' => -1,'name' => 'Unknown', 'subscribed' => false, 'disabled' => true),
995
+ 'lists' => array(),
996
+ 'count' => 0,
997
+ 'list_count' => 0
998
+ );
999
 
1000
+ try
1001
+ {
1002
+ $data['publication'] = $this->getPublication();
1003
+ $data['lists'] = $this->getLists();
1004
 
1005
+ $data = $this->getSubscriberData($data, $email);
 
 
 
 
 
1006
 
1007
+ $this->_logger->resetLogLevel();
 
1008
 
1009
+ return $data;
1010
+ }
1011
+ catch (Exception $e)
1012
+ {
1013
+ Mage::logException($e);
1014
+ $this->_logger->logException($e);
1015
+ $this->_logger->resetLogLevel();
1016
+ return $data;
1017
+ }
1018
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1019
  }
app/code/community/EmailDirect/Integration/Helper/Fields.php CHANGED
@@ -128,6 +128,8 @@ class EmailDirect_Integration_Helper_Fields extends EmailDirect_Integration_Help
128
  $fields[] = $this->addField('AbandonedDate', 'Date');
129
  $fields[] = $this->addField('AbandonedUrl', 'Text', '1000');
130
 
 
 
131
  $fields = $this->getMultiFields($fields,"AB");
132
 
133
  return $fields;
128
  $fields[] = $this->addField('AbandonedDate', 'Date');
129
  $fields[] = $this->addField('AbandonedUrl', 'Text', '1000');
130
 
131
+ $fields[] = $this->addField('Store', 'Text', '100');
132
+
133
  $fields = $this->getMultiFields($fields,"AB");
134
 
135
  return $fields;
app/code/community/EmailDirect/Integration/Helper/Troubleshooting.php CHANGED
@@ -1,715 +1,722 @@
1
  <?php
2
 
3
  class EmailDirect_Integration_Helper_Troubleshooting extends Mage_Core_Helper_Abstract
4
- {
5
- const LOG_FILE_NAME = 'emaildirect';
6
- const LOG_FILE_EXT = '.log';
7
- const LOG_LEVEL_HIGH = 0;
8
- const LOG_LEVEL_NORMAL = 5;
9
- const LOG_LEVEL_LOW = 100;
10
-
11
- const ABANDONED_CART = "AB";
12
- const ORDERS = "OR";
13
- const NEWSLETTER = "NL";
14
- const CUSTOMER = "CU";
15
- const CONFIG = "CG";
16
- const IGNORE = "IG";
17
- const WISHLIST = "WL";
18
- const DEFAULT_AREA = "ED";
19
-
20
- const DISABLED_REASON_PREFIX = "Skipping";
21
-
22
- private $_log_level = self::LOG_LEVEL_NORMAL;
23
- private $_log_level_active = self::LOG_LEVEL_NORMAL;
24
- private $_log_area = self::DEFAULT_AREA;
25
- private $_current_store = null;
26
-
27
- private $_output_log = array();
28
-
29
- private $_config_options = null;
30
-
31
- private $_status = array();
32
- private $_debug_mode = false;
33
-
34
- private $_debug_execute_mode = "request";
35
-
36
- private $_debug_request = null;
37
- private $_debug_response = null;
38
-
39
- protected $_date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
40
-
41
- private $_areas = array(
42
- "AB" => "Abandoned Carts",
43
- "OR" => "Orders",
44
- "NL" => "Newsletter",
45
- "CU" => "Customer",
46
- //"CG" => "Configuration",
47
- "WL" => "Wishlist"
48
- );
49
-
50
- public function validateApiKey($apikey, $report_error = false)
51
- {
52
- $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommandDirect($apikey, 'sources');
53
- if (isset($rc->ErrorCode))
54
- {
55
- if ($report_error)
56
- return (string) $rc->Message;
57
- return false;
58
- }
59
-
60
- return true;
61
- }
62
-
63
- public function getDebugExecuteMode()
64
- {
65
- return $this->_debug_execute_mode;
66
- }
67
-
68
- public function setDebugExecuteMode($mode)
69
- {
70
- $this->_debug_execute_mode = $mode;
71
- }
72
-
73
- public function setDebugRequest($request)
74
- {
75
- $this->_debug_request = $request;
76
- }
77
-
78
- public function setDebugResponse($response)
79
- {
80
- $this->_debug_response = $response;
81
- }
82
-
83
- public function getDebugRequest()
84
- {
85
- return $this->_debug_request;
86
- }
87
-
88
- public function getDebugResponse()
89
- {
90
- return $this->_debug_response;
91
- }
92
-
93
- public function getAreas()
94
- {
95
- return $this->_areas;
96
- }
97
-
98
- public function turnOnDebug()
99
- {
100
- $this->_debug_mode = true;
101
- }
102
-
103
- public function turnOffDebug()
104
- {
105
- $this->_debug_mode = false;
106
- }
107
-
108
- public function getDebugData()
109
- {
110
- return $this->_output_log;
111
- }
112
-
113
- public function safeDump($data, $level = 0)
114
- {
115
- try
116
- {
117
- if ($level > 5)
118
- return "";
119
-
120
- $indent = str_repeat(" ",$level);
121
-
122
- $output = "";
123
-
124
- if (is_object($data))
125
- {
126
- $output = get_class($data) . " Object\n(\n";
127
- $output .= $this->safeDump($data->getData(), $level + 1);
128
- $output .= ")\n";
129
- }
130
-
131
- if (is_array($data))
132
- {
133
- $output = "{$indent}Array\n{$indent}(\n";
134
- //$inner_indent = $indent . " ";
135
- $inner_indent = str_repeat(" ",$level + 1);
136
- foreach ($data as $key => $value)
137
- {
138
- $output .= "{$inner_indent}[{$key}] => ";
139
- if (is_object($value))
140
- $output .= get_class($value) . " Object";
141
- else if (is_array($value))
142
- $output .= $this->safeDump($value,$level + 1);
143
- else
144
- $output .= $value;
145
-
146
- $output .= "\n";
147
- }
148
-
149
- $output .= "{$indent})\n";
150
- }
151
-
152
- return $output;
153
- }
154
- catch (Exception $e)
155
- {
156
- return $e->getMessage();
157
- }
158
- }
159
-
160
- private function formatData($data)
161
- {
162
- $output = $this->safeDump($data);
163
-
164
- $output = str_replace("\n","<br />",$output);
165
- $output = str_replace(" ","&nbsp;&nbsp;",$output);
166
-
167
- return $output;
168
- }
169
-
170
- private function debugFromLog($data)
171
- {
172
- if (!$this->_debug_mode)
173
- return;
174
-
175
- $this->debug($data);
176
- }
177
-
178
- public function debug($data)
179
- {
180
- if (!$this->_debug_mode)
181
- return;
182
-
183
- if (!is_string($data))
184
- $this->_output_log[] = $this->formatData($data);
185
- else
186
- $this->_output_log[] = $data;
187
- }
188
-
189
- public function debugHeader($header, $level = 2)
190
- {
191
- $line = str_repeat('==========================================================',$level);
192
- //$this->debug($line);
193
- $this->debug($header);
194
- $this->debug($line);
195
- $this->debug('');
196
- }
197
-
198
-
199
- public function debugXml($data)
200
- {
201
- if (!$this->_debug_mode)
202
- return;
203
-
204
- $this->_output_log[] = "<pre>" . htmlentities($this->formatXml($data)) . "</pre>";
205
- }
206
-
207
- public function isDebugMode()
208
- {
209
- return $this->_debug_mode;
210
- }
211
-
212
- public function formatXml($xml_string)
213
- {
214
- try
215
- {
216
- $dom = new DOMDocument('1.0');
217
- $dom->preserveWhiteSpace = false;
218
- $dom->formatOutput = true;
219
- $dom->loadXML($xml_string);
220
- return $dom->saveXML();
221
- }
222
- catch (Exception $e)
223
- {
224
- $this->logException($e);
225
- return $xml_string;
226
- }
227
- }
228
-
229
- private function getReportTable($heading, $table, $headings = true)
230
- {
231
- $output = "<h1>{$heading}</h1>";
232
- $output .= "<table cellspacing='0' border='1'>";
233
-
234
- if ($headings)
235
- $output .= "<thead>
236
- <tr class='headings'>
237
- <th>Setting</th>
238
- <th>Value</th>
239
- </tr>
240
- </thead>";
241
-
242
- foreach ($table as $key => $value)
243
- {
244
- $output .= "<tr class='border'>
245
- <td>{$key}</td>
246
- <td>{$value}</td>
247
- </tr>";
248
- }
249
- $output .= "</table>";
250
-
251
- return $output;
252
- }
253
-
254
- public function getReport($customer = null)
255
- {
256
- $environment = $this->getEnvironmentInfo();
257
- $store_configuration = $this->getConfigurationInfo();
258
-
259
- $output = "<html><head></head><body>";
260
-
261
- if ($customer != null)
262
- $output .= $this->getReportTable("Customer Information", $customer, false);
263
-
264
- $output .= $this->getReportTable("General Configuration", $environment);
265
-
266
- foreach ($store_configuration as $code => $configuration)
267
- {
268
- $output .= $this->getReportTable("Module Configuration for store: {$code}", $configuration);
269
- }
270
-
271
- $output .= "<h1>Log File</h1>";
272
- $output .= "<pre>" . $this->getLogFileContents() . "</pre>";
273
-
274
- $output .= "</body></html>";
275
-
276
- return $output;
277
- }
278
-
279
- private function getArrayData($data)
280
- {
281
- $output = "<table cellspacing='0' class='data ed-config-subtable'>
282
- <thead>
283
- <tr class='headings'>
284
- <th>Magento</th>
285
- <th>EmailDirect</th>
286
- </tr>
287
- </thead>";
288
-
289
- foreach ($data as $row)
290
- {
291
- $output .= "<tbody><tr class='border'><td>{$row['magento']}</td><td>{$row['emaildirect']}</td></tr></tbody>";
292
- }
293
-
294
- $output .= "</table>";
295
-
296
- return $output;
297
- }
298
-
299
- public function getEnvironmentInfo()
300
- {
301
- $data = array(
302
- 'Magento Version' => Mage::getVersion(),
303
- 'EmailDirect Version' => (string) Mage::getConfig()->getNode('modules/EmailDirect_Integration/version'),
304
- 'Website URL' => Mage::getBaseUrl(),
305
- 'PHP Version' => phpversion(),
306
- 'Server Software' => $_SERVER['SERVER_SOFTWARE']
307
- );
308
-
309
- if (method_exists("Mage","getEdition"))
310
- $data['Magento Edition'] = Mage::getEdition();
311
- return $data;
312
- }
313
-
314
- public function getConfigurationInfo()
315
- {
316
- $store_data = array();
317
-
318
- $stores = Mage::app()->getStores();
319
-
320
- foreach ($stores as $store)
321
- {
322
- $e_config = Mage::getStoreConfig("emaildirect/general", $store);
323
-
324
- $data = array( );
325
-
326
- $data['store id'] = $store->getId();
327
- $data['url'] = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $store);
328
-
329
- foreach ($e_config as $key => $value)
330
- {
331
- if (is_array($value))
332
- {
333
- // Skip
334
- }
335
- else
336
- {
337
- // Check if the data is serialized
338
- $test_data = @unserialize($value);
339
- if ($test_data !== false)
340
- $data[$key] = $this->getArrayData($test_data);
341
- else
342
- $data[$key] = $value;;
343
- }
344
- }
345
-
346
- $store_data[$store->getName()] = $data;
347
- }
348
-
349
- return $store_data;
350
- }
351
-
352
- public function getLogFileContents()
353
- {
354
- $log_file = $this->getLogFilePath();
355
-
356
- if (!file_exists($log_file))
357
- return "";
358
-
359
- $max_size = $this->getMaxLogFileSize();
360
- $log_file_size = filesize($log_file);
361
- $offset = 0;
362
-
363
- if ($log_file_size > $max_size)
364
- $offset = $log_file_size - $max_size;
365
-
366
- return htmlentities(file_get_contents($log_file,false,null,$offset));
367
- }
368
-
369
- public function getLogFilePath()
370
- {
371
- return Mage::getBaseDir('log') . DS. self::LOG_FILE_NAME . self::LOG_FILE_EXT;
372
- }
373
-
374
- public function getLogFileName()
375
- {
376
- return self::LOG_FILE_NAME . self::LOG_FILE_EXT;
377
- }
378
-
379
- public function getLogFileSize()
380
- {
381
- $log_file = $this->getLogFilePath();
382
-
383
- if (file_exists($log_file))
384
- return filesize($log_file);
385
-
386
- return 0;
387
- }
388
-
389
- public function isLogFileTooLarge()
390
- {
391
- if ($this->getLogFileSize() > $this->getMaxLogFileSize())
392
- return true;
393
- return false;
394
- }
395
-
396
- public function getLoggingStatus()
397
- {
398
- $this->checkTimeout();
399
-
400
- $enabled = $this->config('logging_enabled') == 1;
401
-
402
- $stores = Mage::app()->getStores();
403
- $stores_selected = $this->arrayConfig("logging_stores_selected");
404
-
405
- $areas_selected = $this->arrayConfig("logging_areas_selected");
406
-
407
- $date = $this->config('logging_start_date');
408
-
409
- $duration = (int)$this->config('logging_duration') * 60;
410
-
411
- $trouble_status = array(
412
- 'enabled' => $enabled,
413
- 'start_date' => "",
414
- 'seconds' => "",
415
- 'duration' => $duration,
416
- 'duration_display' => Mage::helper('emaildirect')->getDuration($duration),
417
- 'stores' => array()
418
- );
419
-
420
- if ($date != "")
421
- {
422
- $trouble_status['start_date'] = $date;
423
-
424
- $trouble_status['elapsed'] = Mage::helper('emaildirect')->timeElapsed2String($date);
425
- $now = Mage::getModel('core/date')->gmtTimestamp();
426
- $trouble_status['seconds'] = abs($now - strtotime($date));
427
- }
428
-
429
- foreach ($stores as $store)
430
- {
431
- $data = array();
432
-
433
- $store_id = $store->getId();
434
-
435
- $selected = in_array($store_id,$stores_selected);
436
-
437
- $data['id'] = $store_id;
438
- $data['name'] = Mage::helper('emaildirect')->getFullStoreName($store);
439
-
440
- $data['emaildirect_enabled'] = Mage::helper('emaildirect')->config('active',$store) == 1;
441
-
442
- if ($enabled)
443
- $data['logging_enabled'] = $this->isLoggingEnabledForStore($store_id);
444
- else
445
- $data['logging_enabled'] = false;
446
-
447
- $data['selected'] = $selected;
448
-
449
- $trouble_status['stores'][$store_id] = $data;
450
- }
451
-
452
- $areas = array();
453
-
454
- foreach ($this->_areas as $area => $label)
455
- {
456
-
457
- if ($enabled == false)
458
- $area_enabled = false;
459
- else
460
- $area_enabled = $this->isLoggingEnabledForArea($area);
461
-
462
- $areas[$area] = array(
463
- 'area' => $area,
464
- 'label' => $label,
465
- 'logging_enabled' => $area_enabled,
466
- 'selected' => in_array($area,$areas_selected)
467
- );
468
- }
469
-
470
- $trouble_status['areas'] = $areas;
471
-
472
- return $trouble_status;
473
- }
474
-
475
- public function getLogFilelastUpdate()
476
- {
477
- $log_file = $this->getLogFilePath();
478
-
479
- if (file_exists($log_file))
480
- return filemtime($log_file);
481
-
482
- return "";
483
- }
484
-
485
- public function getMaxLogFileSize()
486
- {
487
- return $this->config('max_file_size');
488
- }
489
-
490
- public function config($value)
491
- {
492
- return Mage::getStoreConfig("emaildirect/troubleshooting/{$value}", 0);
493
- }
494
-
495
- public function arrayConfig($value)
496
- {
497
- $data = $this->config($value);
498
-
499
- if ($data == "")
500
- return array();
501
-
502
- return explode(",",$data);
503
- }
504
-
505
- private function updateConfig($path, $value, $scope = "default", $store = 0)
506
- {
507
- $config = Mage::getConfig();
508
- $config->saveConfig("emaildirect/troubleshooting/{$path}",$value,$scope,$store);
509
- $config->cleanCache();
510
- }
511
-
512
- public function disable()
513
- {
514
- $this->updateConfig("logging_start_date","");
515
- $this->updateConfig("logging_enabled","0");
516
- }
517
-
518
- public function isDiagnosticEnabled()
519
- {
520
- return $this->config('diagnostic_enabled') == 1;
521
- }
522
-
523
- private function getConfigOptions()
524
- {
525
- if ($this->_config_options == null)
526
- {
527
- $options = $this->config('options');
528
-
529
- if ($options == "")
530
- $this->_config_options = "";
531
- else
532
- $this->_config_options = unserialize($options);
533
- }
534
-
535
- return $this->_config_options;
536
- }
537
-
538
- private function isLoggingEnabledForArea($area = "")
539
- {
540
- if ($area == "")
541
- $area = $this->_log_area;
542
-
543
- if ($this->config('logging_areas') == "all")
544
- return true;
545
-
546
- $areas_selected = $this->arrayConfig("logging_areas_selected");
547
-
548
- return in_array($area,$areas_selected);
549
- }
550
-
551
- private function isLoggingEnabledForStore($store = 0)
552
- {
553
- //if ($this->config('logging_enabled') == 0)
554
- //return false;
555
-
556
- if ($this->config('logging_stores') == "all")
557
- return true;
558
-
559
- $stores_selected = $this->arrayConfig("logging_stores_selected");
560
-
561
- if (is_object($store))
562
- $store = $store->getId();
563
-
564
- return in_array($store,$stores_selected);
565
- }
566
-
567
- private function isLoggingEnabledForIP()
568
- {
569
- //if ($this->config('logging_enabled') == 0)
570
- //return false;
571
-
572
- $ip = Mage::helper('core/http')->getRemoteAddr();
573
-
574
- $logging_ip = $this->arrayConfig("logging_ip");
575
-
576
- if (count($logging_ip) == 0)
577
- return true;
578
-
579
- return in_array($ip,$logging_ip);
580
- }
581
-
582
- public function isLoggingEnabled($store = 0)
583
- {
584
- // First check the global setting
585
- if (!$this->config('logging_enabled'))
586
- return false;
587
- if (!$this->isLoggingEnabledForIP())
588
- return false;
589
- if (!$this->isLoggingEnabledForArea())
590
- return false;
591
- if (!$this->isLoggingEnabledForStore($store))
592
- return false;
593
- return $this->checkTimeout();
594
- }
595
-
596
- private function checkTimeout()
597
- {
598
- $date = $this->config('logging_start_date');
599
-
600
- if ($date == "" || $date == 0)
601
- {
602
- $this->disable();
603
- return false;
604
- }
605
-
606
- $now = Mage::getModel('core/date')->gmtTimestamp();
607
-
608
- $seconds = abs($now - strtotime($date));
609
-
610
- $duration = (int)$this->config('logging_duration');
611
-
612
- $duration *= 60;
613
-
614
- if ($seconds > $duration)
615
- {
616
- $this->disable();
617
- Mage::app()->reinitStores();
618
- return false;
619
- }
620
-
621
- return true;
622
- }
623
-
624
- public function logAndDebug($data)
625
- {
626
- $this->debug($data);
627
-
628
- $this->log($data);
629
- }
630
-
631
- public function log($data, $prefix = "", $area = "")
632
- {
633
- //$this->debug($data);
634
-
635
- $store = Mage::helper('emaildirect')->getCurrentStore();
636
-
637
- if ($area == "")
638
- $area = $this->_log_area;
639
-
640
- if ($this->_log_level > $this->_log_level_active)
641
- return;
642
-
643
- if ($this->isLoggingEnabled($store, $area))
644
- {
645
- if (is_array($data) || is_object($data))
646
- {
647
- if (is_object($data) && get_class($data) == "SimpleXMLElement")
648
- $data = $this->formatXml($data->asXml());
649
- else
650
- $data = $this->safeDump($data);
651
- }
652
-
653
- if ($prefix != "")
654
- $prefix .= ": ";
655
-
656
- if ($area != "")
657
- $data = "[{$area}] [{$store}] {$prefix}{$data}";
658
-
659
- $this->forceLog($data);
660
- }
661
- }
662
-
663
- public function forceLog($data)
664
- {
665
- Mage::log($data,null,self::LOG_FILE_NAME . self::LOG_FILE_EXT, true);
666
- }
667
-
668
- public function eraseLog()
669
- {
670
- try
671
- {
672
- $log_file = Mage::getBaseDir('var') . DS . 'log' . DS . self::LOG_FILE_NAME . self::LOG_FILE_EXT;
673
-
674
- if (!file_exists($log_file))
675
- return true;
676
-
677
- unlink($log_file);
678
- return true;
679
- }
680
- catch (Exception $e)
681
- {
682
- return false;
683
- }
684
- }
685
-
686
- public function logReason($data)
687
- {
688
- $this->log($data,self::DISABLED_REASON_PREFIX);
689
- }
690
-
691
- public function logException($e)
692
- {
693
- $this->log($e->__toString(),"Exception");
694
- }
695
-
696
- public function logXml($xml, $prefix = "")
697
- {
698
- $this->log($this->formatXml($xml),$prefix);
699
- }
700
-
701
- public function setLogArea($area)
702
- {
703
- $this->_log_area = $area;
704
- }
705
-
706
- public function setLogLevel($level)
707
- {
708
- $this->_log_level = $level;
709
- }
710
-
711
- public function resetLogLevel()
712
- {
713
- $this->_log_level = self::LOG_LEVEL_NORMAL;
714
- }
 
 
 
 
 
 
 
715
  }
1
  <?php
2
 
3
  class EmailDirect_Integration_Helper_Troubleshooting extends Mage_Core_Helper_Abstract
4
+ {
5
+ const LOG_FILE_NAME = 'emaildirect';
6
+ const LOG_FILE_EXT = '.log';
7
+ const LOG_LEVEL_HIGH = 0;
8
+ const LOG_LEVEL_NORMAL = 5;
9
+ const LOG_LEVEL_LOW = 100;
10
+
11
+ const ABANDONED_CART = "AB";
12
+ const ORDERS = "OR";
13
+ const NEWSLETTER = "NL";
14
+ const CUSTOMER = "CU";
15
+ const CONFIG = "CG";
16
+ const IGNORE = "IG";
17
+ const WISHLIST = "WL";
18
+ const DEFAULT_AREA = "ED";
19
+
20
+ const DISABLED_REASON_PREFIX = "Skipping";
21
+
22
+ private $_log_level = self::LOG_LEVEL_NORMAL;
23
+ private $_log_level_active = self::LOG_LEVEL_NORMAL;
24
+ private $_log_area = self::DEFAULT_AREA;
25
+ private $_current_store = null;
26
+
27
+ private $_output_log = array();
28
+
29
+ private $_config_options = null;
30
+
31
+ private $_status = array();
32
+ private $_debug_mode = false;
33
+
34
+ private $_debug_execute_mode = "request";
35
+
36
+ private $_debug_request = null;
37
+ private $_debug_response = null;
38
+
39
+ protected $_date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
40
+
41
+ private $_areas = array(
42
+ "AB" => "Abandoned Carts",
43
+ "OR" => "Orders",
44
+ "NL" => "Newsletter",
45
+ "CU" => "Customer",
46
+ //"CG" => "Configuration",
47
+ "WL" => "Wishlist"
48
+ );
49
+
50
+ public function validateApiKey($apikey, $report_error = false)
51
+ {
52
+ $rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommandDirect($apikey, 'sources');
53
+ if (isset($rc->ErrorCode))
54
+ {
55
+ if ($report_error)
56
+ return (string) $rc->Message;
57
+ return false;
58
+ }
59
+
60
+ return true;
61
+ }
62
+
63
+ public function getDebugExecuteMode()
64
+ {
65
+ return $this->_debug_execute_mode;
66
+ }
67
+
68
+ public function setDebugExecuteMode($mode)
69
+ {
70
+ $this->_debug_execute_mode = $mode;
71
+ }
72
+
73
+ public function setDebugRequest($request)
74
+ {
75
+ $this->_debug_request = $request;
76
+ }
77
+
78
+ public function setDebugResponse($response)
79
+ {
80
+ $this->_debug_response = $response;
81
+ }
82
+
83
+ public function getDebugRequest()
84
+ {
85
+ return $this->_debug_request;
86
+ }
87
+
88
+ public function getDebugResponse()
89
+ {
90
+ return $this->_debug_response;
91
+ }
92
+
93
+ public function getAreas()
94
+ {
95
+ return $this->_areas;
96
+ }
97
+
98
+ public function turnOnDebug()
99
+ {
100
+ $this->_debug_mode = true;
101
+ }
102
+
103
+ public function turnOffDebug()
104
+ {
105
+ $this->_debug_mode = false;
106
+ }
107
+
108
+ public function getDebugData()
109
+ {
110
+ return $this->_output_log;
111
+ }
112
+
113
+ public function safeDump($data, $level = 0)
114
+ {
115
+ try
116
+ {
117
+ if ($level > 5)
118
+ return "";
119
+
120
+ $indent = str_repeat(" ",$level);
121
+
122
+ $output = "";
123
+
124
+ if (is_object($data))
125
+ {
126
+ $output = get_class($data) . " Object\n(\n";
127
+ $output .= $this->safeDump($data->getData(), $level + 1);
128
+ $output .= ")\n";
129
+ }
130
+
131
+ if (is_array($data))
132
+ {
133
+ $output = "{$indent}Array\n{$indent}(\n";
134
+ //$inner_indent = $indent . " ";
135
+ $inner_indent = str_repeat(" ",$level + 1);
136
+ foreach ($data as $key => $value)
137
+ {
138
+ $output .= "{$inner_indent}[{$key}] => ";
139
+ if (is_object($value))
140
+ $output .= get_class($value) . " Object";
141
+ else if (is_array($value))
142
+ $output .= $this->safeDump($value,$level + 1);
143
+ else
144
+ $output .= $value;
145
+
146
+ $output .= "\n";
147
+ }
148
+
149
+ $output .= "{$indent})\n";
150
+ }
151
+
152
+ return $output;
153
+ }
154
+ catch (Exception $e)
155
+ {
156
+ return $e->getMessage();
157
+ }
158
+ }
159
+
160
+ private function formatData($data)
161
+ {
162
+ $output = $this->safeDump($data);
163
+
164
+ $output = str_replace("\n","<br />",$output);
165
+ $output = str_replace(" ","&nbsp;&nbsp;",$output);
166
+
167
+ return $output;
168
+ }
169
+
170
+ private function debugFromLog($data)
171
+ {
172
+ if (!$this->_debug_mode)
173
+ return;
174
+
175
+ $this->debug($data);
176
+ }
177
+
178
+ public function debug($data)
179
+ {
180
+ if (!$this->_debug_mode)
181
+ return;
182
+
183
+ if (!is_string($data))
184
+ $this->_output_log[] = $this->formatData($data);
185
+ else
186
+ $this->_output_log[] = $data;
187
+ }
188
+
189
+ public function debugHeader($header, $level = 2)
190
+ {
191
+ $line = str_repeat('==========================================================',$level);
192
+ //$this->debug($line);
193
+ $this->debug($header);
194
+ $this->debug($line);
195
+ $this->debug('');
196
+ }
197
+
198
+
199
+ public function debugXml($data)
200
+ {
201
+ if (!$this->_debug_mode)
202
+ return;
203
+
204
+ $this->_output_log[] = "<pre>" . htmlentities($this->formatXml($data)) . "</pre>";
205
+ }
206
+
207
+ public function isDebugMode()
208
+ {
209
+ return $this->_debug_mode;
210
+ }
211
+
212
+ public function formatXml($xml_string)
213
+ {
214
+ try
215
+ {
216
+ $dom = new DOMDocument('1.0');
217
+ $dom->preserveWhiteSpace = false;
218
+ $dom->formatOutput = true;
219
+ $dom->loadXML($xml_string);
220
+ return $dom->saveXML();
221
+ }
222
+ catch (Exception $e)
223
+ {
224
+ $this->logException($e);
225
+ return $xml_string;
226
+ }
227
+ }
228
+
229
+ private function getReportTable($heading, $table, $headings = true)
230
+ {
231
+ $output = "<h1>{$heading}</h1>";
232
+ $output .= "<table cellspacing='0' border='1'>";
233
+
234
+ if ($headings)
235
+ $output .= "<thead>
236
+ <tr class='headings'>
237
+ <th>Setting</th>
238
+ <th>Value</th>
239
+ </tr>
240
+ </thead>";
241
+
242
+ foreach ($table as $key => $value)
243
+ {
244
+ $output .= "<tr class='border'>
245
+ <td>{$key}</td>
246
+ <td>{$value}</td>
247
+ </tr>";
248
+ }
249
+ $output .= "</table>";
250
+
251
+ return $output;
252
+ }
253
+
254
+ public function getReport($customer = null)
255
+ {
256
+ $environment = $this->getEnvironmentInfo();
257
+ $store_configuration = $this->getConfigurationInfo();
258
+
259
+ $output = "<html><head></head><body>";
260
+
261
+ if ($customer != null)
262
+ $output .= $this->getReportTable("Customer Information", $customer, false);
263
+
264
+ $output .= $this->getReportTable("General Configuration", $environment);
265
+
266
+ foreach ($store_configuration as $code => $configuration)
267
+ {
268
+ $output .= $this->getReportTable("Module Configuration for store: {$code}", $configuration);
269
+ }
270
+
271
+ $output .= "<h1>Log File</h1>";
272
+ $output .= "<pre>" . $this->getLogFileContents() . "</pre>";
273
+
274
+ $output .= "</body></html>";
275
+
276
+ return $output;
277
+ }
278
+
279
+ private function getArrayData($data)
280
+ {
281
+ $output = "<table cellspacing='0' class='data ed-config-subtable'>
282
+ <thead>
283
+ <tr class='headings'>
284
+ <th>Magento</th>
285
+ <th>EmailDirect</th>
286
+ </tr>
287
+ </thead>";
288
+
289
+ foreach ($data as $row)
290
+ {
291
+ $output .= "<tbody><tr class='border'><td>{$row['magento']}</td><td>{$row['emaildirect']}</td></tr></tbody>";
292
+ }
293
+
294
+ $output .= "</table>";
295
+
296
+ return $output;
297
+ }
298
+
299
+ public function getEnvironmentInfo()
300
+ {
301
+ $data = array(
302
+ 'Magento Version' => Mage::getVersion(),
303
+ 'EmailDirect Version' => (string) Mage::getConfig()->getNode('modules/EmailDirect_Integration/version'),
304
+ 'Website URL' => Mage::getBaseUrl(),
305
+ 'PHP Version' => phpversion(),
306
+ 'Server Software' => $_SERVER['SERVER_SOFTWARE']
307
+ );
308
+
309
+ if (method_exists("Mage","getEdition"))
310
+ $data['Magento Edition'] = Mage::getEdition();
311
+ return $data;
312
+ }
313
+
314
+ public function getConfigurationInfo()
315
+ {
316
+ $store_data = array();
317
+
318
+ $stores = Mage::app()->getStores();
319
+
320
+ foreach ($stores as $store)
321
+ {
322
+ $e_config = Mage::getStoreConfig("emaildirect/general", $store);
323
+
324
+ $data = array( );
325
+
326
+ $data['store id'] = $store->getId();
327
+ $data['url'] = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $store);
328
+
329
+ foreach ($e_config as $key => $value)
330
+ {
331
+ if (is_array($value))
332
+ {
333
+ // Skip
334
+ }
335
+ else
336
+ {
337
+ // Check if the data is serialized
338
+ $test_data = @unserialize($value);
339
+ if ($test_data !== false)
340
+ $data[$key] = $this->getArrayData($test_data);
341
+ else
342
+ $data[$key] = $value;;
343
+ }
344
+ }
345
+
346
+ $store_data[$store->getName()] = $data;
347
+ }
348
+
349
+ return $store_data;
350
+ }
351
+
352
+ public function getLogFileContents($file = null)
353
+ {
354
+ $log_file = $this->getLogFilePath($file);
355
+
356
+ if (!file_exists($log_file)) {
357
+ return "";
358
+ }
359
+
360
+ $max_size = $this->getMaxLogFileSize();
361
+ $log_file_size = filesize($log_file);
362
+ $offset = 0;
363
+
364
+ if ($log_file_size > $max_size) {
365
+ $offset = $log_file_size - $max_size;
366
+ }
367
+
368
+ return htmlentities(file_get_contents($log_file,false,null,$offset));
369
+ }
370
+
371
+ public function getLogFilePath($file = null)
372
+ {
373
+ if ($file == null) {
374
+ return Mage::getBaseDir('log') . DS. self::LOG_FILE_NAME . self::LOG_FILE_EXT;
375
+ }
376
+
377
+ return Mage::getBaseDir('log') . DS. $file;
378
+ }
379
+
380
+ public function getLogFileName()
381
+ {
382
+ return self::LOG_FILE_NAME . self::LOG_FILE_EXT;
383
+ }
384
+
385
+ public function getLogFileSize($file = null)
386
+ {
387
+ $log_file = $this->getLogFilePath($file);
388
+
389
+ if (file_exists($log_file)) {
390
+ return filesize($log_file);
391
+ }
392
+
393
+ return 0;
394
+ }
395
+
396
+ public function isLogFileTooLarge()
397
+ {
398
+ if ($this->getLogFileSize() > $this->getMaxLogFileSize())
399
+ return true;
400
+ return false;
401
+ }
402
+
403
+ public function getLoggingStatus()
404
+ {
405
+ $this->checkTimeout();
406
+
407
+ $enabled = $this->config('logging_enabled') == 1;
408
+
409
+ $stores = Mage::app()->getStores();
410
+ $stores_selected = $this->arrayConfig("logging_stores_selected");
411
+
412
+ $areas_selected = $this->arrayConfig("logging_areas_selected");
413
+
414
+ $date = $this->config('logging_start_date');
415
+
416
+ $duration = (int)$this->config('logging_duration') * 60;
417
+
418
+ $trouble_status = array(
419
+ 'enabled' => $enabled,
420
+ 'start_date' => "",
421
+ 'seconds' => "",
422
+ 'duration' => $duration,
423
+ 'duration_display' => Mage::helper('emaildirect')->getDuration($duration),
424
+ 'stores' => array()
425
+ );
426
+
427
+ if ($date != "")
428
+ {
429
+ $trouble_status['start_date'] = $date;
430
+
431
+ $trouble_status['elapsed'] = Mage::helper('emaildirect')->timeElapsed2String($date);
432
+ $now = Mage::getModel('core/date')->gmtTimestamp();
433
+ $trouble_status['seconds'] = abs($now - strtotime($date));
434
+ }
435
+
436
+ foreach ($stores as $store)
437
+ {
438
+ $data = array();
439
+
440
+ $store_id = $store->getId();
441
+
442
+ $selected = in_array($store_id,$stores_selected);
443
+
444
+ $data['id'] = $store_id;
445
+ $data['name'] = Mage::helper('emaildirect')->getFullStoreName($store);
446
+
447
+ $data['emaildirect_enabled'] = Mage::helper('emaildirect')->config('active',$store) == 1;
448
+
449
+ if ($enabled)
450
+ $data['logging_enabled'] = $this->isLoggingEnabledForStore($store_id);
451
+ else
452
+ $data['logging_enabled'] = false;
453
+
454
+ $data['selected'] = $selected;
455
+
456
+ $trouble_status['stores'][$store_id] = $data;
457
+ }
458
+
459
+ $areas = array();
460
+
461
+ foreach ($this->_areas as $area => $label)
462
+ {
463
+
464
+ if ($enabled == false)
465
+ $area_enabled = false;
466
+ else
467
+ $area_enabled = $this->isLoggingEnabledForArea($area);
468
+
469
+ $areas[$area] = array(
470
+ 'area' => $area,
471
+ 'label' => $label,
472
+ 'logging_enabled' => $area_enabled,
473
+ 'selected' => in_array($area,$areas_selected)
474
+ );
475
+ }
476
+
477
+ $trouble_status['areas'] = $areas;
478
+
479
+ return $trouble_status;
480
+ }
481
+
482
+ public function getLogFilelastUpdate()
483
+ {
484
+ $log_file = $this->getLogFilePath();
485
+
486
+ if (file_exists($log_file))
487
+ return filemtime($log_file);
488
+
489
+ return "";
490
+ }
491
+
492
+ public function getMaxLogFileSize()
493
+ {
494
+ return $this->config('max_file_size');
495
+ }
496
+
497
+ public function config($value)
498
+ {
499
+ return Mage::getStoreConfig("emaildirect/troubleshooting/{$value}", 0);
500
+ }
501
+
502
+ public function arrayConfig($value)
503
+ {
504
+ $data = $this->config($value);
505
+
506
+ if ($data == "")
507
+ return array();
508
+
509
+ return explode(",",$data);
510
+ }
511
+
512
+ private function updateConfig($path, $value, $scope = "default", $store = 0)
513
+ {
514
+ $config = Mage::getConfig();
515
+ $config->saveConfig("emaildirect/troubleshooting/{$path}",$value,$scope,$store);
516
+ $config->cleanCache();
517
+ }
518
+
519
+ public function disable()
520
+ {
521
+ $this->updateConfig("logging_start_date","");
522
+ $this->updateConfig("logging_enabled","0");
523
+ }
524
+
525
+ public function isDiagnosticEnabled()
526
+ {
527
+ return $this->config('diagnostic_enabled') == 1;
528
+ }
529
+
530
+ private function getConfigOptions()
531
+ {
532
+ if ($this->_config_options == null)
533
+ {
534
+ $options = $this->config('options');
535
+
536
+ if ($options == "")
537
+ $this->_config_options = "";
538
+ else
539
+ $this->_config_options = unserialize($options);
540
+ }
541
+
542
+ return $this->_config_options;
543
+ }
544
+
545
+ private function isLoggingEnabledForArea($area = "")
546
+ {
547
+ if ($area == "")
548
+ $area = $this->_log_area;
549
+
550
+ if ($this->config('logging_areas') == "all")
551
+ return true;
552
+
553
+ $areas_selected = $this->arrayConfig("logging_areas_selected");
554
+
555
+ return in_array($area,$areas_selected);
556
+ }
557
+
558
+ private function isLoggingEnabledForStore($store = 0)
559
+ {
560
+ //if ($this->config('logging_enabled') == 0)
561
+ //return false;
562
+
563
+ if ($this->config('logging_stores') == "all")
564
+ return true;
565
+
566
+ $stores_selected = $this->arrayConfig("logging_stores_selected");
567
+
568
+ if (is_object($store))
569
+ $store = $store->getId();
570
+
571
+ return in_array($store,$stores_selected);
572
+ }
573
+
574
+ private function isLoggingEnabledForIP()
575
+ {
576
+ //if ($this->config('logging_enabled') == 0)
577
+ //return false;
578
+
579
+ $ip = Mage::helper('core/http')->getRemoteAddr();
580
+
581
+ $logging_ip = $this->arrayConfig("logging_ip");
582
+
583
+ if (count($logging_ip) == 0)
584
+ return true;
585
+
586
+ return in_array($ip,$logging_ip);
587
+ }
588
+
589
+ public function isLoggingEnabled($store = 0)
590
+ {
591
+ // First check the global setting
592
+ if (!$this->config('logging_enabled'))
593
+ return false;
594
+ if (!$this->isLoggingEnabledForIP())
595
+ return false;
596
+ if (!$this->isLoggingEnabledForArea())
597
+ return false;
598
+ if (!$this->isLoggingEnabledForStore($store))
599
+ return false;
600
+ return $this->checkTimeout();
601
+ }
602
+
603
+ private function checkTimeout()
604
+ {
605
+ $date = $this->config('logging_start_date');
606
+
607
+ if ($date == "" || $date == 0)
608
+ {
609
+ $this->disable();
610
+ return false;
611
+ }
612
+
613
+ $now = Mage::getModel('core/date')->gmtTimestamp();
614
+
615
+ $seconds = abs($now - strtotime($date));
616
+
617
+ $duration = (int)$this->config('logging_duration');
618
+
619
+ $duration *= 60;
620
+
621
+ if ($seconds > $duration)
622
+ {
623
+ $this->disable();
624
+ Mage::app()->reinitStores();
625
+ return false;
626
+ }
627
+
628
+ return true;
629
+ }
630
+
631
+ public function logAndDebug($data)
632
+ {
633
+ $this->debug($data);
634
+
635
+ $this->log($data);
636
+ }
637
+
638
+ public function log($data, $prefix = "", $area = "")
639
+ {
640
+ //$this->debug($data);
641
+
642
+ $store = Mage::helper('emaildirect')->getCurrentStore();
643
+
644
+ if ($area == "")
645
+ $area = $this->_log_area;
646
+
647
+ if ($this->_log_level > $this->_log_level_active)
648
+ return;
649
+
650
+ if ($this->isLoggingEnabled($store, $area))
651
+ {
652
+ if (is_array($data) || is_object($data))
653
+ {
654
+ if (is_object($data) && get_class($data) == "SimpleXMLElement")
655
+ $data = $this->formatXml($data->asXml());
656
+ else
657
+ $data = $this->safeDump($data);
658
+ }
659
+
660
+ if ($prefix != "")
661
+ $prefix .= ": ";
662
+
663
+ if ($area != "")
664
+ $data = "[{$area}] [{$store}] {$prefix}{$data}";
665
+
666
+ $this->forceLog($data);
667
+ }
668
+ }
669
+
670
+ public function forceLog($data)
671
+ {
672
+ Mage::log($data,null,self::LOG_FILE_NAME . self::LOG_FILE_EXT, true);
673
+ }
674
+
675
+ public function eraseLog()
676
+ {
677
+ try
678
+ {
679
+ $log_file = Mage::getBaseDir('var') . DS . 'log' . DS . self::LOG_FILE_NAME . self::LOG_FILE_EXT;
680
+
681
+ if (!file_exists($log_file))
682
+ return true;
683
+
684
+ unlink($log_file);
685
+ return true;
686
+ }
687
+ catch (Exception $e)
688
+ {
689
+ return false;
690
+ }
691
+ }
692
+
693
+ public function logReason($data)
694
+ {
695
+ $this->log($data,self::DISABLED_REASON_PREFIX);
696
+ }
697
+
698
+ public function logException($e)
699
+ {
700
+ $this->log($e->__toString(),"Exception");
701
+ }
702
+
703
+ public function logXml($xml, $prefix = "")
704
+ {
705
+ $this->log($this->formatXml($xml),$prefix);
706
+ }
707
+
708
+ public function setLogArea($area)
709
+ {
710
+ $this->_log_area = $area;
711
+ }
712
+
713
+ public function setLogLevel($level)
714
+ {
715
+ $this->_log_level = $level;
716
+ }
717
+
718
+ public function resetLogLevel()
719
+ {
720
+ $this->_log_level = self::LOG_LEVEL_NORMAL;
721
+ }
722
  }
app/code/community/EmailDirect/Integration/Model/Abandoned/Observer.php CHANGED
@@ -36,8 +36,9 @@ class EmailDirect_Integration_Model_Abandoned_Observer extends EmailDirect_Integ
36
  $this->_log("ProcessAbandoned Start");
37
  $email = $quote->getCustomerEmail();
38
 
39
- if ($email == null)
40
  $email = $quote->getEmail();
 
41
 
42
  $abandonedDate = $quote->getUpdatedAt();
43
 
@@ -49,6 +50,8 @@ class EmailDirect_Integration_Model_Abandoned_Observer extends EmailDirect_Integ
49
  $merge_vars['AbandonedDate'] = $abandonedDate;
50
  $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
51
 
 
 
52
  Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
53
 
54
  $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
36
  $this->_log("ProcessAbandoned Start");
37
  $email = $quote->getCustomerEmail();
38
 
39
+ if ($email == null) {
40
  $email = $quote->getEmail();
41
+ }
42
 
43
  $abandonedDate = $quote->getUpdatedAt();
44
 
50
  $merge_vars['AbandonedDate'] = $abandonedDate;
51
  $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
52
 
53
+ $merge_vars = Mage::helper('emaildirect')->getStoreMap($merge_vars, $quote->getStore());
54
+
55
  Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
56
 
57
  $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
app/code/community/EmailDirect/Integration/Model/System/Config/Source/Store.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Model_System_Config_Source_Store
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
8
+ Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
9
+
10
+ $options = array(
11
+ array (
12
+ 'value' => 'id',
13
+ 'label' => 'ID',
14
+ ),
15
+ array (
16
+ 'value' => 'code',
17
+ 'label' => 'Code',
18
+ ),
19
+ array (
20
+ 'value' => 'name',
21
+ 'label' => 'Name',
22
+ )
23
+ );
24
+
25
+ return $options;
26
+ }
27
+ }
app/code/community/EmailDirect/Integration/controllers/AbandonedController.php CHANGED
@@ -2,266 +2,279 @@
2
 
3
  class EmailDirect_Integration_AbandonedController extends EmailDirect_Integration_Controller_Front_Abstract
4
  {
5
- public function restoreAction()
6
- {
7
- try
8
- {
9
- $coded_cart = Mage::app()->getRequest()->getParam('cart');
10
-
11
- $cart_data = unserialize(base64_decode($coded_cart));
12
-
13
- $this->clearCart($cart_data['quote']);
14
- $this->restoreCartItems($cart_data);
15
-
16
- $this->_redirect("checkout/cart");
17
- }
18
- catch (Exception $e)
19
- {
20
- $this->getCheckout()->addError('Unable to Restore your cart');
21
- Mage::logException($e);
22
- $this->_redirect("checkout/cart");
23
- }
24
- }
25
-
26
- private function processBundleOptions($option)
27
- {
28
- $option_data = explode("-", $option);
29
-
30
- $bundle_option = array();
31
- $bundle_option_qty = array();
32
-
33
- foreach ($option_data as $od)
34
- {
35
- $od_parts = explode("=",$od);
36
-
37
- $option_id = $od_parts[0];
38
-
39
- $products = $od_parts[1];
40
-
41
- if (strpos($products,"~"))
42
- {
43
- // Single Item with Qty
44
- $option_products = explode("~",$products);
45
-
46
- $bundle_option[$option_id] = $option_products[0];
47
-
48
- $bundle_option_qty[$option_id] = $option_products[1];
49
- }
50
- else
51
- {
52
- // 1 or more items with no qty
53
- $option_products = explode(":",$products);
54
-
55
- foreach ($option_products as $op)
56
- {
57
- $bundle_option[$option_id][] = $op;
58
- }
59
- }
60
- }
61
-
62
- return array('bundle_option' => $bundle_option, 'bundle_option_qty' => $bundle_option_qty);
63
- }
64
-
65
- private function prepareCartItems($cart_data)
66
- {
67
- $id_list = explode(",",$cart_data['id']);
68
- $qty_list = explode(",",$cart_data['qty']);
69
-
70
- $item_list = array();
71
- $group_list = array();
72
- $position = 0;
73
-
74
- foreach ($id_list as $key => $item_id)
75
- {
76
- $position++;
77
- $qty = $qty_list[$key];
78
-
79
- $id_parts = explode('|',$item_id);
80
-
81
- // If there is more than just an id then we have a complex product
82
- if (count($id_parts) > 1)
83
- {
84
- $id = $id_parts[0];
85
- $option = $id_parts[1];
86
-
87
- // MAKE SURE WE CAN LOAD THE PRODUCT
88
- $product = Mage::getModel('catalog/product')->load($id);
89
- if (!$product)
90
- continue;
91
-
92
- switch ($product->getTypeId())
93
- {
94
- case "configurable":
95
- {
96
- $item_list[$position] = array(
97
- 'product_type' => 'configurable',
98
- 'product' => $product,
99
- 'qty' => $qty,
100
- 'option' => array('super_attribute' => Mage::helper('emaildirect')->getConfigurableOptions($product,$option))
101
- );
102
- } break;
103
- case "simple": // Grouped simple products
104
- {
105
- $parent_product = Mage::getModel('catalog/product')->load($option);
106
-
107
- if (!$parent_product)
108
- continue;
109
-
110
- if (!isset($group_list[$option]))
111
- {
112
- $group_list[$option] = array(
113
- 'position' => $position,
114
- 'product_type' => 'grouped',
115
- 'product' => $parent_product,
116
- 'option' => array('super_group' => array())
117
- );
118
- }
119
-
120
- $group_list[$option]['option']['super_group'][$id] = $qty;
121
- } break;
122
- case "bundle":
123
- {
124
- $item_list[$position] = array(
125
- 'product_type' => 'bundle',
126
- 'product' => $product,
127
- 'qty' => $qty,
128
- 'option' => $this->processBundleOptions($option)
129
- );
130
- } break;
131
- }
132
- }
133
- else
134
- {
135
- // Simple Product
136
-
137
- // MAKE SURE WE CAN LOAD THE PRODUCT
138
- $product = Mage::getModel('catalog/product')->load($item_id);
139
- if (!$product)
140
- continue;
141
-
142
- $item_list[] = array(
143
- 'product_type' => 'simple',
144
- 'product' => $product,
145
- 'qty' => $qty
146
- );
147
- }
148
- }
149
-
150
- // Merge the group and simple products
151
- foreach ($group_list as $group)
152
- {
153
- $item_list[$group['position']] = $group;
154
- }
155
-
156
- // Sort it so that the order matches the cart order
157
- ksort($item_list);
158
-
159
- return $item_list;
160
- }
161
-
162
- private function restoreCartItems($cart_data)
163
- {
164
- $quote = $this->getQuote();
165
-
166
- $item_list = $this->prepareCartItems($cart_data);
167
-
168
- foreach ($item_list as $item)
169
- {
170
- $this->addItemToCart($item);
171
- }
172
-
173
- // update our totals, save.
174
- $quote->getBillingAddress();
175
- $quote->collectTotals();
176
- $quote->save();
177
-
178
- $this->getCheckout()->setQuoteId($quote->getId());
179
- }
180
-
181
- private function addItemToCart($item)
182
- {
183
- try
184
- {
185
- $product = $item['product'];
186
-
187
- $data = array(
188
- 'options' => array()
189
- );
190
-
191
- if (isset($item['qty']))
192
- $data['qty'] = $item['qty'];
193
-
194
- if (isset($item['option']))
195
- {
196
- foreach ($item['option'] as $key => $option)
197
- {
198
- $data[$key] = $option;
199
- }
200
- }
201
-
202
- $quote = $this->getQuote();
203
-
204
- // add the product to our quote
205
- $quote->addProductAdvanced($product, new Varien_Object($data));
206
-
207
- return true;
208
- }
209
- catch (Exception $e)
210
- {
211
- Mage::logException($e);
212
- return false;
213
- }
214
- }
215
-
216
- private function removeOldQuote($original_quote_id)
217
- {
218
- $quote = Mage::getModel('sales/quote')->load($original_quote_id);
219
-
220
- if ($quote->getId() == $original_quote_id)
221
- $quote->delete();
222
- }
223
-
224
- private function clearCart($original_quote_id)
225
- {
226
- $customer_session = Mage::getSingleton('customer/session');
227
-
228
- $checkout = $this->getCheckout();
229
-
230
- $checkout->clear();
231
-
232
- $quote = $this->getQuote();
233
-
234
- // Check to see if we need to remove the quote
235
- // if they aren't logged in then we will need to otherwise when they login the items won't match
236
- $test_mode = Mage::app()->getRequest()->getParam('test_mode') == "true";
237
-
238
- if ((!$test_mode && $quote->getId() != $original_quote_id))
239
- $this->removeOldQuote($original_quote_id);
240
-
241
- foreach ($quote->getItemsCollection() as $item)
242
- {
243
- $item->isDeleted(true);
244
- }
245
-
246
- $quote->getBillingAddress();
247
- $quote->getShippingAddress();
248
- $quote->getPayment();
249
- $quote->setEmailDirectAbandonedDate(null);
250
-
251
- $customer = $customer_session->getCustomer();
252
- if ($customer)
253
- $quote->assignCustomer($customer);
 
 
 
 
 
 
 
 
254
 
255
- $quote->save();
256
- }
257
-
258
- private function getQuote()
259
- {
260
- return Mage::getSingleton('checkout/session')->getQuote();
261
- }
262
-
263
- private function getCheckout()
264
- {
265
- return Mage::getSingleton('checkout/session');
266
- }
 
 
 
 
 
267
  }
2
 
3
  class EmailDirect_Integration_AbandonedController extends EmailDirect_Integration_Controller_Front_Abstract
4
  {
5
+ public function restoreAction()
6
+ {
7
+ try
8
+ {
9
+ $coded_cart = Mage::app()->getRequest()->getParam('cart');
10
+
11
+ $cart_data = unserialize(base64_decode($coded_cart));
12
+
13
+ if (!$cart_data) {
14
+ Mage::throwException(Mage::helper('emaildirect')->__('Unable to Restore your cart. $cart_data is empty'));
15
+ }
16
+
17
+ $this->clearCart($cart_data['quote']);
18
+ $this->restoreCartItems($cart_data);
19
+
20
+ $this->_redirect("checkout/cart");
21
+ }
22
+ catch (Exception $e)
23
+ {
24
+ $this->getCheckout()->addError('Unable to Restore your cart');
25
+ Mage::logException($e);
26
+ $this->_redirect("checkout/cart");
27
+ }
28
+ }
29
+
30
+ private function processBundleOptions($option)
31
+ {
32
+ $option_data = explode("-", $option);
33
+
34
+ $bundle_option = array();
35
+ $bundle_option_qty = array();
36
+
37
+ foreach ($option_data as $od)
38
+ {
39
+ $od_parts = explode("=",$od);
40
+
41
+ $option_id = $od_parts[0];
42
+
43
+ $products = $od_parts[1];
44
+
45
+ if (strpos($products,"~"))
46
+ {
47
+ // Single Item with Qty
48
+ $option_products = explode("~",$products);
49
+
50
+ $bundle_option[$option_id] = $option_products[0];
51
+
52
+ $bundle_option_qty[$option_id] = $option_products[1];
53
+ }
54
+ else
55
+ {
56
+ // 1 or more items with no qty
57
+ $option_products = explode(":",$products);
58
+
59
+ foreach ($option_products as $op)
60
+ {
61
+ $bundle_option[$option_id][] = $op;
62
+ }
63
+ }
64
+ }
65
+
66
+ return array('bundle_option' => $bundle_option, 'bundle_option_qty' => $bundle_option_qty);
67
+ }
68
+
69
+ private function prepareCartItems($cart_data)
70
+ {
71
+ $id_list = explode(",",$cart_data['id']);
72
+ $qty_list = explode(",",$cart_data['qty']);
73
+
74
+ $item_list = array();
75
+ $group_list = array();
76
+ $position = 0;
77
+
78
+ foreach ($id_list as $key => $item_id)
79
+ {
80
+ $position++;
81
+ $qty = $qty_list[$key];
82
+
83
+ $id_parts = explode('|',$item_id);
84
+
85
+ // If there is more than just an id then we have a complex product
86
+ if (count($id_parts) > 1)
87
+ {
88
+ $id = $id_parts[0];
89
+ $option = $id_parts[1];
90
+
91
+ // MAKE SURE WE CAN LOAD THE PRODUCT
92
+ $product = Mage::getModel('catalog/product')->load($id);
93
+ if (!$product || !$product->getId()) {
94
+ continue;
95
+ }
96
+
97
+ switch ($product->getTypeId())
98
+ {
99
+ case "configurable":
100
+ {
101
+ $item_list[$position] = array(
102
+ 'product_type' => 'configurable',
103
+ 'product' => $product,
104
+ 'qty' => $qty,
105
+ 'option' => array('super_attribute' => Mage::helper('emaildirect')->getConfigurableOptions($product,$option))
106
+ );
107
+ } break;
108
+ case "simple": // Grouped simple products
109
+ {
110
+ $parent_product = Mage::getModel('catalog/product')->load($option);
111
+
112
+ if (!$parent_product || !$parent_product->getId())
113
+ continue;
114
+
115
+ if (!isset($group_list[$option]))
116
+ {
117
+ $group_list[$option] = array(
118
+ 'position' => $position,
119
+ 'product_type' => 'grouped',
120
+ 'product' => $parent_product,
121
+ 'option' => array('super_group' => array())
122
+ );
123
+ }
124
+
125
+ $group_list[$option]['option']['super_group'][$id] = $qty;
126
+ } break;
127
+ case "bundle":
128
+ {
129
+ $item_list[$position] = array(
130
+ 'product_type' => 'bundle',
131
+ 'product' => $product,
132
+ 'qty' => $qty,
133
+ 'option' => $this->processBundleOptions($option)
134
+ );
135
+ } break;
136
+ }
137
+ }
138
+ else
139
+ {
140
+ // Simple Product
141
+
142
+ // MAKE SURE WE CAN LOAD THE PRODUCT
143
+ $product = Mage::getModel('catalog/product')->load($item_id);
144
+
145
+ if (!$product || !$product->getId()) {
146
+ continue;
147
+ }
148
+
149
+ $item_list[] = array(
150
+ 'product_type' => 'simple',
151
+ 'product' => $product,
152
+ 'qty' => $qty
153
+ );
154
+ }
155
+ }
156
+
157
+ // Merge the group and simple products
158
+ foreach ($group_list as $group)
159
+ {
160
+ $item_list[$group['position']] = $group;
161
+ }
162
+
163
+ // Sort it so that the order matches the cart order
164
+ ksort($item_list);
165
+
166
+ return $item_list;
167
+ }
168
+
169
+ private function restoreCartItems($cart_data)
170
+ {
171
+ $quote = $this->getQuote();
172
+
173
+ $item_list = $this->prepareCartItems($cart_data);
174
+
175
+ if (count($item_list) == 0) {
176
+ throw new Exception("No cart items found!", 1);
177
+ }
178
+
179
+ foreach ($item_list as $item)
180
+ {
181
+ $this->addItemToCart($item);
182
+ }
183
+
184
+ // update our totals, save.
185
+ $quote->getBillingAddress();
186
+ $quote->collectTotals();
187
+ $quote->save();
188
+
189
+ $this->getCheckout()->setQuoteId($quote->getId());
190
+ }
191
+
192
+ private function addItemToCart($item)
193
+ {
194
+ try
195
+ {
196
+ $product = $item['product'];
197
+
198
+ $data = array(
199
+ 'options' => array()
200
+ );
201
+
202
+ if (isset($item['qty']))
203
+ $data['qty'] = $item['qty'];
204
+
205
+ if (isset($item['option']))
206
+ {
207
+ foreach ($item['option'] as $key => $option)
208
+ {
209
+ $data[$key] = $option;
210
+ }
211
+ }
212
+
213
+ $quote = $this->getQuote();
214
+
215
+ // add the product to our quote
216
+ $quote->addProductAdvanced($product, new Varien_Object($data));
217
+
218
+ return true;
219
+ }
220
+ catch (Exception $e)
221
+ {
222
+ Mage::logException($e);
223
+ return false;
224
+ }
225
+ }
226
+
227
+ private function removeOldQuote($original_quote_id)
228
+ {
229
+ $quote = Mage::getModel('sales/quote')->load($original_quote_id);
230
+
231
+ if ($quote->getId() == $original_quote_id) {
232
+ $quote->delete();
233
+ }
234
+ }
235
+
236
+ private function clearCart($original_quote_id)
237
+ {
238
+ $customer_session = Mage::getSingleton('customer/session');
239
+
240
+ $checkout = $this->getCheckout();
241
+
242
+ $checkout->clear();
243
+
244
+ $quote = $this->getQuote();
245
+
246
+ // Check to see if we need to remove the quote
247
+ // if they aren't logged in then we will need to otherwise when they login the items won't match
248
+ $test_mode = Mage::app()->getRequest()->getParam('test_mode') == "true";
249
+
250
+ if ((!$test_mode && $quote->getId() != $original_quote_id)) {
251
+ $this->removeOldQuote($original_quote_id);
252
+ }
253
+
254
+ foreach ($quote->getItemsCollection() as $item) {
255
+ $item->isDeleted(true);
256
+ }
257
+
258
+ $quote->getBillingAddress();
259
+ $quote->getShippingAddress();
260
+ $quote->getPayment();
261
+ $quote->setEmailDirectAbandonedDate(null);
262
 
263
+ $customer = $customer_session->getCustomer();
264
+ if ($customer) {
265
+ $quote->assignCustomer($customer);
266
+ }
267
+
268
+ $quote->save();
269
+ }
270
+
271
+ private function getQuote()
272
+ {
273
+ return Mage::getSingleton('checkout/session')->getQuote();
274
+ }
275
+
276
+ private function getCheckout()
277
+ {
278
+ return Mage::getSingleton('checkout/session');
279
+ }
280
  }
app/code/community/EmailDirect/Integration/controllers/Admin/DiagnosticController.php DELETED
@@ -1,491 +0,0 @@
1
- <?php
2
-
3
- class EmailDirect_Integration_Admin_DiagnosticController extends Mage_Adminhtml_Controller_Action
4
- {
5
- private $_logger = null;
6
- private $_order = null;
7
- private $_quote = null;
8
- private $_result = array();
9
-
10
- protected function _isAllowed()
11
- {
12
- return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_diagnostics');
13
- }
14
-
15
- public function downloadAction()
16
- {
17
- $filename = $this->getRequest()->getParam('filename');
18
-
19
- $output = $this->getRequest()->getParam('output');
20
-
21
- $this->_prepareDownloadResponse($filename, $output);
22
- }
23
-
24
- public function ajaxAction()
25
- {
26
- $this->_logger = Mage::helper('emaildirect/troubleshooting');
27
- $this->_logger->turnOnDebug();
28
-
29
- $method = $this->getRequest()->getParam('method');
30
- $success = false;
31
-
32
- switch ($method)
33
- {
34
- // Orders
35
- case "order_last_items": $success = $this->lastOrderItems(); break;
36
- case "order_related_items": $success = $this->relatedOrderItems(); break;
37
- case "order_full": $success = $this->fullOrder(false); break;
38
- case "order_full_request": $success = $this->fullOrder(); break;
39
- case "order_custom_fields": $success = $this->customFields(); break;
40
- case "tracking_info": $success = $this->trackingInfo(); break;
41
-
42
- // Abandoned
43
- case "abandoned_url": $success = $this->AbandonedUrl(); break;
44
- case "abandoned_custom_fields": $success = $this->AbandonedCustomFields(); break;
45
- case "abandoned_request": $success = $this->abandonedFull(); break;
46
- case "abandoned_request_full": $success = $this->abandonedFull(false); break;
47
- }
48
-
49
- $this->_logger->turnOffDebug();
50
-
51
- if ($success)
52
- $this->setSuccess($this->_output, $this->_logger->getDebugData());
53
-
54
- $this->getResponse()->setBody(json_encode($this->_result));
55
- }
56
-
57
- private function getCss()
58
- {
59
- $css = "<style>
60
-
61
- .diagnostic_table { border-collapse: collapse; }
62
- .diagnostic_table tr td { border: solid 1px; padding: 4px; }
63
- .diagnostic_table tr td:first-child { font-weight: bold; }
64
-
65
- </style>";
66
-
67
- return $css;
68
- }
69
-
70
- private function setSuccess($output, $details)
71
- {
72
- $this->_result['success'] = true;
73
-
74
- if (is_array($details))
75
- $this->_result['details'] = implode("<br />",$details) . "<br /><br />";
76
- else
77
- $this->_result['details'] = $details;
78
-
79
- $this->_result['output'] = $this->getCss() . $output;
80
-
81
- return true;
82
- }
83
-
84
- private function setFailure($message)
85
- {
86
- $this->_result['success'] = false;
87
- $this->_result['error'] = true;
88
-
89
- $this->_result['message'] = $message;
90
-
91
- return false;
92
- }
93
-
94
- private function debug($data)
95
- {
96
- $this->_logger->debug($data);
97
- }
98
-
99
- private function debugHeader($data, $level = 2)
100
- {
101
- $this->_logger->debugHeader($data, $level);
102
- }
103
-
104
- private function getOrder()
105
- {
106
- if ($this->_order != null)
107
- return $this->_order;
108
-
109
- $order_id = $this->getRequest()->getParam('item_id');
110
-
111
- $this->_order = Mage::getModel('sales/order')->load($order_id);
112
-
113
- if ($this->_order != null && !$this->_order->getId())
114
- $this->_order = null;
115
- else
116
- Mage::app()->setCurrentStore($this->_order->getStoreId());
117
-
118
- return $this->_order;
119
- }
120
-
121
- private function getQuote()
122
- {
123
- if ($this->_quote != null)
124
- return $this->_quote;
125
-
126
- $quote_id = $this->getRequest()->getParam('item_id');
127
- $store_id = $this->getRequest()->getParam('store_id');
128
-
129
- $store = Mage::getModel('core/store')->load($store_id);
130
-
131
- $this->_quote = Mage::getModel('sales/quote')->setStore($store)->load($quote_id);
132
-
133
- if ($this->_quote != null && !$this->_quote->getId())
134
- $this->_quote = null;
135
- else
136
- Mage::app()->setCurrentStore($store);
137
-
138
- return $this->_quote;
139
- }
140
-
141
- private function decorateArray($array)
142
- {
143
- //Zend_debug::dump($array);
144
- $output = "<table class='diagnostic_table'>";
145
- $output .= "<tr>";
146
- $keys = array_keys($array);
147
-
148
- foreach ($keys as $key)
149
- {
150
- $output .= "<th>{$key}</th>";
151
- }
152
-
153
- $output .= "</tr>";
154
-
155
- foreach ($array as $row)
156
- {
157
- $output .= "<tr>";
158
-
159
- foreach ($row as $data)
160
- {
161
- $output .= "<td>{$data}</td>";
162
- }
163
-
164
- $output .= "</tr>";
165
- }
166
-
167
- $output .= "</table>";
168
-
169
- return $output;
170
- }
171
-
172
- private function arrayToTable($array)
173
- {
174
- $output = "<table class='diagnostic_table' cellspacing='0'>";
175
-
176
- foreach ($array as $key => $value)
177
- {
178
- $output .= "<tr><td>{$key}</td><td>{$value}</td></tr>";
179
- }
180
-
181
- return $output . "</table>";
182
- }
183
-
184
- private function getNumberedKeys($array)
185
- {
186
- $keys = array();
187
-
188
- foreach ($array as $key => $value)
189
- {
190
- if (strpos($key,"1") === false)
191
- return $keys;
192
-
193
- $keys[] = substr($key,0,strlen($key) - 1);
194
- }
195
-
196
- return $keys;
197
- }
198
-
199
- private function numberedItemsDisplay($array)
200
- {
201
- $output = "";
202
-
203
- $keys = $this->getNumberedKeys($array);
204
-
205
- $first_key = $keys[0];
206
-
207
- $count = 1;
208
-
209
- while (isset($array["{$first_key}{$count}"]))
210
- {
211
- $output .= "<h3>Item # {$count}</h3>";
212
-
213
- $output .= "<table class='diagnostic_table' cellspacing='0'>";
214
-
215
- foreach ($keys as $key)
216
- {
217
- $output .= "<tr><td>{$key}</td><td>" . $array["{$key}{$count}"] . "</td></tr>";
218
- }
219
-
220
- $output .= "</table><br />";
221
-
222
- $count++;
223
- }
224
-
225
-
226
- return $output;
227
- }
228
-
229
- private function lastOrderItems()
230
- {
231
- $order = $this->getOrder();
232
-
233
- if ($order == null)
234
- return $this->setFailure("Order not found");
235
-
236
- $this->debugHeader('Last Order Items');
237
-
238
- $this->debug('Order #' . $order->getIncrementId());
239
-
240
- $merge_vars = array();
241
-
242
- $order_helper = Mage::helper('emaildirect/order');
243
-
244
- $merge_vars = $order_helper->getMergeOrderItems($order, $merge_vars);
245
-
246
- $this->debug('');
247
- $this->debugHeader('Latest Order Items',1);
248
- $this->debug($merge_vars);
249
-
250
- $this->debugHeader('Last Order Items Complete!');
251
-
252
- $this->_output = "<h2>Order Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
253
-
254
- return true;
255
- }
256
-
257
- private function relatedOrderItems()
258
- {
259
- $order = $this->getOrder();
260
-
261
- if ($order == null)
262
- return $this->setFailure("Order not found");
263
-
264
- $this->debugHeader('Related Order Items');
265
-
266
- $this->debug('Order #' . $order->getIncrementId());
267
- $this->debug('');
268
-
269
- $merge_vars = array();
270
-
271
- $order_helper = Mage::helper('emaildirect/order');
272
-
273
- $merge_vars = $order_helper->getRelatedOrderItems($order, $merge_vars);
274
-
275
- $this->debugHeader('Related Order Items',1);
276
- $this->debug($merge_vars);
277
-
278
- $this->debugHeader('Related Order Items Complete!');
279
-
280
- $this->_output = "<h2>Related Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
281
-
282
- return true;
283
- }
284
-
285
- private function fullOrder($request_only = true)
286
- {
287
- $order = $this->getOrder();
288
-
289
- if ($order == null)
290
- return $this->setFailure("Order not found");
291
-
292
- $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
293
-
294
- $merge_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
295
-
296
- $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
297
-
298
- //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
299
-
300
- //$this->_logger->debugXml($order_xml);
301
-
302
- if ($request_only)
303
- $this->_logger->setDebugExecuteMode('request_only');
304
- else
305
- $this->_logger->setDebugExecuteMode('full');
306
-
307
- Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
308
-
309
- $this->_output = "<h2>Full Order Diagnostic Results</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
310
-
311
- if (!$request_only)
312
- {
313
- $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
314
- }
315
-
316
- return true;
317
- }
318
-
319
- private function customFields()
320
- {
321
- $order = $this->getOrder();
322
-
323
- if ($order == null)
324
- return $this->setFailure("Order not found");
325
-
326
- $this->debugHeader('Custom Fields Diagnostic Starting');
327
-
328
- $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
329
-
330
- $this->debugHeader('Customer Related Merge Vars',1);
331
-
332
- $customer_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
333
-
334
- $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
335
-
336
- //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
337
-
338
- //$this->_logger->debugXml($order_xml);
339
-
340
- $this->_output = "<h2>Custom Fields Diagnostic Results</h2><h3>Customer Fields</h3>" . $this->arrayToTable($customer_vars);
341
- $this->_output .= "<br /><h3>Order Fields</h3>" . $this->arrayToTable($merge_vars);
342
-
343
- return true;
344
- }
345
-
346
- private function abandonedUrl()
347
- {
348
- $quote = $this->getQuote();
349
-
350
- if ($quote == null)
351
- return $this->setFailure("Quote not found");
352
-
353
- $this->debugHeader('Abandoned URL');
354
-
355
- //$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
356
-
357
- //$this->debugHeader('Customer Related Merge Vars',1);
358
-
359
- $url = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
360
-
361
- $this->_output = "<h2>Abandoned Cart Url (Restore Cart)</h2><p>Click on the link to test it (opens in a new window and won't replace customer cart data)</p>URL: <a target='_blank' href='{$url}&test_mode=true'>{$url}</a>";
362
-
363
- return true;
364
- }
365
-
366
- private function abandonedCustomFields()
367
- {
368
- $quote = $this->getQuote();
369
-
370
- if ($quote == null)
371
- return $this->setFailure("Quote not found");
372
-
373
- $this->debugHeader('Custom Fields Diagnostic Starting');
374
-
375
- $abandonedDate = $quote->getUpdatedAt();
376
-
377
- $merge_vars = array();
378
-
379
- $merge_vars['FirstName'] = $quote->getData('customer_firstname');
380
- $merge_vars['LastName'] = $quote->getData('customer_lastname');
381
-
382
- $merge_vars['AbandonedDate'] = $abandonedDate;
383
- $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
384
-
385
- // Setup sequence for this store
386
- Mage::helper('emaildirect/abandoned')->setupSequence();
387
-
388
- Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
389
-
390
- $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
391
-
392
-
393
-
394
- if (Mage::helper('emaildirect')->config('save_latest_order'))
395
- {
396
- $this->debug("Processing Last Order");
397
- $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
398
-
399
- if ($order != null)
400
- $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
401
- else
402
- $this->debug("Order not found");
403
- //$this->_log("Order not found");
404
- }
405
-
406
-
407
- //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
408
-
409
- //$this->_logger->debugXml($order_xml);
410
-
411
- $this->_output = "<h2>Custom Fields Diagnostic Results</h2>";
412
- $this->_output .= "<br /><h3>Fields</h3>" . $this->arrayToTable($merge_vars);
413
-
414
- return true;
415
- }
416
-
417
- private function getQuoteEmail($quote)
418
- {
419
- $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart($quote->getId());
420
-
421
- return $abandoned_cart->getEmail();
422
- }
423
-
424
- private function abandonedFull($request_only = true)
425
- {
426
- $quote = $this->getQuote();
427
-
428
- if ($quote == null)
429
- return $this->setFailure("Quote not found");
430
-
431
- $abandonedDate = $quote->getUpdatedAt();
432
-
433
- $email = $quote->getCustomerEmail();
434
-
435
- if ($email == null)
436
- $email = $this->getQuoteEmail($quote);
437
-
438
- $merge_vars = array();
439
-
440
- $merge_vars['FirstName'] = $quote->getData('customer_firstname');
441
- $merge_vars['LastName'] = $quote->getData('customer_lastname');
442
-
443
- $merge_vars['AbandonedDate'] = $abandonedDate;
444
- $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
445
-
446
- // Setup sequence for this store
447
- Mage::helper('emaildirect/abandoned')->setupSequence();
448
-
449
- Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
450
-
451
- $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
452
-
453
- if (Mage::helper('emaildirect')->config('save_latest_order'))
454
- {
455
- $this->debug("Processing Last Order");
456
- $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
457
-
458
- if ($order != null)
459
- $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
460
- else
461
- $this->debug("Order not found");
462
- //$this->_log("Order not found");
463
- }
464
-
465
- $xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
466
-
467
- if ($request_only)
468
- $this->_logger->setDebugExecuteMode('request_only');
469
- else
470
- $this->_logger->setDebugExecuteMode('full');
471
-
472
- $xml = "<Subscribers>{$xml}</Subscribers>";
473
-
474
- //Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
475
- $rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
476
-
477
- $this->_output = "<h2>Abandoned Cart Xml</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
478
-
479
- if (!$request_only)
480
- {
481
- $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
482
- }
483
- return true;
484
- }
485
-
486
- private function trackingInfo()
487
- {
488
-
489
- return true;
490
- }
491
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/EmailDirect/Integration/controllers/Admin/TroubleshootingController.php DELETED
@@ -1,208 +0,0 @@
1
- <?php
2
-
3
- class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Adminhtml_Controller_Action
4
- {
5
- private $_output = array();
6
- private $_config = null;
7
-
8
- protected function _isAllowed()
9
- {
10
- return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_troubleshooting');
11
- }
12
-
13
- public function indexAction()
14
- {
15
- $this->loadLayout();
16
- $this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Troubleshooting'));
17
- $this->_setActiveMenu('emaildirect');
18
- $this->renderLayout();
19
- }
20
-
21
- public function validateAction()
22
- {
23
- $apikey = $this->getRequest()->getParam('apikey');
24
-
25
- $valid = Mage::helper('emaildirect/troubleshooting')->validateApiKey($apikey);
26
-
27
- $result = array('valid' => $valid);
28
- $this->getResponse()->setBody(json_encode($result));
29
- }
30
-
31
- private function getLogFile()
32
- {
33
- $empty = false;
34
- $too_large = false;
35
- $file_size = Mage::helper('emaildirect/troubleshooting')->getLogFileSize();
36
-
37
- if ($file_size == 0)
38
- $empty = true;
39
- else
40
- $too_large = Mage::helper('emaildirect/troubleshooting')->isLogFileTooLarge();
41
-
42
- $max_size = Mage::helper('emaildirect')->formatSize(Mage::helper('emaildirect/troubleshooting')->getMaxLogFileSize());
43
-
44
- $result = array(
45
- 'success' => true,
46
- 'empty' => $empty,
47
- 'too_large' => $too_large,
48
- 'max_size' => $max_size,
49
- 'contents' => Mage::helper('emaildirect/troubleshooting')->getLogFileContents());
50
- return $result;
51
- }
52
-
53
- public function ajaxAction()
54
- {
55
- $method = $this->getRequest()->getParam('method');
56
-
57
- $result = array('success' => false);
58
-
59
- switch ($method)
60
- {
61
- case "status": $result = $this->getStatus(); break;
62
- case "log_refresh": $result = $this->getLogFile(); break;
63
- case "test_logging": $result = $this->testLogging(); break;
64
- case "erase_log": $result = $this->eraseLog(); break;
65
- }
66
-
67
- $this->getResponse()->setBody(json_encode($result));
68
-
69
- return $result;
70
- }
71
-
72
- private function eraseLog()
73
- {
74
- Mage::helper('emaildirect/troubleshooting')->eraseLog();
75
-
76
- return $this->getLogFile();
77
- }
78
-
79
- private function testLogging()
80
- {
81
- Mage::helper('emaildirect/troubleshooting')->forceLog('======================= LOG TEST =======================');
82
-
83
- return $this->getLogFile();
84
- }
85
-
86
- private function getStatus()
87
- {
88
- $status = Mage::helper('emaildirect/troubleshooting')->getStatus();
89
-
90
- $result = array();
91
- $result['success'] = true;
92
- $result['status'] = $status;
93
-
94
- return $result;
95
- }
96
-
97
- public function sendAction()
98
- {
99
- $params = $this->getRequest()->getParams();
100
-
101
- $customer = array();
102
-
103
- $customer['Customer Name'] = $params['customer_name'];
104
- $customer['Email'] = $params['customer_email'];
105
- if ($params['customer_company'] != "")
106
- $customer['Company'] = $params['customer_company'];
107
- $customer['Comments'] = $params['customer_comments'];
108
-
109
- $message = Mage::helper('emaildirect/troubleshooting')->getReport($customer);
110
-
111
- $to = Mage::helper('emaildirect')->troubleConfig('email');
112
- $subject = Mage::helper('emaildirect')->troubleConfig('subject');
113
- $from = $params['customer_email'];
114
-
115
- $headers = "From: {$from}\r\n";
116
- $headers .= "Content-type: text/html\r\n";
117
-
118
- // now lets send the email.
119
- $sent = mail($to, $subject, $message, $headers);
120
-
121
- if ($sent)
122
- {
123
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting Report was sent to EmailDirect'));
124
-
125
- $this->_redirect('adminhtml/system_config/edit/',array('section' => 'emaildirect'));
126
- }
127
- else
128
- {
129
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('emaildirect')->__('Failed to send Report Email'));
130
-
131
- $this->_redirect('ed_integration/admin_troubleshooting/');
132
- }
133
- }
134
-
135
- public function downloadAction()
136
- {
137
- $output = Mage::helper('emaildirect/troubleshooting')->getReport();
138
-
139
- $this->_prepareDownloadResponse(Mage::helper('emaildirect')->troubleConfig('report_file'), $output);
140
- }
141
-
142
- private function updateConfig($path, $value)
143
- {
144
- $this->_config->saveConfig("emaildirect/troubleshooting/{$path}",$value,"default",0);
145
- }
146
-
147
- public function saveAction()
148
- {
149
- $params = $this->getRequest()->getParams();
150
-
151
- $this->_config = Mage::getConfig();
152
-
153
- $enabled = $params['logging_enabled'];
154
-
155
- if ($enabled == "yes")
156
- {
157
- $this->updateConfig('logging_enabled',1);
158
-
159
- $date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
160
- $start_date = date($date_format, Mage::getModel('core/date')->gmtTimestamp());
161
-
162
- $this->updateConfig("logging_start_date",$start_date);
163
-
164
- $advanced_enabled = $params['logging_advanced_enabled'];
165
-
166
- if ($advanced_enabled)
167
- {
168
- $this->updateConfig("logging_advanced_enabled", 1);
169
-
170
- $logging_stores = $params['logging_stores'];
171
-
172
- if ($logging_stores == "selected")
173
- {
174
- if (isset($params['logging_stores_selected']))
175
- $this->updateConfig("logging_stores_selected", implode(",",$params['logging_stores_selected']));
176
- }
177
-
178
- $this->updateConfig("logging_stores", $logging_stores);
179
-
180
- $logging_areas = $params['logging_areas'];
181
-
182
- if ($logging_areas == "selected")
183
- {
184
- if (isset($params['logging_areas_selected']))
185
- $this->updateConfig("logging_areas_selected", implode(",",$params['logging_areas_selected']));
186
- }
187
-
188
- $this->updateConfig("logging_areas", $logging_areas);
189
- $this->updateConfig("logging_duration", $params['logging_duration']);
190
- }
191
- else
192
- {
193
- $this->updateConfig("logging_duration", 10);
194
- $this->updateConfig("logging_advanced_enabled", 0);
195
- }
196
- }
197
- else
198
- $this->updateConfig('logging_enabled',0);
199
-
200
- $this->updateConfig('diagnostic_enabled',$params['diagnostic_enabled']);
201
-
202
- $this->_config->cleanCache();
203
-
204
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting settings updated!'));
205
-
206
- $this->_redirect("*/*/index",Mage::helper('emaildirect')->getAdminUrlParams(array('tab' => 'troubleshooting_view_tabs_trouble_settings')));
207
- }
208
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/EmailDirect/Integration/controllers/{Admin → Adminhtml/EmailDirect}/AbandonedController.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected function _isAllowed()
6
  {
1
  <?php
2
 
3
+ class EmailDirect_Integration_Adminhtml_EmailDirect_AbandonedController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected function _isAllowed()
6
  {
app/code/community/EmailDirect/Integration/controllers/Adminhtml/EmailDirect/DiagnosticController.php ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Adminhtml_EmailDirect_DiagnosticController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ private $_logger = null;
6
+ private $_order = null;
7
+ private $_quote = null;
8
+ private $_result = array();
9
+
10
+ protected function _isAllowed()
11
+ {
12
+ return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_diagnostics');
13
+ }
14
+
15
+ public function downloadAction()
16
+ {
17
+ $filename = $this->getRequest()->getParam('filename');
18
+
19
+ $output = $this->getRequest()->getParam('output');
20
+
21
+ $this->_prepareDownloadResponse($filename, $output);
22
+ }
23
+
24
+ public function ajaxAction()
25
+ {
26
+ $this->_logger = Mage::helper('emaildirect/troubleshooting');
27
+ $this->_logger->turnOnDebug();
28
+
29
+ $method = $this->getRequest()->getParam('method');
30
+ $success = false;
31
+
32
+ switch ($method)
33
+ {
34
+ // Orders
35
+ case "order_last_items": $success = $this->lastOrderItems(); break;
36
+ case "order_related_items": $success = $this->relatedOrderItems(); break;
37
+ case "order_full": $success = $this->fullOrder(false); break;
38
+ case "order_full_request": $success = $this->fullOrder(); break;
39
+ case "order_custom_fields": $success = $this->customFields(); break;
40
+ case "tracking_info": $success = $this->trackingInfo(); break;
41
+
42
+ // Abandoned
43
+ case "abandoned_url": $success = $this->AbandonedUrl(); break;
44
+ case "abandoned_custom_fields": $success = $this->AbandonedCustomFields(); break;
45
+ case "abandoned_request": $success = $this->abandonedFull(); break;
46
+ case "abandoned_request_full": $success = $this->abandonedFull(false); break;
47
+ }
48
+
49
+ $this->_logger->turnOffDebug();
50
+
51
+ if ($success)
52
+ $this->setSuccess($this->_output, $this->_logger->getDebugData());
53
+
54
+ $this->getResponse()->setBody(json_encode($this->_result));
55
+ }
56
+
57
+ private function getCss()
58
+ {
59
+ $css = "<style>
60
+
61
+ .diagnostic_table { border-collapse: collapse; }
62
+ .diagnostic_table tr td { border: solid 1px; padding: 4px; }
63
+ .diagnostic_table tr td:first-child { font-weight: bold; }
64
+
65
+ </style>";
66
+
67
+ return $css;
68
+ }
69
+
70
+ private function setSuccess($output, $details)
71
+ {
72
+ $this->_result['success'] = true;
73
+
74
+ if (is_array($details))
75
+ $this->_result['details'] = implode("<br />",$details) . "<br /><br />";
76
+ else
77
+ $this->_result['details'] = $details;
78
+
79
+ $this->_result['output'] = $this->getCss() . $output;
80
+
81
+ return true;
82
+ }
83
+
84
+ private function setFailure($message)
85
+ {
86
+ $this->_result['success'] = false;
87
+ $this->_result['error'] = true;
88
+
89
+ $this->_result['message'] = $message;
90
+
91
+ return false;
92
+ }
93
+
94
+ private function debug($data)
95
+ {
96
+ $this->_logger->debug($data);
97
+ }
98
+
99
+ private function debugHeader($data, $level = 2)
100
+ {
101
+ $this->_logger->debugHeader($data, $level);
102
+ }
103
+
104
+ private function getOrder()
105
+ {
106
+ if ($this->_order != null)
107
+ return $this->_order;
108
+
109
+ $order_id = $this->getRequest()->getParam('item_id');
110
+
111
+ $this->_order = Mage::getModel('sales/order')->load($order_id);
112
+
113
+ if ($this->_order != null && !$this->_order->getId())
114
+ $this->_order = null;
115
+ else
116
+ Mage::app()->setCurrentStore($this->_order->getStoreId());
117
+
118
+ return $this->_order;
119
+ }
120
+
121
+ private function getQuote()
122
+ {
123
+ if ($this->_quote != null)
124
+ return $this->_quote;
125
+
126
+ $quote_id = $this->getRequest()->getParam('item_id');
127
+ $store_id = $this->getRequest()->getParam('store_id');
128
+
129
+ $store = Mage::getModel('core/store')->load($store_id);
130
+
131
+ $this->_quote = Mage::getModel('sales/quote')->setStore($store)->load($quote_id);
132
+
133
+ if ($this->_quote != null && !$this->_quote->getId())
134
+ $this->_quote = null;
135
+ else
136
+ Mage::app()->setCurrentStore($store);
137
+
138
+ return $this->_quote;
139
+ }
140
+
141
+ private function decorateArray($array)
142
+ {
143
+ //Zend_debug::dump($array);
144
+ $output = "<table class='diagnostic_table'>";
145
+ $output .= "<tr>";
146
+ $keys = array_keys($array);
147
+
148
+ foreach ($keys as $key)
149
+ {
150
+ $output .= "<th>{$key}</th>";
151
+ }
152
+
153
+ $output .= "</tr>";
154
+
155
+ foreach ($array as $row)
156
+ {
157
+ $output .= "<tr>";
158
+
159
+ foreach ($row as $data)
160
+ {
161
+ $output .= "<td>{$data}</td>";
162
+ }
163
+
164
+ $output .= "</tr>";
165
+ }
166
+
167
+ $output .= "</table>";
168
+
169
+ return $output;
170
+ }
171
+
172
+ private function arrayToTable($array)
173
+ {
174
+ $output = "<table class='diagnostic_table' cellspacing='0'>";
175
+
176
+ foreach ($array as $key => $value)
177
+ {
178
+ $output .= "<tr><td>{$key}</td><td>{$value}</td></tr>";
179
+ }
180
+
181
+ return $output . "</table>";
182
+ }
183
+
184
+ private function getNumberedKeys($array)
185
+ {
186
+ $keys = array();
187
+
188
+ foreach ($array as $key => $value)
189
+ {
190
+ if (strpos($key,"1") === false)
191
+ return $keys;
192
+
193
+ $keys[] = substr($key,0,strlen($key) - 1);
194
+ }
195
+
196
+ return $keys;
197
+ }
198
+
199
+ private function numberedItemsDisplay($array)
200
+ {
201
+ $output = "";
202
+
203
+ $keys = $this->getNumberedKeys($array);
204
+
205
+ $first_key = $keys[0];
206
+
207
+ $count = 1;
208
+
209
+ while (isset($array["{$first_key}{$count}"]))
210
+ {
211
+ $output .= "<h3>Item # {$count}</h3>";
212
+
213
+ $output .= "<table class='diagnostic_table' cellspacing='0'>";
214
+
215
+ foreach ($keys as $key)
216
+ {
217
+ $output .= "<tr><td>{$key}</td><td>" . $array["{$key}{$count}"] . "</td></tr>";
218
+ }
219
+
220
+ $output .= "</table><br />";
221
+
222
+ $count++;
223
+ }
224
+
225
+
226
+ return $output;
227
+ }
228
+
229
+ private function lastOrderItems()
230
+ {
231
+ $order = $this->getOrder();
232
+
233
+ if ($order == null)
234
+ return $this->setFailure("Order not found");
235
+
236
+ $this->debugHeader('Last Order Items');
237
+
238
+ $this->debug('Order #' . $order->getIncrementId());
239
+
240
+ $merge_vars = array();
241
+
242
+ $order_helper = Mage::helper('emaildirect/order');
243
+
244
+ $merge_vars = $order_helper->getMergeOrderItems($order, $merge_vars);
245
+
246
+ $this->debug('');
247
+ $this->debugHeader('Latest Order Items',1);
248
+ $this->debug($merge_vars);
249
+
250
+ $this->debugHeader('Last Order Items Complete!');
251
+
252
+ $this->_output = "<h2>Order Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
253
+
254
+ return true;
255
+ }
256
+
257
+ private function relatedOrderItems()
258
+ {
259
+ $order = $this->getOrder();
260
+
261
+ if ($order == null)
262
+ return $this->setFailure("Order not found");
263
+
264
+ $this->debugHeader('Related Order Items');
265
+
266
+ $this->debug('Order #' . $order->getIncrementId());
267
+ $this->debug('');
268
+
269
+ $merge_vars = array();
270
+
271
+ $order_helper = Mage::helper('emaildirect/order');
272
+
273
+ $merge_vars = $order_helper->getRelatedOrderItems($order, $merge_vars);
274
+
275
+ $this->debugHeader('Related Order Items',1);
276
+ $this->debug($merge_vars);
277
+
278
+ $this->debugHeader('Related Order Items Complete!');
279
+
280
+ $this->_output = "<h2>Related Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
281
+
282
+ return true;
283
+ }
284
+
285
+ private function fullOrder($request_only = true)
286
+ {
287
+ $order = $this->getOrder();
288
+
289
+ if ($order == null)
290
+ return $this->setFailure("Order not found");
291
+
292
+ $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
293
+
294
+ $merge_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
295
+
296
+ $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
297
+
298
+ //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
299
+
300
+ //$this->_logger->debugXml($order_xml);
301
+
302
+ if ($request_only)
303
+ $this->_logger->setDebugExecuteMode('request_only');
304
+ else
305
+ $this->_logger->setDebugExecuteMode('full');
306
+
307
+ Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
308
+
309
+ $this->_output = "<h2>Full Order Diagnostic Results</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
310
+
311
+ if (!$request_only)
312
+ {
313
+ $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
314
+ }
315
+
316
+ return true;
317
+ }
318
+
319
+ private function customFields()
320
+ {
321
+ $order = $this->getOrder();
322
+
323
+ if ($order == null)
324
+ return $this->setFailure("Order not found");
325
+
326
+ $this->debugHeader('Custom Fields Diagnostic Starting');
327
+
328
+ $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
329
+
330
+ $this->debugHeader('Customer Related Merge Vars',1);
331
+
332
+ $customer_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
333
+
334
+ $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
335
+
336
+ //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
337
+
338
+ //$this->_logger->debugXml($order_xml);
339
+
340
+ $this->_output = "<h2>Custom Fields Diagnostic Results</h2><h3>Customer Fields</h3>" . $this->arrayToTable($customer_vars);
341
+ $this->_output .= "<br /><h3>Order Fields</h3>" . $this->arrayToTable($merge_vars);
342
+
343
+ return true;
344
+ }
345
+
346
+ private function abandonedUrl()
347
+ {
348
+ $quote = $this->getQuote();
349
+
350
+ if ($quote == null)
351
+ return $this->setFailure("Quote not found");
352
+
353
+ $this->debugHeader('Abandoned URL');
354
+
355
+ //$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
356
+
357
+ //$this->debugHeader('Customer Related Merge Vars',1);
358
+
359
+ $url = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
360
+
361
+ $this->_output = "<h2>Abandoned Cart Url (Restore Cart)</h2><p>Click on the link to test it (opens in a new window and won't replace customer cart data)</p>URL: <a target='_blank' href='{$url}&test_mode=true'>{$url}</a>";
362
+
363
+ return true;
364
+ }
365
+
366
+ private function abandonedCustomFields()
367
+ {
368
+ $quote = $this->getQuote();
369
+
370
+ if ($quote == null) {
371
+ return $this->setFailure("Quote not found");
372
+ }
373
+
374
+ $this->debugHeader('Custom Fields Diagnostic Starting');
375
+
376
+ $abandonedDate = $quote->getUpdatedAt();
377
+
378
+ $merge_vars = array();
379
+
380
+ $merge_vars['FirstName'] = $quote->getData('customer_firstname');
381
+ $merge_vars['LastName'] = $quote->getData('customer_lastname');
382
+
383
+ $merge_vars['AbandonedDate'] = $abandonedDate;
384
+ $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
385
+
386
+ // Setup sequence for this store
387
+ Mage::helper('emaildirect/abandoned')->setupSequence();
388
+
389
+ Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
390
+
391
+ $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
392
+
393
+ $merge_vars = Mage::helper('emaildirect')->getStoreMap($merge_vars, $quote->getStore());
394
+
395
+ if (Mage::helper('emaildirect')->config('save_latest_order'))
396
+ {
397
+ $this->debug("Processing Last Order");
398
+ $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
399
+
400
+ if ($order != null)
401
+ $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
402
+ else
403
+ $this->debug("Order not found");
404
+ }
405
+
406
+ $this->_output = "<h2>Custom Fields Diagnostic Results</h2>";
407
+ $this->_output .= "<br /><h3>Fields</h3>" . $this->arrayToTable($merge_vars);
408
+
409
+ return true;
410
+ }
411
+
412
+ private function getQuoteEmail($quote)
413
+ {
414
+ $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart($quote->getId());
415
+
416
+ return $abandoned_cart->getEmail();
417
+ }
418
+
419
+ private function abandonedFull($request_only = true)
420
+ {
421
+ $quote = $this->getQuote();
422
+
423
+ if ($quote == null) {
424
+ return $this->setFailure("Quote not found");
425
+ }
426
+
427
+ $abandonedDate = $quote->getUpdatedAt();
428
+
429
+ $email = $quote->getCustomerEmail();
430
+
431
+ if ($email == null)
432
+ $email = $this->getQuoteEmail($quote);
433
+
434
+ $merge_vars = array();
435
+
436
+ $merge_vars['FirstName'] = $quote->getData('customer_firstname');
437
+ $merge_vars['LastName'] = $quote->getData('customer_lastname');
438
+
439
+ $merge_vars['AbandonedDate'] = $abandonedDate;
440
+ $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
441
+
442
+ $merge_vars = Mage::helper('emaildirect')->getStoreMap($merge_vars, $quote->getStore());
443
+
444
+ // Setup sequence for this store
445
+ Mage::helper('emaildirect/abandoned')->setupSequence();
446
+
447
+ Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
448
+
449
+ $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
450
+
451
+ if (Mage::helper('emaildirect')->config('save_latest_order'))
452
+ {
453
+ $this->debug("Processing Last Order");
454
+ $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
455
+
456
+ if ($order != null)
457
+ $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
458
+ else
459
+ $this->debug("Order not found");
460
+ //$this->_log("Order not found");
461
+ }
462
+
463
+ $xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
464
+
465
+ if ($request_only)
466
+ $this->_logger->setDebugExecuteMode('request_only');
467
+ else
468
+ $this->_logger->setDebugExecuteMode('full');
469
+
470
+ $xml = "<Subscribers>{$xml}</Subscribers>";
471
+
472
+ //Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
473
+ $rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
474
+
475
+ $this->_output = "<h2>Abandoned Cart Xml</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
476
+
477
+ if (!$request_only)
478
+ {
479
+ $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
480
+ }
481
+ return true;
482
+ }
483
+
484
+ private function trackingInfo()
485
+ {
486
+
487
+ return true;
488
+ }
489
+ }
app/code/community/EmailDirect/Integration/controllers/{Admin → Adminhtml/EmailDirect}/ExportController.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected $_min_category_level = 2;
6
 
@@ -326,7 +326,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
326
  'download_link' => $url,
327
  );
328
 
329
- $ed_url = $this->getUrl('ed_integration/export/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
330
  $api = Mage::getSingleton('emaildirect/wrapper_ftp');
331
  $rc = $api->upload($ed_url,"magento_" . $this->getExportType() . "s_{$file_name}.csv");
332
 
1
  <?php
2
 
3
+ class EmailDirect_Integration_Adminhtml_EmailDirect_ExportController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected $_min_category_level = 2;
6
 
326
  'download_link' => $url,
327
  );
328
 
329
+ $ed_url = $this->getUrl('adminhtml/emaildirect_export/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
330
  $api = Mage::getSingleton('emaildirect/wrapper_ftp');
331
  $rc = $api->upload($ed_url,"magento_" . $this->getExportType() . "s_{$file_name}.csv");
332
 
app/code/community/EmailDirect/Integration/controllers/Adminhtml/EmailDirect/TroubleshootingController.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_Adminhtml_EmailDirect_TroubleshootingController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ private $_output = array();
6
+ private $_config = null;
7
+
8
+ protected function _isAllowed()
9
+ {
10
+ return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_troubleshooting');
11
+ }
12
+
13
+ public function indexAction()
14
+ {
15
+ $this->loadLayout();
16
+ $this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Troubleshooting'));
17
+ $this->_setActiveMenu('emaildirect');
18
+ $this->renderLayout();
19
+ }
20
+
21
+ public function validateAction()
22
+ {
23
+ $apikey = $this->getRequest()->getParam('apikey');
24
+
25
+ $valid = Mage::helper('emaildirect/troubleshooting')->validateApiKey($apikey);
26
+
27
+ $result = array('valid' => $valid);
28
+ $this->getResponse()->setBody(json_encode($result));
29
+ }
30
+
31
+ private function getLogFile()
32
+ {
33
+ $file = $this->getRequest()->getParam('file');
34
+
35
+ $empty = false;
36
+ $too_large = false;
37
+ $file_size = Mage::helper('emaildirect/troubleshooting')->getLogFileSize($file);
38
+
39
+ if ($file_size == 0) {
40
+ $empty = true;
41
+ } else {
42
+ $too_large = Mage::helper('emaildirect/troubleshooting')->isLogFileTooLarge();
43
+ }
44
+
45
+ $max_size = Mage::helper('emaildirect')->formatSize(Mage::helper('emaildirect/troubleshooting')->getMaxLogFileSize());
46
+
47
+ $result = array(
48
+ 'success' => true,
49
+ 'empty' => $empty,
50
+ 'too_large' => $too_large,
51
+ 'max_size' => $max_size,
52
+ 'contents' => utf8_encode(Mage::helper('emaildirect/troubleshooting')->getLogFileContents($file))
53
+ );
54
+
55
+ return $result;
56
+ }
57
+
58
+ public function ajaxAction()
59
+ {
60
+ $method = $this->getRequest()->getParam('method');
61
+
62
+ $result = array('success' => false);
63
+
64
+ switch ($method)
65
+ {
66
+ case "status": $result = $this->getStatus(); break;
67
+ case "log_refresh": $result = $this->getLogFile(); break;
68
+ case "test_logging": $result = $this->testLogging(); break;
69
+ case "erase_log": $result = $this->eraseLog(); break;
70
+ }
71
+
72
+ $this->getResponse()->setBody(json_encode($result));
73
+
74
+ return $result;
75
+ }
76
+
77
+ private function eraseLog()
78
+ {
79
+ Mage::helper('emaildirect/troubleshooting')->eraseLog();
80
+
81
+ return $this->getLogFile();
82
+ }
83
+
84
+ private function testLogging()
85
+ {
86
+ Mage::helper('emaildirect/troubleshooting')->forceLog('======================= LOG TEST =======================');
87
+
88
+ return $this->getLogFile();
89
+ }
90
+
91
+ private function getStatus()
92
+ {
93
+ $status = Mage::helper('emaildirect/troubleshooting')->getStatus();
94
+
95
+ $result = array();
96
+ $result['success'] = true;
97
+ $result['status'] = $status;
98
+
99
+ return $result;
100
+ }
101
+
102
+ public function sendAction()
103
+ {
104
+ $params = $this->getRequest()->getParams();
105
+
106
+ $customer = array();
107
+
108
+ $customer['Customer Name'] = $params['customer_name'];
109
+ $customer['Email'] = $params['customer_email'];
110
+ if ($params['customer_company'] != "")
111
+ $customer['Company'] = $params['customer_company'];
112
+ $customer['Comments'] = $params['customer_comments'];
113
+
114
+ $message = Mage::helper('emaildirect/troubleshooting')->getReport($customer);
115
+
116
+ $to = Mage::helper('emaildirect')->troubleConfig('email');
117
+ $subject = Mage::helper('emaildirect')->troubleConfig('subject');
118
+ $from = $params['customer_email'];
119
+
120
+ $headers = "From: {$from}\r\n";
121
+ $headers .= "Content-type: text/html\r\n";
122
+
123
+ // now lets send the email.
124
+ $sent = mail($to, $subject, $message, $headers);
125
+
126
+ if ($sent)
127
+ {
128
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting Report was sent to EmailDirect'));
129
+
130
+ $this->_redirect('adminhtml/system_config/edit/',array('section' => 'emaildirect'));
131
+ }
132
+ else
133
+ {
134
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('emaildirect')->__('Failed to send Report Email'));
135
+
136
+ $this->_redirect('adminhtml/emaildirect_troubleshooting/');
137
+ }
138
+ }
139
+
140
+ protected function _getCronReport()
141
+ {
142
+ $this->loadLayout();
143
+
144
+ $block = $this->getLayout()->createBlock(
145
+ 'EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Cron',
146
+ 'trouble_cron',
147
+ array('template' => 'emaildirect/troubleshooting/view/tab/cron.phtml')
148
+ );
149
+
150
+ $block->setMode("download");
151
+ return $block->toHtml();
152
+
153
+ $layout = $this->getLayout();
154
+ $update = $layout->getUpdate();
155
+ $update->load('emaildirect/adminhtml_troubleshooting_view_tab_cron');
156
+ $layout->generateXml();
157
+ $layout->generateBlocks();
158
+ $output = $layout->getOutput();
159
+ return $output;
160
+ }
161
+
162
+ public function downloadCronAction()
163
+ {
164
+ $filename = Mage::helper('emaildirect')->troubleConfig('cron_report_file');
165
+
166
+ $output = $this->_getCronReport();
167
+
168
+ $this->_prepareDownloadResponse($filename, $output);
169
+ }
170
+
171
+ public function downloadAction()
172
+ {
173
+ $output = Mage::helper('emaildirect/troubleshooting')->getReport();
174
+
175
+ $this->_prepareDownloadResponse(Mage::helper('emaildirect')->troubleConfig('report_file'), $output);
176
+ }
177
+
178
+ private function updateConfig($path, $value)
179
+ {
180
+ $this->_config->saveConfig("emaildirect/troubleshooting/{$path}",$value,"default",0);
181
+ }
182
+
183
+ public function saveAction()
184
+ {
185
+ $params = $this->getRequest()->getParams();
186
+
187
+ $this->_config = Mage::getConfig();
188
+
189
+ $enabled = $params['logging_enabled'];
190
+
191
+ if ($enabled == "yes")
192
+ {
193
+ $this->updateConfig('logging_enabled',1);
194
+
195
+ $date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
196
+ $start_date = date($date_format, Mage::getModel('core/date')->gmtTimestamp());
197
+
198
+ $this->updateConfig("logging_start_date",$start_date);
199
+
200
+ $advanced_enabled = $params['logging_advanced_enabled'];
201
+
202
+ if ($advanced_enabled)
203
+ {
204
+ $this->updateConfig("logging_advanced_enabled", 1);
205
+
206
+ $logging_stores = $params['logging_stores'];
207
+
208
+ if ($logging_stores == "selected")
209
+ {
210
+ if (isset($params['logging_stores_selected']))
211
+ $this->updateConfig("logging_stores_selected", implode(",",$params['logging_stores_selected']));
212
+ }
213
+
214
+ $this->updateConfig("logging_stores", $logging_stores);
215
+
216
+ $logging_areas = $params['logging_areas'];
217
+
218
+ if ($logging_areas == "selected")
219
+ {
220
+ if (isset($params['logging_areas_selected']))
221
+ $this->updateConfig("logging_areas_selected", implode(",",$params['logging_areas_selected']));
222
+ }
223
+
224
+ $this->updateConfig("logging_areas", $logging_areas);
225
+ $this->updateConfig("logging_duration", $params['logging_duration']);
226
+ }
227
+ else
228
+ {
229
+ $this->updateConfig("logging_duration", 10);
230
+ $this->updateConfig("logging_advanced_enabled", 0);
231
+ }
232
+ }
233
+ else
234
+ $this->updateConfig('logging_enabled',0);
235
+
236
+ $this->updateConfig('diagnostic_enabled',$params['diagnostic_enabled']);
237
+
238
+ $this->_config->cleanCache();
239
+
240
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting settings updated!'));
241
+
242
+ $this->_redirect("*/*/index",Mage::helper('emaildirect')->getAdminUrlParams(array('tab' => 'troubleshooting_view_tabs_trouble_settings')));
243
+ }
244
+ }
app/code/community/EmailDirect/Integration/controllers/CronController.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EmailDirect_Integration_CronController extends EmailDirect_Integration_Controller_Front_Abstract
4
+ {
5
+ public function runAction()
6
+ {
7
+ if (Mage::helper('emaildirect')->isCronUrlEnabled()) {
8
+
9
+ $process = $this->getRequest()->getParam("process");
10
+
11
+ switch ($process) {
12
+ case "abandoned": {
13
+ echo "<p>Starting Abandoned Cart Process...</p>";
14
+ Mage::getSingleton('emaildirect/abandoned_observer')->manualCartsProcessor();
15
+ echo "<p>Abandoned Cart Process completed</p>";
16
+ } break;
17
+ case "orders": {
18
+ echo "<p>Starting Orders Process...</p>";
19
+ Mage::getSingleton('emaildirect/order_observer')->processBatchOrders();
20
+ echo "<p>Orders Process completed</p>";
21
+ } break;
22
+ }
23
+ }
24
+ }
25
+ }
app/code/community/EmailDirect/Integration/etc/adminhtml.xml CHANGED
@@ -8,12 +8,12 @@
8
  <emaildirect_abandoned module='emaildirect'>
9
  <title>Abandoned Carts</title>
10
  <sort_order>100</sort_order>
11
- <action>ed_integration/admin_abandoned</action>
12
  </emaildirect_abandoned>
13
  <emaildirect_troubleshooting module='emaildirect'>
14
  <title>Troubleshooting</title>
15
  <sort_order>110</sort_order>
16
- <action>ed_integration/admin_troubleshooting</action>
17
  </emaildirect_troubleshooting>
18
  <emaildirect_config module='emaildirect'>
19
  <title>Configuration</title>
8
  <emaildirect_abandoned module='emaildirect'>
9
  <title>Abandoned Carts</title>
10
  <sort_order>100</sort_order>
11
+ <action>adminhtml/emaildirect_abandoned</action>
12
  </emaildirect_abandoned>
13
  <emaildirect_troubleshooting module='emaildirect'>
14
  <title>Troubleshooting</title>
15
  <sort_order>110</sort_order>
16
+ <action>adminhtml/emaildirect_troubleshooting</action>
17
  </emaildirect_troubleshooting>
18
  <emaildirect_config module='emaildirect'>
19
  <title>Configuration</title>
app/code/community/EmailDirect/Integration/etc/config.xml CHANGED
@@ -1,328 +1,330 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <modules>
4
- <EmailDirect_Integration>
5
- <version>2.0.16</version>
6
- </EmailDirect_Integration>
7
- </modules>
8
- <global>
9
- <events>
10
- <wishlist_product_add_after>
11
- <observers>
12
- <emaildirect_wishlist_product_add_after_observer>
13
- <class>emaildirect/observer</class>
14
- <method>onWishlistProductAddAfter</method>
15
- </emaildirect_wishlist_product_add_after_observer>
16
- </observers>
17
- </wishlist_product_add_after>
18
- <newsletter_subscriber_save_before>
19
- <observers>
20
- <emaildirect_subscribe_observer>
21
- <class>emaildirect/newsletter_observer</class>
22
- <method>handleSubscriber</method>
23
- </emaildirect_subscribe_observer>
24
- </observers>
25
- </newsletter_subscriber_save_before>
26
- <newsletter_subscriber_delete_after>
27
- <observers>
28
- <emaildirect_subscribe_delete_observer>
29
- <class>emaildirect/newsletter_observer</class>
30
- <method>handleSubscriberDeletion</method>
31
- </emaildirect_subscribe_delete_observer>
32
- </observers>
33
- </newsletter_subscriber_delete_after>
34
- </events>
35
- <models>
36
- <emaildirect>
37
- <class>EmailDirect_Integration_Model</class>
38
- <resourceModel>emaildirect_mysql4</resourceModel>
39
- </emaildirect>
40
- <emaildirect_mysql4>
41
- <class>EmailDirect_Integration_Model_Mysql4</class>
42
- <entities>
43
- <abandoned>
44
- <table>emaildirect_abandoned_cart</table>
45
- </abandoned>
46
- <order>
47
- <table>emaildirect_order</table>
48
- </order>
49
- <session>
50
- <table>emaildirect_session</table>
51
- </session>
52
- </entities>
53
- </emaildirect_mysql4>
54
- </models>
55
- <resources>
56
- <emaildirect_setup>
57
- <setup>
58
- <module>EmailDirect_Integration</module>
59
- <class>EmailDirect_Integration_Model_Resource_Setup</class>
60
- </setup>
61
- <connection>
62
- <use>core_setup</use>
63
- </connection>
64
- </emaildirect_setup>
65
- <emaildirect_write>
66
- <connection>
67
- <use>core_write</use>
68
- </connection>
69
- </emaildirect_write>
70
- <emaildirect_read>
71
- <connection>
72
- <use>core_read</use>
73
- </connection>
74
- </emaildirect_read>
75
- </resources>
76
- <blocks>
77
- <emaildirect>
78
- <class>EmailDirect_Integration_Block</class>
79
- </emaildirect>
80
- </blocks>
81
- <helpers>
82
- <emaildirect>
83
- <class>EmailDirect_Integration_Helper</class>
84
- </emaildirect>
85
- </helpers>
86
- </global>
87
- <frontend>
88
- <translate>
89
- <modules>
90
- <EmailDirect_Integration>
91
- <files>
92
- <default>EmailDirect_Integration.csv</default>
93
- </files>
94
- </EmailDirect_Integration>
95
- </modules>
96
- </translate>
97
- <routers>
98
- <emaildirect>
99
- <use>standard</use>
100
- <args>
101
- <module>EmailDirect_Integration</module>
102
- <frontName>emaildirect</frontName>
103
- </args>
104
- </emaildirect>
105
- </routers>
106
- <layout>
107
- <updates>
108
- <emaildirect>
109
- <file>emaildirect.xml</file>
110
- </emaildirect>
111
- </updates>
112
- </layout>
113
- <events>
114
- <controller_action_postdispatch_checkout_onepage_saveOrder>
115
- <observers>
116
- <emaildirect_subscribe_checkout>
117
- <class>emaildirect/newsletter_observer</class>
118
- <method>registerCheckoutSubscribe</method>
119
- </emaildirect_subscribe_checkout>
120
- </observers>
121
- </controller_action_postdispatch_checkout_onepage_saveOrder>
122
- <checkout_onepage_controller_success_action>
123
- <observers>
124
- <emaildirect_subscribe_checkoutsuccess>
125
- <class>emaildirect/newsletter_observer</class>
126
- <method>registerCheckoutSuccess</method>
127
- </emaildirect_subscribe_checkoutsuccess>
128
- </observers>
129
- </checkout_onepage_controller_success_action>
130
- <sales_quote_save_after>
131
- <observers>
132
- <emaildirect_quote_save_after>
133
- <class>emaildirect/abandoned_observer</class>
134
- <method>quoteSaveAfter</method>
135
- </emaildirect_quote_save_after>
136
- </observers>
137
- </sales_quote_save_after>
138
- <customer_save_after>
139
- <observers>
140
- <emaildirect_update_customer>
141
- <class>emaildirect/customer_observer</class>
142
- <method>updateCustomer</method>
143
- </emaildirect_update_customer>
144
- </observers>
145
- </customer_save_after>
146
- <customer_login>
147
- <observers>
148
- <emaildirect_customer_login>
149
- <class>emaildirect/customer_observer</class>
150
- <method>customerLogin</method>
151
- </emaildirect_customer_login>
152
- </observers>
153
- </customer_login>
154
- <sales_order_save_after>
155
- <observers>
156
- <emaildirect_order_save_after>
157
- <class>emaildirect/order_observer</class>
158
- <method>orderSaveAfter</method>
159
- </emaildirect_order_save_after>
160
- </observers>
161
- </sales_order_save_after>
162
- </events>
163
- </frontend>
164
- <admin>
165
- <routers>
166
- <ed_integration>
167
- <use>admin</use>
168
- <args>
169
- <module>EmailDirect_Integration</module>
170
- <frontName>ed_integration</frontName>
171
- </args>
172
- </ed_integration>
173
- </routers>
174
- </admin>
175
- <adminhtml>
176
- <layout>
177
- <updates>
178
- <emaildirect>
179
- <file>emaildirect.xml</file>
180
- </emaildirect>
181
- </updates>
182
- </layout>
183
- <translate>
184
- <modules>
185
- <EmailDirect_Integration>
186
- <files>
187
- <default>EmailDirect_Integration.csv</default>
188
- </files>
189
- </EmailDirect_Integration>
190
- </modules>
191
- </translate>
192
- <events>
193
- <core_block_abstract_to_html_before>
194
- <observers>
195
- <emaildirect_newsletter_massaction>
196
- <class>emaildirect/newsletter_observer</class>
197
- <method>updateNewsletterMassAction</method>
198
- </emaildirect_newsletter_massaction>
199
- </observers>
200
- </core_block_abstract_to_html_before>
201
- <sales_order_shipment_track_save_after>
202
- <observers>
203
- <emaildirect_track_save_after>
204
- <type>model</type>
205
- <class>emaildirect/order_observer</class>
206
- <method>salesOrderShipmentTrackSaveAfter</method>
207
- </emaildirect_track_save_after>
208
- </observers>
209
- </sales_order_shipment_track_save_after>
210
- <admin_system_config_changed_section_emaildirect>
211
- <observers>
212
- <emaildirect_save_config>
213
- <class>emaildirect/configuration_observer</class>
214
- <method>saveConfig</method>
215
- </emaildirect_save_config>
216
- </observers>
217
- </admin_system_config_changed_section_emaildirect>
218
- <customer_save_after>
219
- <observers>
220
- <emaildirect_update_customer_admin>
221
- <class>emaildirect/customer_observer</class>
222
- <method>updateCustomerAdmin</method>
223
- </emaildirect_update_customer_admin>
224
- </observers>
225
- </customer_save_after>
226
- <sales_order_save_after>
227
- <observers>
228
- <emaildirect_order_save_after_admin>
229
- <class>emaildirect/order_observer</class>
230
- <method>orderSaveAfterAdmin</method>
231
- </emaildirect_order_save_after_admin>
232
- </observers>
233
- </sales_order_save_after>
234
- </events>
235
- </adminhtml>
236
- <default>
237
- <emaildirect>
238
- <general>
239
- <urls>
240
- <accesspoint>https://rest.emaildirect.com/v1/</accesspoint>
241
- <lists>Lists</lists>
242
- <subscribers>Subscribers</subscribers>
243
- <sources>Sources</sources>
244
- <publications>Publications</publications>
245
- <products>Products</products>
246
- <categories>ProductCategories</categories>
247
- <orders>Orders</orders>
248
- <database>Database</database>
249
- <abandoned>Import/Subscribers</abandoned>
250
- <ftp>FTP</ftp>
251
- </urls>
252
- <active>0</active>
253
- <sourceid>0</sourceid>
254
- <source>Magento</source>
255
- <override_source>1</override_source>
256
- <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>
257
- <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>
258
- <abandonedtime>30</abandonedtime>
259
- <sendabandoned>0</sendabandoned>
260
- <abandonedsetup>0</abandonedsetup>
261
- <setup>0</setup>
262
- <debug>0</debug>
263
- <save_latest_order>0</save_latest_order>
264
- <product_fields>3</product_fields>
265
- <related_fields>2</related_fields>
266
- <send_states>complete</send_states>
267
- <send_statuses>complete</send_statuses>
268
- <abandonedsequence_options><![CDATA[A
269
  B
270
  C]]></abandonedsequence_options>
271
- <signup_enabled>0</signup_enabled>
272
- <signup_activated>0</signup_activated>
273
- <signup_delay>3</signup_delay>
274
- <signup_opacity>30</signup_opacity>
275
- <signup_recurrence>1 month</signup_recurrence>
276
- <signup_width>760</signup_width>
277
- <signup_height>400</signup_height>
278
- <batch_size>200</batch_size>
279
- <batch_date_adjust>-1 week</batch_date_adjust>
280
- <wishlist_enabled>0</wishlist_enabled>
281
- <cron_not_run_minutes>80</cron_not_run_minutes>
282
- <schedule_row_limit>50</schedule_row_limit>
283
- </general>
284
- <export>
285
- <include_disabled>1</include_disabled>
286
- <include_already_sent>0</include_already_sent>
287
- <batch>100</batch>
288
- <setup>0</setup>
289
- </export>
290
- <troubleshooting>
291
- <logging_enabled>0</logging_enabled>
292
- <logging_duration>10</logging_duration>
293
- <logging_stores>all</logging_stores>
294
- <logging_areas>all</logging_areas>
295
- <diagnostic_enabled>0</diagnostic_enabled>
296
-
297
- <enabled>0</enabled>
298
- <email>Kevinl@EmailDirect.com</email>
299
- <subject>EmailDirect Magento Module Troubleshooting Report</subject>
300
- <report_file>troubleshootingreport.html</report_file>
301
- <max_file_size>1048576</max_file_size>
302
- <duration>10</duration>
303
- </troubleshooting>
304
- </emaildirect>
305
- </default>
306
- <crontab>
307
- <jobs>
308
- <emaildirect_integration>
309
- <schedule>
310
- <cron_expr>0 */1 * * *</cron_expr>
311
- <!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
312
- </schedule>
313
- <run>
314
- <model>emaildirect/abandoned_observer::abandonedCartsProcessor</model>
315
- </run>
316
- </emaildirect_integration>
317
- <emaildirect_integration_batch_orders>
318
- <schedule>
319
- <cron_expr>30 * * * *</cron_expr>
320
- <!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
321
- </schedule>
322
- <run>
323
- <model>emaildirect/order_observer::processBatchOrders</model>
324
- </run>
325
- </emaildirect_integration_batch_orders>
326
- </jobs>
327
- </crontab>
 
 
328
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
+ <modules>
4
+ <EmailDirect_Integration>
5
+ <version>2.0.17</version>
6
+ </EmailDirect_Integration>
7
+ </modules>
8
+ <global>
9
+ <events>
10
+ <wishlist_product_add_after>
11
+ <observers>
12
+ <emaildirect_wishlist_product_add_after_observer>
13
+ <class>emaildirect/observer</class>
14
+ <method>onWishlistProductAddAfter</method>
15
+ </emaildirect_wishlist_product_add_after_observer>
16
+ </observers>
17
+ </wishlist_product_add_after>
18
+ <newsletter_subscriber_save_before>
19
+ <observers>
20
+ <emaildirect_subscribe_observer>
21
+ <class>emaildirect/newsletter_observer</class>
22
+ <method>handleSubscriber</method>
23
+ </emaildirect_subscribe_observer>
24
+ </observers>
25
+ </newsletter_subscriber_save_before>
26
+ <newsletter_subscriber_delete_after>
27
+ <observers>
28
+ <emaildirect_subscribe_delete_observer>
29
+ <class>emaildirect/newsletter_observer</class>
30
+ <method>handleSubscriberDeletion</method>
31
+ </emaildirect_subscribe_delete_observer>
32
+ </observers>
33
+ </newsletter_subscriber_delete_after>
34
+ </events>
35
+ <models>
36
+ <emaildirect>
37
+ <class>EmailDirect_Integration_Model</class>
38
+ <resourceModel>emaildirect_mysql4</resourceModel>
39
+ </emaildirect>
40
+ <emaildirect_mysql4>
41
+ <class>EmailDirect_Integration_Model_Mysql4</class>
42
+ <entities>
43
+ <abandoned>
44
+ <table>emaildirect_abandoned_cart</table>
45
+ </abandoned>
46
+ <order>
47
+ <table>emaildirect_order</table>
48
+ </order>
49
+ <session>
50
+ <table>emaildirect_session</table>
51
+ </session>
52
+ </entities>
53
+ </emaildirect_mysql4>
54
+ </models>
55
+ <resources>
56
+ <emaildirect_setup>
57
+ <setup>
58
+ <module>EmailDirect_Integration</module>
59
+ <class>EmailDirect_Integration_Model_Resource_Setup</class>
60
+ </setup>
61
+ <connection>
62
+ <use>core_setup</use>
63
+ </connection>
64
+ </emaildirect_setup>
65
+ <emaildirect_write>
66
+ <connection>
67
+ <use>core_write</use>
68
+ </connection>
69
+ </emaildirect_write>
70
+ <emaildirect_read>
71
+ <connection>
72
+ <use>core_read</use>
73
+ </connection>
74
+ </emaildirect_read>
75
+ </resources>
76
+ <blocks>
77
+ <emaildirect>
78
+ <class>EmailDirect_Integration_Block</class>
79
+ </emaildirect>
80
+ </blocks>
81
+ <helpers>
82
+ <emaildirect>
83
+ <class>EmailDirect_Integration_Helper</class>
84
+ </emaildirect>
85
+ </helpers>
86
+ </global>
87
+ <frontend>
88
+ <translate>
89
+ <modules>
90
+ <EmailDirect_Integration>
91
+ <files>
92
+ <default>EmailDirect_Integration.csv</default>
93
+ </files>
94
+ </EmailDirect_Integration>
95
+ </modules>
96
+ </translate>
97
+ <routers>
98
+ <emaildirect>
99
+ <use>standard</use>
100
+ <args>
101
+ <module>EmailDirect_Integration</module>
102
+ <frontName>emaildirect</frontName>
103
+ </args>
104
+ </emaildirect>
105
+ </routers>
106
+ <layout>
107
+ <updates>
108
+ <emaildirect>
109
+ <file>emaildirect.xml</file>
110
+ </emaildirect>
111
+ </updates>
112
+ </layout>
113
+ <events>
114
+ <controller_action_postdispatch_checkout_onepage_saveOrder>
115
+ <observers>
116
+ <emaildirect_subscribe_checkout>
117
+ <class>emaildirect/newsletter_observer</class>
118
+ <method>registerCheckoutSubscribe</method>
119
+ </emaildirect_subscribe_checkout>
120
+ </observers>
121
+ </controller_action_postdispatch_checkout_onepage_saveOrder>
122
+ <checkout_onepage_controller_success_action>
123
+ <observers>
124
+ <emaildirect_subscribe_checkoutsuccess>
125
+ <class>emaildirect/newsletter_observer</class>
126
+ <method>registerCheckoutSuccess</method>
127
+ </emaildirect_subscribe_checkoutsuccess>
128
+ </observers>
129
+ </checkout_onepage_controller_success_action>
130
+ <sales_quote_save_after>
131
+ <observers>
132
+ <emaildirect_quote_save_after>
133
+ <class>emaildirect/abandoned_observer</class>
134
+ <method>quoteSaveAfter</method>
135
+ </emaildirect_quote_save_after>
136
+ </observers>
137
+ </sales_quote_save_after>
138
+ <customer_save_after>
139
+ <observers>
140
+ <emaildirect_update_customer>
141
+ <class>emaildirect/customer_observer</class>
142
+ <method>updateCustomer</method>
143
+ </emaildirect_update_customer>
144
+ </observers>
145
+ </customer_save_after>
146
+ <customer_login>
147
+ <observers>
148
+ <emaildirect_customer_login>
149
+ <class>emaildirect/customer_observer</class>
150
+ <method>customerLogin</method>
151
+ </emaildirect_customer_login>
152
+ </observers>
153
+ </customer_login>
154
+ <sales_order_save_after>
155
+ <observers>
156
+ <emaildirect_order_save_after>
157
+ <class>emaildirect/order_observer</class>
158
+ <method>orderSaveAfter</method>
159
+ </emaildirect_order_save_after>
160
+ </observers>
161
+ </sales_order_save_after>
162
+ </events>
163
+ </frontend>
164
+ <admin>
165
+ <routers>
166
+ <adminhtml>
167
+ <args>
168
+ <modules>
169
+ <emaildirect_integration after="Mage_Adminhtml">EmailDirect_Integration_Adminhtml</emaildirect_integration>
170
+ </modules>
171
+ </args>
172
+ </adminhtml>
173
+ </routers>
174
+ </admin>
175
+ <adminhtml>
176
+ <layout>
177
+ <updates>
178
+ <emaildirect>
179
+ <file>emaildirect.xml</file>
180
+ </emaildirect>
181
+ </updates>
182
+ </layout>
183
+ <translate>
184
+ <modules>
185
+ <EmailDirect_Integration>
186
+ <files>
187
+ <default>EmailDirect_Integration.csv</default>
188
+ </files>
189
+ </EmailDirect_Integration>
190
+ </modules>
191
+ </translate>
192
+ <events>
193
+ <core_block_abstract_to_html_before>
194
+ <observers>
195
+ <emaildirect_newsletter_massaction>
196
+ <class>emaildirect/newsletter_observer</class>
197
+ <method>updateNewsletterMassAction</method>
198
+ </emaildirect_newsletter_massaction>
199
+ </observers>
200
+ </core_block_abstract_to_html_before>
201
+ <sales_order_shipment_track_save_after>
202
+ <observers>
203
+ <emaildirect_track_save_after>
204
+ <type>model</type>
205
+ <class>emaildirect/order_observer</class>
206
+ <method>salesOrderShipmentTrackSaveAfter</method>
207
+ </emaildirect_track_save_after>
208
+ </observers>
209
+ </sales_order_shipment_track_save_after>
210
+ <admin_system_config_changed_section_emaildirect>
211
+ <observers>
212
+ <emaildirect_save_config>
213
+ <class>emaildirect/configuration_observer</class>
214
+ <method>saveConfig</method>
215
+ </emaildirect_save_config>
216
+ </observers>
217
+ </admin_system_config_changed_section_emaildirect>
218
+ <customer_save_after>
219
+ <observers>
220
+ <emaildirect_update_customer_admin>
221
+ <class>emaildirect/customer_observer</class>
222
+ <method>updateCustomerAdmin</method>
223
+ </emaildirect_update_customer_admin>
224
+ </observers>
225
+ </customer_save_after>
226
+ <sales_order_save_after>
227
+ <observers>
228
+ <emaildirect_order_save_after_admin>
229
+ <class>emaildirect/order_observer</class>
230
+ <method>orderSaveAfterAdmin</method>
231
+ </emaildirect_order_save_after_admin>
232
+ </observers>
233
+ </sales_order_save_after>
234
+ </events>
235
+ </adminhtml>
236
+ <default>
237
+ <emaildirect>
238
+ <general>
239
+ <urls>
240
+ <accesspoint>https://rest.emaildirect.com/v1/</accesspoint>
241
+ <lists>Lists</lists>
242
+ <subscribers>Subscribers</subscribers>
243
+ <sources>Sources</sources>
244
+ <publications>Publications</publications>
245
+ <products>Products</products>
246
+ <categories>ProductCategories</categories>
247
+ <orders>Orders</orders>
248
+ <database>Database</database>
249
+ <abandoned>Import/Subscribers</abandoned>
250
+ <ftp>FTP</ftp>
251
+ </urls>
252
+ <active>0</active>
253
+ <sourceid>0</sourceid>
254
+ <source>Magento</source>
255
+ <override_source>1</override_source>
256
+ <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>
257
+ <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>
258
+ <abandonedtime>30</abandonedtime>
259
+ <sendabandoned>0</sendabandoned>
260
+ <abandonedsetup>0</abandonedsetup>
261
+ <setup>0</setup>
262
+ <debug>0</debug>
263
+ <save_latest_order>0</save_latest_order>
264
+ <product_fields>3</product_fields>
265
+ <related_fields>2</related_fields>
266
+ <send_states>complete</send_states>
267
+ <send_statuses>complete</send_statuses>
268
+ <abandonedsequence_options><![CDATA[A
269
  B
270
  C]]></abandonedsequence_options>
271
+ <signup_enabled>0</signup_enabled>
272
+ <signup_activated>0</signup_activated>
273
+ <signup_delay>3</signup_delay>
274
+ <signup_opacity>30</signup_opacity>
275
+ <signup_recurrence>1 month</signup_recurrence>
276
+ <signup_width>760</signup_width>
277
+ <signup_height>400</signup_height>
278
+ <batch_size>200</batch_size>
279
+ <batch_date_adjust>-1 week</batch_date_adjust>
280
+ <wishlist_enabled>0</wishlist_enabled>
281
+ <lastlogin_enabled>0</lastlogin_enabled>
282
+ <cron_not_run_minutes>80</cron_not_run_minutes>
283
+ <schedule_row_limit>50</schedule_row_limit>
284
+ <cron_url_enabled>0</cron_url_enabled>
285
+ </general>
286
+ <export>
287
+ <include_disabled>1</include_disabled>
288
+ <include_already_sent>0</include_already_sent>
289
+ <batch>100</batch>
290
+ <setup>0</setup>
291
+ </export>
292
+ <troubleshooting>
293
+ <logging_enabled>0</logging_enabled>
294
+ <logging_duration>10</logging_duration>
295
+ <logging_stores>all</logging_stores>
296
+ <logging_areas>all</logging_areas>
297
+ <diagnostic_enabled>0</diagnostic_enabled>
298
+ <enabled>0</enabled>
299
+ <email>Kevinl@EmailDirect.com</email>
300
+ <subject>EmailDirect Magento Module Troubleshooting Report</subject>
301
+ <report_file>troubleshootingreport.html</report_file>
302
+ <cron_report_file>cron_troubleshooting.html</cron_report_file>
303
+ <max_file_size>1048576</max_file_size>
304
+ <duration>10</duration>
305
+ </troubleshooting>
306
+ </emaildirect>
307
+ </default>
308
+ <crontab>
309
+ <jobs>
310
+ <emaildirect_integration>
311
+ <schedule>
312
+ <cron_expr>0 */1 * * *</cron_expr>
313
+ <!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
314
+ </schedule>
315
+ <run>
316
+ <model>emaildirect/abandoned_observer::abandonedCartsProcessor</model>
317
+ </run>
318
+ </emaildirect_integration>
319
+ <emaildirect_integration_batch_orders>
320
+ <schedule>
321
+ <cron_expr>30 * * * *</cron_expr>
322
+ <!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
323
+ </schedule>
324
+ <run>
325
+ <model>emaildirect/order_observer::processBatchOrders</model>
326
+ </run>
327
+ </emaildirect_integration_batch_orders>
328
+ </jobs>
329
+ </crontab>
330
  </config>
app/code/community/EmailDirect/Integration/etc/system.xml CHANGED
@@ -131,15 +131,25 @@
131
  <show_in_store>1</show_in_store>
132
  <comment>If set to "Yes", the source will be updated when an existing customer is updated.</comment>
133
  </override_source>
134
-
 
 
 
 
 
 
 
 
 
 
135
  <heading_mappings translate="label">
136
- <label>Field Mappings</label>
137
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
138
- <sort_order>100</sort_order>
139
- <show_in_default>1</show_in_default>
140
- <show_in_website>0</show_in_website>
141
- <show_in_store>1</show_in_store>
142
- </heading_mappings>
143
 
144
  <address_fields translate="label comment">
145
  <label>Address Fields Mapping</label>
@@ -332,14 +342,14 @@
332
 
333
  <!-- SEQUENCES -->
334
  <heading_sequence translate="label">
335
- <label>Abandoned Cart Sequences</label>
336
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
337
- <sort_order>360</sort_order>
338
- <show_in_default>1</show_in_default>
339
- <show_in_website>0</show_in_website>
340
- <show_in_store>1</show_in_store>
341
- <depends><sendabandoned>1</sendabandoned></depends>
342
- </heading_sequence>
343
  <abandonedsequence_enabled>
344
  <label>Add a sequence value to each abandoned cart?</label>
345
  <frontend_type>select</frontend_type>
@@ -377,18 +387,18 @@
377
 
378
  <!-- signup -->
379
  <heading_signup translate="label">
380
- <label>EmailDirect Signup Form</label>
381
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
382
- <sort_order>400</sort_order>
383
- <show_in_default>1</show_in_default>
384
- <show_in_website>0</show_in_website>
385
- <show_in_store>1</show_in_store>
386
- </heading_signup>
387
  <signup_enabled>
388
  <label>Show EmailDirect Signup form?</label>
389
  <frontend_type>select</frontend_type>
390
  <source_model>adminhtml/system_config_source_yesno</source_model>
391
- <sort_order>410</sort_order>
392
  <show_in_default>1</show_in_default>
393
  <show_in_website>0</show_in_website>
394
  <show_in_store>1</show_in_store>
@@ -397,7 +407,7 @@
397
  <signup_url>
398
  <label>URL to Signup Form</label>
399
  <frontend_type>text</frontend_type>
400
- <sort_order>420</sort_order>
401
  <show_in_default>1</show_in_default>
402
  <show_in_website>0</show_in_website>
403
  <show_in_store>1</show_in_store>
@@ -407,7 +417,7 @@
407
  <signup_delay>
408
  <label>Delay before showing</label>
409
  <frontend_type>text</frontend_type>
410
- <sort_order>430</sort_order>
411
  <show_in_default>1</show_in_default>
412
  <show_in_website>0</show_in_website>
413
  <show_in_store>1</show_in_store>
@@ -418,7 +428,7 @@
418
  <label>Recurrence</label>
419
  <frontend_type>select</frontend_type>
420
  <source_model>emaildirect/system_config_source_signup_recurrence</source_model>
421
- <sort_order>440</sort_order>
422
  <show_in_default>1</show_in_default>
423
  <show_in_website>0</show_in_website>
424
  <show_in_store>1</show_in_store>
@@ -428,7 +438,7 @@
428
  <signup_width>
429
  <label>Width of Form</label>
430
  <frontend_type>text</frontend_type>
431
- <sort_order>450</sort_order>
432
  <show_in_default>1</show_in_default>
433
  <show_in_website>0</show_in_website>
434
  <show_in_store>1</show_in_store>
@@ -437,7 +447,7 @@
437
  <signup_height>
438
  <label>Height of Form</label>
439
  <frontend_type>text</frontend_type>
440
- <sort_order>460</sort_order>
441
  <show_in_default>1</show_in_default>
442
  <show_in_website>0</show_in_website>
443
  <show_in_store>1</show_in_store>
@@ -447,7 +457,7 @@
447
  <label>Opacity of background</label>
448
  <frontend_type>select</frontend_type>
449
  <source_model>emaildirect/system_config_source_signup_opacity</source_model>
450
- <sort_order>470</sort_order>
451
  <show_in_default>1</show_in_default>
452
  <show_in_website>0</show_in_website>
453
  <show_in_store>1</show_in_store>
@@ -456,7 +466,7 @@
456
  <signup_test_button>
457
  <label>Test Signup Form</label>
458
  <frontend_model>emaildirect/adminhtml_system_config_form_field_signup_test</frontend_model>
459
- <sort_order>480</sort_order>
460
  <show_in_default>1</show_in_default>
461
  <show_in_website>0</show_in_website>
462
  <show_in_store>1</show_in_store>
@@ -468,7 +478,7 @@
468
  <label>Activate Signup Form?</label>
469
  <frontend_type>select</frontend_type>
470
  <source_model>adminhtml/system_config_source_yesno</source_model>
471
- <sort_order>490</sort_order>
472
  <show_in_default>1</show_in_default>
473
  <show_in_website>0</show_in_website>
474
  <show_in_store>1</show_in_store>
@@ -478,14 +488,14 @@
478
 
479
  <!-- Wishlist -->
480
  <heading_wishlist translate="label">
481
- <label>Wishlist</label>
482
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
483
- <sort_order>600</sort_order>
484
- <show_in_default>1</show_in_default>
485
- <show_in_website>0</show_in_website>
486
- <show_in_store>1</show_in_store>
487
- </heading_wishlist>
488
- <wishlist_enabled>
489
  <label>Activate Wish List Alerts?</label>
490
  <frontend_type>select</frontend_type>
491
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -495,7 +505,75 @@
495
  <show_in_store>1</show_in_store>
496
  <comment>Send subscriber Wishlist URL and their most recent Wishlist Date to your EmailDirect database.</comment>
497
  </wishlist_enabled>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  </fields>
500
  </general>
501
  <export translate="label comment">
@@ -508,14 +586,14 @@
508
  <expanded>1</expanded>
509
  <fields>
510
  <heading_orders translate="label">
511
- <label>Order Exports</label>
512
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
513
- <sort_order>5</sort_order>
514
- <show_in_default>1</show_in_default>
515
- <show_in_website>0</show_in_website>
516
- <show_in_store>1</show_in_store>
517
- </heading_orders>
518
- <include_already_sent translate="label">
519
  <label>Include orders already sent?</label>
520
  <frontend_type>select</frontend_type>
521
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -547,13 +625,13 @@
547
  </export_orders_button>
548
 
549
  <heading_products translate="label">
550
- <label>Category Exports</label>
551
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
552
- <sort_order>30</sort_order>
553
- <show_in_default>1</show_in_default>
554
- <show_in_website>0</show_in_website>
555
- <show_in_store>1</show_in_store>
556
- </heading_products>
557
  <include_disabled translate="label">
558
  <label>Include disabled Products?</label>
559
  <frontend_type>select</frontend_type>
@@ -605,13 +683,13 @@
605
  <expanded>1</expanded>
606
  <fields>
607
  <heading_logging translate="label">
608
- <label>Logging</label>
609
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
610
- <sort_order>10</sort_order>
611
- <show_in_default>1</show_in_default>
612
- <show_in_website>0</show_in_website>
613
- <show_in_store>1</show_in_store>
614
- </heading_logging>
615
  <logging translate="label">
616
  <label>Status</label>
617
  <frontend_model>emaildirect/adminhtml_system_config_form_field_logging</frontend_model>
@@ -622,14 +700,14 @@
622
  <comment></comment>
623
  </logging>
624
  <heading_diagnostics translate="label">
625
- <label>Diagnostics</label>
626
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
627
- <sort_order>200</sort_order>
628
- <show_in_default>1</show_in_default>
629
- <show_in_website>0</show_in_website>
630
- <show_in_store>1</show_in_store>
631
- </heading_diagnostics>
632
- <diagnostics translate="label">
633
  <label>Status</label>
634
  <frontend_model>emaildirect/adminhtml_system_config_form_field_diagnostics</frontend_model>
635
  <sort_order>210</sort_order>
131
  <show_in_store>1</show_in_store>
132
  <comment>If set to "Yes", the source will be updated when an existing customer is updated.</comment>
133
  </override_source>
134
+ <store_send_type translate="label comment">
135
+ <label>Store field to send</label>
136
+ <frontend_type>select</frontend_type>
137
+ <source_model>emaildirect/system_config_source_store</source_model>
138
+ <sort_order>95</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>0</show_in_website>
141
+ <show_in_store>1</show_in_store>
142
+ <can_be_empty>1</can_be_empty>
143
+ <comment>When sending customer data, this will indicate the store that they are associated with</comment>
144
+ </store_send_type>
145
  <heading_mappings translate="label">
146
+ <label>Field Mappings</label>
147
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
148
+ <sort_order>100</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>0</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </heading_mappings>
153
 
154
  <address_fields translate="label comment">
155
  <label>Address Fields Mapping</label>
342
 
343
  <!-- SEQUENCES -->
344
  <heading_sequence translate="label">
345
+ <label>Abandoned Cart Sequences</label>
346
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
347
+ <sort_order>360</sort_order>
348
+ <show_in_default>1</show_in_default>
349
+ <show_in_website>0</show_in_website>
350
+ <show_in_store>1</show_in_store>
351
+ <depends><sendabandoned>1</sendabandoned></depends>
352
+ </heading_sequence>
353
  <abandonedsequence_enabled>
354
  <label>Add a sequence value to each abandoned cart?</label>
355
  <frontend_type>select</frontend_type>
387
 
388
  <!-- signup -->
389
  <heading_signup translate="label">
390
+ <label>EmailDirect Signup Form</label>
391
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
392
+ <sort_order>500</sort_order>
393
+ <show_in_default>1</show_in_default>
394
+ <show_in_website>0</show_in_website>
395
+ <show_in_store>1</show_in_store>
396
+ </heading_signup>
397
  <signup_enabled>
398
  <label>Show EmailDirect Signup form?</label>
399
  <frontend_type>select</frontend_type>
400
  <source_model>adminhtml/system_config_source_yesno</source_model>
401
+ <sort_order>510</sort_order>
402
  <show_in_default>1</show_in_default>
403
  <show_in_website>0</show_in_website>
404
  <show_in_store>1</show_in_store>
407
  <signup_url>
408
  <label>URL to Signup Form</label>
409
  <frontend_type>text</frontend_type>
410
+ <sort_order>520</sort_order>
411
  <show_in_default>1</show_in_default>
412
  <show_in_website>0</show_in_website>
413
  <show_in_store>1</show_in_store>
417
  <signup_delay>
418
  <label>Delay before showing</label>
419
  <frontend_type>text</frontend_type>
420
+ <sort_order>530</sort_order>
421
  <show_in_default>1</show_in_default>
422
  <show_in_website>0</show_in_website>
423
  <show_in_store>1</show_in_store>
428
  <label>Recurrence</label>
429
  <frontend_type>select</frontend_type>
430
  <source_model>emaildirect/system_config_source_signup_recurrence</source_model>
431
+ <sort_order>540</sort_order>
432
  <show_in_default>1</show_in_default>
433
  <show_in_website>0</show_in_website>
434
  <show_in_store>1</show_in_store>
438
  <signup_width>
439
  <label>Width of Form</label>
440
  <frontend_type>text</frontend_type>
441
+ <sort_order>550</sort_order>
442
  <show_in_default>1</show_in_default>
443
  <show_in_website>0</show_in_website>
444
  <show_in_store>1</show_in_store>
447
  <signup_height>
448
  <label>Height of Form</label>
449
  <frontend_type>text</frontend_type>
450
+ <sort_order>560</sort_order>
451
  <show_in_default>1</show_in_default>
452
  <show_in_website>0</show_in_website>
453
  <show_in_store>1</show_in_store>
457
  <label>Opacity of background</label>
458
  <frontend_type>select</frontend_type>
459
  <source_model>emaildirect/system_config_source_signup_opacity</source_model>
460
+ <sort_order>570</sort_order>
461
  <show_in_default>1</show_in_default>
462
  <show_in_website>0</show_in_website>
463
  <show_in_store>1</show_in_store>
466
  <signup_test_button>
467
  <label>Test Signup Form</label>
468
  <frontend_model>emaildirect/adminhtml_system_config_form_field_signup_test</frontend_model>
469
+ <sort_order>580</sort_order>
470
  <show_in_default>1</show_in_default>
471
  <show_in_website>0</show_in_website>
472
  <show_in_store>1</show_in_store>
478
  <label>Activate Signup Form?</label>
479
  <frontend_type>select</frontend_type>
480
  <source_model>adminhtml/system_config_source_yesno</source_model>
481
+ <sort_order>590</sort_order>
482
  <show_in_default>1</show_in_default>
483
  <show_in_website>0</show_in_website>
484
  <show_in_store>1</show_in_store>
488
 
489
  <!-- Wishlist -->
490
  <heading_wishlist translate="label">
491
+ <label>Wishlist</label>
492
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
493
+ <sort_order>600</sort_order>
494
+ <show_in_default>1</show_in_default>
495
+ <show_in_website>0</show_in_website>
496
+ <show_in_store>1</show_in_store>
497
+ </heading_wishlist>
498
+ <wishlist_enabled>
499
  <label>Activate Wish List Alerts?</label>
500
  <frontend_type>select</frontend_type>
501
  <source_model>adminhtml/system_config_source_yesno</source_model>
505
  <show_in_store>1</show_in_store>
506
  <comment>Send subscriber Wishlist URL and their most recent Wishlist Date to your EmailDirect database.</comment>
507
  </wishlist_enabled>
508
+ <!-- Customer Last Login -->
509
+ <heading_lastlogin translate="label">
510
+ <label>Customer Last Login</label>
511
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
512
+ <sort_order>700</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>0</show_in_website>
515
+ <show_in_store>1</show_in_store>
516
+ </heading_lastlogin>
517
+ <lastlogin_enabled translate="label">
518
+ <label>Send Last Login Date?</label>
519
+ <frontend_type>select</frontend_type>
520
+ <source_model>adminhtml/system_config_source_yesno</source_model>
521
+ <sort_order>710</sort_order>
522
+ <show_in_default>1</show_in_default>
523
+ <show_in_website>0</show_in_website>
524
+ <show_in_store>1</show_in_store>
525
+ <comment>When customer logs in, send the date to EmailDirect</comment>
526
+ </lastlogin_enabled>
527
+
528
 
529
+ <!-- CRON URL -->
530
+ <heading_cron_url translate="label">
531
+ <label>Cron URL</label>
532
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
533
+ <sort_order>800</sort_order>
534
+ <show_in_default>1</show_in_default>
535
+ <show_in_website>0</show_in_website>
536
+ <show_in_store>1</show_in_store>
537
+ </heading_cron_url>
538
+ <cron_url_enabled>
539
+ <label>Allow cron to be run from a URL?</label>
540
+ <frontend_type>select</frontend_type>
541
+ <source_model>adminhtml/system_config_source_yesno</source_model>
542
+ <sort_order>810</sort_order>
543
+ <show_in_default>1</show_in_default>
544
+ <show_in_website>0</show_in_website>
545
+ <show_in_store>1</show_in_store>
546
+ <comment>This URL is an alternate method to trigger EmailDirect cron jobs</comment>
547
+ </cron_url_enabled>
548
+ <cron_url_password_enabled>
549
+ <label>Require a password?</label>
550
+ <frontend_type>select</frontend_type>
551
+ <source_model>adminhtml/system_config_source_yesno</source_model>
552
+ <sort_order>820</sort_order>
553
+ <show_in_default>1</show_in_default>
554
+ <show_in_website>0</show_in_website>
555
+ <show_in_store>1</show_in_store>
556
+ <comment>Limit access to the cron URL</comment>
557
+ <depends><cron_url_enabled>1</cron_url_enabled></depends>
558
+ </cron_url_password_enabled>
559
+ <cron_url_password>
560
+ <label>Password</label>
561
+ <frontend_type>text</frontend_type>
562
+ <sort_order>830</sort_order>
563
+ <show_in_default>1</show_in_default>
564
+ <show_in_website>0</show_in_website>
565
+ <show_in_store>1</show_in_store>
566
+ <depends><cron_url_enabled>1</cron_url_enabled><cron_url_password_enabled>1</cron_url_password_enabled></depends>
567
+ </cron_url_password>
568
+ <cron_url_info>
569
+ <label>URL Info</label>
570
+ <frontend_model>emaildirect/adminhtml_system_config_form_field_cron_url_info</frontend_model>
571
+ <sort_order>850</sort_order>
572
+ <show_in_default>1</show_in_default>
573
+ <show_in_website>0</show_in_website>
574
+ <show_in_store>1</show_in_store>
575
+ <depends><cron_url_enabled>1</cron_url_enabled></depends>
576
+ </cron_url_info>
577
  </fields>
578
  </general>
579
  <export translate="label comment">
586
  <expanded>1</expanded>
587
  <fields>
588
  <heading_orders translate="label">
589
+ <label>Order Exports</label>
590
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
591
+ <sort_order>5</sort_order>
592
+ <show_in_default>1</show_in_default>
593
+ <show_in_website>0</show_in_website>
594
+ <show_in_store>1</show_in_store>
595
+ </heading_orders>
596
+ <include_already_sent translate="label">
597
  <label>Include orders already sent?</label>
598
  <frontend_type>select</frontend_type>
599
  <source_model>adminhtml/system_config_source_yesno</source_model>
625
  </export_orders_button>
626
 
627
  <heading_products translate="label">
628
+ <label>Category Exports</label>
629
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
630
+ <sort_order>30</sort_order>
631
+ <show_in_default>1</show_in_default>
632
+ <show_in_website>0</show_in_website>
633
+ <show_in_store>1</show_in_store>
634
+ </heading_products>
635
  <include_disabled translate="label">
636
  <label>Include disabled Products?</label>
637
  <frontend_type>select</frontend_type>
683
  <expanded>1</expanded>
684
  <fields>
685
  <heading_logging translate="label">
686
+ <label>Logging</label>
687
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
688
+ <sort_order>10</sort_order>
689
+ <show_in_default>1</show_in_default>
690
+ <show_in_website>0</show_in_website>
691
+ <show_in_store>1</show_in_store>
692
+ </heading_logging>
693
  <logging translate="label">
694
  <label>Status</label>
695
  <frontend_model>emaildirect/adminhtml_system_config_form_field_logging</frontend_model>
700
  <comment></comment>
701
  </logging>
702
  <heading_diagnostics translate="label">
703
+ <label>Diagnostics</label>
704
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
705
+ <sort_order>200</sort_order>
706
+ <show_in_default>1</show_in_default>
707
+ <show_in_website>0</show_in_website>
708
+ <show_in_store>1</show_in_store>
709
+ </heading_diagnostics>
710
+ <diagnostics translate="label">
711
  <label>Status</label>
712
  <frontend_model>emaildirect/adminhtml_system_config_form_field_diagnostics</frontend_model>
713
  <sort_order>210</sort_order>
app/design/adminhtml/default/default/layout/emaildirect.xml CHANGED
@@ -1,107 +1,107 @@
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
- <reference name="content">
8
- <block type="core/template" name="emaildirect_setup_check" before="-" template="emaildirect/system/config/setup_check.phtml" />
9
- </reference>
10
- </adminhtml_system_config_edit>
11
 
12
- <adminhtml_sales_order_view>
13
- <reference name="sales_order_tabs">
14
- <block type="emaildirect/adminhtml_order_view_tab_diagnostics" name="order_view_tab_emaildirect" template="emaildirect/diagnostics.phtml">
15
- <block type="emaildirect/adminhtml_order_view_tab_diagnostics_status" name="diagnostic_status" template="emaildirect/order/view/tab/diagnostics/status.phtml"></block>
16
- </block>
17
- <action method="addTab">
18
- <name>order_view_tab_emaildirect</name>
19
- <block>order_view_tab_emaildirect</block>
20
- </action>
21
- </reference>
22
- </adminhtml_sales_order_view>
23
 
24
- <ed_integration_admin_export_products>
25
- <remove name="root"/>
26
- <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
27
- <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
28
- <action method="addJs"><script>prototype/prototype.js</script></action>
29
- <action method="addJs"><script>prototype/validation.js</script></action>
30
- <action method="addJs"><script>varien/js.js</script></action>
31
- <action method="addJs"><script>mage/translate.js</script></action>
32
- <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
33
- <action method="setTitle" translate="title"><title>EmailDirect - Export Products</title></action>
34
- </block>
35
- <block type="emaildirect/adminhtml_system_convert_profile_export_products" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
36
- </block>
37
- </ed_integration_admin_export_products>
38
 
39
- <ed_integration_admin_export_orders>
40
- <remove name="root"/>
41
- <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
42
- <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
43
- <action method="addJs"><script>prototype/prototype.js</script></action>
44
- <action method="addJs"><script>prototype/validation.js</script></action>
45
- <action method="addJs"><script>varien/js.js</script></action>
46
- <action method="addJs"><script>mage/translate.js</script></action>
47
- <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
48
- <action method="setTitle" translate="title"><title>EmailDirect - Export Orders</title></action>
49
- </block>
50
- <block type="emaildirect/adminhtml_system_convert_profile_export_orders" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
51
- </block>
52
- </ed_integration_admin_export_orders>
53
 
54
- <ed_integration_admin_troubleshooting_index>
55
- <reference name="head">
56
- <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
57
- </reference>
58
- <reference name="content">
59
  <block type="emaildirect/adminhtml_troubleshooting_view" name="troubleshooting_view">
60
- <block type="emaildirect/adminhtml_troubleshooting_status" name="troubleshooting_status" template='emaildirect/troubleshooting/status.phtml'>
61
- </block>
62
  </block>
63
- </reference>
64
- <reference name="left">
65
- <block type="emaildirect/adminhtml_troubleshooting_tabs" name="trouble.tabs" as="trouble.tabs" template="widget/tabs.phtml" >
66
- <action method="addTab"><name>trouble_help</name><block>emaildirect/adminhtml_troubleshooting_view_tab_help</block></action>
67
- <action method="addTab"><name>trouble_settings</name><block>emaildirect/adminhtml_troubleshooting_view_tab_settings</block></action>
68
- <action method="addTab"><name>trouble_info</name><block>emaildirect/adminhtml_troubleshooting_view_tab_info</block></action>
69
- <action method="addTab"><name>trouble_log</name><block>emaildirect/adminhtml_troubleshooting_view_tab_log</block></action>
70
- <action method="addTab"><name>trouble_cron</name><block>emaildirect/adminhtml_troubleshooting_view_tab_cron</block></action>
71
- <action method="addTab"><name>trouble_submit</name><block>emaildirect/adminhtml_troubleshooting_view_tab_submit</block></action>
72
- <action method="addTab"><name>trouble_download</name><block>emaildirect/adminhtml_troubleshooting_view_tab_download</block></action>
73
- </block>
74
- </reference>
75
- </ed_integration_admin_troubleshooting_index>
76
 
77
- <ed_integration_admin_abandoned_index>
78
- <reference name="head">
79
- <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
80
- </reference>
81
- <reference name="content">
82
- <block type="emaildirect/adminhtml_abandoned" name="abandoned_cart">
83
- </block>
84
- </reference>
85
- </ed_integration_admin_abandoned_index>
86
 
87
- <ed_integration_admin_abandoned_details>
88
- <reference name="head">
89
- <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
90
- </reference>
91
- <reference name="content">
92
- <block type="emaildirect/adminhtml_abandoned_details" name="abandoned_details" template="emaildirect/abandoned/details.phtml">
93
- </block>
94
- </reference>
95
- <reference name="left">
96
- <block type="emaildirect/adminhtml_abandoned_tabs" name="abandoned.tabs" as="abandoned.tabs" template="widget/tabs.phtml" >
97
- <block type="emaildirect/adminhtml_abandoned_details_tab_diagnostics" name="abandoned_tab_details_emaildirect" template="emaildirect/diagnostics.phtml">
98
- <block type="emaildirect/adminhtml_abandoned_details_tab_diagnostics_status" name="diagnostic_status" template="emaildirect/abandoned/details/tab/diagnostics/status.phtml"></block>
99
- </block>
100
 
101
- <action method="addTab"><name>abandoned_cart</name><block>emaildirect/adminhtml_abandoned_details_tab_cart</block></action>
102
- <action method="addTab"><name>abandoned_details</name><block>abandoned_tab_details_emaildirect</block></action>
103
 
104
- </block>
105
- </reference>
106
- </ed_integration_admin_abandoned_details>
107
  </layout>
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
+ <reference name="content">
8
+ <block type="core/template" name="emaildirect_setup_check" before="-" template="emaildirect/system/config/setup_check.phtml" />
9
+ </reference>
10
+ </adminhtml_system_config_edit>
11
 
12
+ <adminhtml_sales_order_view>
13
+ <reference name="sales_order_tabs">
14
+ <block type="emaildirect/adminhtml_order_view_tab_diagnostics" name="order_view_tab_emaildirect" template="emaildirect/diagnostics.phtml">
15
+ <block type="emaildirect/adminhtml_order_view_tab_diagnostics_status" name="diagnostic_status" template="emaildirect/order/view/tab/diagnostics/status.phtml"></block>
16
+ </block>
17
+ <action method="addTab">
18
+ <name>order_view_tab_emaildirect</name>
19
+ <block>order_view_tab_emaildirect</block>
20
+ </action>
21
+ </reference>
22
+ </adminhtml_sales_order_view>
23
 
24
+ <adminhtml_emaildirect_export_products>
25
+ <remove name="root"/>
26
+ <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
27
+ <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
28
+ <action method="addJs"><script>prototype/prototype.js</script></action>
29
+ <action method="addJs"><script>prototype/validation.js</script></action>
30
+ <action method="addJs"><script>varien/js.js</script></action>
31
+ <action method="addJs"><script>mage/translate.js</script></action>
32
+ <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
33
+ <action method="setTitle" translate="title"><title>EmailDirect - Export Products</title></action>
34
+ </block>
35
+ <block type="emaildirect/adminhtml_system_convert_profile_export_products" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
36
+ </block>
37
+ </adminhtml_emaildirect_export_products>
38
 
39
+ <adminhtml_emaildirect_export_orders>
40
+ <remove name="root"/>
41
+ <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
42
+ <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
43
+ <action method="addJs"><script>prototype/prototype.js</script></action>
44
+ <action method="addJs"><script>prototype/validation.js</script></action>
45
+ <action method="addJs"><script>varien/js.js</script></action>
46
+ <action method="addJs"><script>mage/translate.js</script></action>
47
+ <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
48
+ <action method="setTitle" translate="title"><title>EmailDirect - Export Orders</title></action>
49
+ </block>
50
+ <block type="emaildirect/adminhtml_system_convert_profile_export_orders" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
51
+ </block>
52
+ </adminhtml_emaildirect_export_orders>
53
 
54
+ <adminhtml_emaildirect_troubleshooting_index>
55
+ <reference name="head">
56
+ <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
57
+ </reference>
58
+ <reference name="content">
59
  <block type="emaildirect/adminhtml_troubleshooting_view" name="troubleshooting_view">
60
+ <block type="emaildirect/adminhtml_troubleshooting_status" name="troubleshooting_status" template='emaildirect/troubleshooting/status.phtml'>
61
+ </block>
62
  </block>
63
+ </reference>
64
+ <reference name="left">
65
+ <block type="emaildirect/adminhtml_troubleshooting_tabs" name="trouble.tabs" as="trouble.tabs" template="widget/tabs.phtml" >
66
+ <action method="addTab"><name>trouble_help</name><block>emaildirect/adminhtml_troubleshooting_view_tab_help</block></action>
67
+ <action method="addTab"><name>trouble_settings</name><block>emaildirect/adminhtml_troubleshooting_view_tab_settings</block></action>
68
+ <action method="addTab"><name>trouble_info</name><block>emaildirect/adminhtml_troubleshooting_view_tab_info</block></action>
69
+ <action method="addTab"><name>trouble_log</name><block>emaildirect/adminhtml_troubleshooting_view_tab_log</block></action>
70
+ <action method="addTab"><name>trouble_cron</name><block>emaildirect/adminhtml_troubleshooting_view_tab_cron</block></action>
71
+ <action method="addTab"><name>trouble_submit</name><block>emaildirect/adminhtml_troubleshooting_view_tab_submit</block></action>
72
+ <action method="addTab"><name>trouble_download</name><block>emaildirect/adminhtml_troubleshooting_view_tab_download</block></action>
73
+ </block>
74
+ </reference>
75
+ </adminhtml_emaildirect_troubleshooting_index>
76
 
77
+ <adminhtml_emaildirect_abandoned_index>
78
+ <reference name="head">
79
+ <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
80
+ </reference>
81
+ <reference name="content">
82
+ <block type="emaildirect/adminhtml_abandoned" name="abandoned_cart">
83
+ </block>
84
+ </reference>
85
+ </adminhtml_emaildirect_abandoned_index>
86
 
87
+ <adminhtml_emaildirect_abandoned_details>
88
+ <reference name="head">
89
+ <action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
90
+ </reference>
91
+ <reference name="content">
92
+ <block type="emaildirect/adminhtml_abandoned_details" name="abandoned_details" template="emaildirect/abandoned/details.phtml">
93
+ </block>
94
+ </reference>
95
+ <reference name="left">
96
+ <block type="emaildirect/adminhtml_abandoned_tabs" name="abandoned.tabs" as="abandoned.tabs" template="widget/tabs.phtml" >
97
+ <block type="emaildirect/adminhtml_abandoned_details_tab_diagnostics" name="abandoned_tab_details_emaildirect" template="emaildirect/diagnostics.phtml">
98
+ <block type="emaildirect/adminhtml_abandoned_details_tab_diagnostics_status" name="diagnostic_status" template="emaildirect/abandoned/details/tab/diagnostics/status.phtml"></block>
99
+ </block>
100
 
101
+ <action method="addTab"><name>abandoned_cart</name><block>emaildirect/adminhtml_abandoned_details_tab_cart</block></action>
102
+ <action method="addTab"><name>abandoned_details</name><block>abandoned_tab_details_emaildirect</block></action>
103
 
104
+ </block>
105
+ </reference>
106
+ </adminhtml_emaildirect_abandoned_details>
107
  </layout>
app/design/adminhtml/default/default/template/emaildirect/diagnostics.phtml CHANGED
@@ -69,15 +69,15 @@ table.diagnostic-options { width: 100%; }
69
  echo "Note: " . $option['disabled_reason'];
70
  else if (isset($option['note']))
71
  echo "Note: " . $option['note'];
72
- ?>
73
  </div>
74
  </td>
75
  </tr>
76
  <?php endforeach; ?>
77
-
78
  <tr>
79
  <td>
80
- <form id='download_form' method='post' action='<?php echo $this->getUrl("ed_integration/admin_diagnostic/download") ?>'>
81
  <input type='hidden' name='form_key' value='<?php echo $this->getFormKey(); ?>'></input>
82
  <input type='hidden' name='output' id='hidden_output' value='' ></input>
83
  <input type='hidden' name='filename' value='diagnostic_output.html' ></input>
@@ -100,7 +100,7 @@ table.diagnostic-options { width: 100%; }
100
  <a href='#' onclick="return selectText('diagnostic_output');">Select</a>
101
  <!--<span> | </span>
102
  <a href='#' onclick="return clear('output');">Clear</a>-->
103
-
104
  </div>
105
  </div>
106
  <div id="emaildirect_diagnostic_output_fieldset" class="fieldset">
@@ -120,7 +120,7 @@ table.diagnostic-options { width: 100%; }
120
  <a href='#' onclick="return selectText('diagnostic_details');">Select</a>
121
  <!--<span> | </span>
122
  <a href='#' onclick="return clear('details');">Clear</a>-->
123
-
124
  </div>
125
  </div>
126
  <div id="emaildirect_diagnostic_details_fieldset" class="fieldset" style='display:none'>
@@ -148,13 +148,13 @@ function toggleSection(section)
148
  {
149
  console.log(section);
150
  $("emaildirect_" + section + "_fieldset").toggle();
151
-
152
  $(section + "_toggle").toggleClassName("ed_expand");
153
  $(section + "_toggle").toggleClassName("ed_contract");
154
-
155
  if (section == 'diagnostic_output')
156
  $('spacer_output').toggle();
157
-
158
  return false;
159
  }
160
 
@@ -172,7 +172,7 @@ function selectText(containerid)
172
  range.selectNode(document.getElementById(containerid));
173
  window.getSelection().addRange(range);
174
  }
175
-
176
  return false;
177
  }
178
 
@@ -191,7 +191,7 @@ function showData(output, details)
191
  $("hidden_output").value = "<div>" + output + "</div><hr /><h1>Report Details</h1><div>" + details + "</div>";
192
  $("download").removeClassName('disabled');
193
  $("download").removeAttribute('disabled');
194
-
195
  showOutput(output);
196
  showDetails(details);
197
  }
@@ -203,18 +203,18 @@ function performRequest(method)
203
  clear('output');
204
  clear('details');
205
  }
206
-
207
- new Ajax.Request('<?php echo $this->getUrl('ed_integration/admin_diagnostic/ajax') ?>',
208
  {
209
  parameters: {isAjax: 'true', form_key: FORM_KEY, method: method, item_id: item_id, store_id: store_id},
210
- onSuccess: function(transport)
211
  {
212
- try
213
  {
214
  if (transport.responseText.isJSON())
215
  {
216
  var response = transport.responseText.evalJSON()
217
- if (response.error)
218
  {
219
  alert(response.message);
220
  }
@@ -222,7 +222,7 @@ function performRequest(method)
222
  {
223
  setLocation(response.ajaxRedirect);
224
  }
225
-
226
  showData(response.output,response.details);
227
  }
228
  }
69
  echo "Note: " . $option['disabled_reason'];
70
  else if (isset($option['note']))
71
  echo "Note: " . $option['note'];
72
+ ?>
73
  </div>
74
  </td>
75
  </tr>
76
  <?php endforeach; ?>
77
+
78
  <tr>
79
  <td>
80
+ <form id='download_form' method='post' action='<?php echo $this->getUrl("adminhtml/emaildirect_diagnostic/download") ?>'>
81
  <input type='hidden' name='form_key' value='<?php echo $this->getFormKey(); ?>'></input>
82
  <input type='hidden' name='output' id='hidden_output' value='' ></input>
83
  <input type='hidden' name='filename' value='diagnostic_output.html' ></input>
100
  <a href='#' onclick="return selectText('diagnostic_output');">Select</a>
101
  <!--<span> | </span>
102
  <a href='#' onclick="return clear('output');">Clear</a>-->
103
+
104
  </div>
105
  </div>
106
  <div id="emaildirect_diagnostic_output_fieldset" class="fieldset">
120
  <a href='#' onclick="return selectText('diagnostic_details');">Select</a>
121
  <!--<span> | </span>
122
  <a href='#' onclick="return clear('details');">Clear</a>-->
123
+
124
  </div>
125
  </div>
126
  <div id="emaildirect_diagnostic_details_fieldset" class="fieldset" style='display:none'>
148
  {
149
  console.log(section);
150
  $("emaildirect_" + section + "_fieldset").toggle();
151
+
152
  $(section + "_toggle").toggleClassName("ed_expand");
153
  $(section + "_toggle").toggleClassName("ed_contract");
154
+
155
  if (section == 'diagnostic_output')
156
  $('spacer_output').toggle();
157
+
158
  return false;
159
  }
160
 
172
  range.selectNode(document.getElementById(containerid));
173
  window.getSelection().addRange(range);
174
  }
175
+
176
  return false;
177
  }
178
 
191
  $("hidden_output").value = "<div>" + output + "</div><hr /><h1>Report Details</h1><div>" + details + "</div>";
192
  $("download").removeClassName('disabled');
193
  $("download").removeAttribute('disabled');
194
+
195
  showOutput(output);
196
  showDetails(details);
197
  }
203
  clear('output');
204
  clear('details');
205
  }
206
+
207
+ new Ajax.Request('<?php echo $this->getUrl('adminhtml/emaildirect_diagnostic/ajax') ?>',
208
  {
209
  parameters: {isAjax: 'true', form_key: FORM_KEY, method: method, item_id: item_id, store_id: store_id},
210
+ onSuccess: function(transport)
211
  {
212
+ try
213
  {
214
  if (transport.responseText.isJSON())
215
  {
216
  var response = transport.responseText.evalJSON()
217
+ if (response.error)
218
  {
219
  alert(response.message);
220
  }
222
  {
223
  setLocation(response.ajaxRedirect);
224
  }
225
+
226
  showData(response.output,response.details);
227
  }
228
  }
app/design/adminhtml/default/default/template/emaildirect/system/config/fieldset/hint.phtml CHANGED
@@ -11,7 +11,7 @@ $last_run_label = "Cron Last Run";
11
  <div class="emaildirect-notice">
12
  <h4>
13
  <?php if (!$this->isWebsiteConfig()): ?>
14
- <div class='abandoned'>Abandoned Cart Processing: <?php if ($ab_enabled) : ?><span class='ab_ok'>Enabled</span><?php else: ?><span class='ab_ng'>Disabled</span><?php endif; ?> - <?php echo $last_run_label ?>: <?php echo $abandoned_status['cron_last_run'] ?> - <button onclick="window.location='<?php echo $this->getUrl('ed_integration/admin_abandoned/index'); ?>'; return false;" id="emaildirect_details">Details</button></div>
15
  <?php endif; ?>
16
  <strong>EmailDirect Integration v<?php echo $this->getEmaildirectVersion() ?><?php if (!$setup && strlen($api_key) > 0): ?> - <span class='ab_ng'>Invalid API Key</span><?php endif; ?></strong>
17
  </h4>
@@ -29,7 +29,7 @@ document.observe('dom:loaded', function()
29
  {
30
  var id = item.readAttribute('id');
31
  var id_parts = id.split('_');
32
-
33
  if (id_parts[0] == 'row')
34
  {
35
  var name = id_parts.slice(3).join('_');
11
  <div class="emaildirect-notice">
12
  <h4>
13
  <?php if (!$this->isWebsiteConfig()): ?>
14
+ <div class='abandoned'>Abandoned Cart Processing: <?php if ($ab_enabled) : ?><span class='ab_ok'>Enabled</span><?php else: ?><span class='ab_ng'>Disabled</span><?php endif; ?> - <?php echo $last_run_label ?>: <?php echo $abandoned_status['cron_last_run'] ?> - <button onclick="window.location='<?php echo $this->getUrl('adminhtml/emaildirect_abandoned/index'); ?>'; return false;" id="emaildirect_details">Details</button></div>
15
  <?php endif; ?>
16
  <strong>EmailDirect Integration v<?php echo $this->getEmaildirectVersion() ?><?php if (!$setup && strlen($api_key) > 0): ?> - <span class='ab_ng'>Invalid API Key</span><?php endif; ?></strong>
17
  </h4>
29
  {
30
  var id = item.readAttribute('id');
31
  var id_parts = id.split('_');
32
+
33
  if (id_parts[0] == 'row')
34
  {
35
  var name = id_parts.slice(3).join('_');
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/api.phtml CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  $valid = $this->isValid();
3
-
4
  $element = $this->getElement();
5
-
6
  //$enabled = $this->isLoggingEnabled();
7
  ?>
8
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
@@ -15,20 +15,20 @@
15
 
16
  <script type='text/javascript'>
17
 
18
- validate_url = '<?php echo $this->getUrl('ed_integration/admin_troubleshooting/validate'); ?>';
19
 
20
  function performValidation()
21
  {
22
  var apikey = $("emaildirect_general_apikey").value;
23
-
24
  var indicator = $("emaildirect_status_indicator");
25
-
26
  indicator.update("Validating...");
27
  indicator.removeClassName("apikey_valid");
28
  indicator.removeClassName("apikey_invalid");
29
  indicator.addClassName("apikey_validating");
30
-
31
- new Ajax.Request(validate_url + (validate_url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
32
  {
33
  parameters : {apikey: apikey},
34
  method : 'post',
@@ -37,12 +37,12 @@ function performValidation()
37
  if (transport.responseText.isJSON())
38
  {
39
  var response = transport.responseText.evalJSON()
40
-
41
  if (response.valid)
42
  {
43
  indicator.removeClassName("apikey_validating");
44
  indicator.addClassName("apikey_valid");
45
-
46
  $("emaildirect_status_indicator").update("Valid");
47
  }
48
  else
@@ -51,12 +51,12 @@ function performValidation()
51
  indicator.addClassName("apikey_invalid");
52
  $("emaildirect_status_indicator").update("Invalid");
53
  }
54
-
55
  console.log(response);
56
  }
57
  }
58
  });
59
-
60
  return false;
61
  }
62
  </script>
1
  <?php
2
  $valid = $this->isValid();
3
+
4
  $element = $this->getElement();
5
+
6
  //$enabled = $this->isLoggingEnabled();
7
  ?>
8
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
15
 
16
  <script type='text/javascript'>
17
 
18
+ validate_url = '<?php echo $this->getUrl('adminhtml/emaildirect_troubleshooting/validate'); ?>';
19
 
20
  function performValidation()
21
  {
22
  var apikey = $("emaildirect_general_apikey").value;
23
+
24
  var indicator = $("emaildirect_status_indicator");
25
+
26
  indicator.update("Validating...");
27
  indicator.removeClassName("apikey_valid");
28
  indicator.removeClassName("apikey_invalid");
29
  indicator.addClassName("apikey_validating");
30
+
31
+ new Ajax.Request(validate_url + (validate_url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
32
  {
33
  parameters : {apikey: apikey},
34
  method : 'post',
37
  if (transport.responseText.isJSON())
38
  {
39
  var response = transport.responseText.evalJSON()
40
+
41
  if (response.valid)
42
  {
43
  indicator.removeClassName("apikey_validating");
44
  indicator.addClassName("apikey_valid");
45
+
46
  $("emaildirect_status_indicator").update("Valid");
47
  }
48
  else
51
  indicator.addClassName("apikey_invalid");
52
  $("emaildirect_status_indicator").update("Invalid");
53
  }
54
+
55
  console.log(response);
56
  }
57
  }
58
  });
59
+
60
  return false;
61
  }
62
  </script>
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/cron/url/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $options = $this->getProcessOptions();
3
+ ?>
4
+ <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
5
+ <div>
6
+ <h4 id="emaildirect_general_heading_cron_url_info">URL Info</h4>
7
+ <div class='cron_url_note'>Save configuration to see changes to URLs.</div>
8
+ <table>
9
+ <?php foreach($options as $option): ?>
10
+ <tr>
11
+ <td><?php echo $option['label']; ?></td>
12
+ <td><a href='<?php echo $option['url']; ?>' target='_blank'><?php echo $option['url']; ?></a></td>
13
+ </tr>
14
+ <?php endforeach; ?>
15
+ </table>
16
+ </div>
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/diagnostics.phtml CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
  $element = $this->getElement();
3
-
4
  $enabled = $this->getDiagnosticStatus();
5
  ?>
6
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
@@ -13,7 +13,7 @@
13
  function view_details()
14
  {
15
  var form = $('config_edit_form');
16
- var logging_url = '<?php echo Mage::helper('emaildirect')->getAdminUrl("ed_integration/admin_troubleshooting/", array('tab' => 'troubleshooting_view_tabs_trouble_settings')); ?>';
17
 
18
  window.location = logging_url;
19
  }
1
+ <?php
2
  $element = $this->getElement();
3
+
4
  $enabled = $this->getDiagnosticStatus();
5
  ?>
6
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
13
  function view_details()
14
  {
15
  var form = $('config_edit_form');
16
+ var logging_url = '<?php echo Mage::helper('emaildirect')->getAdminUrl("adminhtml/emaildirect_troubleshooting/", array('tab' => 'troubleshooting_view_tabs_trouble_settings')); ?>';
17
 
18
  window.location = logging_url;
19
  }
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/date_range.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
2
- <span>From: </span><input style="width: 75px;" type="text" name="order_export_from" id="order_export_from" value="<?php echo $this->getFromDate() ?>" class="input-text">
3
  <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif'); ?>" alt="Select From Date" class="v-middle" title="Select From Date" id="from_trig">
4
  <span>&nbsp;&nbsp;&nbsp; to: </span>
5
  <input style="width: 75px;" type="text" name="order_export_to" id="order_export_to" value="<?php echo $this->getToDate() ?>" class="input-text">
@@ -12,9 +12,9 @@
12
  var start_from = '<?php echo $this->getFromDate() ?>';
13
  var start_to = '<?php echo $this->getToDate() ?>';
14
  var orders_count = '<?php echo $this->getOrdersCount(); ?>';
15
-
16
  var check_from = parseDate(start_from);
17
-
18
  function setButtonState()
19
  {
20
  if (orders_count == 0 || orders_count == 'Unknown')
@@ -22,13 +22,13 @@
22
  else
23
  toggleValueElements({checked:false}, $('emaildirect_export_orders').parentNode);
24
  }
25
-
26
  function parseDate(date_string)
27
  {
28
  var date_parts = date_string.split('-');
29
  return new Date(date_parts[0],date_parts[1] - 1,date_parts[2]);
30
  }
31
-
32
  var calendarSetupObject = {
33
  inputField : "order_export_from",
34
  ifFormat : "%Y-%m-%d",
@@ -43,7 +43,7 @@
43
  }
44
  }
45
  Calendar.setup(calendarSetupObject);
46
-
47
  var calendarSetupObject2 = {
48
  inputField : "order_export_to",
49
  ifFormat : "%Y-%m-%d",
@@ -58,30 +58,30 @@
58
  }
59
  }
60
  Calendar.setup(calendarSetupObject2);
61
-
62
- var url = '<?php echo $this->getUrl("ed_integration/admin_export/count/"); ?>';
63
-
64
  $('emaildirect_export_include_already_sent').observe('change', function(event)
65
  {
66
  if (!validateDates())
67
  return;
68
-
69
  dateRangeChange();
70
  });
71
-
72
  $('order_export_from').observe('change', function(event)
73
  {
74
  if (!validateDates())
75
  return;
76
-
77
  dateRangeChange();
78
  });
79
-
80
  $('order_export_to').observe('change', function(event)
81
  {
82
  if (!validateDates())
83
  return;
84
-
85
  // Check if the date is < to date
86
  dateRangeChange();
87
  });
@@ -91,27 +91,27 @@ function validateDates()
91
  // Check if the date is < starting date or > to date
92
  var from = parseDate($('order_export_from').value);
93
  var to = parseDate($('order_export_to').value);
94
-
95
  if (from < check_from)
96
  {
97
  $('order_export_from').value = start_from;
98
  return false;
99
  }
100
-
101
  if (to < check_from)
102
  {
103
  $('order_export_to').value = start_to;
104
  return false;
105
  }
106
-
107
  if (from > to)
108
  {
109
  var temp = $('order_export_from').value;
110
-
111
  $('order_export_from').value = $('order_export_to').value;
112
  $('order_export_to').value = temp;
113
  }
114
-
115
  return true;
116
  }
117
 
@@ -120,9 +120,9 @@ function dateRangeChange()
120
  var from = $('order_export_from').value;
121
  var to = $('order_export_to').value;
122
  var include = $('emaildirect_export_include_already_sent').value;
123
-
124
  $('orders_found').update("???");
125
-
126
  new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
127
  parameters : {from: from, to: to, include: include, store: store},
128
  method : 'post',
1
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
2
+ <span>From: </span><input style="width: 75px;" type="text" name="order_export_from" id="order_export_from" value="<?php echo $this->getFromDate() ?>" class="input-text">
3
  <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif'); ?>" alt="Select From Date" class="v-middle" title="Select From Date" id="from_trig">
4
  <span>&nbsp;&nbsp;&nbsp; to: </span>
5
  <input style="width: 75px;" type="text" name="order_export_to" id="order_export_to" value="<?php echo $this->getToDate() ?>" class="input-text">
12
  var start_from = '<?php echo $this->getFromDate() ?>';
13
  var start_to = '<?php echo $this->getToDate() ?>';
14
  var orders_count = '<?php echo $this->getOrdersCount(); ?>';
15
+
16
  var check_from = parseDate(start_from);
17
+
18
  function setButtonState()
19
  {
20
  if (orders_count == 0 || orders_count == 'Unknown')
22
  else
23
  toggleValueElements({checked:false}, $('emaildirect_export_orders').parentNode);
24
  }
25
+
26
  function parseDate(date_string)
27
  {
28
  var date_parts = date_string.split('-');
29
  return new Date(date_parts[0],date_parts[1] - 1,date_parts[2]);
30
  }
31
+
32
  var calendarSetupObject = {
33
  inputField : "order_export_from",
34
  ifFormat : "%Y-%m-%d",
43
  }
44
  }
45
  Calendar.setup(calendarSetupObject);
46
+
47
  var calendarSetupObject2 = {
48
  inputField : "order_export_to",
49
  ifFormat : "%Y-%m-%d",
58
  }
59
  }
60
  Calendar.setup(calendarSetupObject2);
61
+
62
+ var url = '<?php echo $this->getUrl("adminhtml/emaildirect_export/count/"); ?>';
63
+
64
  $('emaildirect_export_include_already_sent').observe('change', function(event)
65
  {
66
  if (!validateDates())
67
  return;
68
+
69
  dateRangeChange();
70
  });
71
+
72
  $('order_export_from').observe('change', function(event)
73
  {
74
  if (!validateDates())
75
  return;
76
+
77
  dateRangeChange();
78
  });
79
+
80
  $('order_export_to').observe('change', function(event)
81
  {
82
  if (!validateDates())
83
  return;
84
+
85
  // Check if the date is < to date
86
  dateRangeChange();
87
  });
91
  // Check if the date is < starting date or > to date
92
  var from = parseDate($('order_export_from').value);
93
  var to = parseDate($('order_export_to').value);
94
+
95
  if (from < check_from)
96
  {
97
  $('order_export_from').value = start_from;
98
  return false;
99
  }
100
+
101
  if (to < check_from)
102
  {
103
  $('order_export_to').value = start_to;
104
  return false;
105
  }
106
+
107
  if (from > to)
108
  {
109
  var temp = $('order_export_from').value;
110
+
111
  $('order_export_from').value = $('order_export_to').value;
112
  $('order_export_to').value = temp;
113
  }
114
+
115
  return true;
116
  }
117
 
120
  var from = $('order_export_from').value;
121
  var to = $('order_export_to').value;
122
  var include = $('emaildirect_export_include_already_sent').value;
123
+
124
  $('orders_found').update("???");
125
+
126
  new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
127
  parameters : {from: from, to: to, include: include, store: store},
128
  method : 'post',
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/orders.phtml CHANGED
@@ -8,10 +8,10 @@ function perform_order_export()
8
  var to = form['order_export_to'];
9
  var store = <?php echo Mage::helper('emaildirect')->getAdminStore(); ?>;
10
  var include = form['groups[export][fields][include_already_sent][value]'];
11
- var url = '<?php echo $this->getUrl("ed_integration/admin_export/orders/"); ?>';
12
 
13
  url += 'export_from/' + $(from).getValue() + '/export_to/' + $(to).getValue() + '/include_already_sent/' + $(include).getValue() + '/store/' + store + '/';
14
-
15
  window.open(url);
16
  }
17
  <?php if ($this->getElement()->getDisabled()):?>
8
  var to = form['order_export_to'];
9
  var store = <?php echo Mage::helper('emaildirect')->getAdminStore(); ?>;
10
  var include = form['groups[export][fields][include_already_sent][value]'];
11
+ var url = '<?php echo $this->getUrl("adminhtml/emaildirect_export/orders/"); ?>';
12
 
13
  url += 'export_from/' + $(from).getValue() + '/export_to/' + $(to).getValue() + '/include_already_sent/' + $(include).getValue() + '/store/' + store + '/';
14
+
15
  window.open(url);
16
  }
17
  <?php if ($this->getElement()->getDisabled()):?>
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/products.phtml CHANGED
@@ -5,13 +5,13 @@ function perform_product_export()
5
  {
6
  var form = $('config_edit_form');
7
  var include_disabled = form['groups[export][fields][include_disabled][value]'];
8
- var url = '<?php echo $this->getUrl("ed_integration/admin_export/products/"); ?>';
9
  var store = <?php echo Mage::helper('emaildirect')->getAdminStore() ?>;
10
 
11
  url += 'include_disabled/' + $(include_disabled).getValue() + '/';
12
  if (store != 0)
13
  url += 'store/' + store;
14
-
15
  window.open(url);
16
  }
17
 
5
  {
6
  var form = $('config_edit_form');
7
  var include_disabled = form['groups[export][fields][include_disabled][value]'];
8
+ var url = '<?php echo $this->getUrl("adminhtml/emaildirect_export/products/"); ?>';
9
  var store = <?php echo Mage::helper('emaildirect')->getAdminStore() ?>;
10
 
11
  url += 'include_disabled/' + $(include_disabled).getValue() + '/';
12
  if (store != 0)
13
  url += 'store/' + store;
14
+
15
  window.open(url);
16
  }
17
 
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/info.phtml CHANGED
@@ -2,7 +2,7 @@
2
  <p>Customer Data and Purchase Behavior Sync by <a href='http://www.emaildirect.com' target='_blank'>www.emaildirect.com</a></p>
3
  <p>Copyright &copy;<?php echo date("Y") ?></p>
4
  <br />
5
- <p>Download our <a href='http://emaildirect.com/downloads/papers/magentoSetupGuide.pdf'>Magento Setup Guide</a> for detailed information on each feature or view the <a href="<?php echo $this->getUrl('ed_integration/admin_troubleshooting/index') ?>">Help</a> page.</p>
6
  <p>Please contact support (<a href='mailto:support@emaildirect.com'>support@emaildirect.com</a>) with any questions that you have.</p>
7
  <br />
8
  <?php if ($this->isWebsiteConfig()): ?>
2
  <p>Customer Data and Purchase Behavior Sync by <a href='http://www.emaildirect.com' target='_blank'>www.emaildirect.com</a></p>
3
  <p>Copyright &copy;<?php echo date("Y") ?></p>
4
  <br />
5
+ <p>Download our <a href='http://emaildirect.com/downloads/papers/magentoSetupGuide.pdf'>Magento Setup Guide</a> for detailed information on each feature or view the <a href="<?php echo $this->getUrl('adminhtml/emaildirect_troubleshooting/index') ?>">Help</a> page.</p>
6
  <p>Please contact support (<a href='mailto:support@emaildirect.com'>support@emaildirect.com</a>) with any questions that you have.</p>
7
  <br />
8
  <?php if ($this->isWebsiteConfig()): ?>
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/logging.phtml CHANGED
@@ -1,14 +1,10 @@
1
- <?php
2
  $element = $this->getElement();
3
-
4
  $status = $this->getLoggingStatus();
5
-
6
- //Zend_debug::dump($status);
7
- //$enabled = $this->isLoggingEnabled();
8
  $enabled_for_store = $this->isEnabledForStore();
9
- //$store = Mage::getSingleton('adminhtml/config_data')->getStore();
10
-
11
-
12
  $enabled = $status['enabled'];
13
  ?>
14
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
@@ -26,5 +22,5 @@
26
  <td><?php echo $this->getLogInfo() ?></td>
27
  </tr>
28
  </table>
29
- </div>
30
- <?php endif; ?>
1
+ <?php
2
  $element = $this->getElement();
3
+
4
  $status = $this->getLoggingStatus();
5
+
 
 
6
  $enabled_for_store = $this->isEnabledForStore();
7
+
 
 
8
  $enabled = $status['enabled'];
9
  ?>
10
  <div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
22
  <td><?php echo $this->getLogInfo() ?></td>
23
  </tr>
24
  </table>
25
+ </div>
26
+ <?php endif; ?>
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/status.phtml CHANGED
@@ -17,13 +17,13 @@ var FORM_KEY = "<?php echo $this->getFormKey();?>";
17
 
18
  function getStatus()
19
  {
20
- new Ajax.Request('<?php echo $this->getUrl('ed_integration/admin_troubleshooting/ajax') ?>',
21
  {
22
  parameters: {isAjax: 'true', form_key: FORM_KEY, method: "status"},
23
  loaderArea : false,
24
  onSuccess: function(transport)
25
  {
26
- try
27
  {
28
  if (transport.responseText.isJSON())
29
  {
@@ -36,15 +36,15 @@ function getStatus()
36
  {
37
  setLocation(response.ajaxRedirect);
38
  }
39
-
40
  var status = response.status;
41
-
42
  if (status.enabled)
43
  {
44
  $("status_state").update("Enabled");
45
-
46
  seconds = status.duration - status.seconds;
47
-
48
  statusCounter.setSeconds(seconds);
49
  statusCounter.start();
50
  $('status').value = "yes";
@@ -72,7 +72,7 @@ function Countdown(options)
72
  seconds = options.seconds || 10,
73
  updateStatus = options.onUpdateStatus || function () {},
74
  counterEnd = options.onCounterEnd || function () {};
75
-
76
  this.setSeconds = function(new_seconds)
77
  {
78
  options.seconds = new_seconds;
@@ -82,7 +82,7 @@ function Countdown(options)
82
  {
83
  //console.log(statusCounter.seconds);
84
  updateStatus(seconds);
85
-
86
  if (seconds === 0)
87
  {
88
  counterEnd();
@@ -91,7 +91,7 @@ function Countdown(options)
91
  }
92
  seconds--;
93
  }
94
-
95
  this.start = function ()
96
  {
97
  clearInterval(timer);
@@ -99,7 +99,7 @@ function Countdown(options)
99
  seconds = options.seconds;
100
  timer = setInterval(decrementCounter, 1000);
101
  };
102
-
103
  this.stop = function ()
104
  {
105
  clearInterval(timer);
@@ -116,46 +116,46 @@ var statusCounter = new Countdown(
116
  // calculate (and subtract) whole days
117
  var days = Math.floor(delta / 86400);
118
  delta -= days * 86400;
119
-
120
  // calculate (and subtract) whole hours
121
  var hours = Math.floor(delta / 3600) % 24;
122
  delta -= hours * 3600;
123
-
124
  // calculate (and subtract) whole minutes
125
  var minutes = Math.floor(delta / 60) % 60;
126
  delta -= minutes * 60;
127
-
128
  // what's left is seconds
129
  var seconds = delta % 60;
130
-
131
  var display = "";
132
-
133
  if (days > 0)
134
  {
135
  display += " " + days + " day";
136
  if (days != 1)
137
  display += "s";
138
  }
139
-
140
  if (hours > 0)
141
  {
142
  display += " " + hours + " hour";
143
  if (hours != 1)
144
  display += "s";
145
  }
146
-
147
  if (minutes > 0)
148
  {
149
  display += " " + minutes + " minute";
150
  if (minutes != 1)
151
  display += "s";
152
  }
153
-
154
  display += " " + seconds + " second";
155
-
156
  if (seconds != 1)
157
  display += "s";
158
-
159
  $('ed_time_remaining').update(display);
160
  }
161
  });
17
 
18
  function getStatus()
19
  {
20
+ new Ajax.Request('<?php echo $this->getUrl('adminhtml/emaildirect_troubleshooting/ajax') ?>',
21
  {
22
  parameters: {isAjax: 'true', form_key: FORM_KEY, method: "status"},
23
  loaderArea : false,
24
  onSuccess: function(transport)
25
  {
26
+ try
27
  {
28
  if (transport.responseText.isJSON())
29
  {
36
  {
37
  setLocation(response.ajaxRedirect);
38
  }
39
+
40
  var status = response.status;
41
+
42
  if (status.enabled)
43
  {
44
  $("status_state").update("Enabled");
45
+
46
  seconds = status.duration - status.seconds;
47
+
48
  statusCounter.setSeconds(seconds);
49
  statusCounter.start();
50
  $('status').value = "yes";
72
  seconds = options.seconds || 10,
73
  updateStatus = options.onUpdateStatus || function () {},
74
  counterEnd = options.onCounterEnd || function () {};
75
+
76
  this.setSeconds = function(new_seconds)
77
  {
78
  options.seconds = new_seconds;
82
  {
83
  //console.log(statusCounter.seconds);
84
  updateStatus(seconds);
85
+
86
  if (seconds === 0)
87
  {
88
  counterEnd();
91
  }
92
  seconds--;
93
  }
94
+
95
  this.start = function ()
96
  {
97
  clearInterval(timer);
99
  seconds = options.seconds;
100
  timer = setInterval(decrementCounter, 1000);
101
  };
102
+
103
  this.stop = function ()
104
  {
105
  clearInterval(timer);
116
  // calculate (and subtract) whole days
117
  var days = Math.floor(delta / 86400);
118
  delta -= days * 86400;
119
+
120
  // calculate (and subtract) whole hours
121
  var hours = Math.floor(delta / 3600) % 24;
122
  delta -= hours * 3600;
123
+
124
  // calculate (and subtract) whole minutes
125
  var minutes = Math.floor(delta / 60) % 60;
126
  delta -= minutes * 60;
127
+
128
  // what's left is seconds
129
  var seconds = delta % 60;
130
+
131
  var display = "";
132
+
133
  if (days > 0)
134
  {
135
  display += " " + days + " day";
136
  if (days != 1)
137
  display += "s";
138
  }
139
+
140
  if (hours > 0)
141
  {
142
  display += " " + hours + " hour";
143
  if (hours != 1)
144
  display += "s";
145
  }
146
+
147
  if (minutes > 0)
148
  {
149
  display += " " + minutes + " minute";
150
  if (minutes != 1)
151
  display += "s";
152
  }
153
+
154
  display += " " + seconds + " second";
155
+
156
  if (seconds != 1)
157
  display += "s";
158
+
159
  $('ed_time_remaining').update(display);
160
  }
161
  });
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/cron.phtml CHANGED
@@ -39,12 +39,12 @@ h4 { border-bottom: solid 1px; }
39
  <?php if (!isset($lastEmailDirectSuccess['date']) || ($lastEmailDirectSuccess['date'] == null)): ?>
40
  <p>None of the EmailDirect cron jobs have been executed. Please check the Exception.log file for information or enable EmailDirect logging to check the emaildirect.log file which can be viewed in the troubleshooting section.</p>
41
  <?php else: ?>
42
- <p>The last time that a EmailDirect cron job was executed: <strong><?php echo $lastEmailDirectSuccess['date'] . " (" . $lastEmailDirectSuccess['elapsed'] . " ago)"; ?></strong></p>
43
 
44
  <?php endif; ?>
45
  <?php endif; ?>
46
  <?php if ($mode != "download"): ?>
47
- <form id='download_form' method='post' action='<?php echo $this->getUrl("emaildirect_dashboard/admin_troubleshooting/downloadCron") ?>'>
48
  <input type='hidden' name='form_key' value='<?php echo $this->getFormKey(); ?>'></input>
49
  </form>
50
  <button id='download' onclick='return performDownload()'>Download Report</button>
39
  <?php if (!isset($lastEmailDirectSuccess['date']) || ($lastEmailDirectSuccess['date'] == null)): ?>
40
  <p>None of the EmailDirect cron jobs have been executed. Please check the Exception.log file for information or enable EmailDirect logging to check the emaildirect.log file which can be viewed in the troubleshooting section.</p>
41
  <?php else: ?>
42
+ <p>The last time that an EmailDirect cron job was executed: <strong><?php echo $lastEmailDirectSuccess['date'] . " (" . $lastEmailDirectSuccess['elapsed'] . " ago)"; ?></strong></p>
43
 
44
  <?php endif; ?>
45
  <?php endif; ?>
46
  <?php if ($mode != "download"): ?>
47
+ <form id='download_form' method='post' action='<?php echo $this->getUrl("adminhtml/emaildirect_troubleshooting/downloadCron") ?>'>
48
  <input type='hidden' name='form_key' value='<?php echo $this->getFormKey(); ?>'></input>
49
  </form>
50
  <button id='download' onclick='return performDownload()'>Download Report</button>
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/download.phtml CHANGED
@@ -6,7 +6,7 @@
6
  <div class="hor-scroll">
7
  <p>Click the button below to download the troubleshooting report.</p>
8
  <p>You can then send this report along with your contact information and description of the problem you are having to <a href="mailto:<?php echo $this->getTroubleEmail() ?>?subject=<?php echo $this->getTroubleSubject() ?>"><?php echo $this->getTroubleEmail() ?></a>.</p>
9
- <button onclick="setLocation('<?php echo $this->getUrl('ed_integration/admin_troubleshooting/download/') ?>'); return false;">Download Report</button>
10
  </div>
11
  </div>
12
  </div>
6
  <div class="hor-scroll">
7
  <p>Click the button below to download the troubleshooting report.</p>
8
  <p>You can then send this report along with your contact information and description of the problem you are having to <a href="mailto:<?php echo $this->getTroubleEmail() ?>?subject=<?php echo $this->getTroubleSubject() ?>"><?php echo $this->getTroubleEmail() ?></a>.</p>
9
+ <button onclick="setLocation('<?php echo $this->getUrl('adminhtml/emaildirect_troubleshooting/download/') ?>'); return false;">Download Report</button>
10
  </div>
11
  </div>
12
  </div>
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/help.phtml CHANGED
@@ -189,5 +189,5 @@ categories and products.</p>
189
  <h3>Orders</h3>
190
  <p>To run Diagnostics on an order, go to the Order View page and select the <strong>EmailDirect Diagnostics</strong> tab on the left side of the screen.</p>
191
  <h3>Abandoned Carts</h3>
192
- <p>To run Diagnostics on an abandoned cart, go to the <a href='<?php echo $this->getUrl('ed_integration/admin_abandoned/index') ?>'>EmailDirect Abandoned Carts Page</a> and click on a row to run diagnostics on that cart.</p>
193
  </div>
189
  <h3>Orders</h3>
190
  <p>To run Diagnostics on an order, go to the Order View page and select the <strong>EmailDirect Diagnostics</strong> tab on the left side of the screen.</p>
191
  <h3>Abandoned Carts</h3>
192
+ <p>To run Diagnostics on an abandoned cart, go to the <a href='<?php echo $this->getUrl('adminhtml/emaildirect_abandoned/index') ?>'>EmailDirect Abandoned Carts Page</a> and click on a row to run diagnostics on that cart.</p>
193
  </div>
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/log.phtml CHANGED
@@ -1,72 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <div class="entry-edit">
2
- <div class="entry-edit-head">
3
- <h4 class="icon-head"><?php echo Mage::helper('emaildirect')->__('EmailDirect Log File') ?></h4>
4
- <div class="tools">
5
- <a href='#' onclick="return performRequest('log_refresh',false);">Refresh</a>
6
- <span> | </span>
7
- <a href='#' onclick="return performRequest('erase_log',true);">Erase Log</a>
8
- <span> | </span>
9
- <a href='#' onclick="return performRequest('test_logging',false);">Test Logging</a>
10
- </div>
11
- </div>
12
- <fieldset>
13
- <div class="entry-logfile" id='logfile_contents'>
14
- <pre><?php echo $this->getLogFile() ?></pre>
15
- </div>
16
- </fieldset>
 
 
17
  </div>
18
 
19
  <script type='text/javascript'>
20
  var FORM_KEY = "<?php echo $this->getFormKey();?>";
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  function showLogFile(contents)
23
  {
24
- $("logfile_contents").update("<pre>" + contents + "</pre>");
25
- scrollToBottom();
26
  }
27
 
28
  function scrollToBottom()
29
  {
30
- var container = document.getElementById("logfile_contents");
31
- container.scrollTop = container.scrollHeight;
32
  }
33
 
34
  function performRequest(method, get_confirmation)
35
  {
36
- if (get_confirmation == true)
37
- {
38
- if (!window.confirm("Are you sure?"))
39
- return;
40
- }
41
- new Ajax.Request('<?php echo $this->getUrl('ed_integration/admin_troubleshooting/ajax') ?>',
42
- {
43
- parameters: {isAjax: 'true', form_key: FORM_KEY, method: method},
44
- onSuccess: function(transport)
45
- {
46
- try
47
- {
48
- if (transport.responseText.isJSON())
49
- {
50
- var response = transport.responseText.evalJSON()
51
- if (response.error)
52
- {
53
- alert(response.message);
54
- }
55
- if(response.ajaxExpired && response.ajaxRedirect)
56
- {
57
- setLocation(response.ajaxRedirect);
58
- }
59
-
60
- showLogFile(response.contents);
61
- }
62
- }
63
- catch (e)
64
- {
65
- showOutput(transport.responseText);
66
- }
67
- }
68
- });
69
-
70
- return false;
71
  }
72
- </script>
1
+ <?php
2
+ $logFiles = $this->getLogFiles();
3
+ $selected = $this->getSelectedLog();
4
+ $default = $this->getDefaultLog();
5
+ $count = 0;
6
+ ?>
7
+
8
+ <div>
9
+ <?php foreach ($logFiles as $file): ?>
10
+ <?php if ($count++ > 0) echo "<span> | </span>";?>
11
+ <a href="#" id="<?php echo $file; ?>" <?php if ($selected == $file) echo " style='font-weight:bold;'"; ?> onclick="return switchLog('<?php echo $file ?>');"><?php echo $file; ?></a>
12
+ <?php endforeach; ?>
13
+ </div>
14
+ <br />
15
  <div class="entry-edit">
16
+ <div class="entry-edit-head">
17
+ <h4 class="icon-head" id='current_logfile'><?php echo $selected ?></h4>
18
+ <div class="tools">
19
+ <a href='#' onclick="return performRequest('log_refresh',false);">Refresh</a>
20
+ <span id='erase_log_sep'> | </span>
21
+ <a href='#' onclick="return performRequest('erase_log',true);" id='erase_log'>Erase Log</a>
22
+ <span id='test_log_sep'> | </span>
23
+ <a href='#' onclick="return performRequest('test_logging',false);" id='test_log'>Test Logging</a>
24
+ </div>
25
+ </div>
26
+ <div class='logfile-fieldset'>
27
+ <div class='logfile-container'>
28
+ <div class="entry-logfile" id='logfile_contents'>
29
+ <pre><?php echo $this->getLogFile() ?></pre>
30
+ </div>
31
+ </div>
32
+ </div>
33
  </div>
34
 
35
  <script type='text/javascript'>
36
  var FORM_KEY = "<?php echo $this->getFormKey();?>";
37
 
38
+ var selected = '<?php echo $selected; ?>';
39
+
40
+ function switchLog(file)
41
+ {
42
+ $('current_logfile').update(file);
43
+ if (file == '<?php echo $default; ?>') {
44
+ $('erase_log').show();
45
+ $('erase_log_sep').show();
46
+ $('test_log').show();
47
+ $('test_log_sep').show();
48
+ } else {
49
+ $('erase_log').hide();
50
+ $('erase_log_sep').hide();
51
+ $('test_log').hide();
52
+ $('test_log_sep').hide();
53
+ }
54
+
55
+ $(selected).setStyle({
56
+ fontWeight: 'normal'
57
+ });
58
+
59
+ selected = file;
60
+
61
+ $(selected).setStyle({
62
+ fontWeight: 'bold'
63
+ });
64
+
65
+ performRequest('log_refresh',false);
66
+
67
+ return false;
68
+ }
69
+
70
  function showLogFile(contents)
71
  {
72
+ $("logfile_contents").update("<pre>" + contents + "</pre>");
73
+ scrollToBottom();
74
  }
75
 
76
  function scrollToBottom()
77
  {
78
+ var container = document.getElementById("logfile_contents");
79
+ container.scrollTop = container.scrollHeight;
80
  }
81
 
82
  function performRequest(method, get_confirmation)
83
  {
84
+ if (get_confirmation == true)
85
+ {
86
+ if (!window.confirm("Are you sure?"))
87
+ return;
88
+ }
89
+ new Ajax.Request('<?php echo $this->getUrl('adminhtml/emaildirect_troubleshooting/ajax') ?>',
90
+ {
91
+ parameters: {isAjax: 'true', form_key: FORM_KEY, method: method, file: selected},
92
+ onSuccess: function(transport)
93
+ {
94
+ try
95
+ {
96
+ if (transport.responseText.isJSON())
97
+ {
98
+ var response = transport.responseText.evalJSON()
99
+ if (response.error)
100
+ {
101
+ alert(response.message);
102
+ }
103
+ if(response.ajaxExpired && response.ajaxRedirect)
104
+ {
105
+ setLocation(response.ajaxRedirect);
106
+ }
107
+
108
+ showLogFile(response.contents);
109
+ }
110
+ }
111
+ catch (e)
112
+ {
113
+ showOutput(transport.responseText);
114
+ }
115
+ }
116
+ });
117
+
118
+ return false;
119
  }
120
+ </script>
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/settings.phtml CHANGED
@@ -17,7 +17,7 @@ $diagnostic_enabled = Mage::helper('emaildirect/troubleshooting')->isDiagnosticE
17
 
18
 
19
  <div class="hor-scroll">
20
- <form id='emaildirect_settings_form' action='<?php echo Mage::helper('emaildirect')->getAdminUrl("ed_integration/admin_troubleshooting/save"); ?>' method='post'>
21
  <input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
22
 
23
  <table cellspacing="0" class="form-list">
17
 
18
 
19
  <div class="hor-scroll">
20
+ <form id='emaildirect_settings_form' action='<?php echo Mage::helper('emaildirect')->getAdminUrl("adminhtml/emaildirect_troubleshooting/save"); ?>' method='post'>
21
  <input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
22
 
23
  <table cellspacing="0" class="form-list">
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/submit.phtml CHANGED
@@ -12,7 +12,7 @@
12
  </div>
13
  <div id="_accountbase_fieldset" class="fieldset ">
14
  <div class="hor-scroll">
15
- <form id='emaildirect_submit_form' action='<?php echo $this->getUrl("ed_integration/admin_troubleshooting/send"); ?>' method='post'>
16
  <input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
17
  <table cellspacing="0" class="form-list">
18
  <tbody>
12
  </div>
13
  <div id="_accountbase_fieldset" class="fieldset ">
14
  <div class="hor-scroll">
15
+ <form id='emaildirect_submit_form' action='<?php echo $this->getUrl("adminhtml/emaildirect_troubleshooting/send"); ?>' method='post'>
16
  <input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
17
  <table cellspacing="0" class="form-list">
18
  <tbody>
package.xml CHANGED
@@ -1,20 +1,22 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>EmailDirect_Integration</name>
4
- <version>2.0.16</version>
5
  <stability>stable</stability>
6
  <license/>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>EmailDirect integration for magento</summary>
10
  <description>EmailDirect integration for magento</description>
11
- <notes>Grouped product price fixes.&#xD;
12
  &#xD;
13
- Cron troubleshooting page.</notes>
 
 
14
  <authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
15
- <date>2015-10-06</date>
16
- <time>03:23:27</time>
17
- <contents><target name="magecommunity"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Abandoned"><dir name="Details"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="8706487c8f465a5ce762cd923258bb35"/></dir><file name="Cart.php" hash="09e9331f6c72157f581ad7135b7f147c"/><file name="Diagnostics.php" hash="eba18ce04ccb125ce4aa6ed5e473734a"/></dir><file name="Form.php" hash="dffc6e49eb95db2f83050706eee1fd55"/></dir><file name="Details.php" hash="9f98f4dd9ea741f9f7dd2eb018af0d7d"/><file name="Grid.php" hash="e0a15673636acb7e113fdf6e3bcd8879"/><file name="Status.php" hash="9a740fd8c63148532bbcf07d19f462df"/><file name="Tabs.php" hash="19e184e72777dfc5b0c35b7027a3e1cf"/></dir><dir name="Diagnostics"><dir name="Status"><file name="Abstract.php" hash="4a54d82d748f880fc5bb8263935ddc98"/></dir></dir><dir name="Order"><dir name="View"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="b4dd8410aa9ce649e603762d5d14f314"/></dir><file name="Diagnostics.php" hash="91bb6af0c9a0e6f41d2575651e8a59ef"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="25796ead15053f86d7adcd551b8b49e7"/></dir><dir name="Form"><dir name="Field"><dir name="Export"><file name="Orders.php" hash="5b101fadb6a64044b276eb07b21cf0a5"/><file name="Products.php" hash="32e13d4b7250890bf84aba87f25de03c"/><file name="Range.php" hash="4adac96fa53fa8e1449bae943a8cca80"/></dir><dir name="Signup"><file name="Test.php" hash="3b773dda25c62bc8cb28031931d67f9f"/></dir><file name="Addressmapfields.php" hash="97b75c8340d561e863a3985ad73ce228"/><file name="Api.php" hash="77dabda85973dc72227937397392c411"/><file name="Common.php" hash="6a86cce53f6df6857ea79241fa281939"/><file name="Diagnostics.php" hash="7efe5c8b90db90e9c512842388d3263d"/><file name="Info.php" hash="246de52ea5d2349ecd7f103cbba8cb8f"/><file name="Logging.php" hash="53b0b7d28d2680e479bfa89b6884802d"/><file name="Mapfields.php" hash="16894c5d76df1293e63128e349700e05"/><file name="Note.php" hash="ef99a474bbc3a828c7a618132a80fe66"/><file name="Shippingmapfields.php" hash="589a74260f394a5eae1b57ca89a74a8b"/></dir></dir></dir><dir name="Convert"><dir name="Profile"><dir name="Export"><file name="Orders.php" hash="947af2b0d8e3f7bc47c47b32cd434f18"/><file name="Products.php" hash="3f93e4789dbeb6710cd2742587d61726"/></dir><file name="Export.php" hash="ba879607ac0693e9db6251bbbc1676a1"/></dir></dir></dir><dir name="Troubleshooting"><dir name="View"><dir name="Tab"><file name="Cron.php" hash="2b50d1641a4c8b630087a23b4780826a"/><file name="Download.php" hash="619916677df7c833e559aae74dae2aa0"/><file name="Help.php" hash="ad4007af59687653f4d6692f2b42b31d"/><file name="Info.php" hash="be5c15da32ef0e042c53d8ac007f8bd6"/><file name="Log.php" hash="a61e66923a287beee5910511b7282a0a"/><file name="Settings.php" hash="f15e57cdc6539c4da84042c98f0ab25c"/><file name="Submit.php" hash="81ae0e0636b66a329cf8f39939788d1d"/></dir><file name="Form.php" hash="e527a3a2335b109c48a69f06c1b0d01f"/></dir><file name="Status.php" hash="d140afcad424ff531bebb412539d6f1c"/><file name="Tabs.php" hash="5d4168cec60212beb87997e6391282e9"/><file name="View.php" hash="47efa0685db07fb73544ad477a0e2c85"/></dir><file name="Abandoned.php" hash="84e127f613dddcde2975b2a0a736aa39"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="a49c1e7f612d379e6509658a56f53d7d"/></dir><dir name="Customer"><dir name="Account"><file name="Lists.php" hash="e1b911c77a78995d3b3390363926ae5a"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><dir name="Abandoned"><file name="Minutes.php" hash="01eacf162f22fef62970ec7de80ce23d"/></dir><file name="Action.php" hash="bf2243f50c9c6dafca26a5bcb889f372"/></dir></dir></dir></dir><file name="Capture.php" hash="e44034ad875957a566d3ac89abb408ed"/><file name="Signup.php" hash="c51c2e5cb93978170a65dc4b69d197bf"/></dir><dir name="Controller"><dir name="Front"><file name="Abstract.php" hash="48d93179d5f8a6b416fd82dd8763daf9"/></dir></dir><dir name="Helper"><file name="Abandoned.php" hash="7910bd8db8a030ae22adae9469d91fe7"/><file name="Data.php" hash="5a668862de9a9f5c9f87b599b63e99ad"/><file name="Diagnostic.php" hash="68867fd906405a6be98e14c1568437b6"/><file name="Fields.php" hash="5fa737c45be172f55fe965975aa6db52"/><file name="Order.php" hash="91d680ba92d44df171c7486f57cfabc7"/><file name="Troubleshooting.php" hash="cf422b72b445a86326e73cbc6f506e18"/></dir><dir name="Model"><dir name="Abandoned"><file name="Observer.php" hash="00f8e4f8186a6c800df932b74b147844"/></dir><dir name="Configuration"><file name="Observer.php" hash="9a188656d5f7d73c91bf4221cc6e4aac"/></dir><dir name="Customer"><file name="Observer.php" hash="cef8d32ba304c51b448343555ea6a066"/></dir><dir name="Mysql4"><dir name="Abandoned"><file name="Collection.php" hash="1a9129267942a98ac3830ceaf714c2ab"/></dir><dir name="Order"><file name="Collection.php" hash="43d343562cf7e54f1b36315aa5d1d4a7"/></dir><dir name="Session"><file name="Collection.php" hash="7d6a8283fdbc1207d709e2bbbc78906d"/></dir><file name="Abandoned.php" hash="485b3771906783d383de75ae9761e55c"/><file name="Order.php" hash="8d538a5737095a1ba0ad448c027b3afb"/><file name="Session.php" hash="516eeeb28038416dc885ed7af6a8a8b0"/></dir><dir name="Newsletter"><file name="Observer.php" hash="d3181ac610e920dead78fff5656f65de"/></dir><dir name="Observer"><file name="Abstract.php" hash="1db39dc86bed51af1d2a3b4df50099bd"/></dir><dir name="Order"><file name="Observer.php" hash="17cd32f5111f0e423ac3a5d8dd62b256"/></dir><dir name="Resource"><file name="Setup.php" hash="2b4fc64eaafbd5f41f95f219871275df"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="96c51fc5c0b947750be4e612e32c83ab"/></dir><dir name="Send"><file name="Field.php" hash="8ecffa8ccce40f3b2db6513b24eb9200"/></dir><dir name="Signup"><file name="Opacity.php" hash="8eabed4c72e7347f0376c3d4cc1023a7"/><file name="Recurrence.php" hash="e11200bbc204b00486c373d8a4e6675e"/></dir><file name="Abandoned.php" hash="9881811b94f38be90bd20a99951a1903"/><file name="Abandonedlist.php" hash="b81d7f2cb03b8482debea5cd6a2bd1c5"/><file name="Additionallist.php" hash="9f109ab04c7ae7832887572b26868e3a"/><file name="Checkoutsubscribe.php" hash="fd90252a1f19649a420dae136ad2a2ba"/><file name="List.php" hash="84c1c8e27f579d5d33992fcb15202748"/><file name="Publication.php" hash="a5bc0192605fc558fe59b37cc0462825"/><file name="Sequence.php" hash="a599f218882d2cfc68dfcf4d58a98a41"/><file name="Source.php" hash="44815cbf4ac6443032df1e7d9c4cadef"/><file name="States.php" hash="a746affc786d8165a98801e68cbf80ab"/><file name="Statuses.php" hash="9844a7a9c3b5c68df45c8f6c518acf16"/><file name="Time.php" hash="8acbb5cb33e66de1e408cf55d17a9398"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="ef81d36a7276737f2d0aa1a5d783a83b"/><file name="Abstract.php" hash="9e97ce6a12e0d074921bb3a1391f3648"/><file name="Database.php" hash="3cceb467358d13584baff58c043762ec"/><file name="Execute.php" hash="e38737d197b2ccd6700ec87ec1836456"/><file name="Ftp.php" hash="d5335cfb68f99761d6902dd390a3d7a8"/><file name="Lists.php" hash="425d64b9256bbdbafa899c4138e78368"/><file name="Orders.php" hash="fa1c481787b0f994c1c1f704f73d6741"/><file name="Publications.php" hash="1bebd172a8bba669d075f09589785652"/><file name="Sources.php" hash="c6caf0274f7d0c50114324bc47a490c4"/><file name="Subscribers.php" hash="53a2c24db3936b7768ae6a8a8f98f394"/><file name="Wishlist.php" hash="2ceb111bbeaa06c4f13f61281aaa5b5e"/></dir><file name="Abandoned.php" hash="b5e001d0bc059c66ef38130b7d6dcec0"/><file name="Observer.php" hash="37a2d4c63e4ef75d535426a8670764f1"/><file name="Order.php" hash="b21426543cd46f799cd0743525120fb8"/><file name="Session.php" hash="c56ecf779dbfb2dae0030935af31911a"/></dir><dir name="controllers"><dir name="Admin"><file name="AbandonedController.php" hash="a5df99cae9322d66954111aaa8be5661"/><file name="DiagnosticController.php" hash="9dd175698b69c2bf59eee728d72726dd"/><file name="ExportController.php" hash="5bb090e4997e9c45367837c66fb9fd01"/><file name="TroubleshootingController.php" hash="02dffffc761bf1ac82ac18f51c75c976"/></dir><dir name="Customer"><file name="AccountController.php" hash="91942750c1c3d20dc31159c1ffbe8200"/></dir><file name="AbandonedController.php" hash="39c9d1a72bca9369a3121ac15f68558e"/><file name="CaptureController.php" hash="89e043bb3864617a062e915d2209dcf4"/><file name="ExportController.php" hash="7ca147debc5c1436b3bf2d9501592f33"/><file name="SignupController.php" hash="fe975d44cc11f1270d34d9d82c7d4be9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="61d894b12944956c74b41f5f96956c2c"/><file name="cache.xml" hash="9f7ad708d6507ec880473689e70ef314"/><file name="config.xml" hash="5f8a95a358a0dccad2738cabb978b316"/><file name="system.xml" hash="38f8dfb41b5fcc55490daf4d7c6e147c"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-2.0.0.php" hash="bdc5e09fe949b36534c50c85fd198e66"/><file name="mysql4-upgrade-1.5.8-2.0.0.php" hash="8f33c7f6dca96cfa8210ec1fe016d95b"/><file name="mysql4-upgrade-2.0.0-2.0.14.php" hash="ead09ac13bb7798b08776dda5948f91d"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="1b07fb2577cc46a1eaea273108a841d5"/><file name="logo.png" hash="2e7e39ced387c798ef27b77dd69f073e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="emaildirect.css" hash="c9caf9ea168efa3b0d6f4b881bcf093c"/><file name="integration.js" hash="7980204c0f594b180b9fa336954c9229"/></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="ee6072cbc17821e860df4e0cf6ff0c90"/></dir><dir name="template"><dir name="emaildirect"><dir name="abandoned"><dir name="details"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="24829356b9dba966e53fb1cfe0f192b6"/></dir><file name="cart.phtml" hash="be7ca2b147fc836c2ca547b290ffe841"/></dir><file name="form.phtml" hash="60633d212382770e99d11d24ae919e47"/></dir><file name="details.phtml" hash="9d467b97a2d773aec950bea7061c6730"/><file name="status.phtml" hash="9e7723dc1fe5f8693345db9cc7cda808"/></dir><dir name="order"><dir name="view"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="a3bdecb1ec08903dd1b61dce6992e190"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="176f3ddb8ea667a64a06967351526f3c"/></dir><dir name="form"><dir name="field"><dir name="export"><file name="date_range.phtml" hash="6a37b1e58456e1dcec734c48deb8c0c1"/><file name="orders.phtml" hash="1dfa19a712b18d2c95c2f4b938f6acef"/><file name="products.phtml" hash="098b7b21b6424c2a4eea26194883a623"/></dir><dir name="signup"><file name="test.phtml" hash="636501cd90c6ab4231bea54efb16b2ff"/></dir><file name="api.phtml" hash="468f33b2a23dbe2828489c1620000c74"/><file name="array.phtml" hash="5415eeff311735624354468c886d39b5"/><file name="diagnostics.phtml" hash="3327dba9e03362077f7562e3045180b7"/><file name="info.phtml" hash="44ab79fdfc5fb5b0cd7e15e79bfd9502"/><file name="logging.phtml" hash="3c7bd2a6f48a84efca1d0f1e75097a8a"/><file name="note.phtml" hash="6625a3771ba10daba5ded5570574716f"/></dir></dir><file name="setup_check.phtml" hash="1814302f58a15fb1629446e074a7e1e0"/></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="c829eeccb120ffe4c0b9f0ddf9c7ff9a"/></dir></dir></dir><dir name="troubleshooting"><dir name="view"><dir name="tab"><file name="cron.phtml" hash="969e8ff6e2ee0e399ea29dd515d44a10"/><file name="download.phtml" hash="d5701a0af7a8f308467fa5552d0de6b2"/><file name="help.phtml" hash="ce11f0fb8f19a00d950266840b4ec3ce"/><file name="info.phtml" hash="bd19bb1072ce1d60a4fb7bda660a0ce7"/><file name="log.phtml" hash="724a65165770bc92ed08ea32d20c1fe7"/><file name="settings.phtml" hash="56cea7faf49b815ac8bd66896130c58c"/><file name="submit.phtml" hash="0d7df80ddbd24e499275315d91fbfd58"/></dir><file name="form.phtml" hash="d2338bfe3598e9315ca8f5ac8d9b5516"/></dir><file name="status.phtml" hash="fac61e17efe7bd4cf67a47eb67786496"/><file name="view.phtml" hash="6ddfc8c6efe25d30e63f792b19a95c84"/></dir><file name="diagnostics.phtml" hash="f1f43a89824cad9f39e599df21ac44b4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="8cb8652ad2505bb6f0c5e80d7be60109"/></dir><dir name="template"><dir name="emaildirect"><dir name="capture"><file name="email.phtml" hash="fa273ff1a48a12eb386f58f3e3e78f66"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="d57eb93aab4e0f1d58f1ec8b9ed24c50"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="50ebf53c50e5e0419dd86a6d5faa2bf9"/></dir><file name="lists.phtml" hash="101ea6709a4355786917a6845b8d52aa"/></dir></dir><dir name="signup"><file name="form.phtml" hash="3d483079d29b79ad4daf306228120c0f"/></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="90a441f2d0dff6c247f810274e8a76ab"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies/>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>EmailDirect_Integration</name>
4
+ <version>2.0.17</version>
5
  <stability>stable</stability>
6
  <license/>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>EmailDirect integration for magento</summary>
10
  <description>EmailDirect integration for magento</description>
11
+ <notes>Store identifier (name, ID or code) is now included in custom fields. This will allow you to associate customers with specific stores in a multi-store environment.&#xD;
12
  &#xD;
13
+ Cron can now be accessed by a URL for situations when traditional Cron setups fail.&#xD;
14
+ &#xD;
15
+ Troubleshooting page can now view system and exception log files to aid in troubleshooting.</notes>
16
  <authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
17
+ <date>2015-10-30</date>
18
+ <time>19:41:01</time>
19
+ <contents><target name="magecommunity"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Abandoned"><dir name="Details"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="8706487c8f465a5ce762cd923258bb35"/></dir><file name="Cart.php" hash="09e9331f6c72157f581ad7135b7f147c"/><file name="Diagnostics.php" hash="eba18ce04ccb125ce4aa6ed5e473734a"/></dir><file name="Form.php" hash="dffc6e49eb95db2f83050706eee1fd55"/></dir><file name="Details.php" hash="628c07e1101ecbbcb45d2c68ae40cf0e"/><file name="Grid.php" hash="e0a15673636acb7e113fdf6e3bcd8879"/><file name="Status.php" hash="9a740fd8c63148532bbcf07d19f462df"/><file name="Tabs.php" hash="19e184e72777dfc5b0c35b7027a3e1cf"/></dir><dir name="Diagnostics"><dir name="Status"><file name="Abstract.php" hash="4a54d82d748f880fc5bb8263935ddc98"/></dir></dir><dir name="Order"><dir name="View"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="b4dd8410aa9ce649e603762d5d14f314"/></dir><file name="Diagnostics.php" hash="91bb6af0c9a0e6f41d2575651e8a59ef"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="25796ead15053f86d7adcd551b8b49e7"/></dir><dir name="Form"><dir name="Field"><dir name="Cron"><dir name="Url"><file name="Info.php" hash="4a1946ecf7a5d9fea3bc6d47fb260ade"/></dir></dir><dir name="Export"><file name="Orders.php" hash="5b101fadb6a64044b276eb07b21cf0a5"/><file name="Products.php" hash="32e13d4b7250890bf84aba87f25de03c"/><file name="Range.php" hash="4adac96fa53fa8e1449bae943a8cca80"/></dir><dir name="Signup"><file name="Test.php" hash="3b773dda25c62bc8cb28031931d67f9f"/></dir><file name="Addressmapfields.php" hash="97b75c8340d561e863a3985ad73ce228"/><file name="Api.php" hash="77dabda85973dc72227937397392c411"/><file name="Common.php" hash="6a86cce53f6df6857ea79241fa281939"/><file name="Diagnostics.php" hash="7efe5c8b90db90e9c512842388d3263d"/><file name="Info.php" hash="39a4a0079c9e865f18ab79a6b11ed5ba"/><file name="Logging.php" hash="53b0b7d28d2680e479bfa89b6884802d"/><file name="Mapfields.php" hash="16894c5d76df1293e63128e349700e05"/><file name="Note.php" hash="ef99a474bbc3a828c7a618132a80fe66"/><file name="Shippingmapfields.php" hash="589a74260f394a5eae1b57ca89a74a8b"/></dir></dir></dir><dir name="Convert"><dir name="Profile"><dir name="Export"><file name="Orders.php" hash="947af2b0d8e3f7bc47c47b32cd434f18"/><file name="Products.php" hash="3f93e4789dbeb6710cd2742587d61726"/></dir><file name="Export.php" hash="ba879607ac0693e9db6251bbbc1676a1"/></dir></dir></dir><dir name="Troubleshooting"><dir name="View"><dir name="Tab"><file name="Cron.php" hash="2b50d1641a4c8b630087a23b4780826a"/><file name="Download.php" hash="619916677df7c833e559aae74dae2aa0"/><file name="Help.php" hash="ad4007af59687653f4d6692f2b42b31d"/><file name="Info.php" hash="be5c15da32ef0e042c53d8ac007f8bd6"/><file name="Log.php" hash="0132095d6fff744b475e8fd44c9c93cb"/><file name="Settings.php" hash="f15e57cdc6539c4da84042c98f0ab25c"/><file name="Submit.php" hash="81ae0e0636b66a329cf8f39939788d1d"/></dir><file name="Form.php" hash="e527a3a2335b109c48a69f06c1b0d01f"/></dir><file name="Status.php" hash="d140afcad424ff531bebb412539d6f1c"/><file name="Tabs.php" hash="5d4168cec60212beb87997e6391282e9"/><file name="View.php" hash="47efa0685db07fb73544ad477a0e2c85"/></dir><file name="Abandoned.php" hash="852b33e1a63dd57cb5a49f64ec22ee35"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="a49c1e7f612d379e6509658a56f53d7d"/></dir><dir name="Customer"><dir name="Account"><file name="Lists.php" hash="e1b911c77a78995d3b3390363926ae5a"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><dir name="Abandoned"><file name="Minutes.php" hash="01eacf162f22fef62970ec7de80ce23d"/></dir><file name="Action.php" hash="bf2243f50c9c6dafca26a5bcb889f372"/></dir></dir></dir></dir><file name="Capture.php" hash="e44034ad875957a566d3ac89abb408ed"/><file name="Signup.php" hash="c51c2e5cb93978170a65dc4b69d197bf"/></dir><dir name="Controller"><dir name="Front"><file name="Abstract.php" hash="48d93179d5f8a6b416fd82dd8763daf9"/></dir></dir><dir name="Helper"><file name="Abandoned.php" hash="9bed50e562c9f8b9311a5c2f6ea2f9ff"/><file name="Data.php" hash="2333204f5730baeca28fbf820a9a0d89"/><file name="Diagnostic.php" hash="68867fd906405a6be98e14c1568437b6"/><file name="Fields.php" hash="cd155f5d050bfed3a163e9918cd48b29"/><file name="Order.php" hash="91d680ba92d44df171c7486f57cfabc7"/><file name="Troubleshooting.php" hash="1f36ab6643eae11f80e126a9488f2154"/></dir><dir name="Model"><dir name="Abandoned"><file name="Observer.php" hash="c4ae0ea8146925969796142c38cb4dac"/></dir><dir name="Configuration"><file name="Observer.php" hash="9a188656d5f7d73c91bf4221cc6e4aac"/></dir><dir name="Customer"><file name="Observer.php" hash="cef8d32ba304c51b448343555ea6a066"/></dir><dir name="Mysql4"><dir name="Abandoned"><file name="Collection.php" hash="1a9129267942a98ac3830ceaf714c2ab"/></dir><dir name="Order"><file name="Collection.php" hash="43d343562cf7e54f1b36315aa5d1d4a7"/></dir><dir name="Session"><file name="Collection.php" hash="7d6a8283fdbc1207d709e2bbbc78906d"/></dir><file name="Abandoned.php" hash="485b3771906783d383de75ae9761e55c"/><file name="Order.php" hash="8d538a5737095a1ba0ad448c027b3afb"/><file name="Session.php" hash="516eeeb28038416dc885ed7af6a8a8b0"/></dir><dir name="Newsletter"><file name="Observer.php" hash="d3181ac610e920dead78fff5656f65de"/></dir><dir name="Observer"><file name="Abstract.php" hash="1db39dc86bed51af1d2a3b4df50099bd"/></dir><dir name="Order"><file name="Observer.php" hash="17cd32f5111f0e423ac3a5d8dd62b256"/></dir><dir name="Resource"><file name="Setup.php" hash="2b4fc64eaafbd5f41f95f219871275df"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="96c51fc5c0b947750be4e612e32c83ab"/></dir><dir name="Send"><file name="Field.php" hash="8ecffa8ccce40f3b2db6513b24eb9200"/></dir><dir name="Signup"><file name="Opacity.php" hash="8eabed4c72e7347f0376c3d4cc1023a7"/><file name="Recurrence.php" hash="e11200bbc204b00486c373d8a4e6675e"/></dir><file name="Abandoned.php" hash="9881811b94f38be90bd20a99951a1903"/><file name="Abandonedlist.php" hash="b81d7f2cb03b8482debea5cd6a2bd1c5"/><file name="Additionallist.php" hash="9f109ab04c7ae7832887572b26868e3a"/><file name="Checkoutsubscribe.php" hash="fd90252a1f19649a420dae136ad2a2ba"/><file name="List.php" hash="84c1c8e27f579d5d33992fcb15202748"/><file name="Publication.php" hash="a5bc0192605fc558fe59b37cc0462825"/><file name="Sequence.php" hash="a599f218882d2cfc68dfcf4d58a98a41"/><file name="Source.php" hash="44815cbf4ac6443032df1e7d9c4cadef"/><file name="States.php" hash="a746affc786d8165a98801e68cbf80ab"/><file name="Statuses.php" hash="9844a7a9c3b5c68df45c8f6c518acf16"/><file name="Store.php" hash="d7936a6286211aa293cde33be36b1bd2"/><file name="Time.php" hash="8acbb5cb33e66de1e408cf55d17a9398"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="ef81d36a7276737f2d0aa1a5d783a83b"/><file name="Abstract.php" hash="9e97ce6a12e0d074921bb3a1391f3648"/><file name="Database.php" hash="3cceb467358d13584baff58c043762ec"/><file name="Execute.php" hash="e38737d197b2ccd6700ec87ec1836456"/><file name="Ftp.php" hash="d5335cfb68f99761d6902dd390a3d7a8"/><file name="Lists.php" hash="425d64b9256bbdbafa899c4138e78368"/><file name="Orders.php" hash="fa1c481787b0f994c1c1f704f73d6741"/><file name="Publications.php" hash="1bebd172a8bba669d075f09589785652"/><file name="Sources.php" hash="c6caf0274f7d0c50114324bc47a490c4"/><file name="Subscribers.php" hash="53a2c24db3936b7768ae6a8a8f98f394"/><file name="Wishlist.php" hash="2ceb111bbeaa06c4f13f61281aaa5b5e"/></dir><file name="Abandoned.php" hash="b5e001d0bc059c66ef38130b7d6dcec0"/><file name="Observer.php" hash="37a2d4c63e4ef75d535426a8670764f1"/><file name="Order.php" hash="b21426543cd46f799cd0743525120fb8"/><file name="Session.php" hash="c56ecf779dbfb2dae0030935af31911a"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="EmailDirect"><file name="AbandonedController.php" hash="94e27cd7e5a2512e11a0dfb37d4cce1c"/><file name="DiagnosticController.php" hash="93ed8f4d6464c913ba7cefe5fd125d0e"/><file name="ExportController.php" hash="f5e888e1e8c6add74c3b1113c16efa7a"/><file name="TroubleshootingController.php" hash="014f67a02564884b63679a0142100362"/></dir></dir><dir name="Customer"><file name="AccountController.php" hash="91942750c1c3d20dc31159c1ffbe8200"/></dir><file name="AbandonedController.php" hash="64eebafd54da8d43234002802c3483ff"/><file name="CaptureController.php" hash="89e043bb3864617a062e915d2209dcf4"/><file name="CronController.php" hash="a86de29047f3e488c2e53a2e9774e8ab"/><file name="ExportController.php" hash="7ca147debc5c1436b3bf2d9501592f33"/><file name="SignupController.php" hash="fe975d44cc11f1270d34d9d82c7d4be9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="91f61c230ecd2dc26196d2e54a4407ec"/><file name="cache.xml" hash="9f7ad708d6507ec880473689e70ef314"/><file name="config.xml" hash="7269c32955c0b102d658a7294403e640"/><file name="system.xml" hash="6e7c4b3ca2db67d0021575cdaca7e35a"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-2.0.0.php" hash="bdc5e09fe949b36534c50c85fd198e66"/><file name="mysql4-upgrade-1.5.8-2.0.0.php" hash="8f33c7f6dca96cfa8210ec1fe016d95b"/><file name="mysql4-upgrade-2.0.0-2.0.14.php" hash="ead09ac13bb7798b08776dda5948f91d"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="9ec2c5c608c4da26dd368766655e4596"/><file name="logo.png" hash="2e7e39ced387c798ef27b77dd69f073e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="emaildirect.css" hash="c9caf9ea168efa3b0d6f4b881bcf093c"/><file name="integration.js" hash="7980204c0f594b180b9fa336954c9229"/></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="ef899ae71b7d3a1ad866e4739a793479"/></dir><dir name="template"><dir name="emaildirect"><dir name="abandoned"><dir name="details"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="24829356b9dba966e53fb1cfe0f192b6"/></dir><file name="cart.phtml" hash="be7ca2b147fc836c2ca547b290ffe841"/></dir><file name="form.phtml" hash="60633d212382770e99d11d24ae919e47"/></dir><file name="details.phtml" hash="9d467b97a2d773aec950bea7061c6730"/><file name="status.phtml" hash="9e7723dc1fe5f8693345db9cc7cda808"/></dir><dir name="order"><dir name="view"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="a3bdecb1ec08903dd1b61dce6992e190"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="5fd5272af534bc973e4a176e15417bc8"/></dir><dir name="form"><dir name="field"><dir name="cron"><dir name="url"><file name="info.phtml" hash="f1e17c0c8392edebfe41eb818501202b"/></dir></dir><dir name="export"><file name="date_range.phtml" hash="6127c68615c3ad69f9cb1a00fe06cb84"/><file name="orders.phtml" hash="693e31ea01509f05633f25192fa77f37"/><file name="products.phtml" hash="00d656846e9a2e5d77e9f0b158cef7af"/></dir><dir name="signup"><file name="test.phtml" hash="636501cd90c6ab4231bea54efb16b2ff"/></dir><file name="api.phtml" hash="097f737c360c6b5bc657f6478ad55994"/><file name="array.phtml" hash="5415eeff311735624354468c886d39b5"/><file name="diagnostics.phtml" hash="36785992f14cf192f638661a4bee23f2"/><file name="info.phtml" hash="7caad513ef98f8788ae34d704577adfd"/><file name="logging.phtml" hash="01d944f8f68383749e920e1ad9faf7a0"/><file name="note.phtml" hash="6625a3771ba10daba5ded5570574716f"/></dir></dir><file name="setup_check.phtml" hash="1814302f58a15fb1629446e074a7e1e0"/></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="c829eeccb120ffe4c0b9f0ddf9c7ff9a"/></dir></dir></dir><dir name="troubleshooting"><dir name="view"><dir name="tab"><file name="cron.phtml" hash="d38e74381b6d0292df16b65fbf3d00da"/><file name="download.phtml" hash="edc5a677eb76e97a7418e2f0553c9a94"/><file name="help.phtml" hash="9d4c8660151194d4107120e2898ec53a"/><file name="info.phtml" hash="bd19bb1072ce1d60a4fb7bda660a0ce7"/><file name="log.phtml" hash="b5d2265e0dc739b1d28b272119ab54a7"/><file name="settings.phtml" hash="298ea2103f696bc2bd0e78bd17125c4a"/><file name="submit.phtml" hash="2ada0868c9e4e5b24285056f60ae1d6a"/></dir><file name="form.phtml" hash="d2338bfe3598e9315ca8f5ac8d9b5516"/></dir><file name="status.phtml" hash="72f0e59ddb990625af87cf55b091d87a"/><file name="view.phtml" hash="6ddfc8c6efe25d30e63f792b19a95c84"/></dir><file name="diagnostics.phtml" hash="5ac82a165bef737a85aaa80a894c80a5"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="8cb8652ad2505bb6f0c5e80d7be60109"/></dir><dir name="template"><dir name="emaildirect"><dir name="capture"><file name="email.phtml" hash="fa273ff1a48a12eb386f58f3e3e78f66"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="d57eb93aab4e0f1d58f1ec8b9ed24c50"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="50ebf53c50e5e0419dd86a6d5faa2bf9"/></dir><file name="lists.phtml" hash="101ea6709a4355786917a6845b8d52aa"/></dir></dir><dir name="signup"><file name="form.phtml" hash="3d483079d29b79ad4daf306228120c0f"/></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="90a441f2d0dff6c247f810274e8a76ab"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies/>
22
  </package>
skin/adminhtml/default/default/emaildirect/emaildirect.css CHANGED
@@ -16,6 +16,8 @@ margin-bottom:10px;
16
  padding:11px 10px 5px;
17
  }
18
 
 
 
19
  div.emaildirect-status
20
  {
21
  padding:10px;
@@ -72,8 +74,15 @@ div.emaildirect-notice h4 div.abandoned
72
  #config_details table { width: 100%; border-collapse: collapse;}
73
  .ed-config-table tr td:first-child { width: 180px; }
74
 
 
75
  .entry-logfile { overflow: scroll; height: 600px;}
76
 
 
 
 
 
 
 
77
  .grid .ed-config-subtable tr.headings {
78
  background: url("../images/sort_row_bg.gif") repeat-x scroll 0 50% transparent !important;
79
  }
16
  padding:11px 10px 5px;
17
  }
18
 
19
+ .cron_url_note { font-style: italic; padding-top: 5px; }
20
+
21
  div.emaildirect-status
22
  {
23
  padding:10px;
74
  #config_details table { width: 100%; border-collapse: collapse;}
75
  .ed-config-table tr td:first-child { width: 180px; }
76
 
77
+ .logfile-container { padding: 10px 15px; }
78
  .entry-logfile { overflow: scroll; height: 600px;}
79
 
80
+ .logfile-fieldset { width: auto;
81
+ background: none repeat scroll 0 0 #fafafa;
82
+ border: 1px solid #d6d6d6;
83
+ margin-bottom: 15px;
84
+ }
85
+
86
  .grid .ed-config-subtable tr.headings {
87
  background: url("../images/sort_row_bg.gif") repeat-x scroll 0 50% transparent !important;
88
  }