dotmailer - Version 0.1.0

Version Notes

Initial release

Download this release

Release Info

Developer Yaroslav Bogutsky
Extension dotmailer
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (34) hide show
  1. app/code/local/Dotdigitalgroup/Dotmailer/Block/Manager.php +239 -0
  2. app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Banner.php +17 -0
  3. app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Credentialbutton.php +13 -0
  4. app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Footer.php +28 -0
  5. app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Header.php +85 -0
  6. app/code/local/Dotdigitalgroup/Dotmailer/Helper/Data.php +5 -0
  7. app/code/local/Dotdigitalgroup/Dotmailer/Model/History.php +9 -0
  8. app/code/local/Dotdigitalgroup/Dotmailer/Model/Mysql4/History.php +8 -0
  9. app/code/local/Dotdigitalgroup/Dotmailer/Model/Mysql4/History/Collection.php +10 -0
  10. app/code/local/Dotdigitalgroup/Dotmailer/Model/Observer.php +515 -0
  11. app/code/local/Dotdigitalgroup/Dotmailer/Model/System/Config/Source/Books.php +27 -0
  12. app/code/local/Dotdigitalgroup/Dotmailer/Model/System/Config/Source/Campaigns.php +26 -0
  13. app/code/local/Dotdigitalgroup/Dotmailer/config/config.xml +6 -0
  14. app/code/local/Dotdigitalgroup/Dotmailer/config/dotMailerConfig.php +77 -0
  15. app/code/local/Dotdigitalgroup/Dotmailer/controllers/IndexController.php +28 -0
  16. app/code/local/Dotdigitalgroup/Dotmailer/controllers/ManagerController.php +353 -0
  17. app/code/local/Dotdigitalgroup/Dotmailer/etc/adminhtml.xml +56 -0
  18. app/code/local/Dotdigitalgroup/Dotmailer/etc/config.xml +231 -0
  19. app/code/local/Dotdigitalgroup/Dotmailer/etc/system.xml +145 -0
  20. app/code/local/Dotdigitalgroup/Dotmailer/sql/dotmailer_setup/mysql4-install-0.1.0.php +17 -0
  21. app/design/adminhtml/default/default/layout/dotdigitalgroup_dotmailer.xml +18 -0
  22. app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/manager.phtml +122 -0
  23. app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/banner.phtml +3 -0
  24. app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/credentialbutton.phtml +1 -0
  25. app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/footer.phtml +3 -0
  26. app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/header.phtml +14 -0
  27. app/design/frontend/base/default/layout/dotdigitalgroup_dotmailer.xml +8 -0
  28. app/design/frontend/base/default/template/dotmailer/track.phtml +19 -0
  29. app/etc/modules/Dotdigitalgroup_Dotmailer.xml +12 -0
  30. js/dotmailer/config.js +113 -0
  31. js/dotmailer/dotmailer.js +31 -0
  32. package.xml +18 -0
  33. skin/adminhtml/default/default/dotmailer.css +52 -0
  34. skin/adminhtml/default/default/images/dotmailer-section.png +0 -0
app/code/local/Dotdigitalgroup/Dotmailer/Block/Manager.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once dirname(dirname(__FILE__)) . "/config/dotMailerConfig.php";
3
+ class Dotdigitalgroup_Dotmailer_Block_Manager extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public $SoapClient;
6
+ public $date;
7
+ public $logoLink;
8
+ public $supportLink;
9
+ public $supportText;
10
+ public $phoneNumber;
11
+
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setTemplate('dotdigitalgroup/dotmailer/manager.phtml');
17
+ $this->SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL");
18
+ $this->config = Mage::getStoreConfig('dotmailer');
19
+ $dotMailerConfig = new dotMailerConfig();
20
+ $this->logoLink = $dotMailerConfig->getLogoLink();
21
+ $this->supportLink = $dotMailerConfig->getSupportLink();
22
+ $this->supportText = $dotMailerConfig->getSupportText();
23
+ $this->phoneNumber = $dotMailerConfig->getPhoneNumber();
24
+
25
+ $code = Mage::app()->getStore()->getBaseCurrencyCode();
26
+ $currency = Mage::app()->getLocale()->currency($code);
27
+ $this->currencySymbol = $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName();
28
+
29
+
30
+ $date = new Zend_Date();
31
+ $date = $date->sub(7, Zend_Date::DAY);
32
+ $from_date = $date->toString('YYYY-MM-dd HH:mm:ss');
33
+
34
+ $this->abandoned_carts = Mage::getModel('sales/quote')->getCollection()->addFieldToFilter('is_active',1)->addFieldToFilter('items_count', array('gt' => 0))->addFieldToFilter('customer_email', array('neq' => ''))->addFieldToFilter('updated_at', array('from' => $from_date));
35
+ $this->no_completed_orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('status', array('nin' => array('complete','canceled','closed','holded')))->addAttributeToFilter('updated_at', array('from' => $from_date));
36
+ $this->completed_orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('status', 'complete')->addAttributeToFilter('updated_at', array('from' => $from_date));
37
+
38
+ $this->abandoned_carts_count = $this->abandoned_carts->count()+$this->no_completed_orders->count();
39
+
40
+ $this->completed_orders_count = $this->completed_orders->count();
41
+
42
+ $campaign_users_emails = array();
43
+ $lostCartsCampaignId = $this->config['dotMailer_group']['dotMailer_campaign_cart_abandoned'];
44
+ $incompleteOrdersCampaignId = $this->config['dotMailer_group']['dotMailer_campaign_incomplete_order'];
45
+
46
+ $date = new Zend_Date();
47
+ $date = $date->sub(7, Zend_Date::DAY);
48
+ $from_date = $date->toString('YYYY-MM-dd');
49
+
50
+ $campaign_users_lost_carts = $this->getListCampaignActivities($lostCartsCampaignId,$from_date);
51
+ $campaign_users_incomplete_orders = $this->getListCampaignActivities($incompleteOrdersCampaignId,$from_date);
52
+ $campaign_users_emails = array_merge($campaign_users_lost_carts,$campaign_users_incomplete_orders);
53
+ if($campaign_users_emails)
54
+ {
55
+ $followed_orders_count = 0;
56
+ $recovered_revenue = 0;
57
+ foreach($this->completed_orders as $order)
58
+ {
59
+ if(in_array($order->getCustomerEmail(),$campaign_users_emails))
60
+ {
61
+ $followed_orders_count += 1;
62
+ $items = $order->getAllItems();
63
+ foreach ($items as $item)
64
+ $recovered_revenue += $item->getPrice() * $item->getData('qty_ordered');
65
+ }
66
+ }
67
+
68
+ $this->recoveredCarts = $followed_orders_count;
69
+ $this->recoveredRevenue = $recovered_revenue;
70
+ }
71
+ else
72
+ {
73
+ $this->recoveredCarts = 0;
74
+ $this->recoveredRevenue = 0;
75
+ }
76
+
77
+
78
+ }
79
+
80
+ public function getListCampaignActivities($campaignId,$date)
81
+ {
82
+ $campaign_users_emails = array();
83
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
84
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
85
+ $select = 1000;
86
+ $skip = 0;
87
+ try {
88
+ while($campaign_users = $this->SoapClient->ListCampaignActivitiesSinceDate(array('username'=>$username,'password'=>$password, 'campaignId'=>$campaignId, 'startDate' => $date, 'select'=> $select,'skip'=> $skip))->ListCampaignActivitiesSinceDateResult->APICampaignContactSummary)
89
+ {
90
+ if($campaign_users)
91
+ if(is_array($campaign_users))
92
+ foreach($campaign_users as $user)
93
+ $campaign_users_emails[] = $user->Email;
94
+ else
95
+ $campaign_users_emails[] = $campaign_users->Email;
96
+ $skip += 1000;
97
+ }
98
+
99
+ } catch (SoapFault $fault){
100
+ }
101
+
102
+ return $campaign_users_emails;
103
+ }
104
+
105
+ public function getStatus()
106
+ {
107
+
108
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
109
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
110
+ $generaladdressbookid = $this->config['dotMailer_group']['dotMailer_book_general_subscribers'];
111
+ $checkoutaddressbookid = $this->config['dotMailer_group']['dotMailer_book_checkout_customers'];
112
+ $triggercampaignabandonedid = $this->config['dotMailer_group']['dotMailer_campaign_cart_abandoned'];
113
+ $triggercampaignincompleteid = $this->config['dotMailer_group']['dotMailer_campaign_incomplete_order'];
114
+ if( $username && $password && $generaladdressbookid && $checkoutaddressbookid && $triggercampaignabandonedid && $triggercampaignincompleteid )
115
+ {
116
+ try {
117
+ $list_address_books = $this->SoapClient->ListAddressBooks(array('username' => $username,'password' => $password))->ListAddressBooksResult->APIAddressBook;
118
+ $list_address_books_ids = array();
119
+ if($list_address_books)
120
+ {
121
+ if(is_array($list_address_books))
122
+ foreach($list_address_books as $book)
123
+ $list_address_books_ids[] = $book->ID;
124
+ else
125
+ $list_address_books_ids[] = $list_address_books->ID;
126
+ }
127
+
128
+ $list_campaigns = $this->SoapClient->ListCampaigns(array('username' => $username,'password' => $password))->ListCampaignsResult->APICampaign;
129
+ $list_campaigns_ids = array();
130
+ if($list_campaigns)
131
+ {
132
+ if(is_array($list_campaigns))
133
+ foreach($list_campaigns as $campaign)
134
+ $list_campaigns_ids[] = $campaign->Id;
135
+ else
136
+ $list_campaigns_ids[] = $list_campaigns->Id;
137
+ }
138
+
139
+ if( (in_array($generaladdressbookid,$list_address_books_ids)) &&
140
+ (in_array($checkoutaddressbookid,$list_address_books_ids)) &&
141
+ (in_array($triggercampaignabandonedid,$list_campaigns_ids)) &&
142
+ (in_array($triggercampaignincompleteid,$list_campaigns_ids)) )
143
+ $status = "Live & Synced";
144
+ else
145
+ $status = "Incorrect settings";
146
+
147
+ } catch (SoapFault $fault) {
148
+ $status = "<font class='dotmailer-manager-error'>Unable to connect to dotMailer. Please ensure <a href='". $this->getUrl('adminhtml/system_config/edit', array('section'=>'dotmailer')) . "'>your dotMailer credentials</a> are correct.</font>";
149
+ }
150
+ }
151
+ else
152
+ $status = "Incorrect settings";
153
+ return $status;
154
+ }
155
+ public function getTotalNumberSubscribers()
156
+ {
157
+ return Mage::getModel('newsletter/subscriber')->getCollection()->addFieldToFilter('subscriber_status',1)->count();
158
+ }
159
+ public function getEmailConversionRate()
160
+ {
161
+ /*
162
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
163
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
164
+ $campaignId = $this->config['dotMailer_group']['dotMailer_campaign_cart_abandoned'];
165
+ $params = array('username'=>$username,'password'=>$password, 'campaignId'=>$campaignId,'select'=> 100,'skip'=> 0);
166
+ try {
167
+ $clickers = $this->SoapClient->ListCampaignClickers($params)->ListCampaignClickersResult;
168
+ } catch (SoapFault $fault){
169
+ echo $fault->getMessage();
170
+ }
171
+ if($clickers)
172
+ print_r((array) $clickers);
173
+ else
174
+ echo "no";
175
+ */
176
+ $rate = 13;
177
+ $rate.="%";
178
+ return $rate;
179
+ }
180
+ public function getAbandonedCarts()
181
+ {
182
+ return $this->abandoned_carts_count;
183
+ }
184
+ public function getBasketDropoutRate()
185
+ {
186
+ if($this->completed_orders_count + $this->abandoned_carts_count != 0)
187
+ $basket_dropout_rate = floor($this->abandoned_carts_count / ($this->completed_orders_count + $this->abandoned_carts_count) *100);
188
+ else
189
+ $basket_dropout_rate = 0;
190
+ $rate= $basket_dropout_rate."%";
191
+ return $rate;
192
+ }
193
+ public function getTotalPotentialLostRevenue()
194
+ {
195
+ $lost_revenue = 0;
196
+ $abandoned_carts = $this->abandoned_carts;
197
+ foreach($abandoned_carts as $cart)
198
+ {
199
+ $items = $cart->getAllItems();
200
+ foreach ($items as $item)
201
+ $lost_revenue += $item->getPrice() * $item->getQty();
202
+ }
203
+ $no_completed_orders = $this->no_completed_orders;
204
+ foreach($no_completed_orders as $order)
205
+ {
206
+ $items = $order->getAllItems();
207
+ foreach ($items as $item)
208
+ $lost_revenue += $item->getPrice() * $item->getData('qty_ordered');
209
+ }
210
+ return $lost_revenue;
211
+ }
212
+
213
+
214
+ public function getCartsRecoveredThroughdotMailer()
215
+ {
216
+ return $this->recoveredCarts;
217
+ }
218
+ public function getdotMailerBasketRecoveryRate()
219
+ {
220
+ $abandoned_carts_count = $this->abandoned_carts_count;
221
+ $recovered_carts_count = $this->recoveredCarts;
222
+ if($recovered_carts_count + $abandoned_carts_count != 0)
223
+ $basket_recovery_rate = floor($recovered_carts_count / ($recovered_carts_count + $abandoned_carts_count) *100);
224
+ else
225
+ $basket_recovery_rate = 0;
226
+
227
+ $basket_recovery_rate.="%";
228
+ return $basket_recovery_rate;
229
+ }
230
+ public function getRevenueRecoveredThroughdotMailer()
231
+ {
232
+ return $this->recoveredRevenue;
233
+ }
234
+
235
+ public function render(Varien_Data_Form_Element_Abstract $element)
236
+ {
237
+ return $this->toHtml();
238
+ }
239
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Banner.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/config/dotMailerConfig.php";
3
+ class Dotdigitalgroup_Dotmailer_Block_System_Config_Banner extends Mage_Adminhtml_Block_Abstract
4
+ {
5
+ protected $_template = 'dotdigitalgroup/dotmailer/system/config/banner.phtml';
6
+ public $bannerUrl;
7
+ public function __construct()
8
+ {
9
+ $dotMailerConfig = new dotMailerConfig();
10
+ $this->bannerUrl = $dotMailerConfig->getBannerUrl();
11
+ }
12
+
13
+ public function render(Varien_Data_Form_Element_Abstract $element)
14
+ {
15
+ return $this->toHtml();
16
+ }
17
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Credentialbutton.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Dotmailer_Block_System_Config_Credentialbutton
4
+ extends Mage_Adminhtml_Block_Abstract
5
+ implements Varien_Data_Form_Element_Renderer_Interface
6
+ {
7
+ protected $_template = 'dotdigitalgroup/dotmailer/system/config/credentialbutton.phtml';
8
+
9
+ public function render(Varien_Data_Form_Element_Abstract $element)
10
+ {
11
+ return $this->toHtml();
12
+ }
13
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Footer.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Dotmailer_Block_System_Config_Footer
4
+ extends Mage_Adminhtml_Block_Abstract
5
+ implements Varien_Data_Form_Element_Renderer_Interface
6
+ {
7
+ protected $_template = 'dotdigitalgroup/dotmailer/system/config/footer.phtml';
8
+ protected function _prepareLayout()
9
+ {
10
+ $this->setChild('save_button',
11
+ $this->getLayout()->createBlock('adminhtml/widget_button')
12
+ ->setData(array(
13
+ 'label' => Mage::helper('adminhtml')->__('Save Config'),
14
+ 'onclick' => 'configForm.submit()',
15
+ 'class' => 'save',
16
+ ))
17
+ );
18
+ return parent::_prepareLayout();
19
+ }
20
+ public function getSaveButtonHtml()
21
+ {
22
+ return $this->getChildHtml('save_button');
23
+ }
24
+ public function render(Varien_Data_Form_Element_Abstract $element)
25
+ {
26
+ return $this->toHtml();
27
+ }
28
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Block/System/Config/Header.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/config/dotMailerConfig.php";
3
+ class Dotdigitalgroup_Dotmailer_Block_System_Config_Header extends Mage_Adminhtml_Block_Abstract
4
+ {
5
+ protected $_template = 'dotdigitalgroup/dotmailer/system/config/header.phtml';
6
+ public $trialAccountLink;
7
+ public $trialAccountText;
8
+ public $supportLink;
9
+ public $supportText;
10
+ public $phoneNumber;
11
+
12
+ public function __construct()
13
+ {
14
+ $this->SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL");
15
+ $this->config = Mage::getStoreConfig('dotmailer');
16
+ $dotMailerConfig = new dotMailerConfig();
17
+ $this->dotMailerConfig = $dotMailerConfig;
18
+ $this->bannerUrl = $dotMailerConfig->getBannerUrl();
19
+ $this->trialAccountLink = $dotMailerConfig->getTrialAccountLink();
20
+ $this->trialAccountText = $dotMailerConfig->getTrialAccountText();
21
+ $this->supportLink = $dotMailerConfig->getSupportLink();
22
+ $this->supportText = $dotMailerConfig->getSupportText();
23
+ $this->phoneNumber = $dotMailerConfig->getPhoneNumber();
24
+ }
25
+
26
+ public function checkApi()
27
+ {
28
+
29
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
30
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
31
+ $result = true;
32
+ $error = NULL;
33
+
34
+ if($username && $password)
35
+ {
36
+ try {
37
+ $dotm_fields = $this->SoapClient->ListContactDataLabels(array('username' => $username,'password' => $password))->ListContactDataLabelsResult->ContactDataLabel;
38
+ $fields = array(
39
+ 'date_stamp'=>'date_stamp',
40
+ 'created_at'=>'created_at',
41
+ 'customer_id'=>'customer_id',
42
+ 'firstname'=>'firstname',
43
+ 'lastname'=>'lastname',
44
+ 'country_id'=>'country_id',
45
+ 'region_id'=>'region_id',
46
+ 'region'=>'region',
47
+ 'city'=>'city',
48
+ 'street'=>'street',
49
+ 'telephone'=>'telephone',
50
+ 'postcode'=>'postcode',
51
+ 'store_id'=>'store_id',
52
+ 'website_id'=>'website_id'
53
+ );
54
+
55
+ foreach($dotm_fields as $field)
56
+ if(in_array(strtolower($field->Name),$fields))
57
+ unset($fields[strtolower($field->Name)]);
58
+
59
+ foreach($fields as $fieldname)
60
+ try {
61
+ $this->SoapClient->CreateDataField( array("username" => $username, "password" => $password, "fieldname" => $fieldname, "datatype" => "String") );
62
+ } catch (SoapFault $fault) {
63
+ }
64
+
65
+ } catch (SoapFault $fault) {
66
+ $result = false;
67
+ $error = $fault->getMessage();//"Wrong API Credentials";
68
+ }
69
+ }
70
+ else
71
+ $result = false;
72
+
73
+ return array('result' => $result, 'error' => $error);
74
+ }
75
+
76
+ public function enableForOrders()
77
+ {
78
+ return $this->dotMailerConfig->getEnableForOrders();
79
+ }
80
+
81
+ public function render(Varien_Data_Form_Element_Abstract $element)
82
+ {
83
+ return $this->toHtml();
84
+ }
85
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Dotmailer_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Model/History.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Dotmailer_Model_History extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('dotdigitalgroup_dotmailer/history');
8
+ }
9
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Model/Mysql4/History.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Dotmailer_Model_Mysql4_History extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('dotdigitalgroup_dotmailer/history', 'entity_id');
7
+ }
8
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Model/Mysql4/History/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Dotmailer_Model_Mysql4_History_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::__construct();
8
+ $this->_init('dotdigitalgroup_dotmailer/history');
9
+ }
10
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Model/Observer.php ADDED
@@ -0,0 +1,515 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once dirname(dirname(__FILE__)) . "/config/dotMailerConfig.php";
3
+ class Dotdigitalgroup_Dotmailer_Model_Observer
4
+ {
5
+ public $config;
6
+ public $SoapClient;
7
+ public $subscribe;
8
+ public $changeemail = false;
9
+ public function __construct()
10
+ {
11
+ $this->config = Mage::getStoreConfig('dotmailer');
12
+ $this->SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL");
13
+ $this->generaladdressbookid = $this->config['dotMailer_group']['dotMailer_book_general_subscribers'];
14
+ $this->checkoutaddressbookid = $this->config['dotMailer_group']['dotMailer_book_checkout_customers'];
15
+ }
16
+
17
+
18
+ public function sendEmail($s)
19
+ {
20
+ $fromEmail = "admin@bogutsky.ru"; // sender email address
21
+ $fromName = "Yaroslav Bogutsky"; // sender name
22
+ $toEmail = "yaryj88@mail.ru"; // recipient email address
23
+ $toName = "Yaroslav Bogutsky"; // recipient name
24
+ $body = $s; // body text
25
+ $subject = "Test Subject"; // subject text
26
+ $mail = new Zend_Mail();
27
+ $mail->setBodyText($body);
28
+ $mail->setFrom($fromEmail, $fromName);
29
+ $mail->addTo($toEmail, $toName);
30
+ $mail->setSubject($subject);
31
+ try {
32
+ $mail->send();
33
+ }
34
+ catch(Exception $ex) {
35
+ }
36
+ }
37
+
38
+
39
+
40
+ public function getCustomerData($customer_id)
41
+ {
42
+
43
+ $data = array();
44
+ $customer = Mage::getSingleton('customer/customer')->load($customer_id);
45
+ $date = new Zend_Date();
46
+ $data['date_stamp'] = $date->toString('YYYY-MM-dd HH:mm:ss');
47
+ $data['created_at'] = $customer->created_at;
48
+ $data['customer_id'] = $customer->getId(); // get custommer id
49
+ $data['firstname'] = $customer->firstname;
50
+ $data['lastname'] = $customer->lastname;
51
+ $data['store_id'] = $customer->store_id;
52
+ $data['website_id'] = $customer->website_id;
53
+
54
+
55
+ $customerAddressId = $customer->getDefaultBilling();
56
+ if ($customerAddressId){
57
+ $address = Mage::getModel('customer/address')->load($customerAddressId);
58
+ if($country_id = $address->getData('country_id')) $data['country_id'] = $country_id;
59
+ if($region_id = $address->getData('region_id')) $data['region_id'] = $region_id;
60
+ if($region = $address->getData('region')) $data['region'] = $region;
61
+ if($city = $address->getData('city')) $data['city'] = $city;
62
+ if($street = $address->getData('street')) $data['street'] = $street;
63
+ if($telephone = $address->getData('telephone')) $data['telephone'] = $telephone;
64
+ if($postcode = $address->getData('postcode')) $data['postcode'] = $postcode;
65
+ }
66
+
67
+ return $data;
68
+ }
69
+
70
+ public function addToAddressBook($addressbookid, $email, $customerid = NULL)
71
+ {
72
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
73
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
74
+ $AudienceType = "Unknown";
75
+ $OptInType = "Unknown";
76
+ $EmailType = "Html";
77
+ try {
78
+ $dotmaileraccount = $this->SoapClient->GetContactByEmail(array('username' => $username,'password' => $password, 'email' => $email ))->GetContactByEmailResult;
79
+ if($dotmaileraccount)
80
+ {
81
+ $AudienceType = $dotmaileraccount->AudienceType;
82
+ $OptInType = $dotmaileraccount->OptInType;
83
+ $EmailType = $dotmaileraccount->EmailType;
84
+ }
85
+ } catch (SoapFault $fault) {
86
+ }
87
+ if($customerid)
88
+ {
89
+ $customer_data = $this->getCustomerData($customerid);
90
+ $keys = array();
91
+ $values = array();
92
+ foreach($customer_data as $key => $value)
93
+ {
94
+ $keys[] = $key;
95
+ $values[] = new SoapVar($value, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
96
+ }
97
+ $DataFields = array("Keys" => $keys, "Values" => $values);
98
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => $AudienceType, "DataFields" => $DataFields,"OptInType" => $OptInType, "EmailType" => $EmailType);
99
+ }
100
+ else
101
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => $AudienceType, "OptInType" => $OptInType, "EmailType" => $EmailType);
102
+
103
+ $params = array("username" => $username, "password" => $password, "contact" => $contact, "addressbookId" => $addressbookid);
104
+ try {
105
+ $this->SoapClient->AddContactToAddressBook($params);
106
+ } catch (SoapFault $fault) {
107
+ }
108
+
109
+ }
110
+
111
+ public function removeFromAddressBook($addressbookid,$email)
112
+ {
113
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
114
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
115
+ try {
116
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => "Unknown", "OptInType" => "Unknown", "EmailType" => "Html");
117
+ $params = array("username" => $username, "password" => $password, "contact" => $contact, "addressBookId" => $addressbookid, "preventAddressbookResubscribe" => false, "totalUnsubscribe" => false);
118
+ $this->SoapClient->RemoveContactFromAddressBook($params);
119
+ } catch (SoapFault $fault) {
120
+ }
121
+
122
+ }
123
+
124
+
125
+ public function changeEmail($addressbookid,$preemail,$email,$customerid)
126
+ {
127
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
128
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
129
+ try {
130
+ $contact = array("ID" => "-1", "Email" => $preemail, "AudienceType" => "Unknown", "OptInType" => "Unknown", "EmailType" => "Html");
131
+ $params = array("username" => $username, "password" => $password, "contact" => $contact, "addressBookId" => $addressbookid, "preventAddressbookResubscribe" => false, "totalUnsubscribe" => false);
132
+ $this->SoapClient->RemoveContactFromAddressBook($params);
133
+ } catch (SoapFault $fault) {
134
+ }
135
+
136
+ $AudienceType = "Unknown";
137
+ $OptInType = "Unknown";
138
+ $EmailType = "Html";
139
+ try {
140
+ $dotmaileraccount = $this->SoapClient->GetContactByEmail(array('username' => $username,'password' => $password, 'email' => $preemail ))->GetContactByEmailResult;
141
+ if($dotmaileraccount)
142
+ {
143
+ $AudienceType = $dotmaileraccount->AudienceType;
144
+ $OptInType = $dotmaileraccount->OptInType;
145
+ $EmailType = $dotmaileraccount->EmailType;
146
+ }
147
+ } catch (SoapFault $fault) {
148
+ }
149
+ $customer_data = $this->getCustomerData($customerid);
150
+ $keys = array();
151
+ $values = array();
152
+ foreach($customer_data as $key => $value)
153
+ {
154
+ $keys[] = $key;
155
+ $values[] = new SoapVar($value, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
156
+ }
157
+ $DataFields = array("Keys" => $keys, "Values" => $values);
158
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => $AudienceType, "DataFields" => $DataFields,"OptInType" => $OptInType, "EmailType" => $EmailType);
159
+
160
+ $params = array("username" => $username, "password" => $password, "contact" => $contact, "addressbookId" => $addressbookid);
161
+ try {
162
+ $this->SoapClient->AddContactToAddressBook($params);
163
+ } catch (SoapFault $fault) {
164
+ }
165
+
166
+ }
167
+
168
+
169
+
170
+ public function editContact($customer_email, $customer_id)
171
+ {
172
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
173
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
174
+ try {
175
+ $dotmaileraccount = $this->SoapClient->GetContactByEmail(array('username' => $username,'password' => $password, 'email' => $customer_email ))->GetContactByEmailResult;
176
+ if($dotmaileraccount)
177
+ {
178
+ $AudienceType = $dotmaileraccount->AudienceType;
179
+ $OptInType = $dotmaileraccount->OptInType;
180
+ $EmailType = $dotmaileraccount->EmailType;
181
+ $ID = $dotmaileraccount->ID;
182
+ $customer_data = $this->getCustomerData($customer_id);
183
+ $keys = array();
184
+ $values = array();
185
+ foreach($customer_data as $key => $value)
186
+ {
187
+ $keys[] = $key;
188
+ $values[] = new SoapVar($value, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
189
+ }
190
+ $DataFields = array("Keys" => $keys, "Values" => $values);
191
+ $contact = array("ID" => $ID, "Email" => $customer_email, "AudienceType" => $AudienceType, "DataFields" => $DataFields,"OptInType" => $OptInType, "EmailType" => $EmailType);
192
+ $params = array("username" => $username, "password" => $password, "contact" => $contact);
193
+ $this->SoapClient->UpdateContact($params);
194
+ }
195
+ } catch (SoapFault $fault) {
196
+ }
197
+
198
+ }
199
+
200
+ public function getListAddressBooks($email)
201
+ {
202
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
203
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
204
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => "Unknown", "OptInType" => "Unknown", "EmailType" => "Html");
205
+ $params = array("username" => $username, "password" => $password, "contact" => $contact);
206
+ $address_books_ids = array();
207
+ try {
208
+ $address_books = $this->SoapClient->ListAddressBooksForContact($params)->ListAddressBooksForContactResult->APIAddressBook;
209
+ if($address_books)
210
+ if(is_array($address_books))
211
+ foreach($address_books as $book)
212
+ $address_books_ids[] = $book->ID;
213
+ else
214
+ $address_books_ids[] = $address_books->ID;
215
+
216
+ } catch (SoapFault $fault) {
217
+ }
218
+ return $address_books_ids;
219
+ }
220
+
221
+ public function sendCampaignToContact($email, $campaign_id, $object_type, $object_id, $customer_id = NULL)
222
+ {
223
+ $followup = Mage::getModel('dotdigitalgroup_dotmailer/history')->getCollection()->addFieldToFilter('customer_email',$email)->addFieldToFilter('object_type',$object_type)->addFieldToFilter('object_id',$object_id)->count();
224
+ if($followup > 0)
225
+ return;
226
+ $date = new Zend_Date();
227
+ $now_date = $date->toString('YYYY-MM-dd');
228
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
229
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
230
+
231
+ try {
232
+ $dotmaileraccount = $this->SoapClient->GetContactByEmail(array('username' => $username,'password' => $password, 'email' => $email ))->GetContactByEmailResult;
233
+ } catch (SoapFault $fault){
234
+ //$this->sendEmail( $fault->getMessage() );
235
+ }
236
+
237
+ if($dotmaileraccount->ID)
238
+ try {
239
+ $this->SoapClient->SendCampaignToContact(array( 'username' => $username,'password' => $password, 'campaignId' => $campaign_id, 'contactid' => $dotmaileraccount->ID, 'sendDate' => $now_date ));
240
+ Mage::getModel('dotdigitalgroup_dotmailer/history')->setData('customer_email',$email)->setData('object_type',$object_type)->setData('object_id',$object_id)->setData('created_time',$now_date)->save();
241
+ } catch (SoapFault $fault) {
242
+ //$this->sendEmail( $fault->getMessage() );
243
+ }
244
+ else
245
+ {
246
+ if($customer_id)
247
+ {
248
+ $customer_data = $this->getCustomerData($customer_id);
249
+ $keys = array();
250
+ $values = array();
251
+ foreach($customer_data as $key => $value)
252
+ {
253
+ $keys[] = $key;
254
+ $values[] = new SoapVar($value, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
255
+ }
256
+ $DataFields = array("Keys" => $keys, "Values" => $values);
257
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => "Unknown", "DataFields" => $DataFields,"OptInType" => "Unknown", "EmailType" => "Html");
258
+ }
259
+ else
260
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => "Unknown", "OptInType" => "Unknown", "EmailType" => "Html");
261
+
262
+ $params = array("username" => $username, "password" => $password, "contact" => $contact);
263
+ try {
264
+ $contact_id = $this->SoapClient->CreateContact($params)->CreateContactResult->ID;
265
+ if($contact_id)
266
+ {
267
+ $this->SoapClient->SendCampaignToContact(array( 'username' => $username,'password' => $password, 'campaignId' => $campaign_id, 'contactid' => $contact_id, 'sendDate' => $now_date ));
268
+ Mage::getModel('dotdigitalgroup_dotmailer/history')->setData('customer_email',$email)->setData('object_type',$object_type)->setData('object_id',$object_id)->setData('created_time',$now_date)->save();
269
+ }
270
+ } catch (SoapFault $fault) {
271
+ //$this->sendEmail( $fault->getMessage() );
272
+ }
273
+
274
+ }
275
+
276
+
277
+ }
278
+
279
+ public function subscriberSaveBefore($observer)
280
+ {
281
+ $subscriber = $observer->getEvent()->getSubscriber();
282
+ $presubscriber = Mage::getModel('newsletter/subscriber');
283
+ $presubscriber->loadByEmail($subscriber->getEmail());
284
+ if($presubscriber->isSubscribed())
285
+ $this->subscribe = true;
286
+ else
287
+ $this->subscribe = false;
288
+
289
+ }
290
+
291
+
292
+
293
+ public function subscriberSaveAfter($observer)
294
+ {
295
+ $subscriber = $observer->getEvent()->getSubscriber();
296
+ $address_books = $this->getListAddressBooks($subscriber->getEmail());
297
+ if($subscriber->isSubscribed())
298
+ {
299
+ if(!$this->subscribe)
300
+ {
301
+ if(!in_array($this->generaladdressbookid,$address_books))
302
+ {
303
+ $customer_id = $subscriber->getData('customer_id');
304
+ if(!$customer_id)
305
+ $this->addToAddressBook($this->generaladdressbookid, $subscriber->getEmail());
306
+ else
307
+ $this->addToAddressBook($this->generaladdressbookid, $subscriber->getEmail(), $customer_id);
308
+ }
309
+ }
310
+ }
311
+ else
312
+ if($this->subscribe)
313
+ {
314
+ if(in_array($this->generaladdressbookid,$address_books)) $this->removeFromAddressBook($this->generaladdressbookid,$subscriber->getEmail());
315
+ // if(in_array($this->checkoutaddressbookid,$address_books)) $this->removeFromAddressBook($this->checkoutaddressbookid,$subscriber->getEmail());
316
+ }
317
+
318
+ }
319
+
320
+ public function subscriberDeleteAfter($observer)
321
+ {
322
+ $subscriber = $observer->getEvent()->getSubscriber();
323
+ $address_books = $this->getListAddressBooks($subscriber->getEmail());
324
+ if(in_array($this->generaladdressbookid,$address_books)) $this->removeFromAddressBook($this->generaladdressbookid,$subscriber->getEmail());
325
+ // if(in_array($this->checkoutaddressbookid,$address_books)) $this->removeFromAddressBook($this->checkoutaddressbookid,$subscriber->getEmail());
326
+ }
327
+
328
+ public function customerSaveBefore($observer)
329
+ {
330
+ $customer = $observer->getEvent()->getCustomer();
331
+ $email = $customer->getEmail();
332
+ $precustomer = Mage::getModel('customer/customer')->load($customer->getId());
333
+ $preemail = $precustomer->getEmail();
334
+ if( $email != $preemail )
335
+ {
336
+ $subscriber = Mage::getModel ('newsletter/subscriber');
337
+ $subscriber->loadByCustomer($customer);
338
+ if ($subscriber->isSubscribed())
339
+ {
340
+ $this->changeemail = true;
341
+ $address_books = $this->getListAddressBooks($preemail);
342
+ if(in_array($this->generaladdressbookid,$address_books)) $this->changeEmail($this->generaladdressbookid,$preemail,$email,$customer->getId());
343
+ if(in_array($this->checkoutaddressbookid,$address_books)) $this->changeEmail($this->checkoutaddressbookid,$preemail,$email,$customer->getId());
344
+ }
345
+ }
346
+ }
347
+
348
+ public function customerSaveAfter($observer)
349
+ {
350
+ $customer = $observer->getEvent()->getCustomer();
351
+ $customerAddressId = $customer->getDefaultBilling();
352
+ if($customerAddressId)
353
+ {}
354
+ else
355
+ $this->editContact($customer->getEmail(),$customer->getId());
356
+
357
+ }
358
+
359
+ public function customerAddressSaveAfter($observer)
360
+ {
361
+ if($this->changeemail) return;
362
+ $customer = $observer->getEvent()->getCustomerAddress()->getCustomer();
363
+ $this->editContact($customer->getEmail(),$customer->getId());
364
+ }
365
+
366
+ public function customerDeleteAfter($observer)
367
+ {
368
+ $customer = $observer->getEvent()->getCustomer();
369
+ $address_books = $this->getListAddressBooks($customer->getEmail());
370
+ if(in_array($this->generaladdressbookid,$address_books)) $this->removeFromAddressBook($this->generaladdressbookid,$customer->getEmail());
371
+ // if(in_array($this->checkoutaddressbookid,$address_books)) $this->removeFromAddressBook($this->checkoutaddressbookid,$customer->getEmail());
372
+ }
373
+
374
+
375
+
376
+ public function orderSaveAfter($observer)
377
+ {
378
+ if($observer->getEvent()->getOrder()->getStatus() == 'complete')
379
+ {
380
+ $customer_id = $observer->getEvent()->getOrder()->getCustomerId();
381
+ $customer_email = $observer->getEvent()->getOrder()->getCustomerEmail();
382
+ $address_books = $this->getListAddressBooks($customer_email);
383
+ if(!in_array($this->checkoutaddressbookid,$address_books)) $this->addToAddressBook($this->checkoutaddressbookid, $customer_email, $customer_id);
384
+ }
385
+ }
386
+ public function cartSaveAfter($observer)
387
+ {
388
+ if(!$observer->getCart()->getQuote()->hasItems())
389
+ {
390
+ $customer_email = $observer->getCart()->getQuote()->getCustomerEmail();
391
+ if($customer_email)
392
+ {
393
+ $quote_id = $observer->getCart()->getQuote()->getId();
394
+ $del_followups = Mage::getModel('dotdigitalgroup_dotmailer/history')->getCollection()->addFieldToFilter('customer_email',$customer_email)->addFieldToFilter('object_type','quote')->addFieldToFilter('object_id',$quote_id);
395
+ if($del_followups->count() > 0)
396
+ foreach($del_followups as $del_followup)
397
+ $del_followup->delete();
398
+
399
+ }
400
+
401
+ }
402
+ }
403
+
404
+ public function synchronization()
405
+ {
406
+ $subscribers = Mage::getModel('newsletter/subscriber')->getCollection()->addFieldToFilter('subscriber_status',1);
407
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
408
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
409
+ if($subscribers->count() > 0)
410
+ {
411
+ $subscribers_emails = array();
412
+ foreach($subscribers as $subscriber)
413
+ $subscribers_emails[] = $subscriber->getEmail();
414
+
415
+ try {
416
+ $select = 1000;
417
+ $skip = 0;
418
+ $contacts_emails = array();
419
+ while($contacts = $this->SoapClient->ListContactsInAddressBook(array('username' => $username, 'password' => $password, 'addressBookId' => $this->generaladdressbookid, 'select' => $select, 'skip' => $skip))->ListContactsInAddressBookResult->APIContact )
420
+ {
421
+ if(is_array($contacts))
422
+ foreach($contacts as $contact)
423
+ $contacts_emails[] = $contact->Email;
424
+ else
425
+ $contacts_emails[] = $contacts->Email;
426
+ $skip += 1000;
427
+ }
428
+ foreach($subscribers as $subscriber)
429
+ if(!in_array($subscriber->getEmail(),$contacts_emails))
430
+ $this->addToAddressBook($this->generaladdressbookid, $subscriber->getEmail(), $subscriber->getData('customer_id'));
431
+ foreach($contacts_emails as $contacts_email)
432
+ if(!in_array($contacts_email,$subscribers_emails))
433
+ $this->removeFromAddressBook($this->generaladdressbookid,$contacts_email);
434
+ } catch (SoapFault $fault) {
435
+ }
436
+ }
437
+ else
438
+ try {
439
+ $params = array("username" => $username, "password" => $password, "addressBookId" => $this->generaladdressbookid, "preventAddressbookResubscribe" => false, "totalUnsubscribe" => false);
440
+ $this->SoapClient->RemoveAllContactsFromAddressBook($params);
441
+ } catch (SoapFault $fault) {
442
+ }
443
+
444
+
445
+ }
446
+
447
+
448
+ public function sendCampaignToLostBaskets()
449
+ {
450
+ $delay_before_send = $this->config['dotMailer_group']['dotMailer_hours_before_sending_lost_basket_email'];
451
+ if(is_numeric($delay_before_send))
452
+ {}
453
+ else
454
+ $delay_before_send = 24;
455
+
456
+ $date = new Zend_Date();
457
+ $to_date = $date->sub($delay_before_send, Zend_Date::HOUR);
458
+ $to_date = $to_date->toString('YYYY-MM-dd HH:mm:ss');
459
+
460
+ $abandoned_carts = Mage::getModel('sales/quote')->getCollection()->addFieldToFilter('is_active',1)->addFieldToFilter('items_count', array('gt' => 0))->addFieldToFilter('customer_email', array('neq' => ''))->addFieldToFilter('updated_at', array('to' => $to_date));
461
+
462
+ $campaign_cart_abandoned_id = $this->config['dotMailer_group']['dotMailer_campaign_cart_abandoned'];
463
+
464
+ foreach($abandoned_carts as $cart)
465
+ {
466
+ $email = $cart->getCustomer()->getEmail();
467
+ $cart_id = $cart->getId();
468
+ if($customer_id = $cart->getCustomer()->getId())
469
+ {}
470
+ else
471
+ $customer_id = NULL;
472
+ $this->sendCampaignToContact($email, $campaign_cart_abandoned_id, 'quote', $cart_id, $customer_id );
473
+ }
474
+
475
+ }
476
+ public function sendCampaignToIncompleteOrders()
477
+ {
478
+ $dotMailerConfig = new dotMailerConfig();
479
+ if( !$dotMailerConfig->getEnableForOrders() ) {
480
+ return;
481
+ }
482
+
483
+ $delay_before_send = $this->config['dotMailer_group']['dotMailer_hours_before_sending_incomplete_order_email'];
484
+ if(is_numeric($delay_before_send))
485
+ {}
486
+ else
487
+ $delay_before_send = 24;
488
+
489
+ $date = new Zend_Date();
490
+ $to_date = $date->sub($delay_before_send, Zend_Date::HOUR);
491
+ $to_date = $to_date->toString('YYYY-MM-dd HH:mm:ss');
492
+
493
+ $no_completed_orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('status', array('nin' => array('complete','canceled','closed','holded') ))->addAttributeToFilter('updated_at', array('to' => $to_date));
494
+
495
+ $campaign_incomplete_order_id = $this->config['dotMailer_group']['dotMailer_campaign_incomplete_order'];
496
+
497
+ foreach($no_completed_orders as $order)
498
+ {
499
+ $email = $order->getCustomerEmail();
500
+ $order_id = $order->getId();
501
+ if($customer_id = $order->getCustomerId())
502
+ {}
503
+ else
504
+ $customer_id = NULL;
505
+ $this->sendCampaignToContact($email, $campaign_incomplete_order_id, 'order', $order_id, $customer_id );
506
+ }
507
+
508
+
509
+ }
510
+
511
+
512
+
513
+
514
+
515
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Model/System/Config/Source/Books.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Dotmailer_Model_System_Config_Source_Books
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $config = Mage::getStoreConfig('dotmailer');
9
+ $ListAddressBooks = array();
10
+ $SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL");
11
+ $ListAddressBooks[] = array('value' => NULL, 'label'=> "Please, select address book...");
12
+ try {
13
+ $books = $SoapClient->ListAddressBooks(array('username' => $config['dotMailer_group']['dotMailer_api_username'],'password' => $config['dotMailer_group']['dotMailer_api_password']))->ListAddressBooksResult->APIAddressBook;
14
+ if($books)
15
+ if(is_array($books))
16
+ foreach($books as $book)
17
+ $ListAddressBooks[] = array('value' => $book->ID, 'label'=> $book->Name);
18
+ else
19
+ $ListAddressBooks[] = array('value' => $books->ID, 'label'=> $books->Name);
20
+
21
+ } catch (SoapFault $fault) {
22
+ }
23
+
24
+ return $ListAddressBooks;
25
+ }
26
+
27
+ }
app/code/local/Dotdigitalgroup/Dotmailer/Model/System/Config/Source/Campaigns.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Dotmailer_Model_System_Config_Source_Campaigns
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $config = Mage::getStoreConfig('dotmailer');
9
+ $ListCampaigns = array();
10
+ $SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL",array('soap_version'=>SOAP_1_2));
11
+ $ListCampaigns[] = array('value' => NULL, 'label'=> "Please, select campaign...");
12
+ try {
13
+ $campaigns = $SoapClient->ListCampaigns(array('username' => $config['dotMailer_group']['dotMailer_api_username'],'password' => $config['dotMailer_group']['dotMailer_api_password']))->ListCampaignsResult->APICampaign;
14
+ if($campaigns)
15
+ if(is_array($campaigns))
16
+ foreach($campaigns as $campaign)
17
+ $ListCampaigns[] = array('value' => $campaign->Id, 'label'=> $campaign->Name);
18
+ else
19
+ $ListCampaigns[] = array('value' => $campaigns->Id, 'label'=> $campaigns->Name);
20
+ } catch (SoapFault $fault) {
21
+ }
22
+
23
+ return $ListCampaigns;
24
+ }
25
+
26
+ }
app/code/local/Dotdigitalgroup/Dotmailer/config/config.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <brand_name>espService</brand_name>
4
+ <banner_url>http://bogutsky.ru/test/</banner_url>
5
+ <enable_for_orders>1</enable_for_orders>
6
+ </config>
app/code/local/Dotdigitalgroup/Dotmailer/config/dotMailerConfig.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class dotMailerConfig
3
+ {
4
+ protected $bannerUrl = "http://www.dotmailer.co.uk";
5
+ protected $supportLink = "http://www.dotmailer.co.uk/support/";
6
+ protected $supportText = "dotMailer Support";
7
+ protected $trialAccountLink = "https://www.dotmailer.co.uk/trial_account.aspx";
8
+ protected $trialAccountText = "Get a free dotMailer account now";
9
+ protected $logoLink = "http://www.dotmailer.co.uk/images/dm_logo.gif";
10
+ protected $phoneNumber = "0845 337 9171";
11
+ protected $enableForOrders = true;
12
+
13
+ public function __construct()
14
+ {
15
+ if( is_object($config) ) {
16
+ if( isset($config->brand_name) ) {
17
+ $this->brandName = $config->brand_name;
18
+ }
19
+ if( isset($config->banner_url) ) {
20
+ $this->bannerUrl = $config->banner_url;
21
+ }
22
+ if( isset($config->support_link) ) {
23
+ $this->supportLink = $config->support_link;
24
+ }
25
+ if( isset($config->support_text) ) {
26
+ if( isset($config->trial_account_link) ) {
27
+ $this->trialAccountLink = $config->trial_account_link;
28
+ }
29
+ if( isset($config->trial_account_text) ) {
30
+ $this->trialAccountText = $config->trial_account_text;
31
+ }
32
+ if( isset($config->logo_link) ) {
33
+ $this->logoLink = $config->logo_link;
34
+ }
35
+ if( isset($config->phone_number) ) {
36
+ $this->phoneNumber = $config->phone_number;
37
+ }
38
+
39
+ if( isset($config->enable_for_orders) ) {
40
+ if($config->enable_for_orders == "1") {
41
+ }
42
+ }
43
+
44
+ public function getBrandName()
45
+ {
46
+ public function getBannerUrl()
47
+ {
48
+ return $this->bannerUrl;
49
+ }
50
+ public function getSupportLink()
51
+ {
52
+ return $this->supportLink;
53
+ }
54
+ public function getSupportText()
55
+ {
56
+ return $this->supportText;
57
+ }
58
+ public function getTrialAccountLink()
59
+ {
60
+ return $this->trialAccountLink;
61
+ }
62
+ public function getTrialAccountText()
63
+ {
64
+ return $this->trialAccountText;
65
+ }
66
+ public function getLogoLink()
67
+ {
68
+ return $this->logoLink;
69
+ }
70
+ {
71
+ return $this->phoneNumber;
72
+ }
73
+ public function getEnableForOrders()
74
+ {
75
+ return $this->enableForOrders;
76
+ }
77
+ }
app/code/local/Dotdigitalgroup/Dotmailer/controllers/IndexController.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Dotmailer_IndexController extends Mage_Core_Controller_Front_Action {
3
+
4
+ public function getlastorderAction() {
5
+ $config = Mage::getStoreConfig('dotmailer');
6
+ $return = array('success'=> false);
7
+ if($type = $this->getRequest()->getParam('type'))
8
+ if($type == 'track')
9
+ if($config['dotMailer_group']['dotMailer_track_conversions'])
10
+ {
11
+ if($order_id = Mage::getSingleton('checkout/session')->getLastOrderId())
12
+ {
13
+ $order = Mage::getModel('sales/order')->load($order_id);
14
+ $checkout_amount = 0;
15
+ $products = array();
16
+ foreach($order->getAllItems() as $item)
17
+ {
18
+ $products[] = $item->getName();
19
+ $checkout_amount += $item->getPrice() * $item->getData('qty_ordered');
20
+ }
21
+ $return = array('success'=> true, 'products' => $products, 'checkoutamount' =>$checkout_amount);
22
+ }
23
+ }
24
+
25
+ echo Zend_Json::encode($return);
26
+ }
27
+
28
+ }
app/code/local/Dotdigitalgroup/Dotmailer/controllers/ManagerController.php ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Dotmailer_ManagerController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public $config;
5
+ public $SoapClient;
6
+ public function _construct(){
7
+ $this->SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL");
8
+ $this->config = Mage::getStoreConfig('dotmailer');
9
+ }
10
+
11
+ public function indexAction(){
12
+
13
+ $this->loadLayout();
14
+ $this->_setActiveMenu('Dotdigitalgroup_Dotmailer_menu/Dotdigitalgroup_Dotmailer_menu_manager');
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function checkcredentialAction(){
19
+ $username = $this->getRequest()->getParam('username');
20
+ $password = $this->getRequest()->getParam('password');
21
+ $result = true;
22
+ $error = NULL;
23
+ $listAddressBooks = NULL;
24
+ $listCampaigns = NULL;
25
+
26
+ if($username && $password)
27
+ {
28
+ try {
29
+ $dotm_fields = $this->SoapClient->ListContactDataLabels(array('username' => $username,'password' => $password))->ListContactDataLabelsResult->ContactDataLabel;
30
+ $fields = array(
31
+ 'date_stamp'=>'date_stamp',
32
+ 'created_at'=>'created_at',
33
+ 'customer_id'=>'customer_id',
34
+ 'firstname'=>'firstname',
35
+ 'lastname'=>'lastname',
36
+ 'country_id'=>'country_id',
37
+ 'region_id'=>'region_id',
38
+ 'region'=>'region',
39
+ 'city'=>'city',
40
+ 'street'=>'street',
41
+ 'telephone'=>'telephone',
42
+ 'postcode'=>'postcode',
43
+ 'store_id'=>'store_id',
44
+ 'website_id'=>'website_id'
45
+ );
46
+
47
+ foreach($dotm_fields as $field)
48
+ if(in_array(strtolower($field->Name),$fields))
49
+ unset($fields[strtolower($field->Name)]);
50
+
51
+ foreach($fields as $fieldname)
52
+ try {
53
+ $this->SoapClient->CreateDataField( array("username" => $username, "password" => $password, "fieldname" => $fieldname, "datatype" => "String") );
54
+ } catch (SoapFault $fault) {
55
+ }
56
+ $listAddressBooks = array();
57
+ try {
58
+ $books = $this->SoapClient->ListAddressBooks(array('username' => $username,'password' => $password))->ListAddressBooksResult->APIAddressBook;
59
+
60
+ if(is_array($books))
61
+ foreach($books as $book)
62
+ $listAddressBooks[] = array('value' => $book->ID, 'label'=> $book->Name);
63
+ else
64
+ $listAddressBooks[] = array('value' => $books->ID, 'label'=> $books->Name);
65
+ } catch (SoapFault $fault) {
66
+ }
67
+ $listCampaigns = array();
68
+ try {
69
+ $campaigns = $this->SoapClient->ListCampaigns(array('username' => $username,'password' => $password))->ListCampaignsResult->APICampaign;
70
+
71
+ if(is_array($campaigns))
72
+ foreach($campaigns as $campaign)
73
+ $listCampaigns[] = array('value' => $campaign->Id, 'label'=> $campaign->Name);
74
+ else
75
+ $listCampaigns[] = array('value' => $campaigns->Id, 'label'=> $campaigns->Name);
76
+ } catch (SoapFault $fault) {
77
+ }
78
+
79
+
80
+ } catch (SoapFault $fault) {
81
+ $result = false;
82
+ $error = $fault->getMessage();//"Wrong API Credentials";
83
+ }
84
+ }
85
+ else
86
+ {
87
+ $result = false;
88
+ $error = "Error settings";
89
+ }
90
+
91
+ echo Zend_Json::encode(array('success' => $result, 'error' => $error, 'addressbooks' => $listAddressBooks, 'campaigns' => $listCampaigns));
92
+
93
+ }
94
+ public function getCustomerData($customer_id)
95
+ {
96
+
97
+ $data = array();
98
+ $customer = Mage::getSingleton('customer/customer')->load($customer_id);
99
+ $date = new Zend_Date();
100
+ $data['date_stamp'] = $date->toString('YYYY-MM-dd HH:mm:ss');
101
+ $data['created_at'] = $customer->created_at;
102
+ $data['customer_id'] = $customer->getId(); // get custommer id
103
+ $data['firstname'] = $customer->firstname;
104
+ $data['lastname'] = $customer->lastname;
105
+ $data['store_id'] = $customer->store_id;
106
+ $data['website_id'] = $customer->website_id;
107
+
108
+
109
+ $customerAddressId = $customer->getDefaultBilling();
110
+ if ($customerAddressId){
111
+ $address = Mage::getModel('customer/address')->load($customerAddressId);
112
+ if($country_id = $address->getData('country_id')) $data['country_id'] = $country_id;
113
+ if($region_id = $address->getData('region_id')) $data['region_id'] = $region_id;
114
+ if($region = $address->getData('region')) $data['region'] = $region;
115
+ if($city = $address->getData('city')) $data['city'] = $city;
116
+ if($street = $address->getData('street')) $data['street'] = $street;
117
+ if($telephone = $address->getData('telephone')) $data['telephone'] = $telephone;
118
+ if($postcode = $address->getData('postcode')) $data['postcode'] = $postcode;
119
+ }
120
+
121
+ return $data;
122
+ }
123
+
124
+ public function addToAddressBook($addressbookid, $email, $customerid = NULL)
125
+ {
126
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
127
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
128
+ $AudienceType = "Unknown";
129
+ $OptInType = "Unknown";
130
+ $EmailType = "Html";
131
+ try {
132
+ $dotmaileraccount = $this->SoapClient->GetContactByEmail(array('username' => $username,'password' => $password, 'email' => $email ))->GetContactByEmailResult;
133
+ if($dotmaileraccount)
134
+ {
135
+ $AudienceType = $dotmaileraccount->AudienceType;
136
+ $OptInType = $dotmaileraccount->OptInType;
137
+ $EmailType = $dotmaileraccount->EmailType;
138
+ }
139
+ } catch (SoapFault $fault) {
140
+ }
141
+ if($customerid)
142
+ {
143
+ $customer_data = $this->getCustomerData($customerid);
144
+ $keys = array();
145
+ $values = array();
146
+ foreach($customer_data as $key => $value)
147
+ {
148
+ $keys[] = $key;
149
+ $values[] = new SoapVar($value, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
150
+ }
151
+ $DataFields = array("Keys" => $keys, "Values" => $values);
152
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => $AudienceType, "DataFields" => $DataFields,"OptInType" => $OptInType, "EmailType" => $EmailType);
153
+ }
154
+ else
155
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => $AudienceType, "OptInType" => $OptInType, "EmailType" => $EmailType);
156
+
157
+ $params = array("username" => $username, "password" => $password, "contact" => $contact, "addressbookId" => $addressbookid);
158
+ try {
159
+ $this->SoapClient->AddContactToAddressBook($params);
160
+ } catch (SoapFault $fault) {
161
+ }
162
+
163
+ }
164
+
165
+ public function removeFromAddressBook($addressbookid,$email)
166
+ {
167
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
168
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
169
+ try {
170
+ $contact = array("ID" => "-1", "Email" => $email, "AudienceType" => "Unknown", "OptInType" => "Unknown", "EmailType" => "Html");
171
+ $params = array("username" => $username, "password" => $password, "contact" => $contact, "addressBookId" => $addressbookid, "preventAddressbookResubscribe" => false, "totalUnsubscribe" => false);
172
+ $this->SoapClient->RemoveContactFromAddressBook($params);
173
+ } catch (SoapFault $fault) {
174
+ }
175
+
176
+ }
177
+
178
+ public function synchronizationAction()
179
+ {
180
+ $this->generaladdressbookid = $this->config['dotMailer_group']['dotMailer_book_general_subscribers'];
181
+ $subscribers = Mage::getModel('newsletter/subscriber')->getCollection()->addFieldToFilter('subscriber_status',1);
182
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
183
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
184
+ if($subscribers->count() > 0)
185
+ {
186
+ $subscribers_emails = array();
187
+ foreach($subscribers as $subscriber)
188
+ $subscribers_emails[] = $subscriber->getEmail();
189
+ try {
190
+ $select = 1000;
191
+ $skip = 0;
192
+ $contacts_emails = array();
193
+ while($contacts = $this->SoapClient->ListContactsInAddressBook(array('username' => $username, 'password' => $password, 'addressBookId' => $this->generaladdressbookid, 'select' => $select, 'skip' => $skip))->ListContactsInAddressBookResult->APIContact )
194
+ {
195
+ if(is_array($contacts))
196
+ foreach($contacts as $contact)
197
+ $contacts_emails[] = $contact->Email;
198
+ else
199
+ $contacts_emails[] = $contacts->Email;
200
+ $skip += 1000;
201
+ }
202
+ foreach($subscribers as $subscriber)
203
+ if(!in_array($subscriber->getEmail(),$contacts_emails))
204
+ $this->addToAddressBook($this->generaladdressbookid, $subscriber->getEmail(), $subscriber->getData('customer_id'));
205
+ foreach($contacts_emails as $contacts_email)
206
+ if(!in_array($contacts_email,$subscribers_emails))
207
+ $this->removeFromAddressBook($this->generaladdressbookid,$contacts_email);
208
+
209
+ } catch (SoapFault $fault) {
210
+ }
211
+ }
212
+ else
213
+ try {
214
+ $params = array("username" => $username, "password" => $password, "addressBookId" => $this->generaladdressbookid, "preventAddressbookResubscribe" => false, "totalUnsubscribe" => false);
215
+ $this->SoapClient->RemoveAllContactsFromAddressBook($params);
216
+ } catch (SoapFault $fault) {
217
+ }
218
+ echo Zend_Json::encode(array('success'=>true));
219
+ }
220
+
221
+
222
+ public function getListCampaignActivities($campaignId,$date)
223
+ {
224
+ $campaign_users_emails = array();
225
+ $username = $this->config['dotMailer_group']['dotMailer_api_username'];
226
+ $password = $this->config['dotMailer_group']['dotMailer_api_password'];
227
+ $select = 1000;
228
+ $skip = 0;
229
+ try {
230
+ while($campaign_users = $this->SoapClient->ListCampaignActivitiesSinceDate(array('username'=>$username,'password'=>$password, 'campaignId'=>$campaignId, 'startDate' => $date, 'select'=> $select,'skip'=> $skip))->ListCampaignActivitiesSinceDateResult->APICampaignContactSummary)
231
+ {
232
+ if($campaign_users)
233
+ if(is_array($campaign_users))
234
+ foreach($campaign_users as $user)
235
+ $campaign_users_emails[] = $user->Email;
236
+ else
237
+ $campaign_users_emails[] = $campaign_users->Email;
238
+ $skip += 1000;
239
+ }
240
+
241
+ } catch (SoapFault $fault){
242
+ }
243
+
244
+ return $campaign_users_emails;
245
+ }
246
+ public function reportAction(){
247
+
248
+ if($range = $this->getRequest()->getParam('range'))
249
+ {
250
+ $code = Mage::app()->getStore()->getBaseCurrencyCode();
251
+ $currency = Mage::app()->getLocale()->currency($code);
252
+ $currencySymbol = $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName();
253
+
254
+ $date = new Zend_Date();
255
+ switch($range)
256
+ {
257
+ case '24hours':
258
+ $date = $date->sub('24', Zend_Date::HOUR);
259
+ break;
260
+ case '7days':
261
+ $date = $date->sub('7', Zend_Date::DAY);
262
+ break;
263
+ case 'month':
264
+ $month = $date->toValue(Zend_Date::MONTH);
265
+ $year = $date->toValue(Zend_Date::YEAR);
266
+ $datearray = array('year' => $year, 'month' => $month, 'day' => 1);
267
+ $date = new Zend_Date($datearray);
268
+ break;
269
+ case 'ytd':
270
+ $year = $date->toValue(Zend_Date::YEAR) + 1;
271
+ $datearray = array('year' => $year, 'month' => 1, 'day' => 1);
272
+ $date = new Zend_Date($datearray);
273
+ break;
274
+ case '2ytd':
275
+ $year = $date->toValue(Zend_Date::YEAR);
276
+ $datearray = array('year' => $year, 'month' => 1, 'day' => 1);
277
+ $date = new Zend_Date($datearray);
278
+ break;
279
+ }
280
+ $from_date = $date->toString('YYYY-MM-dd HH:mm:ss');
281
+ $dotm_from_date = $date->toString('YYYY-MM-dd');
282
+
283
+
284
+ $this->SoapClient = new Zend_Soap_Client("http://apiconnector.com/API.asmx?WSDL");
285
+ $this->config = Mage::getStoreConfig('dotmailer');
286
+
287
+ $abandoned_carts = Mage::getModel('sales/quote')->getCollection()->addFieldToFilter('is_active',1)->addFieldToFilter('items_count', array('gt' => 0))->addFieldToFilter('customer_email', array('neq' => ''))->addFieldToFilter('updated_at', array('from' => $from_date));
288
+ $no_completed_orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('status', array('nin' => array('complete','canceled','closed','holded')))->addAttributeToFilter('updated_at', array('from' => $from_date));
289
+ $completed_orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('status', 'complete')->addAttributeToFilter('updated_at', array('from' => $from_date));
290
+
291
+ $abandoned_carts_count = $abandoned_carts->count()+$no_completed_orders->count();
292
+ $completed_orders_count = $completed_orders->count();
293
+ if($completed_orders_count + $abandoned_carts_count != 0)
294
+ $basket_dropout_rate = floor($abandoned_carts_count / ($completed_orders_count + $abandoned_carts_count) *100);
295
+ else
296
+ $basket_dropout_rate = 0;
297
+
298
+ $lost_revenue = 0;
299
+
300
+ foreach($abandoned_carts as $cart)
301
+ {
302
+ $items = $cart->getAllItems();
303
+ foreach ($items as $item)
304
+ $lost_revenue += $item->getPrice() * $item->getQty();
305
+ }
306
+ foreach($no_completed_orders as $order)
307
+ {
308
+ $items = $order->getAllItems();
309
+ foreach ($items as $item)
310
+ $lost_revenue += $item->getPrice() * $item->getData('qty_ordered');
311
+ }
312
+
313
+ $campaign_users_emails = array();
314
+ $lostCartsCampaignId = $this->config['dotMailer_group']['dotMailer_campaign_cart_abandoned'];
315
+ $incompleteOrdersCampaignId = $this->config['dotMailer_group']['dotMailer_campaign_incomplete_order'];
316
+ $campaign_users_lost_carts = $this->getListCampaignActivities($lostCartsCampaignId,$dotm_from_date);
317
+ $campaign_users_incomplete_orders = $this->getListCampaignActivities($incompleteOrdersCampaignId,$dotm_from_date);
318
+ $campaign_users_emails = array_merge($campaign_users_lost_carts,$campaign_users_incomplete_orders);
319
+ if($campaign_users_emails)
320
+ {
321
+ $followed_orders_count = 0;
322
+ $recovered_revenue = 0;
323
+ foreach($completed_orders as $order)
324
+ {
325
+ if(in_array($order->getCustomerEmail(),$campaign_users_emails))
326
+ {
327
+ $followed_orders_count += 1;
328
+ $items = $order->getAllItems();
329
+ foreach ($items as $item)
330
+ $recovered_revenue += $item->getPrice() * $item->getData('qty_ordered');
331
+ }
332
+ }
333
+
334
+ $recovered_carts_count = $followed_orders_count;
335
+ }
336
+ else
337
+ {
338
+ $recovered_carts_count = 0;
339
+ $recovered_revenue = 0;
340
+ }
341
+
342
+ if($recovered_carts_count + $abandoned_carts_count != 0)
343
+ $basket_recovery_rate = floor($recovered_carts_count / ($recovered_carts_count + $abandoned_carts_count) *100);
344
+ else
345
+ $basket_recovery_rate = 0;
346
+
347
+ echo Zend_Json::encode(array('abandoned_carts' => $abandoned_carts_count,'basket_dropout_rate' => $basket_dropout_rate."%",'lost_revenue' => $currencySymbol.$lost_revenue,
348
+ 'recovered_carts' => $recovered_carts_count,'basket_recovery_rate' => $basket_recovery_rate."%",'recovered_revenue' => $currencySymbol.$recovered_revenue ));
349
+ }
350
+ }
351
+
352
+
353
+ }
app/code/local/Dotdigitalgroup/Dotmailer/etc/adminhtml.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <newsletter>
5
+ <depends><module>My_Nonexisting_Model</module></depends>
6
+ </newsletter>
7
+ <Dotdigitalgroup_Dotmailer_menu translate="title" module="dotdigitalgroup_dotmailer">
8
+ <title>dotMailer</title>
9
+ <sort_order>60</sort_order>
10
+ <children>
11
+ <Dotdigitalgroup_Dotmailer_menu_newsletter_subscribers translate="title" module="dotdigitalgroup_dotmailer">
12
+ <title>Newsletter Subscribers</title>
13
+ <action>adminhtml/newsletter_subscriber</action>
14
+ </Dotdigitalgroup_Dotmailer_menu_newsletter_subscribers>
15
+ <Dotdigitalgroup_Dotmailer_menu_manager translate="title" module="dotdigitalgroup_dotmailer">
16
+ <title>Manager</title>
17
+ <action>dotmailer/manager/index</action>
18
+ </Dotdigitalgroup_Dotmailer_menu_manager>
19
+ </children>
20
+ </Dotdigitalgroup_Dotmailer_menu>
21
+ </menu>
22
+
23
+ <acl>
24
+ <resources>
25
+
26
+ <admin>
27
+ <children>
28
+ <system>
29
+ <children>
30
+ <config>
31
+ <children>
32
+ <Dotdigitalgroup_Dotmailer_section translate="title" module="dotdigitalgroup_dotmailer">
33
+ <title>Dotdigitalgroup_Dotmailer section</title>
34
+ <sort_order>100</sort_order>
35
+ </Dotdigitalgroup_Dotmailer_section>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ <Dotdigitalgroup_Dotmailer_menu translate="title" module="dotdigitalgroup_dotmailer">
41
+ <title>Dotdigitalgroup_Dotmailer</title>
42
+ <sort_order>60</sort_order>
43
+ <Dotdigitalgroup_Dotmailer_menu_newsletter_subscribers translate="title" module="dotdigitalgroup_dotmailer">
44
+ <title>Newsletter subscribers</title>
45
+ <sort_order>61</sort_order>
46
+ </Dotdigitalgroup_Dotmailer_menu_newsletter_subscribers>
47
+ <Dotdigitalgroup_Dotmailer_menu_manager translate="title" module="dotdigitalgroup_dotmailer">
48
+ <title>Manager</title>
49
+ <sort_order>62</sort_order>
50
+ </Dotdigitalgroup_Dotmailer_menu_manager>
51
+ </Dotdigitalgroup_Dotmailer_menu>
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ </config>
app/code/local/Dotdigitalgroup/Dotmailer/etc/config.xml ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dotdigitalgroup_Dotmailer>
5
+ <version>0.1.0</version>
6
+ </Dotdigitalgroup_Dotmailer>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <dotdigitalgroup_dotmailer>
11
+ <class>Dotdigitalgroup_Dotmailer_Block</class>
12
+ </dotdigitalgroup_dotmailer>
13
+ </blocks>
14
+ <models>
15
+ <dotdigitalgroup_dotmailer>
16
+ <class>Dotdigitalgroup_Dotmailer_Model</class>
17
+ <resourceModel>dotdigitalgroup_dotmailer_mysql4</resourceModel>
18
+ </dotdigitalgroup_dotmailer>
19
+ <dotdigitalgroup_dotmailer_mysql4>
20
+ <class>Dotdigitalgroup_Dotmailer_Model_Mysql4</class>
21
+ <entities>
22
+ <history>
23
+ <table>dotdigitalgroup_dotmailer_history</table>
24
+ </history>
25
+ </entities>
26
+ </dotdigitalgroup_dotmailer_mysql4>
27
+ </models>
28
+ <resources>
29
+ <dotmailer_setup>
30
+ <setup>
31
+ <module>Dotdigitalgroup_Dotmailer</module>
32
+ </setup>
33
+ <connection>
34
+ <use>core_setup</use>
35
+ </connection>
36
+ </dotmailer_setup>
37
+ <dotmailer_write>
38
+ <connection>
39
+ <use>core_write</use>
40
+ </connection>
41
+ </dotmailer_write>
42
+ <dotmailer_read>
43
+ <connection>
44
+ <use>core_read</use>
45
+ </connection>
46
+ </dotmailer_read>
47
+ </resources>
48
+ <helpers>
49
+ <dotdigitalgroup_dotmailer>
50
+ <class>Dotdigitalgroup_Dotmailer_Helper</class>
51
+ </dotdigitalgroup_dotmailer>
52
+ </helpers>
53
+ <events>
54
+ <newsletter_subscriber_save_before>
55
+ <observers>
56
+ <newsletter_subscriber_save_before>
57
+ <type>singleton</type>
58
+ <class>dotdigitalgroup_dotmailer/observer</class>
59
+ <method>subscriberSaveBefore</method>
60
+ </newsletter_subscriber_save_before>
61
+ </observers>
62
+ </newsletter_subscriber_save_before>
63
+
64
+ <newsletter_subscriber_save_after>
65
+ <observers>
66
+ <newsletter_subscriber_save_after>
67
+ <type>singleton</type>
68
+ <class>dotdigitalgroup_dotmailer/observer</class>
69
+ <method>subscriberSaveAfter</method>
70
+ </newsletter_subscriber_save_after>
71
+ </observers>
72
+ </newsletter_subscriber_save_after>
73
+
74
+
75
+ <newsletter_subscriber_delete_after>
76
+ <observers>
77
+ <newsletter_subscriber_delete_after>
78
+ <type>singleton</type>
79
+ <class>dotdigitalgroup_dotmailer/observer</class>
80
+ <method>subscriberDeleteAfter</method>
81
+ </newsletter_subscriber_delete_after>
82
+ </observers>
83
+ </newsletter_subscriber_delete_after>
84
+
85
+
86
+ <customer_save_before>
87
+ <observers>
88
+ <customer_save_before>
89
+ <type>singleton</type>
90
+ <class>dotdigitalgroup_dotmailer/observer</class>
91
+ <method>customerSaveBefore</method>
92
+ </customer_save_before>
93
+ </observers>
94
+ </customer_save_before>
95
+ <customer_save_after>
96
+ <observers>
97
+ <customer_save_after>
98
+ <type>singleton</type>
99
+ <class>dotdigitalgroup_dotmailer/observer</class>
100
+ <method>customerSaveAfter</method>
101
+ </customer_save_after>
102
+ </observers>
103
+ </customer_save_after>
104
+
105
+ <customer_address_save_after>
106
+ <observers>
107
+ <customer_address_save_after>
108
+ <type>singleton</type>
109
+ <class>dotdigitalgroup_dotmailer/observer</class>
110
+ <method>customerAddressSaveAfter</method>
111
+ </customer_address_save_after>
112
+ </observers>
113
+ </customer_address_save_after>
114
+ <customer_delete_after>
115
+ <observers>
116
+ <customer_delete_after>
117
+ <type>singleton</type>
118
+ <class>dotdigitalgroup_dotmailer/observer</class>
119
+ <method>customerDeleteAfter</method>
120
+ </customer_delete_after>
121
+ </observers>
122
+ </customer_delete_after>
123
+
124
+ <sales_order_save_after>
125
+ <observers>
126
+ <sales_order_save_after>
127
+ <type>singleton</type>
128
+ <class>dotdigitalgroup_dotmailer/observer</class>
129
+ <method>orderSaveAfter</method>
130
+ </sales_order_save_after>
131
+ </observers>
132
+ </sales_order_save_after>
133
+ <checkout_cart_save_after>
134
+ <observers>
135
+ <checkout_cart_save_after>
136
+ <type>singleton</type>
137
+ <class>dotdigitalgroup_dotmailer/observer</class>
138
+ <method>cartSaveAfter</method>
139
+ </checkout_cart_save_after>
140
+ </observers>
141
+ </checkout_cart_save_after>
142
+
143
+ </events>
144
+ </global>
145
+ <admin>
146
+ <routers>
147
+ <dotmailer>
148
+ <use>admin</use>
149
+ <args>
150
+ <module>Dotdigitalgroup_Dotmailer</module>
151
+ <frontName>dotmailer</frontName>
152
+ </args>
153
+ </dotmailer>
154
+ </routers>
155
+ </admin>
156
+ <adminhtml>
157
+ <layout>
158
+ <updates>
159
+ <dotdigitalgroup_dotmailer module="dotdigitalgroup_dotmailer">
160
+ <file>dotdigitalgroup_dotmailer.xml</file>
161
+ </dotdigitalgroup_dotmailer>
162
+ </updates>
163
+ </layout>
164
+ <acl>
165
+ <resources>
166
+ <admin>
167
+ <children>
168
+ <system>
169
+ <children>
170
+ <config>
171
+ <children>
172
+ <dotmailer translate="title" module="customer">
173
+ <title>dotMailer</title>
174
+ <sort_order>50</sort_order>
175
+ </dotmailer>
176
+ </children>
177
+ </config>
178
+ </children>
179
+ </system>
180
+ </children>
181
+ </admin>
182
+ </resources>
183
+ </acl>
184
+ </adminhtml>
185
+ <frontend>
186
+ <routers>
187
+ <dotmailer>
188
+ <use>standard</use>
189
+ <args>
190
+ <module>Dotdigitalgroup_Dotmailer</module>
191
+ <frontName>dotmailer</frontName>
192
+ </args>
193
+ </dotmailer>
194
+ </routers>
195
+ <layout>
196
+ <updates>
197
+ <dotdigitalgroup_dotmailer module="dotdigitalgroup_dotmailer">
198
+ <file>dotdigitalgroup_dotmailer.xml</file>
199
+ </dotdigitalgroup_dotmailer>
200
+ </updates>
201
+ </layout>
202
+ </frontend>
203
+ <crontab>
204
+ <jobs>
205
+ <dotdigitalgroup_dotmailer_sendCampaignToLostBaskets>
206
+ <schedule>
207
+ <cron_expr>*/5 * * * *</cron_expr>
208
+ </schedule>
209
+ <run>
210
+ <model>dotdigitalgroup_dotmailer/observer::sendCampaignToLostBaskets</model>
211
+ </run>
212
+ </dotdigitalgroup_dotmailer_sendCampaignToLostBaskets>
213
+ <dotdigitalgroup_dotmailer_sendCampaignToIncompleteOrders>
214
+ <schedule>
215
+ <cron_expr>*/5 * * * *</cron_expr>
216
+ </schedule>
217
+ <run>
218
+ <model>dotdigitalgroup_dotmailer/observer::sendCampaignToIncompleteOrders</model>
219
+ </run>
220
+ </dotdigitalgroup_dotmailer_sendCampaignToIncompleteOrders>
221
+ <dotdigitalgroup_dotmailer_synchronization>
222
+ <schedule>
223
+ <cron_expr>0 4 * * *</cron_expr>
224
+ </schedule>
225
+ <run>
226
+ <model>dotdigitalgroup_dotmailer/observer::synchronization</model>
227
+ </run>
228
+ </dotdigitalgroup_dotmailer_synchronization>
229
+ </jobs>
230
+ </crontab>
231
+ </config>
app/code/local/Dotdigitalgroup/Dotmailer/etc/system.xml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <dotmailer translate="label" module="dotdigitalgroup_dotmailer">
5
+ <label>dotMailer Configuration</label>
6
+ <class>dotmailer-section</class>
7
+ <tab>customer</tab>
8
+ <sort_order>105</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <dotMailer_banner>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <frontend_model>dotdigitalgroup_dotmailer/system_config_banner</frontend_model>
19
+ </dotMailer_banner>
20
+
21
+ <dotMailer_group translate="label">
22
+ <label>General</label>
23
+ <sort_order>20</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <expanded>1</expanded>
28
+ <fields>
29
+ <dotMailer_header>
30
+ <sort_order>0</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <frontend_model>dotdigitalgroup_dotmailer/system_config_header</frontend_model>
35
+ </dotMailer_header>
36
+ <dotMailer_api_username translate="label comment">
37
+ <label>API Username</label>
38
+ <validate>required-entry</validate>
39
+ <sort_order>1</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <frontend_type>text</frontend_type>
44
+ </dotMailer_api_username>
45
+ <dotMailer_api_password translate="label comment">
46
+ <label>API Password</label>
47
+ <validate>required-entry</validate>
48
+ <sort_order>2</sort_order>
49
+ <comment>The API Username and Password are not the same as your normal login details. Speak to your account manager if you're unsure what to enter.</comment>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <frontend_type>text</frontend_type>
54
+ </dotMailer_api_password>
55
+ <dotMailer_credential_button>
56
+ <sort_order>3</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <frontend_model>dotdigitalgroup_dotmailer/system_config_credentialbutton</frontend_model>
61
+ </dotMailer_credential_button>
62
+ <dotMailer_book_general_subscribers translate="label comment">
63
+ <label>Add General Subscribers To Address Book</label>
64
+ <validate>required-entry</validate>
65
+ <sort_order>4</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>dotdigitalgroup_dotmailer/system_config_source_books</source_model>
71
+ </dotMailer_book_general_subscribers>
72
+ <dotMailer_book_checkout_customers translate="label comment">
73
+ <label>Add Customers Who Complete Checkout To Address Book</label>
74
+ <validate>required-entry</validate>
75
+ <sort_order>5</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>dotdigitalgroup_dotmailer/system_config_source_books</source_model>
81
+ </dotMailer_book_checkout_customers>
82
+ <dotMailer_campaign_cart_abandoned translate="label comment">
83
+ <label>Campaign To Trigger for Abandoned Carts</label>
84
+ <validate>required-entry</validate>
85
+ <sort_order>6</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>dotdigitalgroup_dotmailer/system_config_source_campaigns</source_model>
91
+ </dotMailer_campaign_cart_abandoned>
92
+ <dotMailer_hours_before_sending_lost_basket_email translate="label comment">
93
+ <label>Hours Before Sending Lost Basket Email</label>
94
+ <validate>required-entry validate-number</validate>
95
+ <sort_order>7</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ <frontend_type>text</frontend_type>
100
+ </dotMailer_hours_before_sending_lost_basket_email>
101
+ <dotMailer_campaign_incomplete_order translate="label comment">
102
+ <label>Campaign To Trigger for Incomplete Orders</label>
103
+ <validate>required-entry</validate>
104
+ <sort_order>8</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <frontend_type>select</frontend_type>
109
+ <source_model>dotdigitalgroup_dotmailer/system_config_source_campaigns</source_model>
110
+ </dotMailer_campaign_incomplete_order>
111
+ <dotMailer_hours_before_sending_incomplete_order_email translate="label comment">
112
+ <label>Hours Before Sending Incomplete Order Email</label>
113
+ <validate>required-entry validate-number</validate>
114
+ <sort_order>9</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ <frontend_type>text</frontend_type>
119
+ </dotMailer_hours_before_sending_incomplete_order_email>
120
+ <dotMailer_track_conversions translate="label comment">
121
+ <label>Track Conversions on dotMailer</label>
122
+ <validate>required-entry</validate>
123
+ <comment>Sends information to dotMailer about orders that convert from emails so you can see how effective they are.</comment>
124
+ <sort_order>10</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>adminhtml/system_config_source_yesno</source_model>
130
+ </dotMailer_track_conversions>
131
+ </fields>
132
+ </dotMailer_group>
133
+ <dotMailer_footer>
134
+ <sort_order>30</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ <frontend_model>dotdigitalgroup_dotmailer/system_config_footer</frontend_model>
139
+ </dotMailer_footer>
140
+
141
+ </groups>
142
+ </dotmailer>
143
+ </sections>
144
+
145
+ </config>
app/code/local/Dotdigitalgroup/Dotmailer/sql/dotmailer_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ $installer->run("
6
+
7
+ CREATE TABLE `{$this->getTable('dotdigitalgroup_dotmailer_history')}` (
8
+ `entity_id` int(11) unsigned NOT NULL auto_increment,
9
+ `customer_email` varchar(255) NOT NULL default '',
10
+ `object_type` varchar(10) NOT NULL default '',
11
+ `object_id` int(11) NOT NULL default '0',
12
+ `created_time` varchar(100) NOT NULL default '',
13
+ PRIMARY KEY (`entity_id`)
14
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+
16
+ ");
17
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/dotdigitalgroup_dotmailer.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout>
4
+ <default>
5
+ <reference name="head">
6
+ <action method="addCss"><link>dotmailer.css</link></action>
7
+ </reference>
8
+
9
+ </default>
10
+ <dotmailer_manager_index>
11
+ <reference name="content">
12
+ <block type="dotdigitalgroup_dotmailer/manager" name="dotmailer_manager_index"></block>
13
+ </reference>
14
+ <reference name="head">
15
+ <action method="addJs"><script>dotmailer/dotmailer.js</script></action>
16
+ </reference>
17
+ </dotmailer_manager_index>
18
+ </layout>
app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/manager.phtml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="dotmailer-header">
2
+ <div id="dotmailer-logo" align="left" style="width: 49%; float:left; border:0px solid;">
3
+ <img src="<?php echo $this->logoLink; ?>">
4
+ </div>
5
+ <div align="right" style="width: 49%; float:right; border:0px solid;">
6
+ <a href="<?php echo $this->supportLink; ?>" target="_blank"><?php echo $this->supportText; ?></a><br><font color="blue">or call us on <?php echo $this->phoneNumber; ?></font>
7
+ </div>
8
+ </div>
9
+
10
+ <table style="width: 100%; " border=0 cellspacing="0" cellpading="0">
11
+ <tr>
12
+ <td width="33%">
13
+ <div class="entry-edit dotmailer-entry">
14
+ <div class="entry-edit-head"><h4>Magento / dotMailer Status</h4></div>
15
+ <fieldset class="a-center bold dotmailer-fieldset dotmailer-fieldset">
16
+ <?php echo $this->getStatus(); ?>
17
+ </fieldset>
18
+ <div align="right"><button id="dotmailer_syncronise" url="<?php echo Mage::helper("adminhtml")->getUrl("dotmailer/manager/synchronization/",array( )); ?>">Syncronise Now</button></div>
19
+ </div>
20
+ </td>
21
+ <td width="33%">
22
+ <div class="entry-edit dotmailer-entry">
23
+ <div class="entry-edit-head"><h4>Total Number of Subscribers</h4></div>
24
+ <fieldset class="a-center bold dotmailer-fieldset">
25
+ <?php echo $this->getTotalNumberSubscribers(); ?>
26
+ </fieldset>
27
+ </div>
28
+ </td>
29
+ <td width="33%">
30
+ <div class="entry-edit dotmailer-entry">
31
+ <div class="entry-edit-head"><h4>Email Conversion Rate</h4></div>
32
+ <fieldset class="a-center bold dotmailer-fieldset">
33
+ <?php echo $this->getEmailConversionRate(); ?>
34
+ </fieldset>
35
+ </div>
36
+ </td>
37
+ </tr>
38
+
39
+ <tr>
40
+ <td colspan="3">
41
+ <div class="dotmailer-range" align="right">
42
+ Select Range:
43
+ <select id="dotmailer-select-range" url="<?php echo Mage::helper("adminhtml")->getUrl("dotmailer/manager/report/",array( )); ?>">
44
+ <option value="24hours">Last 24 Hours</option>
45
+ <option value="7days" selected="selected">Last 7 Days</option>
46
+ <option value="month">Current Month</option>
47
+ <option value="ytd">YTD</option>
48
+ <option value="2ytd">2YTD</option>
49
+ </select>
50
+ </div>
51
+ </td>
52
+ </tr>
53
+ <tr>
54
+ <td colspan="3">
55
+ <div class="entry-edit dotmailer-entry">
56
+ <font class="dotmailer-entry-title">Dropouts</font>
57
+ </div>
58
+ </td>
59
+ </tr>
60
+
61
+ <tr>
62
+ <td>
63
+ <div class="entry-edit dotmailer-entry">
64
+ <div class="entry-edit-head"><h4>Abandoned Carts</h4></div>
65
+ <fieldset id="abandonedcarts" class="a-center bold dotmailer-fieldset">
66
+ <?php echo $this->getAbandonedCarts(); ?>
67
+ </fieldset>
68
+ </div>
69
+ </td>
70
+ <td>
71
+ <div class="entry-edit dotmailer-entry">
72
+ <div class="entry-edit-head"><h4>Basket Dropout Rate</h4></div>
73
+ <fieldset id="basketdropoutrate" class="a-center bold dotmailer-fieldset">
74
+ <?php echo $this->getBasketDropoutRate(); ?>
75
+ </fieldset>
76
+ </div>
77
+ </td>
78
+ <td>
79
+ <div class="entry-edit dotmailer-entry">
80
+ <div class="entry-edit-head"><h4>Total Potential Lost Revenue (without dotMailer)</h4></div>
81
+ <fieldset id="lostrevenue" class="a-center bold dotmailer-fieldset">
82
+ <?php echo $this->currencySymbol.$this->getTotalPotentialLostRevenue(); ?>
83
+ </fieldset>
84
+ </div>
85
+ </td>
86
+ </tr>
87
+ <tr>
88
+ <td colspan="3">
89
+ <div class="entry-edit dotmailer-entry">
90
+ <font class="dotmailer-entry-title">Recoveries</font>
91
+ </div>
92
+ </td>
93
+ </tr>
94
+
95
+ <tr>
96
+ <td>
97
+ <div class="entry-edit dotmailer-entry">
98
+ <div class="entry-edit-head"><h4>Carts Recovered Through dotMailer</h4></div>
99
+ <fieldset id="recoveredcarts" class="a-center bold dotmailer-fieldset">
100
+ <?php echo $this->getCartsRecoveredThroughdotMailer(); ?>
101
+ </fieldset>
102
+ </div>
103
+ </td>
104
+ <td>
105
+ <div class="entry-edit dotmailer-entry">
106
+ <div class="entry-edit-head"><h4>dotMailer Basket Recovery Rate</h4></div>
107
+ <fieldset id="basketrecoveryrate" class="a-center bold dotmailer-fieldset">
108
+ <?php echo $this->getdotMailerBasketRecoveryRate(); ?>
109
+ </fieldset>
110
+ </div>
111
+ </td>
112
+ <td>
113
+ <div class="entry-edit dotmailer-entry">
114
+ <div class="entry-edit-head"><h4>Revenue Generated Through dotMailer</h4></div>
115
+ <fieldset id="recoveredrevenue" class="a-center bold dotmailer-fieldset">
116
+ <?php echo $this->currencySymbol.$this->getRevenueRecoveredThroughdotMailer(); ?>
117
+ </fieldset>
118
+ </div>
119
+ </td>
120
+ </tr>
121
+
122
+ </table>
app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/banner.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div>
2
+ <iframe width="100%" style="border: 0px;" marginheight="1" scrolling="no" src="<?php echo $this->bannerUrl; ?>"></iframe>
3
+ </div>
app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/credentialbutton.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <tr><td colspan="3" align="right"><button id="credential-button" url="<?php echo Mage::helper("adminhtml")->getUrl("dotmailer/manager/checkcredential/",array( )); ?>" type="button">Modify Credentials</button> <button type="button" id="cancel-button" username="" password="">Cancel</button></td></tr>
app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/footer.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div align="right">
2
+ <?php echo $this->getSaveButtonHtml(); ?>
3
+ </div>
app/design/adminhtml/default/default/template/dotdigitalgroup/dotmailer/system/config/header.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="height:50px; border:0px solid;">
2
+ <div align="left" style="width: 49%; float:left; border:0px solid;">
3
+ <a href="<?php echo $this->trialAccountLink; ?>"><?php echo $this->trialAccountText; ?></a>
4
+ </div>
5
+ <div align="right" style="width: 49%; float:right; border:0px solid;">
6
+ <a href="<?php echo $this->supportLink; ?>" target="_blank"><?php echo $this->supportText; ?></a><br><font color="blue">or call us on <?php echo $this->phoneNumber; ?></font>
7
+ </div>
8
+ </div>
9
+
10
+ <?php $checkApi = $this->checkApi(); ?>
11
+ <div id="dotmailer-error" class="dotmailer-error"><?php if(!$checkApi['result']) echo $checkApi['error']; ?></div>
12
+ <input type="hidden" id="checkapi" value="<?php if($checkApi['result']) echo "1"; else echo "0"; ?>">
13
+ <input type="hidden" id="enableForOrders" value="<?php if($this->enableForOrders()) echo "1"; else echo "0"; ?>">
14
+ <script type="text/javascript" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); ?>dotmailer/config.js"></script>
app/design/frontend/base/default/layout/dotdigitalgroup_dotmailer.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <checkout_onepage_success>
4
+ <reference name="head">
5
+ <block type="page/html" name="trackurl" template="dotmailer/track.phtml"></block>
6
+ </reference>
7
+ </checkout_onepage_success>
8
+ </layout>
app/design/frontend/base/default/template/dotmailer/track.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script src="http://t.trackedlink.net/_dmpt.js" type="text/javascript"></script>
2
+ <script type="text/javascript">
3
+ document.observe('dom:loaded', function(){
4
+
5
+ new Ajax.Request('<?php echo Mage::getUrl('dotmailer/index/getlastorder',array()); ?>',{
6
+ parameters: {type: 'track'},
7
+ onSuccess: function(response) {
8
+ var data = response.responseText.evalJSON();
9
+ if(data.success)
10
+ {
11
+ for(var i=0; i<data.products.length; i++)
12
+ _dmTrack("product", data.products[i]);
13
+ _dmTrack("CheckOutAmount", data.checkoutamount);
14
+ }
15
+ }
16
+ });
17
+
18
+ });
19
+ </script>
app/etc/modules/Dotdigitalgroup_Dotmailer.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dotdigitalgroup_Dotmailer>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Adminhtml/>
9
+ </depends>
10
+ </Dotdigitalgroup_Dotmailer>
11
+ </modules>
12
+ </config>
js/dotmailer/config.js ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.observe('dom:loaded', function(){
2
+
3
+ function setSelectOptions(id, list)
4
+ {
5
+ $(id).options.length = 1;
6
+ for (var i = 0;i<list.length;i++)
7
+ $(id).options[$(id).options.length] = new Option(list[i].label, list[i].value);
8
+ }
9
+
10
+ function dotmailerCheckCredential(value)
11
+ {
12
+ var savebuttons = $$('button.save');
13
+ $('dotmailer_dotMailer_group_dotMailer_api_username').readOnly = value;
14
+ $('dotmailer_dotMailer_group_dotMailer_api_password').readOnly = value;
15
+ if(value)
16
+ {
17
+ $('dotmailer_dotMailer_group_dotMailer_api_username').setStyle({border: '0px'});
18
+ $('dotmailer_dotMailer_group_dotMailer_api_password').setStyle({border: '0px'});
19
+ $('checkapi').setValue("1")
20
+ $('credential-button').update('Modify credentials');
21
+ $('cancel-button').hide();
22
+ for (var i = 0; i < savebuttons.size(); i++) savebuttons[i].show();
23
+ $('row_dotmailer_dotMailer_group_dotMailer_book_general_subscribers').show();
24
+ $('row_dotmailer_dotMailer_group_dotMailer_book_checkout_customers').show();
25
+ $('row_dotmailer_dotMailer_group_dotMailer_hours_before_sending_lost_basket_email').show();
26
+ $('row_dotmailer_dotMailer_group_dotMailer_campaign_cart_abandoned').show();
27
+ $('row_dotmailer_dotMailer_group_dotMailer_hours_before_sending_incomplete_order_email').show();
28
+ $('row_dotmailer_dotMailer_group_dotMailer_campaign_incomplete_order').show();
29
+ $('row_dotmailer_dotMailer_group_dotMailer_track_conversions').show();
30
+ }
31
+ else
32
+ {
33
+ $('dotmailer_dotMailer_group_dotMailer_api_username').setStyle({border: '1px solid'});
34
+ $('dotmailer_dotMailer_group_dotMailer_api_password').setStyle({border: '1px solid'});
35
+ $('credential-button').update('Save');
36
+ if($('cancel-button').getAttribute('username') && $('cancel-button').getAttribute('password'))
37
+ // if($('dotmailer_dotMailer_group_dotMailer_api_username').getValue() && $('dotmailer_dotMailer_group_dotMailer_api_password').getValue())
38
+ $('cancel-button').show();
39
+ else
40
+ $('cancel-button').hide();
41
+ $('checkapi').setValue("0")
42
+ for (var i = 0; i < savebuttons.size(); i++) savebuttons[i].hide();
43
+ $('row_dotmailer_dotMailer_group_dotMailer_book_general_subscribers').hide();
44
+ $('row_dotmailer_dotMailer_group_dotMailer_book_checkout_customers').hide();
45
+ $('row_dotmailer_dotMailer_group_dotMailer_hours_before_sending_lost_basket_email').hide();
46
+ $('row_dotmailer_dotMailer_group_dotMailer_campaign_cart_abandoned').hide();
47
+
48
+ $('row_dotmailer_dotMailer_group_dotMailer_hours_before_sending_incomplete_order_email').hide();
49
+ $('row_dotmailer_dotMailer_group_dotMailer_campaign_incomplete_order').hide();
50
+
51
+ $('row_dotmailer_dotMailer_group_dotMailer_track_conversions').hide();
52
+ }
53
+
54
+ }
55
+
56
+
57
+
58
+ if($('checkapi').getValue() == "1") {
59
+ dotmailerCheckCredential(true);
60
+ }
61
+ else {
62
+ dotmailerCheckCredential(false);
63
+ }
64
+
65
+ if($('enableForOrders').getValue() == "0") {
66
+ $('row_dotmailer_dotMailer_group_dotMailer_hours_before_sending_incomplete_order_email').hide();
67
+ $('row_dotmailer_dotMailer_group_dotMailer_campaign_incomplete_order').hide();
68
+ }
69
+
70
+
71
+
72
+ $('credential-button').observe('click', function() {
73
+ if($('checkapi').getValue() == "0")
74
+ new Ajax.Request($(this).readAttribute('url'),{
75
+ parameters: {username: $('dotmailer_dotMailer_group_dotMailer_api_username').getValue(), password: $('dotmailer_dotMailer_group_dotMailer_api_password').getValue()},
76
+ onSuccess: function(response) {
77
+ var data = response.responseText.evalJSON();
78
+ //alert('success='+data.success+', data='+data.data);
79
+ if(data.success)
80
+ {
81
+
82
+ $('dotmailer-error').hide();
83
+ setSelectOptions('dotmailer_dotMailer_group_dotMailer_book_general_subscribers',data.addressbooks);
84
+ setSelectOptions('dotmailer_dotMailer_group_dotMailer_book_checkout_customers',data.addressbooks);
85
+ setSelectOptions('dotmailer_dotMailer_group_dotMailer_campaign_incomplete_order',data.campaigns);
86
+ setSelectOptions('dotmailer_dotMailer_group_dotMailer_campaign_cart_abandoned',data.campaigns);
87
+ dotmailerCheckCredential(true);
88
+
89
+ }
90
+ else
91
+ {
92
+ $('dotmailer-error').update(data.error);
93
+ $('dotmailer-error').show();
94
+ dotmailerCheckCredential(false);
95
+ }
96
+ }
97
+ });
98
+ else
99
+ {
100
+ $('cancel-button').setAttribute('username',$('dotmailer_dotMailer_group_dotMailer_api_username').getValue());
101
+ $('cancel-button').setAttribute('password',$('dotmailer_dotMailer_group_dotMailer_api_password').getValue());
102
+ dotmailerCheckCredential(false);
103
+ }
104
+ });
105
+
106
+ $('cancel-button').observe('click', function() {
107
+ $('dotmailer-error').hide();
108
+ dotmailerCheckCredential(true);
109
+ $('dotmailer_dotMailer_group_dotMailer_api_username').setValue($('cancel-button').getAttribute('username'));
110
+ $('dotmailer_dotMailer_group_dotMailer_api_password').setValue($('cancel-button').getAttribute('password'));
111
+
112
+ });
113
+ });
js/dotmailer/dotmailer.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.observe('dom:loaded', function(){
2
+ $('dotmailer-select-range').observe('change', function() {
3
+ new Ajax.Request($(this).readAttribute('url'),{
4
+ parameters: {range: $(this).getValue()},
5
+ onSuccess: function(response) {
6
+ var data = response.responseText.evalJSON();
7
+ $('abandonedcarts').update(data.abandoned_carts);
8
+ $('basketdropoutrate').update(data.basket_dropout_rate);
9
+ $('lostrevenue').update(data.lost_revenue);
10
+
11
+ $('recoveredcarts').update(data.recovered_carts);
12
+
13
+ $('basketrecoveryrate').update(data.basket_recovery_rate);
14
+ $('recoveredrevenue').update(data.recovered_revenue);
15
+
16
+ }
17
+ });
18
+ });
19
+
20
+ $('dotmailer_syncronise').observe('click', function() {
21
+ new Ajax.Request($(this).readAttribute('url'),{
22
+ parameters: {},
23
+ onSuccess: function(response) {
24
+ var data = response.responseText.evalJSON();
25
+ location.reload();
26
+ }
27
+ });
28
+ });
29
+
30
+
31
+ });
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>dotmailer</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Module for dotMailer</summary>
10
+ <description>Module for simplify integration between Magento and dotMailer.</description>
11
+ <notes>Initial release</notes>
12
+ <authors><author><name>Yaroslav Bogutsky</name><user>yaryj</user><email>yaryj88@gmail.com</email></author></authors>
13
+ <date>2011-11-04</date>
14
+ <time>15:06:09</time>
15
+ <contents><target name="magelocal"><dir name="Dotdigitalgroup"><dir name="Dotmailer"><dir name="Block"><file name="Manager.php" hash="584e1d5be2fc498b9b64d44ddae430d4"/><dir name="System"><dir name="Config"><file name="Banner.php" hash="67132451fd11939ac25a4f42f4f72a8f"/><file name="Credentialbutton.php" hash="78a476738cb6bf6365d9833c054c84fc"/><file name="Footer.php" hash="292f146bfa9ac87fa14d64afdeb7ae1f"/><file name="Header.php" hash="e7042c58e38b4689aec4fa989c4dde39"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0d73cbcb7ccf559255d2088f88564001"/></dir><dir name="Model"><file name="History.php" hash="73678a0a3442c85f2e02a5f116936f1c"/><dir name="Mysql4"><dir name="History"><file name="Collection.php" hash="247070c9df434f54961062390108b6e4"/></dir><file name="History.php" hash="665f4f9db11f800f48d1978f5e7eb9f1"/></dir><file name="Observer.php" hash="981c0ae1b6e05349287cc84ded4aa3d2"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Books.php" hash="de46d5605e6bd4d1b96bcd0cd34eac00"/><file name="Campaigns.php" hash="07ff5f7e66ff60d85ceafa855a1c83b6"/></dir></dir></dir></dir><dir name="config"><file name="config.xml" hash="bcedd76ace1974cebf9f78dceafe94b3"/><file name="dotMailerConfig.php" hash="b8693b9c890d3ebe1ba5f7ce19eca5a0"/></dir><dir name="controllers"><file name="IndexController.php" hash="ae020b1312e2ac6ae50fae62cff48622"/><file name="ManagerController.php" hash="1b2191a47a0afd738855227218bf5fdd"/></dir><dir name="etc"><file name="adminhtml.xml" hash="b0d84051c49a55a0285a6b5eb52fa360"/><file name="config.xml" hash="1a892633864b8d5ff7661f8b7bbf6bc2"/><file name="system.xml" hash="5884dfe9eae528b45646f29ccb92cec3"/></dir><dir name="sql"><dir name="dotmailer_setup"><file name="mysql4-install-0.1.0.php" hash="067527c0100b0d508f92b0470eb0d040"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dotdigitalgroup_Dotmailer.xml" hash="0607a6d0ed6a36d2be1c7ad5783e63d8"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="dotdigitalgroup_dotmailer.xml" hash="b91bf5c41ed85e4ade59e4bcbd820a8c"/></dir><dir name="template"><dir name="dotdigitalgroup"><dir name="dotmailer"><file name="manager.phtml" hash="f86b27de6c73203a4b950d4df69649a3"/><dir name="system"><dir name="config"><file name="banner.phtml" hash="7b1428cee3b69b75f1b8eddd7ddb2380"/><file name="credentialbutton.phtml" hash="f76c58621f913d0089a9a25ee4d26db9"/><file name="footer.phtml" hash="3442a1f4f42929f94b59cf84f2f98143"/><file name="header.phtml" hash="fc5f56868938599410fab44d782aa997"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="dotdigitalgroup_dotmailer.xml" hash="a65d1c0e2f4ff00c2a24a17e735d92ec"/></dir><dir name="template"><dir name="dotmailer"><file name="track.phtml" hash="dfd2ccc4dc39ff7d7ae264ef12ce0701"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="dotmailer"><file name="config.js" hash="02e4300c875b52447aa5c265aa11eac6"/><file name="dotmailer.js" hash="96218f45d4b01cc1f7b845319edb1b9d"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="dotmailer.css" hash="2ffc587a38c982f6a5ccd537075ccd2b"/><dir name="images"><file name="dotmailer-section.png" hash="1234cdb4e9d0233348c8e384babf86da"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/dotmailer.css ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ul.tabs a.dotmailer-section,
2
+ ul.tabs a.dotmailer-section:hover { background:url(images/tabs_span_bg.gif) repeat-x 0 100%; border-bottom:none; padding:0.5em 0.5em 0.28em 1.5em; }
3
+ ul.tabs a.dotmailer-section:hover { background-color:#d8e6e6; }
4
+ ul.tabs a.dotmailer-section.active, ul.tabs a.dotmailer-section.active:hover { background-color:#fff; }
5
+ ul.tabs a.dotmailer-section span,
6
+ ul.tabs a.dotmailer-section:hover span { background:url(images/dotmailer-section.png) no-repeat 0 0; height:0; overflow:hidden; padding:23px 0 0; width:77px; }
7
+ #dotmailer-header {
8
+ overflow: auto;
9
+ padding: 10px;
10
+ }
11
+
12
+
13
+ .dotmailer-entry {
14
+ margin: 0px 10px 0px 10px;
15
+ padding-bottom:10px;
16
+ }
17
+ .dotmailer-entry-title {
18
+ color: orange;
19
+ font-weight:bold;
20
+ font-size:18px;
21
+
22
+ }
23
+ p.dotmailer-note {
24
+ margin:0;
25
+ padding:0 0 0 13px;
26
+ background:url(images/note_bg.gif) 1px 6px no-repeat;
27
+ font-size:11px;
28
+ }
29
+ .dotmailer-range {
30
+ background-color: #CCC;
31
+ padding:5px 15px;
32
+ margin:10px 10px 20px 10px;
33
+ }
34
+ #dotmailer-select-range{
35
+ width:150px;
36
+ }
37
+ .dotmailer-fieldset {
38
+ font-size: 20px;
39
+ }
40
+ .dotmailer-error {
41
+ color:#900 !important;
42
+ font-weight: bold !important;
43
+ padding: 0px 15px !important;
44
+ }
45
+
46
+ .dotmailer-manager-error {
47
+ color: red;
48
+ }
49
+
50
+ #credential-button {
51
+ margin-bottom: 16px !important;
52
+ }
skin/adminhtml/default/default/images/dotmailer-section.png ADDED
Binary file