MailUp - Version 2.3.1

Version Notes

Added support for multi-store installations

Settings, including field mappings, can now be set at the store view level

Added date/time stamp of latest data sync

Updated some areas of the extension to improve performance

Download this release

Release Info

Developer MailUp
Extension MailUp
Version 2.3.1
Comparing to
See all releases


Code changes from version 2.2.1 to 2.3.1

Files changed (53) hide show
  1. app/code/local/SevenLike/MailUp/Block/.DS_Store +0 -0
  2. app/code/local/SevenLike/MailUp/Block/Filters.php +25 -0
  3. app/code/local/SevenLike/MailUp/Helper/.DS_Store +0 -0
  4. app/code/local/SevenLike/MailUp/Helper/Data.php +602 -446
  5. app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Frequency.php +37 -37
  6. app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Hours.php +18 -18
  7. app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Fields.php +63 -0
  8. app/code/local/SevenLike/MailUp/Model/Config.php +205 -0
  9. app/code/local/SevenLike/MailUp/Model/Consoleurlvalidator.php +18 -18
  10. app/code/local/SevenLike/MailUp/Model/Cron.php +161 -86
  11. app/code/local/SevenLike/MailUp/Model/Lists.php +96 -54
  12. app/code/local/SevenLike/MailUp/Model/MailUp.php +9 -9
  13. app/code/local/SevenLike/MailUp/Model/MailUpWsImport.php +1001 -658
  14. app/code/local/SevenLike/MailUp/Model/Mysql14/MailUp.php +8 -8
  15. app/code/local/SevenLike/MailUp/Model/Mysql14/MailUp/Collection.php +9 -9
  16. app/code/local/SevenLike/MailUp/Model/Observer.php +348 -264
  17. app/code/local/SevenLike/MailUp/Model/Subscriber.php +73 -0
  18. app/code/local/SevenLike/MailUp/Model/Webserviceusernamevalidator.php +17 -17
  19. app/code/local/SevenLike/MailUp/Model/Ws.php +2 -2
  20. app/code/local/SevenLike/MailUp/Model/Wssend.php +348 -305
  21. app/code/local/SevenLike/MailUp/controllers/.DS_Store +0 -0
  22. app/code/local/SevenLike/MailUp/controllers/Adminhtml/.DS_Store +0 -0
  23. app/code/local/SevenLike/MailUp/controllers/Adminhtml/ConfigurationController.php +14 -14
  24. app/code/local/SevenLike/MailUp/controllers/Adminhtml/FieldsmappingController.php +29 -27
  25. app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php +265 -222
  26. app/code/local/SevenLike/MailUp/controllers/Adminhtml/ViewdatatransferlogController.php +13 -13
  27. app/code/local/SevenLike/MailUp/controllers/IndexController.php +60 -0
  28. app/code/local/SevenLike/MailUp/controllers/WebhookController.php +166 -147
  29. app/code/local/SevenLike/MailUp/etc/.DS_Store +0 -0
  30. app/code/local/SevenLike/MailUp/etc/config.xml +281 -246
  31. app/code/local/SevenLike/MailUp/etc/system.xml +403 -98
  32. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-0.1.0.php +2 -2
  33. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-2.3.0.php +36 -0
  34. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-0.1.0-1.0.0.php +2 -2
  35. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-0.3.0-1.0.0.php +10 -10
  36. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-1.0.0-1.5.2.php +10 -10
  37. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.1.3-2.2.0.php +24 -24
  38. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.2.0-2.3.0.php +47 -0
  39. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.2.1-2.3.0.php +47 -0
  40. app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.0-2.3.1.php +14 -0
  41. app/design/adminhtml/default/default/layout/mailup.xml +14 -1
  42. app/design/adminhtml/default/default/template/sevenlike/mailup/confirm.phtml +194 -181
  43. app/design/adminhtml/default/default/template/sevenlike/mailup/fieldsmapping.phtml +60 -54
  44. app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml +526 -497
  45. app/design/adminhtml/default/default/template/sevenlike/mailup/filter_.phtml +526 -0
  46. app/design/adminhtml/default/default/template/sevenlike/mailup/viewdatatransferlog.phtml +71 -71
  47. app/design/frontend/base/default/layout/mailup.xml +8 -0
  48. app/design/frontend/base/default/template/mailup/subscribe.phtml +39 -0
  49. app/design/frontend/enterprise/default/layout/mailup.xml +8 -0
  50. app/design/frontend/enterprise/default/template/mailup/subscribe.phtml +39 -0
  51. package.xml +50 -95
  52. skin/adminhtml/default/default/sevenlike/mailup/images/MailUp_300_200_transparent_small.png +0 -0
  53. skin/adminhtml/default/default/sevenlike/mailup/mailup.css +1 -21
app/code/local/SevenLike/MailUp/Block/.DS_Store DELETED
Binary file
app/code/local/SevenLike/MailUp/Block/Filters.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Filters.php
4
+ *
5
+ * Adminhtml block for the filters section
6
+ */
7
+ class SevenLike_MailUp_Block_Filters extends Mage_Core_Block_Template
8
+ {
9
+ public function _toHtml()
10
+ {
11
+ return parent::_toHtml();
12
+ }
13
+
14
+ /**
15
+ * Get an array of all stores
16
+ *
17
+ * @return array
18
+ */
19
+ protected function _getStoresArray()
20
+ {
21
+ $config = Mage::getModel('mailup/config');
22
+ /* @var $config SevenLike_Mailup_Model_Config */
23
+ return $config->getStoreArray();
24
+ }
25
+ }
app/code/local/SevenLike/MailUp/Helper/.DS_Store DELETED
Binary file
app/code/local/SevenLike/MailUp/Helper/Data.php CHANGED
@@ -1,447 +1,603 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
4
- {
5
- public static function getCustomersData($customerCollection = null)
6
- {
7
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Getting customers data', 0);
8
- $dateFormat = 'm/d/y h:i:s';
9
- $lastDateTime = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-7*3600*24);
10
- $thirtyDaysAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-30*3600*24);
11
- $twelveMonthsAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-365*3600*24);
12
-
13
- $parseSubscribers = false;
14
- $toSend = array();
15
- if ($customerCollection === null) {
16
- $customerCollection = Mage::getModel('customer/customer')->getCollection();
17
- $parseSubscribers = true;
18
- }
19
- foreach ($customerCollection as $currentCustomerId) {
20
- if (is_object($currentCustomerId)) {
21
- $currentCustomerId = $currentCustomerId->getId();
22
- }
23
-
24
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Customer with id '.$currentCustomerId, 0);
25
- $customer = Mage::getModel('customer/customer')->load($currentCustomerId);
26
- $i = $customer->getEmail();
27
-
28
- //recupero gli ordini del cliente corrente
29
- $allOrdersTotalAmount = 0;
30
- $allOrdersDateTimes = array();
31
- $allOrdersTotals = array();
32
- $allOrdersIds = array();
33
- $allProductsIds = array();
34
- $last30daysOrdersAmount = 0;
35
- $last12monthsOrdersAmount = 0;
36
- $lastShipmentOrderId = null;
37
- $lastShipmentOrderDate = null;
38
-
39
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Parsing orders of customer with id '.$currentCustomerId, 0);
40
- $orders = Mage::getModel('sales/order')
41
- ->getCollection()
42
- ->addAttributeToFilter('customer_id', $currentCustomerId);
43
- foreach ($orders as $order) {
44
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("ORDINE IN STATUS: " . $order->getStatus());
45
- if (!in_array($order->getStatus(), array("closed", "complete", "processing"))) continue;
46
- $currentOrderTotal = floatval($order->getGrandTotal());
47
- $allOrdersTotalAmount += $currentOrderTotal;
48
-
49
- $currentOrderCreationDate = $order->getCreatedAt();
50
- if ($currentOrderCreationDate > $thirtyDaysAgo) {
51
- $last30daysOrdersAmount += $currentOrderTotal;
52
-
53
- }
54
- if ($currentOrderCreationDate > $twelveMonthsAgo) {
55
- $last12monthsOrdersAmount += $currentOrderTotal;
56
- }
57
-
58
- $currentOrderTotal = self::_formatPrice($currentOrderTotal);
59
-
60
- $currentOrderId = $order->getIncrementId();
61
- $allOrdersTotals[$currentOrderId] = $currentOrderTotal;
62
- $allOrdersDateTimes[$currentOrderId] = $currentOrderCreationDate;
63
- $allOrdersIds[$currentOrderId] = $currentOrderId;
64
-
65
- if ($order->hasShipments() and ($order->getId()>$lastShipmentOrderId)) {
66
- $lastShipmentOrderId = $order->getId();
67
- $lastShipmentOrderDate = self::_retriveDateFromDatetime($order->getCreatedAt());
68
- }
69
-
70
- $items = $order->getAllItems();
71
- foreach ($items as $item) {
72
- $allProductsIds[] = $item->getProductId();
73
- }
74
- }
75
-
76
- $toSend[$i]['TotaleFatturatoUltimi30gg'] = self::_formatPrice($last30daysOrdersAmount);
77
- $toSend[$i]['TotaleFatturatoUltimi12Mesi'] = self::_formatPrice($last12monthsOrdersAmount);
78
- $toSend[$i]['IDTuttiProdottiAcquistati'] = implode(',', $allProductsIds);
79
-
80
- ksort($allOrdersDateTimes);
81
- ksort($allOrdersTotals);
82
- ksort($allOrdersIds);
83
-
84
- //recupero i carrelli abbandonati del cliente
85
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Parsing abandoned carts of customer with id '.$currentCustomerId, 0);
86
- $cartCollection = Mage::getResourceModel('reports/quote_collection');
87
- $cartCollection->prepareForAbandonedReport(array(1));
88
- $cartCollection->addFieldToFilter('customer_id', $currentCustomerId);
89
- $cartCollection->load();
90
-
91
- $datetimeCart = null;
92
- if (! empty($cartCollection)) {
93
- $lastCart = end($cartCollection);
94
-
95
- $toSend[$i]['TotaleCarrelloAbbandonato'] = '';
96
- $toSend[$i]['DataCarrelloAbbandonato'] = '';
97
- $toSend[$i]['IDCarrelloAbbandonato'] = '';
98
-
99
- if (! empty($lastCart)) {
100
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Customer with id '.$currentCustomerId .' has abandoned cart', 0);
101
- $datetimeCart = $lastCart->getUpdatedAt();
102
- $toSend[$i]['TotaleCarrelloAbbandonato'] = self::_formatPrice($lastCart->getGrandTotal());
103
- $toSend[$i]['DataCarrelloAbbandonato'] = self::_retriveDateFromDatetime($datetimeCart);
104
- $toSend[$i]['IDCarrelloAbbandonato'] = $lastCart->getId();
105
- }
106
- }
107
-
108
- $toSend[$i]['IDUltimoOrdineSpedito'] = $lastShipmentOrderId;
109
- $toSend[$i]['DataUltimoOrdineSpedito'] = $lastShipmentOrderDate;
110
-
111
- $lastOrderDateTime = end($allOrdersDateTimes);
112
-
113
- if ($customer->getUpdatedAt() > $lastDateTime
114
- || $lastOrderDateTime > $lastDateTime
115
- || ($datetimeCart && $datetimeCart > $lastDateTime))
116
- {
117
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Adding customer with id '.$currentCustomerId, 0);
118
-
119
- $toSend[$i]['nome'] = $customer->getFirstname();
120
- $toSend[$i]['cognome'] = $customer->getLastname();
121
- $toSend[$i]['email'] = $customer->getEmail();
122
- $toSend[$i]['IDCliente'] = $currentCustomerId;
123
-
124
- $toSend[$i]['registeredDate'] = self::_retriveDateFromDatetime($customer->getCreatedAt());
125
-
126
- //controllo se iscritto o meno alla newsletter
127
- if (Mage::getModel('newsletter/subscriber')->loadByCustomer($customer)->isSubscribed()) {
128
- $toSend[$i]['subscribed'] = 'yes';
129
- } else {
130
- $toSend[$i]['subscribed'] = 'no';
131
- }
132
-
133
- //recupero i dati dal default billing address
134
- $customerAddressId = $customer->getDefaultBilling();
135
- if ($customerAddressId) {
136
- $address = Mage::getModel('customer/address')->load($customerAddressId);
137
- $toSend[$i]['azienda'] = $address->getData('company');
138
- $toSend[$i]['paese'] = $address->getCountry();
139
- $toSend[$i]['città'] = $address->getData('city');
140
- $toSend[$i]['regione'] = $address->getData('region');
141
- $regionId = $address->getData('region_id');
142
- $regionModel = Mage::getModel('directory/region')->load($regionId);
143
- $regionCode = $regionModel->getCode();
144
- $toSend[$i]['provincia'] = $regionCode;
145
- $toSend[$i]['cap'] = $address->getData('postcode');
146
- $toSend[$i]['indirizzo'] = $address->getData('street');
147
- $toSend[$i]['fax'] = $address->getData('fax');
148
- $toSend[$i]['telefono'] = $address->getData('telephone');
149
- }
150
-
151
- $toSend[$i]['DataUltimoOrdine'] = self::_retriveDateFromDatetime($lastOrderDateTime);
152
- $toSend[$i]['TotaleUltimoOrdine'] = end($allOrdersTotals);
153
- $toSend[$i]['IDUltimoOrdine'] = end($allOrdersIds);
154
-
155
- $toSend[$i]['TotaleFatturato'] = self::_formatPrice($allOrdersTotalAmount);
156
-
157
- //ottengo gli id di prodotti e categorie (dell'ultimo ordine)
158
- $lastOrder = Mage::getModel('sales/order')->loadByIncrementId(end($allOrdersIds));
159
- $items = $lastOrder->getAllItems();
160
- $productIds = array();
161
- $categoryIds = array();
162
- foreach ($items as $item) {
163
- $productId = $item->getProductId();
164
- $productIds[] = $productId;
165
- $product = Mage::getModel('catalog/product')->load($productId);
166
- if ($product->getCategoryIds()) {
167
- $categoryIds[] = implode(',', $product->getCategoryIds());
168
- }
169
- }
170
-
171
- $toSend[$i]['IDProdottiUltimoOrdine'] = implode(',', $productIds);
172
- if ($toSend[$i]['IDProdottiUltimoOrdine']) $toSend[$i]['IDProdottiUltimoOrdine'] = ",{$toSend[$i]['IDProdottiUltimoOrdine']},";
173
- $toSend[$i]['IDCategorieUltimoOrdine'] = implode(',', $categoryIds);
174
- if ($toSend[$i]['IDCategorieUltimoOrdine']) $toSend[$i]['IDCategorieUltimoOrdine'] = ",{$toSend[$i]['IDCategorieUltimoOrdine']},";
175
- }
176
-
177
- //unsetto la variabile
178
- unset($customer);
179
- }
180
-
181
- /*
182
- * disabled cause useless in segmentation
183
- if ($parseSubscribers) {
184
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Parsing subscribers', 0);
185
- $subscriberCollection = Mage::getModel('newsletter/subscriber')
186
- ->getCollection()
187
- ->useOnlySubscribed()
188
- ->addFieldToFilter('customer_id', 0);
189
-
190
- foreach ($subscriberCollection as $subscriber) {
191
- $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriber->getId());
192
- $i = $subscriber->getEmail();
193
- if (strlen($i)) continue;
194
- if (isset($toSend[$i])) continue;
195
- $toSend[$i]['nome'] = '';
196
- $toSend[$i]['cognome'] = '';
197
- $toSend[$i]['email'] = $i;
198
- $toSend[$i]['subscribed'] = 'yes';
199
- }
200
- }
201
- */
202
-
203
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('End getting customers data', 0);
204
- return $toSend;
205
- }
206
-
207
- public static function generateAndSendCustomers($mailupCustomerIds, $post = null, $newsletter_subscribers = null)
208
- {
209
- $wsSend = new MailUpWsSend();
210
- require_once dirname(__FILE__) . "/../Model/MailUpWsImport.php";
211
- $wsImport = new MailUpWsImport();
212
- $accessKey = $wsSend->loginFromId();
213
-
214
- if (empty($mailupCustomerIds)) return false;
215
- if ($post === null) {
216
- // chiamata da cron, popolo con i dati del gruppo "magento" di default
217
- $post['mailupNewGroup'] = 0;
218
- $post['mailupIdList'] = Mage::getStoreConfig('newsletter/mailup/list');
219
-
220
- $tmp = new SevenLike_MailUp_Model_Lists;
221
- $tmp = $tmp->toOptionArray();
222
- foreach ($tmp as $t) {
223
- if ($t["value"] == $post['mailupIdList']) {
224
- $post['mailupListGUID'] = $t["guid"];
225
- $post["groups"] = $t["groups"];
226
- break;
227
- }
228
- }
229
- unset($tmp); unset($t);
230
-
231
- $post['mailupGroupId'] = "";
232
- foreach ($post["groups"] as $tmp_id_group=>$tmp_group_name) {
233
- if ($tmp_group_name == "MAGENTO") {
234
- $post['mailupGroupId'] = $tmp_id_group;
235
- break;
236
- }
237
- }
238
- unset($tmp_id_group); unset($tmp_group_name);
239
-
240
- if (!strlen($post['mailupGroupId'])) {
241
- $newGroup = array(
242
- "idList" => $post['mailupIdList'],
243
- "listGUID" => $post['mailupListGUID'],
244
- "newGroupName" => "MAGENTO"
245
- );
246
-
247
- $post['mailupGroupId'] = $wsImport->CreaGruppo($newGroup);
248
- }
249
- }
250
-
251
- if ($accessKey === false) {
252
- Mage::throwException('no access key returned');
253
- }
254
- $fields = $wsSend->GetFields($accessKey);
255
- $fields_mapping = $wsImport->getFieldsMapping();
256
-
257
- //definisco il gruppo a cui aggiungere gli iscritti
258
- $groupId = $post['mailupGroupId'];
259
- $listGUID = $post['mailupListGUID'];
260
- $idList = $post['mailupIdList'];
261
-
262
- if ($post['mailupNewGroup'] == 1) {
263
- $newGroup = array(
264
- "idList" => $idList,
265
- "listGUID" => $listGUID,
266
- "newGroupName" => $post['mailupNewGroupName']
267
- );
268
-
269
- $groupId = $wsImport->CreaGruppo($newGroup);
270
- }
271
-
272
- if (isset($post["send_optin_email_to_new_subscribers"]) and $post["send_optin_email_to_new_subscribers"]) {
273
- $importProcessData = array(
274
- "idList" => $idList,
275
- "listGUID" => $listGUID,
276
- "idGroup" => $groupId,
277
- "xmlDoc" => "",
278
- "idGroups" => $groupId,
279
- "importType" => 1,
280
- "mobileInputType" => 2,
281
- "asPending" => false,
282
- "ConfirmEmail" => true,
283
- "asOptOut" => false,
284
- "forceOptIn" => false,
285
- "replaceGroups" => false,
286
- "idConfirmNL" => 0
287
- );
288
- } else {
289
- $importProcessData = array(
290
- "idList" => $idList,
291
- "listGUID" => $listGUID,
292
- "idGroup" => $groupId,
293
- "xmlDoc" => "",
294
- "idGroups" => $groupId,
295
- "importType" => 1,
296
- "mobileInputType" => 2,
297
- "asPending" => false,
298
- "ConfirmEmail" => false,
299
- "asOptOut" => false,
300
- "forceOptIn" => false,
301
- "replaceGroups" => false,
302
- "idConfirmNL" => 0
303
- );
304
- }
305
-
306
- //preparo l'xml degli iscritti da inviare a mailup (da gestire in base ai filtri)
307
- $xmlData = '';
308
- $subscribers_counter = 0;
309
- $total_subscribers_to_send = sizeof($mailupCustomerIds);
310
- foreach ($mailupCustomerIds as $customerId) {
311
- $tmp = array();
312
- $subscribers_counter++;
313
- $subscriber = self::getCustomersData(array($customerId));
314
- $subscriber = array_values($subscriber);
315
- $subscriber = $subscriber[0];
316
-
317
- $subscriber["DataCarrelloAbbandonato"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataCarrelloAbbandonato"]);
318
- $subscriber["DataUltimoOrdineSpedito"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataUltimoOrdineSpedito"]);
319
- $subscriber["registeredDate"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["registeredDate"]);
320
- $subscriber["DataUltimoOrdine"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataUltimoOrdine"]);
321
-
322
- $xmlData .= '<subscriber email="'.$subscriber['email'].'" Number="" Name="">';
323
-
324
- if (@$fields_mapping["Name"]) $tmp[$fields_mapping["Name"]] = '<campo'.$fields_mapping["Name"].'>'. ((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') .'</campo'.$fields_mapping["Name"].'>';
325
- if (@$fields_mapping["Last"]) $tmp[$fields_mapping["Last"]] = '<campo'.$fields_mapping["Last"].'>'. ((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') .'</campo'.$fields_mapping["Last"].'>';
326
-
327
- foreach ($subscriber as $k=>$v) {
328
- if (!strlen($subscriber[$k])) {
329
- $subscriber[$k] = "-";
330
- } else {
331
- $subscriber[$k] = str_replace(array("\r\n", "\r", "\n"), " ", $v);
332
- }
333
- }
334
-
335
- if (@$fields_mapping["Company"]) $tmp[$fields_mapping["Company"]] = '<campo'.$fields_mapping["Company"].'>'. $subscriber['azienda'] .'</campo'.$fields_mapping["Company"].'>';
336
- if (@$fields_mapping["City"]) $tmp[$fields_mapping["City"]] = '<campo'.$fields_mapping["City"].'>'. $subscriber['città'] .'</campo'.$fields_mapping["City"].'>';
337
- if (@$fields_mapping["Province"]) $tmp[$fields_mapping["Province"]] = '<campo'.$fields_mapping["Province"].'>'. $subscriber['provincia'] .'</campo'.$fields_mapping["Province"].'>';
338
- if (@$fields_mapping["ZIP"]) $tmp[$fields_mapping["ZIP"]] = '<campo'.$fields_mapping["ZIP"].'>'. $subscriber['cap'].'</campo'.$fields_mapping["ZIP"].'>';
339
- if (@$fields_mapping["Region"]) $tmp[$fields_mapping["Region"]] = '<campo'.$fields_mapping["Region"].'>'. $subscriber['regione'] .'</campo'.$fields_mapping["Region"].'>';
340
- if (@$fields_mapping["Country"]) $tmp[$fields_mapping["Country"]] = '<campo'.$fields_mapping["Country"].'>'. $subscriber['paese'] .'</campo'.$fields_mapping["Country"].'>';
341
- if (@$fields_mapping["Address"]) $tmp[$fields_mapping["Address"]] = '<campo'.$fields_mapping["Address"].'>'. $subscriber['indirizzo'] .'</campo'.$fields_mapping["Address"].'>';
342
- if (@$fields_mapping["Fax"]) $tmp[$fields_mapping["Fax"]] = '<campo'.$fields_mapping["Fax"].'>'. $subscriber['fax'] .'</campo'.$fields_mapping["Fax"].'>';
343
- if (@$fields_mapping["Phone"]) $tmp[$fields_mapping["Phone"]] = '<campo'.$fields_mapping["Phone"].'>'. $subscriber['telefono'] .'</campo'.$fields_mapping["Phone"].'>';
344
- if (@$fields_mapping["CustomerID"]) $tmp[$fields_mapping["CustomerID"]] = '<campo'.$fields_mapping["CustomerID"].'>'. $subscriber['IDCliente'] .'</campo'.$fields_mapping["CustomerID"].'>';
345
- if (@$fields_mapping["LatestOrderID"]) $tmp[$fields_mapping["LatestOrderID"]] = '<campo'.$fields_mapping["LatestOrderID"].'>'. $subscriber['IDUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderID"].'>';
346
- if (@$fields_mapping["LatestOrderDate"]) $tmp[$fields_mapping["LatestOrderDate"]] = '<campo'.$fields_mapping["LatestOrderDate"].'>'. $subscriber['DataUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderDate"].'>';
347
- if (@$fields_mapping["LatestOrderAmount"]) $tmp[$fields_mapping["LatestOrderAmount"]] = '<campo'.$fields_mapping["LatestOrderAmount"].'>'. $subscriber['TotaleUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderAmount"].'>';
348
- if (@$fields_mapping["LatestOrderProductIDs"]) $tmp[$fields_mapping["LatestOrderProductIDs"]] = '<campo'.$fields_mapping["LatestOrderProductIDs"].'>'. $subscriber['IDProdottiUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderProductIDs"].'>';
349
- if (@$fields_mapping["LatestOrderCategoryIDs"]) $tmp[$fields_mapping["LatestOrderCategoryIDs"]] = '<campo'.$fields_mapping["LatestOrderCategoryIDs"].'>'. $subscriber['IDCategorieUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderCategoryIDs"].'>';
350
- if (@$fields_mapping["LatestShippedOrderDate"]) $tmp[$fields_mapping["LatestShippedOrderDate"]] = '<campo'.$fields_mapping["LatestShippedOrderDate"].'>'. $subscriber['DataUltimoOrdineSpedito'] .'</campo'.$fields_mapping["LatestShippedOrderDate"].'>';
351
- if (@$fields_mapping["LatestShippedOrderID"]) $tmp[$fields_mapping["LatestShippedOrderID"]] = '<campo'.$fields_mapping["LatestShippedOrderID"].'>'. $subscriber['IDUltimoOrdineSpedito'] .'</campo'.$fields_mapping["LatestShippedOrderID"].'>';
352
- if (@$fields_mapping["LatestAbandonedCartDate"]) $tmp[$fields_mapping["LatestAbandonedCartDate"]] = '<campo'.$fields_mapping["LatestAbandonedCartDate"].'>'. $subscriber['DataCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartDate"].'>';
353
- if (@$fields_mapping["LatestAbandonedCartTotal"]) $tmp[$fields_mapping["LatestAbandonedCartTotal"]] = '<campo'.$fields_mapping["LatestAbandonedCartTotal"].'>'. $subscriber['TotaleCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartTotal"].'>';
354
- if (@$fields_mapping["LatestAbandonedCartID"]) $tmp[$fields_mapping["LatestAbandonedCartID"]] = '<campo'.$fields_mapping["LatestAbandonedCartID"].'>'. $subscriber['IDCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartID"].'>';
355
- if (@$fields_mapping["TotalOrdered"]) $tmp[$fields_mapping["TotalOrdered"]] = '<campo'.$fields_mapping["TotalOrdered"].'>'. $subscriber['TotaleFatturato'] .'</campo'.$fields_mapping["TotalOrdered"].'>';
356
- if (@$fields_mapping["TotalOrderedLast12m"]) $tmp[$fields_mapping["TotalOrderedLast12m"]] = '<campo'.$fields_mapping["TotalOrderedLast12m"].'>'. $subscriber['TotaleFatturatoUltimi12Mesi'] .'</campo'.$fields_mapping["TotalOrderedLast12m"].'>';
357
- if (@$fields_mapping["TotalOrderedLast30d"]) $tmp[$fields_mapping["TotalOrderedLast30d"]] = '<campo'.$fields_mapping["TotalOrderedLast30d"].'>'. $subscriber['TotaleFatturatoUltimi30gg'] .'</campo'.$fields_mapping["TotalOrderedLast30d"].'>';
358
- if (@$fields_mapping["AllOrderedProductIDs"]) $tmp[$fields_mapping["AllOrderedProductIDs"]] = '<campo'.$fields_mapping["AllOrderedProductIDs"].'>'. $subscriber['IDTuttiProdottiAcquistati'] .'</campo'.$fields_mapping["AllOrderedProductIDs"].'>';
359
-
360
- $last_field = max(array_keys($tmp));
361
- for ($i=1; $i<$last_field; $i++) {
362
- if (!isset($tmp[$i])) $tmp[$i] = "<campo{$i}>-</campo{$i}>";
363
- }
364
- ksort($tmp);
365
- $tmp = implode("", $tmp);
366
- $xmlData .= $tmp;
367
- $xmlData .= "</subscriber>\n";
368
-
369
- // ogni 5000 utenti invio i dati
370
- if ($subscribers_counter == 5000) {
371
- $importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
372
- $xmlData = "";
373
- $subscribers_counter = 0;
374
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($importProcessData, 0);
375
- $processID = $wsImport->newImportProcess($importProcessData);
376
- if ($processID === false) return false;
377
- }
378
- }
379
-
380
- //invio gli ultimi utenti
381
- if (strlen($xmlData)) {
382
- $importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
383
- $xmlData = "";
384
- $subscribers_counter = 0;
385
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($importProcessData, 0);
386
- $processID = $wsImport->newImportProcess($importProcessData);
387
- if ($processID === false) return false;
388
- }
389
-
390
- if (isset($newsletter_subscribers) and is_array($newsletter_subscribers) and !empty($newsletter_subscribers)) {
391
- $subscribers_counter = 0;
392
- foreach ($newsletter_subscribers as $newsletter_subscriber) {
393
- $subscribers_counter++;
394
- $xmlData .= '<subscriber email="' . $newsletter_subscriber . '" Number="" Name=""></subscriber>';
395
- if ($subscribers_counter == 5000 or $subscribers_counter == $total_subscribers_to_send) {
396
- $importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
397
- $xmlData = "";
398
- $subscribers_counter = 0;
399
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($importProcessData, 0);
400
- $processID = $wsImport->newImportProcess($importProcessData);
401
- if ($processID === false) return false;
402
- }
403
- }
404
- }
405
-
406
- //avvio l'importazione su mailup
407
- unset($importProcessData["xmlDoc"]);
408
- $importProcessData["listsIDs"] = $post['mailupIdList'];
409
- $importProcessData["listsGUIDs"] = $post['mailupListGUID'];
410
- $importProcessData["groupsIDs"] = $groupId;
411
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("mailup: StartImportProcesses", 0);
412
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($importProcessData, 0);
413
- $check = $wsImport->StartImportProcesses($importProcessData);
414
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($check, 0);
415
- return $check;
416
- }
417
-
418
- private static function _formatPrice($price) {
419
- return number_format($price, 2, ',', '');
420
- }
421
-
422
- private static function _retriveDateFromDatetime($datetime) {
423
- if (empty($datetime)) return "";
424
- return date("Y-m-d H:i:s", strtotime($datetime));
425
- }
426
-
427
- public static function _convertUTCToStoreTimezone($datetime)
428
- {
429
- if (empty($datetime)) return "";
430
-
431
- $TIMEZONE_STORE = new DateTimeZone(Mage::getStoreConfig("general/locale/timezone"));
432
- $TIMEZONE_UTC = new DateTimeZone("UTC");
433
-
434
- $datetime = new DateTime($datetime, $TIMEZONE_UTC);
435
- $datetime->setTimezone($TIMEZONE_STORE);
436
- $datetime = (string)$datetime->format("Y-m-d H:i:s");
437
-
438
- return $datetime;
439
- }
440
-
441
- public static function _convertUTCToStoreTimezoneAndFormatForMailup($datetime)
442
- {
443
- if (empty($datetime)) return "";
444
- $datetime = self::_convertUTCToStoreTimezone($datetime);
445
- return date("d/m/Y", strtotime($datetime));
446
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public static function getCustomersData($customerCollection = null)
6
+ {
7
+ $config = Mage::getModel('mailup/config');
8
+ /* @var $config SevenLike_Mailup_Model_Config */
9
+
10
+ if ($config->isLogEnabled()) {
11
+ Mage::log('Getting customers data', 0);
12
+ }
13
+
14
+ if(is_array($customerCollection) && empty($customerCollection)) {
15
+ if ($config->isLogEnabled()) {
16
+ Mage::log('CustomerCollection is Empty!');
17
+ }
18
+ }
19
+
20
+ $dateFormat = 'm/d/y h:i:s';
21
+ $lastDateTime = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-7*3600*24);
22
+ $thirtyDaysAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-30*3600*24);
23
+ $twelveMonthsAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-365*3600*24);
24
+
25
+ $parseSubscribers = false;
26
+ $toSend = array();
27
+ if ($customerCollection === null) {
28
+ /**
29
+ * @todo Change to only load form current store/website
30
+ */
31
+ $customerCollection = Mage::getModel('customer/customer')->getCollection();
32
+ $parseSubscribers = true;
33
+ if ($config->isLogEnabled()) {
34
+ Mage::log('Parsing Subscribers, NULL collection passed.');
35
+ }
36
+ }
37
+ foreach ($customerCollection as $currentCustomerId) {
38
+ if (is_object($currentCustomerId)) {
39
+ $currentCustomerId = $currentCustomerId->getId();
40
+ }
41
+
42
+ if( ! $currentCustomerId) {
43
+ if($config->isLogEnabled()) {
44
+ Mage::log('Skipping Empty Customer ID!');
45
+ continue;
46
+ }
47
+ }
48
+
49
+ if($config->isLogEnabled()) {
50
+ Mage::log('Customer with id '.$currentCustomerId, 0);
51
+ }
52
+ $customer = Mage::getModel('customer/customer')->load($currentCustomerId);
53
+ $i = $customer->getEmail();
54
+
55
+ //recupero gli ordini del cliente corrente
56
+ $allOrdersTotalAmount = 0;
57
+ $allOrdersDateTimes = array();
58
+ $allOrdersTotals = array();
59
+ $allOrdersIds = array();
60
+ $allProductsIds = array();
61
+ $last30daysOrdersAmount = 0;
62
+ $last12monthsOrdersAmount = 0;
63
+ $lastShipmentOrderId = null;
64
+ $lastShipmentOrderDate = null;
65
+
66
+ if($config->isLogEnabled()) {
67
+ Mage::log('Parsing orders of customer with id '.$currentCustomerId, 0);
68
+ }
69
+ $orders = Mage::getModel('sales/order')
70
+ ->getCollection()
71
+ ->addAttributeToFilter('customer_id', $currentCustomerId)
72
+ ;
73
+ foreach($orders as $order) {
74
+ if($config->isLogEnabled()) {
75
+ Mage::log("ORDINE IN STATUS: " . $order->getStatus());
76
+ }
77
+ if( ! in_array($order->getStatus(), array("closed", "complete", "processing"))) {
78
+ continue;
79
+ }
80
+ $currentOrderTotal = floatval($order->getGrandTotal());
81
+ $allOrdersTotalAmount += $currentOrderTotal;
82
+
83
+ $currentOrderCreationDate = $order->getCreatedAt();
84
+ if ($currentOrderCreationDate > $thirtyDaysAgo) {
85
+ $last30daysOrdersAmount += $currentOrderTotal;
86
+
87
+ }
88
+ if ($currentOrderCreationDate > $twelveMonthsAgo) {
89
+ $last12monthsOrdersAmount += $currentOrderTotal;
90
+ }
91
+
92
+ $currentOrderTotal = self::_formatPrice($currentOrderTotal);
93
+
94
+ $currentOrderId = $order->getIncrementId();
95
+ $allOrdersTotals[$currentOrderId] = $currentOrderTotal;
96
+ $allOrdersDateTimes[$currentOrderId] = $currentOrderCreationDate;
97
+ $allOrdersIds[$currentOrderId] = $currentOrderId;
98
+
99
+ if ($order->hasShipments() and ($order->getId()>$lastShipmentOrderId)) {
100
+ $lastShipmentOrderId = $order->getId();
101
+ $lastShipmentOrderDate = self::_retriveDateFromDatetime($order->getCreatedAt());
102
+ }
103
+
104
+ $items = $order->getAllItems();
105
+ foreach ($items as $item) {
106
+ $allProductsIds[] = $item->getProductId();
107
+ }
108
+ }
109
+
110
+ $toSend[$i]['TotaleFatturatoUltimi30gg'] = self::_formatPrice($last30daysOrdersAmount);
111
+ $toSend[$i]['TotaleFatturatoUltimi12Mesi'] = self::_formatPrice($last12monthsOrdersAmount);
112
+ $toSend[$i]['IDTuttiProdottiAcquistati'] = implode(',', $allProductsIds);
113
+
114
+ ksort($allOrdersDateTimes);
115
+ ksort($allOrdersTotals);
116
+ ksort($allOrdersIds);
117
+
118
+ //recupero i carrelli abbandonati del cliente
119
+ if($config->isLogEnabled()) {
120
+ Mage::log('Parsing abandoned carts of customer with id '.$currentCustomerId, 0);
121
+ }
122
+ $cartCollection = Mage::getResourceModel('reports/quote_collection');
123
+ $cartCollection->prepareForAbandonedReport($config->getAllStoreIds());
124
+ $cartCollection->addFieldToFilter('customer_id', $currentCustomerId);
125
+ $cartCollection->load();
126
+
127
+ $datetimeCart = null;
128
+ if ( ! empty($cartCollection)) {
129
+ $lastCart = $cartCollection->getLastItem();
130
+ $toSend[$i]['TotaleCarrelloAbbandonato'] = '';
131
+ $toSend[$i]['DataCarrelloAbbandonato'] = '';
132
+ $toSend[$i]['IDCarrelloAbbandonato'] = '';
133
+
134
+ if ( ! empty($lastCart)) {
135
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
136
+ Mage::log('Customer with id '.$currentCustomerId .' has abandoned cart', 0);
137
+ }
138
+ $datetimeCart = $lastCart->getUpdatedAt();
139
+ //$toSend[$i]['TotaleCarrelloAbbandonato'] = self::_formatPrice($lastCart->getGrandTotal());
140
+ $toSend[$i]['TotaleCarrelloAbbandonato'] = self::_formatPrice($lastCart->getSubtotal());
141
+ $toSend[$i]['DataCarrelloAbbandonato'] = self::_retriveDateFromDatetime($datetimeCart);
142
+ $toSend[$i]['IDCarrelloAbbandonato'] = $lastCart->getId();
143
+ }
144
+ else {
145
+ if ($config->isLogEnabled()) {
146
+ Mage::log('Customer with id '.$currentCustomerId .' has empty LAST CART', 0);
147
+ }
148
+ }
149
+ }
150
+ else {
151
+ if ($config->isLogEnabled()) {
152
+ Mage::log('Customer id '.$currentCustomerId .' has empty abandoned cart collection', 0);
153
+ }
154
+ }
155
+
156
+ $toSend[$i]['IDUltimoOrdineSpedito'] = $lastShipmentOrderId;
157
+ $toSend[$i]['DataUltimoOrdineSpedito'] = $lastShipmentOrderDate;
158
+
159
+ $lastOrderDateTime = end($allOrdersDateTimes);
160
+
161
+ if ($customer->getUpdatedAt() > $lastDateTime
162
+ || $lastOrderDateTime > $lastDateTime
163
+ || ($datetimeCart && $datetimeCart > $lastDateTime))
164
+ {
165
+ if ($config->isLogEnabled()) {
166
+ Mage::log('Adding customer with id '.$currentCustomerId, 0);
167
+ }
168
+
169
+ $toSend[$i]['nome'] = $customer->getFirstname();
170
+ $toSend[$i]['cognome'] = $customer->getLastname();
171
+ $toSend[$i]['email'] = $customer->getEmail();
172
+ $toSend[$i]['IDCliente'] = $currentCustomerId;
173
+
174
+ $toSend[$i]['registeredDate'] = self::_retriveDateFromDatetime($customer->getCreatedAt());
175
+
176
+ //controllo se iscritto o meno alla newsletter
177
+ if (Mage::getModel('newsletter/subscriber')->loadByCustomer($customer)->isSubscribed()) {
178
+ $toSend[$i]['subscribed'] = 'yes';
179
+ }
180
+ else {
181
+ $toSend[$i]['subscribed'] = 'no';
182
+ }
183
+
184
+ //recupero i dati dal default billing address
185
+ $customerAddressId = $customer->getDefaultBilling();
186
+ if ($customerAddressId) {
187
+ $address = Mage::getModel('customer/address')->load($customerAddressId);
188
+ $toSend[$i]['azienda'] = $address->getData('company');
189
+ $toSend[$i]['paese'] = $address->getCountry();
190
+ $toSend[$i]['città'] = $address->getData('city');
191
+ $toSend[$i]['regione'] = $address->getData('region');
192
+ $regionId = $address->getData('region_id');
193
+ $regionModel = Mage::getModel('directory/region')->load($regionId);
194
+ $regionCode = $regionModel->getCode();
195
+ $toSend[$i]['provincia'] = $regionCode;
196
+ $toSend[$i]['cap'] = $address->getData('postcode');
197
+ $toSend[$i]['indirizzo'] = $address->getData('street');
198
+ $toSend[$i]['fax'] = $address->getData('fax');
199
+ $toSend[$i]['telefono'] = $address->getData('telephone');
200
+ }
201
+
202
+ $toSend[$i]['DataUltimoOrdine'] = self::_retriveDateFromDatetime($lastOrderDateTime);
203
+ $toSend[$i]['TotaleUltimoOrdine'] = end($allOrdersTotals);
204
+ $toSend[$i]['IDUltimoOrdine'] = end($allOrdersIds);
205
+
206
+ $toSend[$i]['TotaleFatturato'] = self::_formatPrice($allOrdersTotalAmount);
207
+
208
+ //ottengo gli id di prodotti e categorie (dell'ultimo ordine)
209
+ $lastOrder = Mage::getModel('sales/order')->loadByIncrementId(end($allOrdersIds));
210
+ $items = $lastOrder->getAllItems();
211
+ $productIds = array();
212
+ $categoryIds = array();
213
+ foreach ($items as $item) {
214
+ $productId = $item->getProductId();
215
+ $productIds[] = $productId;
216
+ $product = Mage::getModel('catalog/product')->load($productId);
217
+ if ($product->getCategoryIds()) {
218
+ $categoryIds[] = implode(',', $product->getCategoryIds());
219
+ }
220
+ }
221
+
222
+ $toSend[$i]['IDProdottiUltimoOrdine'] = implode(',', $productIds);
223
+ if ($toSend[$i]['IDProdottiUltimoOrdine']) $toSend[$i]['IDProdottiUltimoOrdine'] = ",{$toSend[$i]['IDProdottiUltimoOrdine']},";
224
+ $toSend[$i]['IDCategorieUltimoOrdine'] = implode(',', $categoryIds);
225
+ if ($toSend[$i]['IDCategorieUltimoOrdine']) $toSend[$i]['IDCategorieUltimoOrdine'] = ",{$toSend[$i]['IDCategorieUltimoOrdine']},";
226
+ }
227
+
228
+ //unsetto la variabile
229
+ unset($customer);
230
+ }
231
+
232
+ /*
233
+ * disabled cause useless in segmentation
234
+ if ($parseSubscribers) {
235
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) Mage::log('Parsing subscribers', 0);
236
+ $subscriberCollection = Mage::getModel('newsletter/subscriber')
237
+ ->getCollection()
238
+ ->useOnlySubscribed()
239
+ ->addFieldToFilter('customer_id', 0);
240
+
241
+ foreach ($subscriberCollection as $subscriber) {
242
+ $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriber->getId());
243
+ $i = $subscriber->getEmail();
244
+ if (strlen($i)) continue;
245
+ if (isset($toSend[$i])) continue;
246
+ $toSend[$i]['nome'] = '';
247
+ $toSend[$i]['cognome'] = '';
248
+ $toSend[$i]['email'] = $i;
249
+ $toSend[$i]['subscribed'] = 'yes';
250
+ }
251
+ }
252
+ */
253
+
254
+ if($config->isLogEnabled()) {
255
+ Mage::log('End getting customers data', 0);
256
+ }
257
+
258
+ return $toSend;
259
+ }
260
+
261
+ /**
262
+ * Sebd Customer Data
263
+ *
264
+ * @param type $mailupCustomerIds
265
+ * @param type $post
266
+ * @param type $newsletter_subscribers
267
+ * @param int
268
+ * @return boolean
269
+ */
270
+ public static function generateAndSendCustomers($mailupCustomerIds, $post = null, $newsletter_subscribers = null, $storeId = NULL)
271
+ {
272
+ $config = Mage::getModel('mailup/config');
273
+ /* @var $config SevenLike_Mailup_Model_Config */
274
+
275
+ $wsSend = new MailUpWsSend($storeId);
276
+ require_once dirname(__FILE__) . "/../Model/MailUpWsImport.php";
277
+ $wsImport = new MailUpWsImport($storeId);
278
+ $accessKey = $wsSend->loginFromId();
279
+
280
+ if (empty($mailupCustomerIds)) {
281
+ if($config->isLogEnabled($storeId)) {
282
+ Mage::log('Empty Customer ID Array');
283
+ }
284
+ return false;
285
+ }
286
+ /**
287
+ * Post EMPTY
288
+ */
289
+ if ($post === NULL) {
290
+ // chiamata da cron, popolo con i dati del gruppo "magento" di default
291
+ $post['mailupNewGroup'] = 0;
292
+ $post['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
293
+
294
+ $tmp = new SevenLike_MailUp_Model_Lists;
295
+ $tmp = $tmp->toOptionArray($storeId); // pass store id!
296
+
297
+ foreach ($tmp as $t) {
298
+ if ($t["value"] == $post['mailupIdList']) {
299
+ $post['mailupListGUID'] = $t["guid"];
300
+ $post["groups"] = $t["groups"];
301
+ break;
302
+ }
303
+ }
304
+
305
+ unset($tmp);
306
+ unset($t);
307
+
308
+ $post['mailupGroupId'] = "";
309
+ foreach ($post["groups"] as $tmp_id_group => $tmp_group_name) {
310
+ if ($tmp_group_name == "MAGENTO") {
311
+ $post['mailupGroupId'] = $tmp_id_group;
312
+ break;
313
+ }
314
+ }
315
+ unset($tmp_id_group); unset($tmp_group_name);
316
+
317
+ if (!strlen($post['mailupGroupId'])) {
318
+ $newGroup = array(
319
+ "idList" => $post['mailupIdList'],
320
+ "listGUID" => $post['mailupListGUID'],
321
+ "newGroupName" => "MAGENTO"
322
+ );
323
+
324
+ $post['mailupGroupId'] = $wsImport->CreaGruppo($newGroup);
325
+ }
326
+ }
327
+
328
+ if ($accessKey === false) {
329
+ Mage::throwException('no access key returned');
330
+ }
331
+
332
+ $fields = $wsSend->GetFields($accessKey);
333
+ $fields_mapping = $wsImport->getFieldsMapping($storeId); // Pass StoreId
334
+
335
+ //definisco il gruppo a cui aggiungere gli iscritti
336
+ $groupId = $post['mailupGroupId'];
337
+ $listGUID = $post['mailupListGUID'];
338
+ $idList = $post['mailupIdList'];
339
+
340
+ if ($post['mailupNewGroup'] == 1) {
341
+ $newGroup = array(
342
+ "idList" => $idList,
343
+ "listGUID" => $listGUID,
344
+ "newGroupName" => $post['mailupNewGroupName']
345
+ );
346
+
347
+ $groupId = $wsImport->CreaGruppo($newGroup);
348
+ }
349
+
350
+ if (isset($post["send_optin_email_to_new_subscribers"]) and $post["send_optin_email_to_new_subscribers"]) {
351
+ $importProcessData = array(
352
+ "idList" => $idList,
353
+ "listGUID" => $listGUID,
354
+ "idGroup" => $groupId,
355
+ "xmlDoc" => "",
356
+ "idGroups" => $groupId,
357
+ "importType" => 1,
358
+ "mobileInputType" => 2,
359
+ "asPending" => 0,
360
+ "ConfirmEmail" => 1,
361
+ "asOptOut" => 0,
362
+ "forceOptIn" => 0, //1,
363
+ "replaceGroups" => 0,
364
+ "idConfirmNL" => 0
365
+ );
366
+ }
367
+ else {
368
+ $importProcessData = array(
369
+ "idList" => $idList,
370
+ "listGUID" => $listGUID,
371
+ "idGroup" => $groupId,
372
+ "xmlDoc" => "",
373
+ "idGroups" => $groupId,
374
+ "importType" => 1,
375
+ "mobileInputType" => 2,
376
+ "asPending" => 0,
377
+ "ConfirmEmail" => 0,
378
+ "asOptOut" => 0,
379
+ "forceOptIn" => 0, //1,
380
+ "replaceGroups" => 0,
381
+ "idConfirmNL" => 0
382
+ );
383
+ }
384
+
385
+ //preparo l'xml degli iscritti da inviare a mailup (da gestire in base ai filtri)
386
+ $xmlData = '';
387
+ $subscribers_counter = 0;
388
+ $total_subscribers_to_send = sizeof($mailupCustomerIds);
389
+ foreach ($mailupCustomerIds as $customerId) {
390
+ $tmp = array();
391
+ $subscribers_counter++;
392
+ $subscriber = self::getCustomersData(array($customerId));
393
+
394
+ if(is_array($subscriber) && empty($subscriber)) {
395
+ if($config->isLogEnabled($storeId)) {
396
+ Mage::log('EMPTY DATA FROM getCustomersData');
397
+ }
398
+ }
399
+
400
+ $subscriber = array_values($subscriber);
401
+ $subscriber = $subscriber[0];
402
+
403
+ $subscriber["DataCarrelloAbbandonato"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataCarrelloAbbandonato"]);
404
+ $subscriber["DataUltimoOrdineSpedito"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataUltimoOrdineSpedito"]);
405
+ $subscriber["registeredDate"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["registeredDate"]);
406
+ $subscriber["DataUltimoOrdine"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataUltimoOrdine"]);
407
+
408
+ $xmlData .= '<subscriber email="'.$subscriber['email'].'" Number="" Name="">';
409
+
410
+ if (@$fields_mapping["Name"]) $tmp[$fields_mapping["Name"]] = '<campo'.$fields_mapping["Name"].'>'."<![CDATA[". ((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') ."]]>".'</campo'.$fields_mapping["Name"].'>';
411
+ if (@$fields_mapping["Last"]) $tmp[$fields_mapping["Last"]] = '<campo'.$fields_mapping["Last"].'>'."<![CDATA[". ((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') ."]]>".'</campo'.$fields_mapping["Last"].'>';
412
+
413
+
414
+ foreach ($subscriber as $k=>$v) {
415
+ if (!strlen($subscriber[$k])) {
416
+ $subscriber[$k] = "-";
417
+ }
418
+ else {
419
+ $subscriber[$k] = str_replace(array("\r\n", "\r", "\n"), " ", $v);
420
+ }
421
+ }
422
+
423
+ if (@$fields_mapping["Company"]) $tmp[$fields_mapping["Company"]] = '<campo'.$fields_mapping["Company"].'>'. "<![CDATA[". $subscriber['azienda'] ."]]>". '</campo'.$fields_mapping["Company"].'>';
424
+ if (@$fields_mapping["City"]) $tmp[$fields_mapping["City"]] = '<campo'.$fields_mapping["City"].'>'. "<![CDATA[" . $subscriber['città'] ."]]>". '</campo'.$fields_mapping["City"].'>';
425
+ if (@$fields_mapping["Province"]) $tmp[$fields_mapping["Province"]] = '<campo'.$fields_mapping["Province"].'>'. "<![CDATA[" . $subscriber['provincia'] ."]]>" . '</campo'.$fields_mapping["Province"].'>';
426
+ if (@$fields_mapping["ZIP"]) $tmp[$fields_mapping["ZIP"]] = '<campo'.$fields_mapping["ZIP"].'>'. $subscriber['cap'].'</campo'.$fields_mapping["ZIP"].'>';
427
+ if (@$fields_mapping["Region"]) $tmp[$fields_mapping["Region"]] = '<campo'.$fields_mapping["Region"].'>'. $subscriber['regione'] .'</campo'.$fields_mapping["Region"].'>';
428
+ if (@$fields_mapping["Country"]) $tmp[$fields_mapping["Country"]] = '<campo'.$fields_mapping["Country"].'>'. $subscriber['paese'] .'</campo'.$fields_mapping["Country"].'>';
429
+ if (@$fields_mapping["Address"]) $tmp[$fields_mapping["Address"]] = '<campo'.$fields_mapping["Address"].'>'."<![CDATA[". $subscriber['indirizzo'] ."]]>" .'</campo'.$fields_mapping["Address"].'>';
430
+ if (@$fields_mapping["Fax"]) $tmp[$fields_mapping["Fax"]] = '<campo'.$fields_mapping["Fax"].'>'. $subscriber['fax'] .'</campo'.$fields_mapping["Fax"].'>';
431
+ if (@$fields_mapping["Phone"]) $tmp[$fields_mapping["Phone"]] = '<campo'.$fields_mapping["Phone"].'>'. $subscriber['telefono'] .'</campo'.$fields_mapping["Phone"].'>';
432
+ if (@$fields_mapping["CustomerID"]) $tmp[$fields_mapping["CustomerID"]] = '<campo'.$fields_mapping["CustomerID"].'>'. $subscriber['IDCliente'] .'</campo'.$fields_mapping["CustomerID"].'>';
433
+ if (@$fields_mapping["LatestOrderID"]) $tmp[$fields_mapping["LatestOrderID"]] = '<campo'.$fields_mapping["LatestOrderID"].'>'. $subscriber['IDUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderID"].'>';
434
+ if (@$fields_mapping["LatestOrderDate"]) $tmp[$fields_mapping["LatestOrderDate"]] = '<campo'.$fields_mapping["LatestOrderDate"].'>'. $subscriber['DataUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderDate"].'>';
435
+ if (@$fields_mapping["LatestOrderAmount"]) $tmp[$fields_mapping["LatestOrderAmount"]] = '<campo'.$fields_mapping["LatestOrderAmount"].'>'. $subscriber['TotaleUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderAmount"].'>';
436
+ if (@$fields_mapping["LatestOrderProductIDs"]) $tmp[$fields_mapping["LatestOrderProductIDs"]] = '<campo'.$fields_mapping["LatestOrderProductIDs"].'>'. $subscriber['IDProdottiUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderProductIDs"].'>';
437
+ if (@$fields_mapping["LatestOrderCategoryIDs"]) $tmp[$fields_mapping["LatestOrderCategoryIDs"]] = '<campo'.$fields_mapping["LatestOrderCategoryIDs"].'>'. $subscriber['IDCategorieUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderCategoryIDs"].'>';
438
+ if (@$fields_mapping["LatestShippedOrderDate"]) $tmp[$fields_mapping["LatestShippedOrderDate"]] = '<campo'.$fields_mapping["LatestShippedOrderDate"].'>'. $subscriber['DataUltimoOrdineSpedito'] .'</campo'.$fields_mapping["LatestShippedOrderDate"].'>';
439
+ if (@$fields_mapping["LatestShippedOrderID"]) $tmp[$fields_mapping["LatestShippedOrderID"]] = '<campo'.$fields_mapping["LatestShippedOrderID"].'>'. $subscriber['IDUltimoOrdineSpedito'] .'</campo'.$fields_mapping["LatestShippedOrderID"].'>';
440
+ if (@$fields_mapping["LatestAbandonedCartDate"]) $tmp[$fields_mapping["LatestAbandonedCartDate"]] = '<campo'.$fields_mapping["LatestAbandonedCartDate"].'>'. $subscriber['DataCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartDate"].'>';
441
+ if (@$fields_mapping["LatestAbandonedCartTotal"]) $tmp[$fields_mapping["LatestAbandonedCartTotal"]] = '<campo'.$fields_mapping["LatestAbandonedCartTotal"].'>'. $subscriber['TotaleCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartTotal"].'>';
442
+ if (@$fields_mapping["LatestAbandonedCartID"]) $tmp[$fields_mapping["LatestAbandonedCartID"]] = '<campo'.$fields_mapping["LatestAbandonedCartID"].'>'. $subscriber['IDCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartID"].'>';
443
+ if (@$fields_mapping["TotalOrdered"]) $tmp[$fields_mapping["TotalOrdered"]] = '<campo'.$fields_mapping["TotalOrdered"].'>'. $subscriber['TotaleFatturato'] .'</campo'.$fields_mapping["TotalOrdered"].'>';
444
+ if (@$fields_mapping["TotalOrderedLast12m"]) $tmp[$fields_mapping["TotalOrderedLast12m"]] = '<campo'.$fields_mapping["TotalOrderedLast12m"].'>'. $subscriber['TotaleFatturatoUltimi12Mesi'] .'</campo'.$fields_mapping["TotalOrderedLast12m"].'>';
445
+ if (@$fields_mapping["TotalOrderedLast30d"]) $tmp[$fields_mapping["TotalOrderedLast30d"]] = '<campo'.$fields_mapping["TotalOrderedLast30d"].'>'. $subscriber['TotaleFatturatoUltimi30gg'] .'</campo'.$fields_mapping["TotalOrderedLast30d"].'>';
446
+ if (@$fields_mapping["AllOrderedProductIDs"]) $tmp[$fields_mapping["AllOrderedProductIDs"]] = '<campo'.$fields_mapping["AllOrderedProductIDs"].'>'. $subscriber['IDTuttiProdottiAcquistati'] .'</campo'.$fields_mapping["AllOrderedProductIDs"].'>';
447
+
448
+ $last_field = max(array_keys($tmp));
449
+ for ($i=1; $i<$last_field; $i++) {
450
+ if (!isset($tmp[$i])) $tmp[$i] = "<campo{$i}>-</campo{$i}>";
451
+ }
452
+ ksort($tmp);
453
+ $tmp = implode("", $tmp);
454
+ $xmlData .= $tmp;
455
+ $xmlData .= "</subscriber>\n";
456
+
457
+ //if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log', $storeId)) Mage::log("Store ID before newImportProcess: {$storeId}");
458
+
459
+ // ogni 5000 utenti invio i dati
460
+ if ($subscribers_counter == 5000) {
461
+ $importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
462
+ $xmlData = "";
463
+ $subscribers_counter = 0;
464
+ if($config->isLogEnabled($storeId)) {
465
+ Mage::log('ImportProcessData SubscriberCounr == 5000');
466
+ Mage::log($importProcessData, 0);
467
+ }
468
+ $processID = $wsImport->newImportProcess($importProcessData);
469
+ if ($processID === false) {
470
+ return false;
471
+ }
472
+ }
473
+ }
474
+
475
+ //invio gli ultimi utenti
476
+ if (strlen($xmlData)) {
477
+ $importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
478
+
479
+ $xmlData = "";
480
+ $subscribers_counter = 0;
481
+ if($config->isLogEnabled($storeId)) {
482
+ Mage::log('ImportProcessData');
483
+ Mage::log($importProcessData, 0);
484
+ }
485
+ $processID = $wsImport->newImportProcess($importProcessData);
486
+ if($processID === FALSE) {
487
+ if($config->isLogEnabled($storeId)) {
488
+ Mage::log('newImportProcess B FALSE');
489
+ }
490
+ return FALSE;
491
+ }
492
+ }
493
+
494
+ if (isset($newsletter_subscribers) and is_array($newsletter_subscribers) and !empty($newsletter_subscribers)) {
495
+ $subscribers_counter = 0;
496
+ foreach ($newsletter_subscribers as $newsletter_subscriber) {
497
+ $subscribers_counter++;
498
+ $xmlData .= '<subscriber email="' . $newsletter_subscriber . '" Number="" Name=""></subscriber>';
499
+ if ($subscribers_counter == 5000 or $subscribers_counter == $total_subscribers_to_send) {
500
+ $importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
501
+ $xmlData = "";
502
+ $subscribers_counter = 0;
503
+ if($config->isLogEnabled($storeId)) {
504
+ Mage::log($importProcessData, 0);
505
+ }
506
+ $processID = $wsImport->newImportProcess($importProcessData);
507
+ if ($processID === FALSE) {
508
+ if($config->isLogEnabled($storeId)) {
509
+ Mage::log('newImportProcess C FALSE');
510
+ }
511
+ return FALSE;
512
+ }
513
+ }
514
+ }
515
+ }
516
+
517
+ /**
518
+ * This needs unset in the newer version of the API, we needed it in the old API backend.
519
+ */
520
+ unset($importProcessData["xmlDoc"]);
521
+
522
+ $importProcessData["listsIDs"] = $post['mailupIdList'];
523
+ $importProcessData["listsGUIDs"] = $post['mailupListGUID'];
524
+ $importProcessData["groupsIDs"] = $groupId;
525
+
526
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log', $storeId)) {
527
+ Mage::log("mailup: StartImportProcesses (STORE: {$storeId})", 0);
528
+ Mage::log($importProcessData, 0);
529
+ }
530
+
531
+ $check = $wsImport->StartImportProcesses($importProcessData);
532
+
533
+ if ($config->isLogEnabled($storeId)) {
534
+ Mage::log('StartImportProcesses Check: ' . $check, 0);
535
+ }
536
+
537
+ return $check;
538
+ }
539
+
540
+ private static function _formatPrice($price) {
541
+ return number_format($price, 2, ',', '');
542
+ }
543
+
544
+ private static function _retriveDateFromDatetime($datetime) {
545
+ if (empty($datetime)) return "";
546
+ return date("Y-m-d H:i:s", strtotime($datetime));
547
+ }
548
+
549
+ public static function _convertUTCToStoreTimezone($datetime)
550
+ {
551
+ if (empty($datetime)) return "";
552
+
553
+ $TIMEZONE_STORE = new DateTimeZone(Mage::getStoreConfig("general/locale/timezone"));
554
+ $TIMEZONE_UTC = new DateTimeZone("UTC");
555
+
556
+ $datetime = new DateTime($datetime, $TIMEZONE_UTC);
557
+ $datetime->setTimezone($TIMEZONE_STORE);
558
+ $datetime = (string)$datetime->format("Y-m-d H:i:s");
559
+
560
+ return $datetime;
561
+ }
562
+
563
+ public static function _convertUTCToStoreTimezoneAndFormatForMailup($datetime)
564
+ {
565
+ if (empty($datetime)) return "";
566
+ $datetime = self::_convertUTCToStoreTimezone($datetime);
567
+ return date("d/m/Y", strtotime($datetime));
568
+ }
569
+
570
+ /**
571
+ * Clean the Resource Table
572
+ */
573
+ public function cleanResourceTable()
574
+ {
575
+ $sql = "DELETE FROM `core_resource` WHERE `code` = 'mailup_setup';";
576
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
577
+ try {
578
+ $connection->query($sql);
579
+ die('deleted module in core_resource!');
580
+ }
581
+ catch(Exception $e){
582
+ echo $e->getMessage();
583
+ }
584
+ }
585
+
586
+ /**
587
+ * Clean the Resource Table
588
+ */
589
+ public function showResourceTable()
590
+ {
591
+ $sql = "SELECT * FROM `core_resource`";
592
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
593
+ try {
594
+ $result = $connection->fetchAll($sql);
595
+ foreach($result as $row) {
596
+ echo $row['code'] . "<br />";
597
+ }
598
+ }
599
+ catch(Exception $e){
600
+ echo $e->getMessage();
601
+ }
602
+ }
603
  }
app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Frequency.php CHANGED
@@ -1,37 +1,37 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency
4
- {
5
- const HOURLY = 0;
6
- const EVERY_2_HOURS = 1;
7
- const EVERY_6_HOURS = 2;
8
- const EVERY_12_HOURS = 3;
9
- const DAILY = 4;
10
-
11
- /**
12
- * Fetch options array
13
- *
14
- * @return array
15
- */
16
- public function toOptionArray()
17
- {
18
- return array(
19
- array(
20
- 'label' => 'Hourly',
21
- 'value' => self::HOURLY),
22
- array(
23
- 'label' => 'Every 2 Hours',
24
- 'value' => self::EVERY_2_HOURS),
25
- array(
26
- 'label' => 'Every 6 hours',
27
- 'value' => self::EVERY_6_HOURS),
28
- array(
29
- 'label' => 'Every 12 hours',
30
- 'value' => self::EVERY_12_HOURS),
31
- array(
32
- 'label' => 'Daily',
33
- 'value' => self::DAILY),
34
-
35
- );
36
- }
37
- }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency
4
+ {
5
+ const HOURLY = 0;
6
+ const EVERY_2_HOURS = 1;
7
+ const EVERY_6_HOURS = 2;
8
+ const EVERY_12_HOURS = 3;
9
+ const DAILY = 4;
10
+
11
+ /**
12
+ * Fetch options array
13
+ *
14
+ * @return array
15
+ */
16
+ public function toOptionArray()
17
+ {
18
+ return array(
19
+ array(
20
+ 'label' => 'Hourly',
21
+ 'value' => self::HOURLY),
22
+ array(
23
+ 'label' => 'Every 2 Hours',
24
+ 'value' => self::EVERY_2_HOURS),
25
+ array(
26
+ 'label' => 'Every 6 hours',
27
+ 'value' => self::EVERY_6_HOURS),
28
+ array(
29
+ 'label' => 'Every 12 hours',
30
+ 'value' => self::EVERY_12_HOURS),
31
+ array(
32
+ 'label' => 'Daily',
33
+ 'value' => self::DAILY),
34
+
35
+ );
36
+ }
37
+ }
app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Hours.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Hours
4
- {
5
- /**
6
- * Fetch options array
7
- *
8
- * @return array
9
- */
10
- public function toOptionArray()
11
- {
12
- $hours = array();
13
- for ($i = 1; $i <= 24; $i++) {
14
- $hours[] = array('label' => $i, 'value' => $i);
15
- }
16
- return $hours;
17
- }
18
- }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Hours
4
+ {
5
+ /**
6
+ * Fetch options array
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ $hours = array();
13
+ for ($i = 1; $i <= 24; $i++) {
14
+ $hours[] = array('label' => $i, 'value' => $i);
15
+ }
16
+ return $hours;
17
+ }
18
+ }
app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Fields.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Adminhtml_System_Source_Fields
4
+ {
5
+ const CACHE_LIFETIME = 600; // 10 min
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $websiteCode = Mage::app()->getRequest()->getParam('website');
14
+ $storeCode = Mage::app()->getRequest()->getParam('store');
15
+
16
+ if($storeCode) {
17
+ $storeId = Mage::app()->getStore($storeCode)->getId();
18
+ $cacheId = 'mailup_fields_array_store_'.$storeId;
19
+ }
20
+ elseif($websiteCode) {
21
+ $storeId = Mage::app()
22
+ ->getWebsite($websiteCode)
23
+ ->getDefaultGroup()
24
+ ->getDefaultStoreId()
25
+ ;
26
+ $cacheId = 'mailup_fields_array_store_'.$storeId;
27
+ }
28
+ else {
29
+ $storeId = NULL;
30
+ $cacheId = 'mailup_fields_array';
31
+ //$storeId = Mage::app()->getDefaultStoreView()->getStoreId();
32
+ }
33
+
34
+ // var_dump($storeCode);
35
+ // var_dump($websiteCode);
36
+ // var_dump($storeId);
37
+ // var_dump(Mage::app()->getStores());
38
+
39
+
40
+ $options = array(array('value' => '', 'label' => ''));
41
+ if(false !== ($data = Mage::app()->getCache()->load($cacheId))) {
42
+ $options = unserialize($data);
43
+ }
44
+ else {
45
+ $wsSend = new MailUpWsSend($storeId);
46
+ $accessKey = $wsSend->loginFromId();
47
+ if($accessKey !== false) {
48
+ $wsFields = $wsSend->getFields($accessKey);
49
+ //$wsFields = array('test' => 'test');
50
+ foreach ($wsFields as $label => $value) {
51
+ $options[] = array(
52
+ 'value' => $value,
53
+ 'label' => $label, //Mage::helper('adminhtml')->__($label)
54
+ );
55
+ }
56
+ }
57
+ Mage::app()->getCache()->save(serialize($options), $cacheId, array(), self::CACHE_LIFETIME);
58
+ }
59
+
60
+ return $options;
61
+ }
62
+
63
+ }
app/code/local/SevenLike/MailUp/Model/Config.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Config.php
4
+ *
5
+ * Central config model
6
+ */
7
+ class SevenLike_MailUp_Model_Config
8
+ {
9
+ const XML_CONSOLE = 'mailup_newsletter/mailup/url_console';
10
+ const XML_LOG_ENABLE = 'mailup_newsletter/mailup/enable_log';
11
+ const XML_CRON_EXPORT_ENABLE = 'mailup_newsletter/mailup/enable_cron_export';
12
+ const XML_MAILUP_USERNAME = 'mailup_newsletter/mailup/username_ws';
13
+ const XML_MAILUP_PASSWORD = 'mailup_newsletter/mailup/password_ws';
14
+ const XML_MAILUP_LIST_ID = 'mailup_newsletter/mailup/list';
15
+ const XML_SUBSCRIBE_IN_CHECKOUT = 'mailup_newsletter/mailup/enable_subscribe_in_checkout';
16
+ const XML_CRON_FREQ = 'mailup_newsletter/mailup/mailup_cron_frequency';
17
+ const XML_WEBHOOK_KEY = 'mailup_newsletter/mailup/webhook_crypt_key';
18
+ const XML_DISABLE_NOTIFICATION = 'mailup_newsletter/mailup/disablenewslettersuccesses';
19
+
20
+ const XML_MAPPING_SECTION = 'mailup_newsletter/mailup_mapping';
21
+
22
+ /**
23
+ * Is the log enabled?
24
+ *
25
+ * @return bool
26
+ */
27
+ public function isLogEnabled($storeId = NULL)
28
+ {
29
+ return (int) Mage::getStoreConfig(self::XML_LOG_ENABLE, $storeId);
30
+ }
31
+
32
+ /**
33
+ * Disable Magnetos Newsletter Subscription Notifiactions??
34
+ *
35
+ * @param int
36
+ * @return bool
37
+ */
38
+ public function isNewsletterNotificationDisabled($storeId = NULL)
39
+ {
40
+ return (int) Mage::getStoreConfig(self::XML_DISABLE_NOTIFICATION, $storeId);
41
+ }
42
+
43
+ /**
44
+ * Get the url console url from Config
45
+ *
46
+ * @param int
47
+ * @return string
48
+ */
49
+ public function getUrlConsole($storeId = NULL)
50
+ {
51
+ return Mage::getStoreConfig(self::XML_CONSOLE, $storeId);
52
+ }
53
+
54
+ /**
55
+ * Is the cron enabled?
56
+ *
57
+ * @param int
58
+ * @return int
59
+ */
60
+ public function isCronExportEnabled($storeId = NULL)
61
+ {
62
+ return (int) Mage::getStoreConfig(self::XML_CRON_EXPORT_ENABLE, $storeId);
63
+ }
64
+
65
+ /**
66
+ * Get the list ID
67
+ *
68
+ * @param int
69
+ * @return int
70
+ */
71
+ public function getMailupListId($storeId = NULL)
72
+ {
73
+ return Mage::getStoreConfig(self::XML_MAILUP_LIST_ID, $storeId);
74
+ }
75
+
76
+ /**
77
+ * Get the username from Config
78
+ *
79
+ * @param int
80
+ * @return string
81
+ */
82
+ public function getUsername($storeId = NULL)
83
+ {
84
+ return Mage::getStoreConfig(self::XML_MAILUP_USERNAME, $storeId);
85
+ }
86
+
87
+ /**
88
+ * Get the password from Config
89
+ *
90
+ * @param int
91
+ * @return string
92
+ */
93
+ public function getPassword($storeId = NULL)
94
+ {
95
+ return Mage::getStoreConfig(self::XML_MAILUP_PASSWORD, $storeId);
96
+ }
97
+
98
+ /**
99
+ * Is Subscribe in checkout enabled?
100
+ *
101
+ * @param int
102
+ * @return int
103
+ */
104
+ public function isSubscribeInCheckout($storeId = NULL)
105
+ {
106
+ return (int) Mage::getStoreConfig(self::XML_SUBSCRIBE_IN_CHECKOUT, $storeId);
107
+ }
108
+
109
+ /**
110
+ * Get the cron freq settings
111
+ *
112
+ * @param int
113
+ * @return string
114
+ */
115
+ public function getCronFrequency($storeId = NULL)
116
+ {
117
+ return Mage::getStoreConfig(self::XML_CRON_FREQ, $storeId);
118
+ }
119
+
120
+ /**
121
+ * Get Field Mapping
122
+ *
123
+ * @todo Fix to use the config for mappings, per store..
124
+ * @param int
125
+ * @return array
126
+ */
127
+ public function getFieldsMapping($storeId = NULL)
128
+ {
129
+ return Mage::getStoreConfig(self::XML_MAPPING_SECTION, $storeId);
130
+
131
+ /*$return = array();
132
+
133
+ foreach(Mage::getStoreConfig(self::XML_MAPPING_SECTION, $storeId) as $key => $field) {
134
+ var_dump($key);
135
+ var_dump($field);
136
+ }
137
+
138
+ return $return;*/
139
+ }
140
+
141
+ /**
142
+ * Get an array of Stores, for use in a dropdown.
143
+ *
144
+ * array(
145
+ * id => code
146
+ * )
147
+ *
148
+ * @return array
149
+ */
150
+ public function getStoreArray()
151
+ {
152
+ //$storeModel = Mage::getSingleton('adminhtml/system_store');
153
+ /* @var $storeModel Mage_Adminhtml_Model_System_Store */
154
+ //$websiteCollection = $storeModel->getWebsiteCollection();
155
+ //$groupCollection = $storeModel->getGroupCollection();
156
+ //$storeCollection = $storeModel->getStoreCollection();
157
+ $storesArr = array();
158
+
159
+ /*$defaultStoreId = Mage::app()->getDefaultStoreView()->getStoreId();
160
+ $storesArr[$defaultStoreId] = array(
161
+ 'id' => $defaultStoreId,
162
+ 'code' => Mage::app()->getDefaultStoreView()->getCode(),
163
+ 'name' => Mage::app()->getDefaultStoreView()->getName(),
164
+ );*/
165
+
166
+ $storesArr[0] = array(
167
+ 'id' => 0,
168
+ 'code' => 'default',
169
+ 'name' => 'Default',
170
+ );
171
+
172
+ foreach (Mage::app()->getWebsites() as $website) {
173
+ foreach ($website->getGroups() as $group) {
174
+ $stores = $group->getStores();
175
+ foreach ($stores as $store) {
176
+ /* @var $store Mage_Core_Model_Store */
177
+ $storesArr[$store->getId()] = array(
178
+ 'id' => $store->getId(),
179
+ 'code' => $store->getCode(),
180
+ 'name' => $store->getName(),
181
+ );
182
+ }
183
+ }
184
+ }
185
+
186
+ return $storesArr;
187
+ }
188
+
189
+ /**
190
+ * Get an array of all store ids
191
+ *
192
+ * @reutrn array
193
+ */
194
+ public function getAllStoreIds()
195
+ {
196
+ $ids = array();
197
+
198
+ $allStores = Mage::app()->getStores();
199
+ foreach ($allStores as $storeId => $val) {
200
+ $ids[] = Mage::app()->getStore($storeId)->getId();
201
+ }
202
+
203
+ return $ids;
204
+ }
205
+ }
app/code/local/SevenLike/MailUp/Model/Consoleurlvalidator.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_Consoleurlvalidator extends Mage_Core_Model_Config_Data
4
- {
5
- public function save()
6
- {
7
- $value = $this->getValue();
8
- if (strlen($value) == 0) {
9
- Mage::throwException(Mage::helper("mailup")->__("Please fill the admin console URL"));
10
- }
11
-
12
- $validator = new Zend_Validate_Hostname();
13
- if (!$validator->isValid($value)) {
14
- Mage::throwException(Mage::helper("mailup")->__("Admin console URL is not in the right format"));
15
- }
16
-
17
- return parent::save();
18
- }
19
  }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Consoleurlvalidator extends Mage_Core_Model_Config_Data
4
+ {
5
+ public function save()
6
+ {
7
+ $value = $this->getValue();
8
+ if (strlen($value) == 0) {
9
+ Mage::throwException(Mage::helper("mailup")->__("Please fill the admin console URL"));
10
+ }
11
+
12
+ $validator = new Zend_Validate_Hostname();
13
+ if (!$validator->isValid($value)) {
14
+ Mage::throwException(Mage::helper("mailup")->__("Admin console URL is not in the right format"));
15
+ }
16
+
17
+ return parent::save();
18
+ }
19
  }
app/code/local/SevenLike/MailUp/Model/Cron.php CHANGED
@@ -1,87 +1,162 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/Wssend.php";
5
- class SevenLike_MailUp_Model_Cron
6
- {
7
- public function run()
8
- {
9
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Cron mailup', 0);
10
-
11
- if (Mage::getStoreConfig('newsletter/mailup/enable_cron_export') == 1) {
12
- $indexProcess = new Mage_Index_Model_Process();
13
- $indexProcess->setId("mailupcronrun");
14
- if ($indexProcess->isLocked()) {
15
- Mage::log("MAILUP: cron already running or locked");
16
- return false;
17
- }
18
- $indexProcess->lockAndBlock();
19
-
20
- require_once dirname(__FILE__) . '/../Helper/Data.php';
21
- $db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
22
- $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
23
- $lastsync = gmdate("Y-m-d H:i:s");
24
-
25
- // reading newsletter subscribers
26
- //$newsletter_subscriber_table_name = Mage::getSingleton('core/resource')->getTableName('newsletter_subscriber');
27
- //$newsletter_subscribers = $db_read->fetchAll("SELECT ms.*, ns.subscriber_email FROM mailup_sync ms JOIN $newsletter_subscriber_table_name ns ON (ms.customer_id = ns.subscriber_id) WHERE ms.needs_sync=1 AND ms.entity='subscriber'");
28
-
29
- // reading customers (jobid == 0, their updates)
30
- $customers = array();
31
- $customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
32
- $stmt = $db_read->query("SELECT ms.*, ce.email FROM mailup_sync ms JOIN $customer_entity_table_name ce ON (ms.customer_id = ce.entity_id) WHERE ms.needs_sync=1 AND ms.entity='customer' AND job_id=0");
33
- while ($row = $stmt->fetch()) {
34
- $customers[] = $row["customer_id"];
35
- }
36
-
37
- // generating and sending data to mailup
38
- //SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, null, $newsletter_subscribers);
39
- $check = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers);
40
-
41
- // reading and processing jobs
42
- $jobs = $db_read->fetchAll("SELECT * FROM mailup_sync_jobs WHERE status='queued'");
43
- foreach ($jobs as $job) {
44
- $stmt = $db_write->query("UPDATE mailup_sync_jobs SET status='started', start_datetime='" . gmdate("Y-m-d H:i:s") . "' WHERE id={$job["id"]}");
45
- $customers = array();
46
- $job['mailupNewGroup'] = 0;
47
- $job['mailupIdList'] = Mage::getStoreConfig('newsletter/mailup/list');
48
- $job["mailupGroupId"] = $job["mailupgroupid"];
49
- $job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
50
- $tmp = new SevenLike_MailUp_Model_Lists;
51
- $tmp = $tmp->toOptionArray();
52
- foreach ($tmp as $t) {
53
- if ($t["value"] == $job['mailupIdList']) {
54
- $job['mailupListGUID'] = $t["guid"];
55
- $job["groups"] = $t["groups"];
56
- break;
57
- }
58
- }
59
- unset($tmp); unset($t);
60
- $stmt = $db_read->query("SELECT ms.*, ce.email FROM mailup_sync ms JOIN $customer_entity_table_name ce ON (ms.customer_id = ce.entity_id) WHERE ms.needs_sync=1 AND ms.entity='customer' AND job_id={$job["id"]}");
61
- while ($row = $stmt->fetch()) {
62
- $customers[] = $row["customer_id"];
63
- }
64
- $check = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, $job);
65
- if ($check) {
66
- // saving sync state for customers
67
- foreach ($customers as $row) {
68
- $db_write->query("UPDATE mailup_sync SET needs_sync=0, last_sync='$lastsync' WHERE customer_id={$row} AND entity='customer'");
69
- }
70
-
71
- // finishing the job also
72
- $db_write->query("UPDATE mailup_sync_jobs SET status='finished', finish_datetime='" . gmdate("Y-m-d H:i:s") . "' WHERE id={$job["id"]}");
73
- }
74
- }
75
-
76
- $indexProcess->unlock();
77
- } else {
78
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Cron export not enabled', 0);
79
- }
80
-
81
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Cron mailup finished', 0);
82
- }
83
-
84
- public static function resendConnectionErrors()
85
- {
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
1
+ <?php
2
+ /**
3
+ * Cron.php
4
+ */
5
+ require_once dirname(__FILE__) . "/MailUpWsImport.php";
6
+ require_once dirname(__FILE__) . "/Wssend.php";
7
+
8
+ class SevenLike_MailUp_Model_Cron
9
+ {
10
+ public function run()
11
+ {
12
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
13
+ Mage::log('Cron mailup', 0);
14
+ }
15
+
16
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_cron_export') == 1) {
17
+ $indexProcess = new Mage_Index_Model_Process();
18
+ $indexProcess->setId("mailupcronrun");
19
+ if ($indexProcess->isLocked()) {
20
+ Mage::log("MAILUP: cron already running or locked");
21
+ return false;
22
+ }
23
+ $indexProcess->lockAndBlock();
24
+
25
+ require_once dirname(__FILE__) . '/../Helper/Data.php';
26
+ $db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
27
+ $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
28
+ $lastsync = gmdate("Y-m-d H:i:s");
29
+
30
+ // reading newsletter subscribers
31
+ //$newsletter_subscriber_table_name = Mage::getSingleton('core/resource')->getTableName('newsletter_subscriber');
32
+ //$newsletter_subscribers = $db_read->fetchAll("SELECT ms.*, ns.subscriber_email FROM mailup_sync ms JOIN $newsletter_subscriber_table_name ns ON (ms.customer_id = ns.subscriber_id) WHERE ms.needs_sync=1 AND ms.entity='subscriber'");
33
+
34
+ // reading customers (jobid == 0, their updates)
35
+ $customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
36
+
37
+ $stmt = $db_read->query("
38
+ SELECT ms.*, ce.email FROM mailup_sync ms
39
+ JOIN $customer_entity_table_name ce
40
+ ON (ms.customer_id = ce.entity_id)
41
+ WHERE
42
+ ms.needs_sync=1
43
+ AND ms.entity='customer'
44
+ AND job_id=0"
45
+ );
46
+
47
+ $storeArr = array();
48
+ $rows = $stmt->fetchAll();
49
+ /**
50
+ * Customer Updates, job_id = 0
51
+ */
52
+ foreach($rows as $row) {
53
+ $storeId = $row["store_id"];
54
+ /*if( ! isset($storeId)) {
55
+ Mage::log('StoreID Not Set On Cron Job');
56
+ //$storeId = Mage::app()->getDefaultStoreView()->getStoreId(); // Fallback incase not set?!?
57
+ }*/
58
+ /**
59
+ * Send/Group each stores data together.
60
+ */
61
+ $storeArr[$storeId][] = $row["customer_id"];
62
+ }
63
+
64
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
65
+ if(count($storeArr) > 0) {
66
+ Mage::log('STORE DATA ARRAY');
67
+ Mage::log($storeArr);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Send each Store's data together!
73
+ */
74
+ foreach($storeArr as $singleStoreId => $customers) {
75
+ // generating and sending data to mailup
76
+ $check = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, NULL, NULL, $singleStoreId);
77
+ }
78
+
79
+ // reading and processing jobs
80
+ $jobs = $db_read->fetchAll("SELECT * FROM mailup_sync_jobs WHERE status='queued'");
81
+ /**
82
+ * Sync Jobs
83
+ */
84
+ foreach ($jobs as $job) {
85
+ $stmt = $db_write->query("UPDATE mailup_sync_jobs SET status='started', start_datetime='" . gmdate("Y-m-d H:i:s") . "' WHERE id={$job["id"]}");
86
+
87
+ $storeId = isset($job['store_id']) ? $job['store_id'] : NULL;
88
+ //if( ! isset($storeId)) {
89
+ //Mage::log('StoreID Not Set On Cron Job');
90
+ //$storeId = Mage::app()->getDefaultStoreView()->getStoreId(); // Fallback incase not set?!?
91
+ //}
92
+
93
+ $customers = array();
94
+ $job['mailupNewGroup'] = 0;
95
+ $job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
96
+ $job["mailupGroupId"] = $job["mailupgroupid"];
97
+ $job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
98
+
99
+ $tmp = new SevenLike_MailUp_Model_Lists;
100
+ $tmp = $tmp->toOptionArray($storeId); // pass store id!
101
+ foreach ($tmp as $t) {
102
+ if ($t["value"] == $job['mailupIdList']) {
103
+ $job['mailupListGUID'] = $t["guid"];
104
+ $job["groups"] = $t["groups"];
105
+ break;
106
+ }
107
+ }
108
+ unset($tmp); unset($t);
109
+ $stmt = $db_read->query("
110
+ SELECT ms.*, ce.email
111
+ FROM mailup_sync ms
112
+ JOIN $customer_entity_table_name ce
113
+ ON (ms.customer_id = ce.entity_id)
114
+ WHERE ms.needs_sync=1
115
+ AND ms.entity='customer'
116
+ AND job_id={$job["id"]}"
117
+ );
118
+ while ($row = $stmt->fetch()) {
119
+ $customers[] = $row["customer_id"];
120
+ }
121
+
122
+ $check = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, $job, NULL, $storeId);
123
+
124
+ /**
125
+ * @todo We need to check the result of the import, if there's an error
126
+ * we do not want to mark this ask Synced! we need to retry..
127
+ */
128
+ if ($check) {
129
+ // saving sync state for customers
130
+ foreach ($customers as $row) {
131
+ $db_write->query("
132
+ UPDATE mailup_sync SET needs_sync=0, last_sync='$lastsync'
133
+ WHERE customer_id={$row}
134
+ AND entity='customer'"
135
+ );
136
+ }
137
+
138
+ // finishing the job also
139
+ $db_write->query("
140
+ UPDATE mailup_sync_jobs SET status='finished', finish_datetime='" . gmdate("Y-m-d H:i:s") . "'
141
+ WHERE id={$job["id"]}"
142
+ );
143
+ }
144
+ }
145
+
146
+ $indexProcess->unlock();
147
+ }
148
+ else {
149
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
150
+ Mage::log('Cron export not enabled', 0);
151
+ }
152
+ }
153
+
154
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
155
+ Mage::log('Cron mailup finished', 0);
156
+ }
157
+ }
158
+
159
+ public static function resendConnectionErrors()
160
+ {
161
+ }
162
  }
app/code/local/SevenLike/MailUp/Model/Lists.php CHANGED
@@ -1,54 +1,96 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/Wssend.php";
5
- class SevenLike_MailUp_Model_Lists
6
- {
7
- public function toOptionArray() {
8
- //genero la select per Magento
9
- $selectLists = array();
10
-
11
- if (Mage::getStoreConfig('newsletter/mailup/url_console') && Mage::getStoreConfig('newsletter/mailup/username_ws') && Mage::getStoreConfig('newsletter/mailup/password_ws')) {
12
- $wsSend = new MailUpWsSend();
13
- $accessKey = $wsSend->loginFromId();
14
-
15
- if ($accessKey !== false) {
16
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
17
- $wsImport = new MailUpWsImport();
18
-
19
- $xmlString = $wsImport->GetNlList();
20
-
21
- $selectLists[0] = array('value' => 0, 'label'=>'-- Select a list (if any) --');
22
-
23
- if ($xmlString) {
24
- $xmlString = html_entity_decode($xmlString);
25
-
26
- $startLists = strpos($xmlString, '<Lists>');
27
- $endPos = strpos($xmlString, '</Lists>');
28
- $endLists = $endPos + strlen('</Lists>') - $startLists;
29
-
30
- $xmlLists = substr($xmlString, $startLists, $endLists);
31
-
32
- $xmlLists = str_replace("&", "&amp;", $xmlLists);
33
-
34
- $xml = simplexml_load_string($xmlLists);
35
-
36
- $count = 1;
37
- foreach ($xml->List as $list) {
38
- $groups = array();
39
- foreach ($list->Groups->Group as $tmp) {
40
- $groups[(string)$tmp["idGroup"]] = (string)$tmp["groupName"];
41
- }
42
- $selectLists[$count] = array('value' => (string)$list['idList'], 'label'=> (string)$list['listName'], 'guid'=>(string)$list['listGUID'], "groups"=>$groups);
43
- $count++;
44
- }
45
- }
46
- } else {
47
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('LoginFromId failed', 0);
48
- $selectLists[0] = array('value' => 0, 'label'=>$GLOBALS["__sl_mailup_login_error"]);
49
- }
50
- }
51
-
52
- return $selectLists;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists.php
4
+ */
5
+ require_once dirname(__FILE__) . "/MailUpWsImport.php";
6
+ require_once dirname(__FILE__) . "/Wssend.php";
7
+
8
+ class SevenLike_MailUp_Model_Lists
9
+ {
10
+ /**
11
+ * Get as options
12
+ *
13
+ * @todo Add Caching
14
+ * @return array
15
+ */
16
+ public function toOptionArray($storeId = NULL)
17
+ {
18
+ $websiteCode = Mage::app()->getRequest()->getParam('website');
19
+ $storeCode = Mage::app()->getRequest()->getParam('store');
20
+
21
+ if(isset($storeId) && $storeId != FALSE) {
22
+ $storeId = $storeId;
23
+ }
24
+ elseif($storeCode) {
25
+ $storeId = Mage::app()->getStore($storeCode)->getId();
26
+ $cacheId = 'mailup_fields_array_store_'.$storeId;
27
+ }
28
+ elseif($websiteCode) {
29
+ $storeId = Mage::app()
30
+ ->getWebsite($websiteCode)
31
+ ->getDefaultGroup()
32
+ ->getDefaultStoreId()
33
+ ;
34
+ $cacheId = 'mailup_fields_array_store_'.$storeId;
35
+ }
36
+ else {
37
+ $storeId = NULL;
38
+ $cacheId = 'mailup_fields_array';
39
+ //$storeId = Mage::app()->getDefaultStoreView()->getStoreId();
40
+ }
41
+
42
+ //genero la select per Magento
43
+ $selectLists = array();
44
+
45
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $storeId)
46
+ && Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $storeId)
47
+ && Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $storeId)) {
48
+
49
+ $wsSend = new MailUpWsSend($storeId);
50
+ $accessKey = $wsSend->loginFromId();
51
+
52
+ if ($accessKey !== false) {
53
+ require_once dirname(__FILE__) . "/MailUpWsImport.php";
54
+ $wsImport = new MailUpWsImport($storeId);
55
+
56
+ $xmlString = $wsImport->GetNlList();
57
+
58
+ $selectLists[0] = array('value' => 0, 'label'=>'-- Select a list (if any) --');
59
+
60
+ if ($xmlString) {
61
+ $xmlString = html_entity_decode($xmlString);
62
+
63
+ $startLists = strpos($xmlString, '<Lists>');
64
+ $endPos = strpos($xmlString, '</Lists>');
65
+ $endLists = $endPos + strlen('</Lists>') - $startLists;
66
+
67
+ $xmlLists = substr($xmlString, $startLists, $endLists);
68
+
69
+ $xmlLists = str_replace("&", "&amp;", $xmlLists);
70
+
71
+ $xml = simplexml_load_string($xmlLists);
72
+
73
+ $count = 1;
74
+ foreach ($xml->List as $list) {
75
+ $groups = array();
76
+ foreach ($list->Groups->Group as $tmp) {
77
+ $groups[(string)$tmp["idGroup"]] = (string)$tmp["groupName"];
78
+ }
79
+ $selectLists[$count] = array(
80
+ 'value' => (string)$list['idList'],
81
+ 'label'=> (string)$list['listName'],
82
+ 'guid'=>(string)$list['listGUID'],
83
+ "groups"=>$groups
84
+ );
85
+ $count++;
86
+ }
87
+ }
88
+ } else {
89
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log', $storeId)) Mage::log('LoginFromId failed', 0);
90
+ $selectLists[0] = array('value' => 0, 'label'=>$GLOBALS["__sl_mailup_login_error"]);
91
+ }
92
+ }
93
+
94
+ return $selectLists;
95
+ }
96
+ }
app/code/local/SevenLike/MailUp/Model/MailUp.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_MailUp extends Mage_Core_Model_Abstract
4
- {
5
- public function _construct()
6
- {
7
- parent::_construct();
8
- $this->_init('mailup/mailup');
9
- }
10
  }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_MailUp extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('mailup/mailup');
9
+ }
10
  }
app/code/local/SevenLike/MailUp/Model/MailUpWsImport.php CHANGED
@@ -1,659 +1,1002 @@
1
- <?php
2
-
3
- class MailUpWsImport
4
- {
5
- protected $ns = "http://ws.mailupnet.it/";
6
-
7
- //protected $WSDLUrl = "http://g4a0.s03.it/services/WSMailUpImport.asmx?WSDL";
8
- //protected $headers = array("User" => "a7410", "Password" => "GA6VAN0W");
9
- protected $rCode;
10
- private $soapClient;
11
- private $xmlResponse;
12
- protected $domResult;
13
-
14
- function __construct() {
15
- $urlConsole = Mage::getStoreConfig('newsletter/mailup/url_console');
16
- $WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
17
- $user = Mage::getStoreConfig('newsletter/mailup/username_ws');
18
- $password = Mage::getStoreConfig('newsletter/mailup/password_ws');
19
- $headers = array('User' => $user, 'Password' => $password);
20
- $this->header = new SOAPHeader($this->ns, 'Authentication', $headers);
21
-
22
- try {
23
- $this->soapClient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
24
- $this->soapClient->__setSoapHeaders($this->header);
25
- } catch (Exception $e) {
26
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper("mailup")->__("Unable to connect to MailUp console"));
27
- }
28
- }
29
-
30
- function __destruct() {
31
- unset($this->soapClient);
32
- }
33
-
34
- public function getFunctions() {
35
- print_r($this->soapClient->__getFunctions());
36
- }
37
-
38
- public function creaGruppo($newGroup) {
39
- if (!is_object($this->soapClient)) return false;
40
- try {
41
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("Mailup: creazione nuovo gruppo");
42
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($newGroup);
43
- $this->soapClient->CreateGroup($newGroup);
44
- $this->printLastRequest();
45
- $this->printLastResponse();
46
- return $this->readReturnCode('CreateGroup', 'ReturnCode');
47
- } catch (SoapFault $soapFault) {
48
- Mage::log('SOAP error', 0);
49
- Mage::log($soapFault, 0);
50
- }
51
- }
52
-
53
- public function GetNlList() {
54
- if (!is_object($this->soapClient)) return false;
55
- try {
56
- $this->soapClient->GetNlLists();
57
- $this->printLastRequest();
58
- $this->printLastResponse();
59
- $result = $this->soapClient->__getLastResponse();
60
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($result, 0);
61
- return $result;
62
- } catch (SoapFault $soapFault) {
63
- Mage::log('SOAP error', 0);
64
- Mage::log($soapFault, 0);
65
- }
66
- }
67
-
68
- public function newImportProcess($importProcessData) {
69
- if (!is_object($this->soapClient)) return false;
70
- try {
71
- $this->soapClient->NewImportProcess($importProcessData);
72
- $returncode = $this->readReturnCode('NewImportProcess', 'ReturnCode');
73
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("mailup: newImportProcess result: $returncode", 0);
74
- return $returncode;
75
- } catch (SoapFault $soapFault) {
76
- Mage::log('SOAP error', 0);
77
- Mage::log($soapFault, 0);
78
- return false;
79
- }
80
- }
81
-
82
- public function startProcess($processData) {
83
- if (!is_object($this->soapClient)) return false;
84
- try {
85
- $this->soapClient->StartProcess($processData);
86
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("mailup: ws: startimportprocess", 0);
87
- return true;
88
- } catch (SoapFault $soapFault) {
89
- Mage::log('SOAP error', 0);
90
- Mage::log($soapFault, 0);
91
- return false;
92
- }
93
- }
94
-
95
- public function getProcessDetail($processData) {
96
- if (!is_object($this->soapClient)) return false;
97
- try {
98
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($this->soapClient->GetProcessDetails($processData), 0);
99
- } catch (SoapFault $soapFault) {
100
- Mage::log('SOAP error', 0);
101
- Mage::log($soapFault, 0);
102
- }
103
- }
104
-
105
- public function startImportProcesses($processData) {
106
- if (!is_object($this->soapClient)) return false;
107
- try {
108
- $this->soapClient->StartImportProcesses($processData);
109
- $this->printLastRequest();
110
- $this->printLastResponse();
111
- return true;
112
- } catch (SoapFault $soapFault) {
113
- Mage::log('SOAP error', 0);
114
- Mage::log($soapFault, 0);
115
- return false;
116
- }
117
- }
118
-
119
- private function readReturnCode($func, $param) {
120
- if (!is_object($this->soapClient)) return false;
121
-
122
- static $func_in = ''; //static variable to test xmlResponse update
123
- if ($func_in != $func) {//(!isset($this->xmlResponse))
124
- $func_in = $func;
125
- //prendi l'XML di ritorno se non l'ho già preso
126
- $this->xmlResponse = $this->soapClient->__getLastResponse();
127
-
128
- $dom = new DomDocument();
129
- $dom->loadXML($this->xmlResponse) or die('File XML non valido!');
130
- $xmlResult = $dom->getElementsByTagName($func.'Result');
131
-
132
- $this->domResult = new DomDocument();
133
- $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die('File XML non valido!');
134
- }
135
- $rCode = $this->domResult->getElementsByTagName($param);
136
- return $rCode->item(0)->nodeValue;
137
- }
138
-
139
- private function printLastRequest()
140
- {
141
- return "";
142
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) $this->soapClient->__getLastRequest();
143
- }
144
-
145
- private function printLastResponse()
146
- {
147
- return "";
148
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) $this->soapClient->__getLastResponse();
149
- }
150
-
151
- public function getCustomersFiltered($request)
152
- {
153
- $TIMEZONE_STORE = new DateTimeZone(Mage::getStoreConfig("general/locale/timezone"));
154
- $TIMEZONE_UTC = new DateTimeZone("UTC");
155
-
156
- //inizializzo l'array dei clienti
157
- $customersFiltered = array();
158
-
159
- if (!$request->getRequest()->getParam('mailupCustomerFilteredMod')) {
160
- //ottengo la collection con tutti i clienti
161
- $customerCollection = Mage::getModel('customer/customer')
162
- ->getCollection()
163
- ->addAttributeToSelect('entity_id')
164
- ->addAttributeToSelect('group_id')
165
- ->addAttributeToSelect('created_at')
166
- ->getSelect()
167
- ->query();
168
-
169
- while ($row = $customerCollection->fetch()) {
170
- $customersFiltered[] = $row;
171
- }
172
-
173
- //se richiesto, seleziono solo quelli iscritti alla newsletter di Magento
174
- if ($request->getRequest()->getParam('mailupSubscribed') > 0) {
175
- $tempSubscribed = array();
176
- foreach ($customersFiltered as $customer) {
177
- $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
178
- if (Mage::getModel('newsletter/subscriber')->loadByCustomer($customerItem)->isSubscribed()) {
179
- $tempSubscribed[] = $customer;
180
- }
181
- }
182
- $customersFiltered = array_intersect($tempSubscribed, $customersFiltered);
183
- }
184
-
185
- //FILTRO 1 ACQUISTATO: in base al fatto se ha effettuato o meno acquisti: 0 = tutti, 1 = chi ha acquistato, 2 = chi non ha mai acquistato
186
- $count = 0;
187
- $result = array();
188
- $tempPurchased = array();
189
- $tempNoPurchased = array();
190
-
191
- if ($request->getRequest()->getParam('mailupCustomers') > 0) {
192
- foreach ($customersFiltered as $customer) {
193
- $result[] = $customer;
194
-
195
- //filtro gli ordini in base al customer id
196
- $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
197
-
198
- //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
199
- if ($orders->getData()) {
200
- $tempPurchased[] = $result[$count];
201
- } else {
202
- $tempNoPurchased[] = $result[$count];
203
- }
204
-
205
- //unsetto la variabile
206
- unset($orders); //->unsetData();
207
-
208
- $count++;
209
- }
210
-
211
- if ($request->getRequest()->getParam('mailupCustomers') == 1) {
212
- $customersFiltered = array_intersect($tempPurchased, $customersFiltered);
213
- } elseif ($request->getRequest()->getParam('mailupCustomers') == 2) {
214
- $customersFiltered = array_intersect($tempNoPurchased, $customersFiltered);
215
- }
216
- }
217
- //FINE FILTRO 1 ACQUISTATO: testato OK
218
-
219
- //FILTRO 2 PRODOTTO ACQUISTATO: in base al fatto se ha acquistato un determinato prodotto
220
- $count = 0;
221
- $result = array();
222
- $tempProduct = array();
223
-
224
- if ($request->getRequest()->getParam('mailupProductSku')) {
225
- foreach ($customersFiltered as $customer) {
226
- $result[] = $customer;
227
-
228
- //filtro gli ordini in base al customer id
229
- $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
230
- $purchasedProduct = 0;
231
-
232
- $mailupProductId = Mage::getModel('catalog/product')->getIdBySku($request->getRequest()->getParam('mailupProductSku'));
233
-
234
- foreach ($orders->getData() as $order) {
235
- if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
236
- $orderIncrementId = $order['increment_id'];
237
-
238
- //carico i dati di ogni ordine
239
- $orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
240
- $items = $orderData->getAllItems();
241
- $ids = array();
242
- foreach ($items as $itemId => $item) {
243
- $ids[] = $item->getProductId();
244
- }
245
-
246
- if (in_array($mailupProductId, $ids)) {
247
- $purchasedProduct = 1;
248
- }
249
- }
250
-
251
- //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
252
- if ($purchasedProduct == 1) {
253
- $tempProduct[] = $result[$count];
254
- }
255
-
256
- //unsetto la variabile
257
- unset($orders); //->unsetData();
258
-
259
- $count++;
260
- }
261
-
262
- $customersFiltered = array_intersect($tempProduct, $customersFiltered);
263
- }
264
- //FINE FILTRO 2 PRODOTTO ACQUISTATO: testato OK
265
-
266
-
267
- //FILTRO 3 ACQUISTATO IN CATEGORIA: in base al fatto se ha acquistato almeno un prodotto in una determinata categoria
268
- $count = 0;
269
- $result = array();
270
- $tempCategory = array();
271
-
272
- if ($request->getRequest()->getParam('mailupCategoryId') > 0) {
273
- foreach ($customersFiltered as $customer) {
274
- $result[] = $customer;
275
-
276
- //filtro gli ordini in base al customer id
277
- $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
278
- $purchasedCategory = 0;
279
-
280
- foreach ($orders->getData() as $order) {
281
- if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
282
- $orderIncrementId = $order['increment_id'];
283
-
284
- //carico i dati di ogni ordine
285
- $orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
286
- $items = $orderData->getAllItems();
287
- $cat_ids = array();
288
- foreach ($items as $product) {
289
- if (in_array($request->getRequest()->getParam('mailupCategoryId'), Mage::getResourceSingleton('catalog/product')->getCategoryIds($product))) {
290
- $tempCategory[] = $result[$count];
291
- break 2;
292
- }
293
- }
294
- }
295
-
296
- unset($orders);
297
- $count++;
298
- }
299
-
300
- $customersFiltered = array_intersect($tempCategory, $customersFiltered);
301
- }
302
- //FINE FILTRO 3 ACQUISTATO IN CATEGORIA: testato ok
303
-
304
-
305
- //FILTRO 4 GRUPPO DI CLIENTI
306
- $count = 0;
307
- $result = array();
308
- $tempGroup = array();
309
-
310
- if ($request->getRequest()->getParam('mailupCustomerGroupId') > 0) {
311
- foreach ($customersFiltered as $customer) {
312
- if ($customer['group_id'] == $request->getRequest()->getParam('mailupCustomerGroupId')) {
313
- $tempGroup[] = $customer;
314
- }
315
- }
316
-
317
- $customersFiltered = array_intersect($tempGroup, $customersFiltered);
318
- }
319
- //FINE FILTRO 4 GRUPPO DI CLIENTI: testato ok
320
-
321
-
322
- //FILTRO 5 PAESE DI PROVENIENZA
323
- $count = 0;
324
- $result = array();
325
- $tempCountry = array();
326
-
327
- if ($request->getRequest()->getParam('mailupCountry') != '0') {
328
- foreach ($customersFiltered as $customer) {
329
- //ottengo la nazione del primary billing address
330
- $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
331
- $customerAddress = $customerItem->getPrimaryBillingAddress();
332
- $countryId = $customerAddress['country_id'];
333
-
334
- if ($countryId == $request->getRequest()->getParam('mailupCountry')) {
335
- $tempCountry[] = $customer;
336
- }
337
-
338
- //unsetto la variabile
339
- unset($customerItem); //->unsetData();
340
- }
341
-
342
- $customersFiltered = array_intersect($tempCountry, $customersFiltered);
343
- }
344
- //FINE FILTRO 5 PAESE DI PROVENIENZA: testato ok
345
-
346
-
347
- //FILTRO 6 CAP DI PROVENIENZA
348
- $count = 0;
349
- $result = array();
350
- $tempPostCode = array();
351
-
352
- if ($request->getRequest()->getParam('mailupPostCode')) {
353
- foreach ($customersFiltered as $customer) {
354
- //ottengo la nazione del primary billing address
355
- $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
356
- $customerAddress = $customerItem->getPrimaryBillingAddress();
357
- $postCode = $customerAddress['postcode'];
358
-
359
- if ($postCode == $request->getRequest()->getParam('mailupPostCode')) {
360
- $tempPostCode[] = $customer;
361
- }
362
-
363
- //unsetto la variabile
364
- unset($customerItem); //->unsetData();
365
- }
366
-
367
- $customersFiltered = array_intersect($tempPostCode, $customersFiltered);
368
- }
369
- //FINE FILTRO 6 CAP DI PROVENIENZA: testato ok
370
-
371
-
372
- //FILTRO 7 DATA CREAZIONE CLIENTE
373
- $count = 0;
374
- $result = array();
375
- $tempDate = array();
376
-
377
- if ($request->getRequest()->getParam('mailupCustomerStartDate') || $request->getRequest()->getParam('mailupCustomerEndDate') ) {
378
- foreach ($customersFiltered as $customer) {
379
- $createdAt = $customer['created_at'];
380
- $createdAt = new DateTime($createdAt, $TIMEZONE_UTC);
381
- $createdAt->setTimezone($TIMEZONE_STORE);
382
- $createdAt = (string)$createdAt->format("Y-m-d H:i:s");
383
- $filterStart = '';
384
- $filterEnd = '';
385
-
386
- if ($request->getRequest()->getParam('mailupCustomerStartDate')) {
387
- $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupCustomerStartDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
388
- $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
389
- $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
390
- $filterStart = "{$date['year']}-{$date['month']}-{$date['day']} 00:00:00";
391
- }
392
- if ($request->getRequest()->getParam('mailupCustomerEndDate')) {
393
- $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupCustomerEndDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
394
- $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
395
- $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
396
- $filterEnd = "{$date['year']}-{$date['month']}-{$date['day']} 23:59:59";
397
- }
398
- if ($filterStart && $filterEnd) {
399
- //compreso tra start e end date
400
- if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
401
- $tempDate[] = $customer;
402
- }
403
- } elseif ($filterStart) {
404
- // >= di start date
405
- if ($createdAt >= $filterStart) {
406
- $tempDate[] = $customer;
407
- }
408
- } else {
409
- // <= di end date
410
- if ($createdAt <= $filterEnd) {
411
- $tempDate[] = $customer;
412
- }
413
- }
414
- }
415
-
416
- $customersFiltered = array_intersect($tempDate, $customersFiltered);
417
- }
418
- //FINE FILTRO 7 DATA CREAZIONE CLIENTE: testato ok
419
-
420
-
421
- //FILTRO 8 TOTALE ACQUISTATO
422
- $count = 0;
423
- $result = array();
424
- $tempTotal = array();
425
-
426
- if ($request->getRequest()->getParam('mailupTotalAmountValue') > 0) {
427
- foreach ($customersFiltered as $customer) {
428
- $result[] = $customer;
429
-
430
- //filtro gli ordini in base al customer id
431
- $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
432
-
433
- $totalOrdered = 0;
434
-
435
- foreach ($orders->getData() as $order) {
436
- if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
437
- $totalOrdered += $order['subtotal'];
438
- }
439
-
440
- if ($totalOrdered == $request->getRequest()->getParam('mailupTotalAmountValue') && $request->getRequest()->getParam('mailupTotalAmountCond') == "eq") {
441
- $tempTotal[] = $result[$count];
442
- }
443
-
444
- if ($totalOrdered > $request->getRequest()->getParam('mailupTotalAmountValue') && $request->getRequest()->getParam('mailupTotalAmountCond') == "gt") {
445
- $tempTotal[] = $result[$count];
446
- }
447
-
448
- if ($totalOrdered < $request->getRequest()->getParam('mailupTotalAmountValue') && $request->getRequest()->getParam('mailupTotalAmountCond') == "lt" ) {
449
- $tempTotal[] = $result[$count];
450
- }
451
-
452
- $count++;
453
-
454
- //unsetto la variabile
455
- unset($orders); //->unsetData();
456
- }
457
-
458
- $customersFiltered = array_intersect($tempTotal, $customersFiltered);
459
- }
460
- //FINE FILTRO 8 TOTALE ACQUISTATO: testato ok
461
-
462
-
463
- //FILTRO 9 DATA ACQUISTATO
464
- $count = 0;
465
- $result = array();
466
- $tempOrderedDateYes = array();
467
- $tempOrderedDateNo = array();
468
-
469
- if ($request->getRequest()->getParam('mailupOrderStartDate') || $request->getRequest()->getParam('mailupOrderEndDate') ) {
470
- foreach ($customersFiltered as $customer) {
471
- $result[] = $customer;
472
-
473
- //filtro gli ordini in base al customer id
474
- $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
475
-
476
- $orderedDate = 0;
477
-
478
- foreach ($orders->getData() as $order) {
479
- if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
480
- $createdAt = $order['created_at'];
481
- $createdAt = new DateTime($createdAt, $TIMEZONE_UTC);
482
- $createdAt->setTimezone($TIMEZONE_STORE);
483
- $createdAt = (string)$createdAt->format("Y-m-d H:i:s");
484
- $filterStart = '';
485
- $filterEnd = '';
486
-
487
- if ($request->getRequest()->getParam('mailupOrderStartDate')) {
488
- $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupOrderStartDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
489
- $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
490
- $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
491
- $filterStart = "{$date['year']}-{$date['month']}-{$date['day']} 00:00:00";
492
- }
493
- if ($request->getRequest()->getParam('mailupOrderEndDate')) {
494
- $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupOrderEndDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
495
- $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
496
- $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
497
- $filterEnd = "{$date['year']}-{$date['month']}-{$date['day']} 23:59:59";
498
- }
499
-
500
- if ($filterStart and $filterEnd) {
501
- //compreso tra start e end date
502
- if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
503
- $orderedDate = 1;
504
- }
505
- } elseif ($filterStart) {
506
- // >= di start date
507
- if ($createdAt >= $filterStart) {
508
- $orderedDate = 1;
509
- }
510
- } else {
511
- // <= di end date
512
- if ($createdAt <= $filterEnd) {
513
- $orderedDate = 1;
514
- }
515
- }
516
-
517
- //unsetto la variabile
518
- unset($orders); //->unsetData();
519
- }
520
-
521
- if ($orderedDate == 1) {
522
- $tempOrderedDateYes[] = $result[$count];
523
- } else {
524
- $tempOrderedDateNo[] = $result[$count];
525
- }
526
-
527
- $count++;
528
- }
529
-
530
- if ($request->getRequest()->getParam('mailupOrderYesNo') == 'yes') {
531
- $customersFiltered = array_intersect($tempOrderedDateYes, $customersFiltered);
532
- } else {
533
- $customersFiltered = array_intersect($tempOrderedDateNo, $customersFiltered);
534
- }
535
- }
536
- //FINE FILTRO 9 DATA ACQUISTATO: testato ok
537
-
538
- } else {
539
- //GESTISCO LE MODIFICHE MANUALI
540
- $count = 0;
541
- $result = array();
542
- $tempMod = array();
543
-
544
- $emails = explode("\n", $request->getRequest()->getParam('mailupCustomerFilteredMod'));
545
-
546
- foreach ($emails as $email) {
547
- $email = trim($email);
548
-
549
- if (strstr($email, '@') !== false) {
550
- $customerModCollection = Mage::getModel('customer/customer')
551
- ->getCollection()
552
- ->addAttributeToSelect('email')
553
- ->addAttributeToFilter('email', $email);
554
-
555
- $added = 0;
556
-
557
- foreach ($customerModCollection as $customerMod) {
558
- $tempMod[] = $customerMod->toArray();
559
- $added = 1;
560
- }
561
-
562
- if ($added == 0) {
563
- $tempMod[] = array('entity_id'=>0, 'firstname'=>'', 'lastname'=>'', 'email'=>$email);
564
- }
565
- }
566
- }
567
-
568
- //$customersFiltered = array_intersect($tempMod, $customersFiltered);
569
- $customersFiltered = $tempMod;
570
- }
571
- //FINE GESTISCO LE MODIFICHE MANUALI
572
-
573
- return $customersFiltered;
574
- }
575
-
576
-
577
- public function getFilterHints() {
578
- $filter_hints = array();
579
- try {
580
- // fetch write database connection that is used in Mage_Core module
581
- $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
582
-
583
- // now $write is an instance of Zend_Db_Adapter_Abstract
584
- $result = $connectionRead->query("select * from mailup_filter_hints");
585
-
586
- while ($row = $result->fetch()) {
587
- array_push($filter_hints, array('filter_name' => $row['filter_name'], 'hints' => $row['hints']));
588
- }
589
- } catch (Exception $e) {
590
- Mage::log('Exception: '.$e->getMessage(), 0);
591
- die($e);
592
- }
593
-
594
- return $filter_hints;
595
- }
596
-
597
- public function saveFilterHint($filter_name, $post) {
598
- try {
599
- $hints = '';
600
- foreach ($post as $k => $v) {
601
- if ($v!='' && $k!='form_key') {
602
- if ($hints!='') {
603
- $hints .= '|';
604
- }
605
- $hints .= $k.'='.$v;
606
- }
607
- }
608
- //(e.g. $hints = 'mailupCustomers=2|mailupSubscribed=1';)
609
-
610
- $connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
611
-
612
- $connectionWrite->query("INSERT INTO mailup_filter_hints (filter_name, hints) VALUES ('".$filter_name."', '".$hints."')");
613
- } catch (Exception $e) {
614
- Mage::log('Exception: '.$e->getMessage(), 0);
615
- die($e);
616
- }
617
- }
618
-
619
- public function deleteFilterHint($filter_name) {
620
- try {
621
- $connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
622
-
623
- $connectionWrite->query("DELETE FROM mailup_filter_hints WHERE filter_name LIKE '".$filter_name."'");
624
- } catch (Exception $e) {
625
- Mage::log('Exception: '.$e->getMessage(), 0);
626
- die($e);
627
- }
628
- }
629
-
630
- public function getFieldsMapping() {
631
- $fieldsMappings = array();
632
- try {
633
- $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
634
- return $connectionRead->fetchPairs("select magento_field_name, mailup_field_id from mailup_fields_mapping");
635
- } catch (Exception $e) {
636
- Mage::log('Exception: '.$e->getMessage(), 0);
637
- die($e);
638
- }
639
-
640
- return $fieldsMappings;
641
- }
642
-
643
- public function saveFieldMapping($post) {
644
- try {
645
- $connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
646
- $connectionWrite->query("DELETE FROM mailup_fields_mapping");
647
- foreach ($post as $k => $v) {
648
- if (strlen($v) == 0) continue;
649
- $connectionWrite->insert("mailup_fields_mapping", array(
650
- "magento_field_name" => $k,
651
- "mailup_field_id" => $v
652
- ));
653
- }
654
- } catch (Exception $e) {
655
- Mage::log('Exception: '.$e->getMessage(), 0);
656
- die($e);
657
- }
658
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
  }
1
+ <?php
2
+ /**
3
+ * MailUpWsImport.php
4
+ */
5
+ class MailUpWsImport
6
+ {
7
+ /**
8
+ * NewImportProcess Return Codes
9
+ */
10
+ const ERROR_UNRECOGNISED = -400;
11
+ const ERROR_XML_EMPTY = 401;
12
+ const ERROR_XML_TO_CSV_FAILED = -402;
13
+ const ERROR_NEW_IMPORT_PROCESS_FAILED = -403;
14
+ const ERROR_CONFIRMATION_EMAIL = -410;
15
+ /**
16
+ * StartImportProcesses Return Codes
17
+ */
18
+ const ERROR_LISTID_LISTGUID_MISMATCH = -450;
19
+ const ERROR_UNRECOGNISED_600 = -600;
20
+ const ERROR_IMPORT_PROCESS_RUNNING_FOR_LIST = -601;
21
+ const ERROR_IMPORT_PROCESS_RUNNING_FOR_DIFF_LIST = -602;
22
+ const ERROR_CHECKING_PROCESS_STATUS = -603;
23
+ const ERROR_STARTING_PROCESS_JOB = -604;
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ protected $ns = "http://ws.mailupnet.it/";
29
+ /**
30
+ * @var string
31
+ */
32
+ protected $rCode;
33
+ /**
34
+ * @var SoapClient
35
+ */
36
+ private $soapClient;
37
+ /**
38
+ * @var string
39
+ */
40
+ private $xmlResponse;
41
+ /**
42
+ * @var DomDocument
43
+ */
44
+ protected $domResult;
45
+ /**
46
+ * @var SevenLike_Mailup_Model_Config
47
+ */
48
+ protected $_config;
49
+ /**
50
+ * @var int
51
+ */
52
+ protected $storeId;
53
+
54
+ /**
55
+ * Constructor
56
+ */
57
+ function __construct($storeId = NULL)
58
+ {
59
+ $this->setStoreId($storeId);
60
+
61
+ $this->_config = $config = Mage::getModel('mailup/config');
62
+ /* @var $config SevenLike_Mailup_Model_Config */
63
+
64
+ $urlConsole = Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $this->storeId);
65
+ $WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
66
+ $user = Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId);
67
+ $password = Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $this->storeId);
68
+ $headers = array('User' => $user, 'Password' => $password);
69
+ $this->header = new SOAPHeader($this->ns, 'Authentication', $headers);
70
+
71
+
72
+ if ($this->_config()->isLogEnabled($this->storeId)) {
73
+ Mage::log("Connecting to {$urlConsole} as {$user}");
74
+ }
75
+
76
+ try {
77
+ $this->soapClient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
78
+ $this->soapClient->__setSoapHeaders($this->header);
79
+ }
80
+ catch (Exception $e) {
81
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper("mailup")->__("Unable to connect to MailUp console"));
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Set the store ID
87
+ *
88
+ * @param int
89
+ */
90
+ public function setStoreId($id)
91
+ {
92
+ $this->storeId = $id;
93
+
94
+ return $this;
95
+ }
96
+
97
+ function __destruct()
98
+ {
99
+ unset($this->soapClient);
100
+ }
101
+
102
+ /**
103
+ * Get a list of functions from the web service.
104
+ */
105
+ public function getFunctions()
106
+ {
107
+ print_r($this->soapClient->__getFunctions());
108
+ }
109
+
110
+ /**
111
+ * Create a New Group
112
+ *
113
+ * @param type $newGroup
114
+ * @return boolean
115
+ */
116
+ public function creaGruppo($newGroup)
117
+ {
118
+ if ( ! is_object($this->soapClient)) {
119
+ return false;
120
+ }
121
+ try {
122
+ if ($this->_config()->isLogEnabled($this->storeId)) {
123
+ Mage::log("Mailup: creazione nuovo gruppo");
124
+ Mage::log($newGroup);
125
+ }
126
+ $this->soapClient->CreateGroup($newGroup);
127
+ $this->printLastRequest();
128
+ $this->printLastResponse();
129
+
130
+ return $this->readReturnCode('CreateGroup', 'ReturnCode');
131
+ }
132
+ catch (SoapFault $soapFault) {
133
+ Mage::log('SOAP error', 0);
134
+ Mage::log($soapFault, 0);
135
+ }
136
+ }
137
+
138
+ /**
139
+ * GetNlList
140
+ *
141
+ * @return boolean
142
+ */
143
+ public function GetNlList()
144
+ {
145
+ if ( ! is_object($this->soapClient)) {
146
+ return false;
147
+ }
148
+ try {
149
+ $this->soapClient->GetNlLists();
150
+ $this->printLastRequest();
151
+ $this->printLastResponse();
152
+ $result = $this->soapClient->__getLastResponse();
153
+ if ($this->_config()->isLogEnabled($this->storeId)) {
154
+ Mage::log($result, 0);
155
+ }
156
+ return $result;
157
+ }
158
+ catch (SoapFault $soapFault) {
159
+ Mage::log('SOAP error', 0);
160
+ Mage::log($soapFault, 0);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * newImportProcess
166
+ *
167
+ * @see http://help.mailup.com/display/mailupapi/WSMailUpImport.NewImportProcess
168
+ * @param type $importProcessData
169
+ * @return boolean
170
+ */
171
+ public function newImportProcess($importProcessData)
172
+ {
173
+ if ( ! is_object($this->soapClient)) {
174
+ return false;
175
+ }
176
+ try {
177
+ $this->soapClient->NewImportProcess($importProcessData);
178
+ $this->printLastResponse();
179
+ /**
180
+ * This isn't correct.
181
+ *
182
+ * There's only a NewImportPrcoess return code if it's successful.
183
+ *
184
+ * If not we've got to look for the other format return code..
185
+ */
186
+ $returncode = $this->readReturnCode('NewImportProcess', 'ReturnCode');
187
+ if ($this->_config()->isLogEnabled($this->storeId)) {
188
+ Mage::log("mailup: newImportProcess result: $returncode", 0);
189
+ }
190
+ return $returncode;
191
+ }
192
+ catch (SoapFault $soapFault) {
193
+ Mage::log('SOAP error', 0);
194
+ Mage::log($soapFault, 0);
195
+ return false;
196
+ }
197
+ }
198
+
199
+ /**
200
+ * Start Process
201
+ *
202
+ * @see http://help.mailup.com/display/mailupapi/WSMailUpImport.StartProcess
203
+ * @param type $processData
204
+ * @return boolean
205
+ */
206
+ public function startProcess($processData)
207
+ {
208
+ if ( ! is_object($this->soapClient)) {
209
+ return false;
210
+ }
211
+ try {
212
+ $this->soapClient->StartProcess($processData);
213
+ $this->printLastResponse();
214
+ if ($this->_config()->isLogEnabled($this->storeId)) {
215
+ Mage::log("mailup: ws: startProcess", 0);
216
+ }
217
+ return true;
218
+ }
219
+ catch (SoapFault $soapFault) {
220
+ Mage::log('SOAP error', 0);
221
+ Mage::log($soapFault, 0);
222
+ return false;
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Process Detail
228
+ *
229
+ * @param type $processData
230
+ * @return boolean
231
+ */
232
+ public function getProcessDetail($processData)
233
+ {
234
+ if ( ! is_object($this->soapClient)) {
235
+ return false;
236
+ }
237
+ try {
238
+ if ($this->_config()->isLogEnabled($this->storeId)) {
239
+ Mage::log($this->soapClient->GetProcessDetails($processData), 0);
240
+ }
241
+ }
242
+ catch (SoapFault $soapFault) {
243
+ Mage::log('SOAP error', 0);
244
+ Mage::log($soapFault, 0);
245
+ }
246
+ }
247
+
248
+ /**
249
+ * startImportProcesses
250
+ *
251
+ * @see http://help.mailup.com/display/mailupapi/WSMailUpImport.StartImportProcesses
252
+ * @param type $processData
253
+ * @return boolean
254
+ */
255
+ public function startImportProcesses($processData)
256
+ {
257
+ if ( ! is_object($this->soapClient)) {
258
+ return false;
259
+ }
260
+ try {
261
+ $this->soapClient->StartImportProcesses($processData);
262
+ $returnCode = $this->_getStartImportProcessResult();
263
+ Mage::log('_getStartImportProcessResult');
264
+ Mage::log($returnCode);
265
+ //$returncode = $this->readReturnCode('StartImportProcesses', 'ReturnCode');
266
+
267
+ if ($this->_config()->isLogEnabled($this->storeId)) {
268
+ Mage::log("mailup: ws: startImportProcesses", 0);
269
+ }
270
+ $this->printLastRequest();
271
+ $this->printLastResponse();
272
+ return TRUE;
273
+ }
274
+ catch (SoapFault $soapFault) {
275
+ Mage::log('SOAP error', 0);
276
+ Mage::log($soapFault, 0);
277
+ return FALSE;
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Get the return code from the XML response.
283
+ *
284
+ * @staticvar string
285
+ * @param type $func
286
+ * @param type $param
287
+ * @return boolean|int
288
+ */
289
+ private function readReturnCode($func, $param)
290
+ {
291
+ if ( ! is_object($this->soapClient)) {
292
+ return FALSE;
293
+ }
294
+
295
+ //prendi l'XML di ritorno se non l'ho già preso
296
+ $this->xmlResponse = $this->soapClient->__getLastResponse();
297
+
298
+ $dom = new DomDocument();
299
+ $dom->loadXML($this->xmlResponse) or die('File XML non valido!');
300
+ $xmlResult = $dom->getElementsByTagName($func.'Result');
301
+ /**
302
+ * Not successful, try and get a MailupMessae instead.
303
+ *
304
+ * Check the API, it's not got a consistent return format! it's different if there's an issue
305
+ */
306
+ if(empty($xmlResult)) {
307
+ $xmlResult = $dom->getElementsByTagName('mailupMessage');
308
+ }
309
+
310
+ $this->domResult = new DomDocument();
311
+ $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die('File XML non valido!');
312
+ /**
313
+ * @todo FIX
314
+ *
315
+ * Getting an error here, during Cron.
316
+ * Fatal error: Call to a member function getElementsByTagName()
317
+ */
318
+ if(isset($this->domResult) && is_object($this->domResult)) {
319
+ $rCode = $this->domResult->getElementsByTagName($param);
320
+ return $rCode->item(0)->nodeValue;
321
+ }
322
+ else {
323
+ Mage::log('NO RESULT');
324
+ return 9999;
325
+ }
326
+
327
+ return FALSE;
328
+ }
329
+
330
+ /**
331
+ * Get the result form the Import Process
332
+ *
333
+ * An array of status code,s the first one is the overall return code,
334
+ * but may be followed by return codes for each process started.
335
+ *
336
+ * @param string
337
+ * @return array
338
+ */
339
+ protected function _getStartImportProcessResult($param = 'ReturnCode')
340
+ {
341
+ if ( ! is_object($this->soapClient)) {
342
+ return FALSE;
343
+ }
344
+
345
+ $this->xmlResponse = $this->soapClient->__getLastResponse();
346
+
347
+ $dom = new DomDocument();
348
+ $dom->loadXML($this->xmlResponse) or die('File XML non valido!');
349
+ $xmlResult = $dom->getElementsByTagName('StartImportProcessesResult');
350
+
351
+ $this->domResult = new DomDocument();
352
+ $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die('File XML non valido!');
353
+
354
+ if(isset($this->domResult) && is_object($this->domResult)) {
355
+ $returnCodes = array();
356
+ $nodes = $this->domResult->getElementsByTagName($param);
357
+ foreach($nodes as $node) {
358
+ $returnCodes[] = $node->nodeValue;
359
+ }
360
+
361
+ return $returnCodes;
362
+ }
363
+ else {
364
+ Mage::log('NO RESULT _getStartImportProcessResult');
365
+ return 9999;
366
+ }
367
+
368
+ return FALSE;
369
+ }
370
+
371
+ /**
372
+ * NOT IN USE /////////////////////
373
+ *
374
+ * Get the result form New Import Process
375
+ *
376
+ * An array of status code,s the first one is the overall return code,
377
+ * but may be followed by return codes for each process started.
378
+ *
379
+ * @param string
380
+ * @return array
381
+ */
382
+ protected function _getNewImportProcessResult($param = 'ReturnCode')
383
+ {
384
+ if ( ! is_object($this->soapClient)) {
385
+ return FALSE;
386
+ }
387
+
388
+ $this->xmlResponse = $this->soapClient->__getLastResponse();
389
+
390
+ $dom = new DomDocument();
391
+ $dom->loadXML($this->xmlResponse) or die('File XML non valido!');
392
+ $xmlResult = $dom->getElementsByTagName('mailupMessage');
393
+
394
+ $this->domResult = new DomDocument();
395
+ $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die('File XML non valido!');
396
+
397
+ if(isset($this->domResult) && is_object($this->domResult)) {
398
+ $rCode = $this->domResult->getElementsByTagName($param);
399
+ return $rCode->nodeValue;
400
+ }
401
+ else {
402
+ Mage::log('NO RESULT');
403
+ return 9999;
404
+ }
405
+
406
+ return FALSE;
407
+ }
408
+
409
+ /**
410
+ * Print the last request
411
+ *
412
+ * @return void
413
+ */
414
+ private function printLastRequest()
415
+ {
416
+ return "";
417
+ if ($this->_config()->isLogEnabled($this->storeId)) {
418
+ $this->soapClient->__getLastRequest();
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Print the Last Response
424
+ */
425
+ private function printLastResponse()
426
+ {
427
+ //return "";
428
+ if ($this->_config()->isLogEnabled($this->storeId)) {
429
+ Mage::log('Last Response');
430
+ Mage::log($this->soapClient->__getLastResponse());
431
+ }
432
+ }
433
+
434
+ /**
435
+ * Get filtered customers.
436
+ *
437
+ * @todo refactor this it's v poor
438
+ * @param
439
+ * @return int
440
+ */
441
+ public function getCustomersFiltered($request, $storeId = NULL)
442
+ {
443
+ $TIMEZONE_STORE = new DateTimeZone(Mage::getStoreConfig("general/locale/timezone"));
444
+ $TIMEZONE_UTC = new DateTimeZone("UTC");
445
+
446
+ //inizializzo l'array dei clienti
447
+ $customersFiltered = array();
448
+
449
+ if (!$request->getRequest()->getParam('mailupCustomerFilteredMod')) {
450
+ //ottengo la collection con tutti i clienti
451
+ $customerCollection = Mage::getModel('customer/customer')
452
+ ->getCollection()
453
+ ->addAttributeToSelect('entity_id')
454
+ ->addAttributeToSelect('group_id')
455
+ ->addAttributeToSelect('created_at')
456
+ ->addAttributeToSelect('store_id')
457
+ ->addAttributeToFilter('store_id', array('eq' => $storeId))
458
+ ->getSelect()->query()
459
+ ;
460
+
461
+ // if(isset($storeId)) {
462
+ // $customerCollection->addAttributeToFilter('store_id', array('eq' => $storeId));
463
+ // }
464
+ // $customerCollection->getSelect()->query();
465
+
466
+ while ($row = $customerCollection->fetch()) {
467
+ $customersFiltered[] = $row;
468
+ }
469
+
470
+ //se richiesto, seleziono solo quelli iscritti alla newsletter di Magento
471
+ if ($request->getRequest()->getParam('mailupSubscribed') > 0) {
472
+ $tempSubscribed = array();
473
+ foreach ($customersFiltered as $customer) {
474
+ $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
475
+ if (Mage::getModel('newsletter/subscriber')->loadByCustomer($customerItem)->isSubscribed()) {
476
+ $tempSubscribed[] = $customer;
477
+ }
478
+ }
479
+ $customersFiltered = array_intersect($tempSubscribed, $customersFiltered);
480
+ }
481
+
482
+ //FILTRO 1 ACQUISTATO: in base al fatto se ha effettuato o meno acquisti: 0 = tutti, 1 = chi ha acquistato, 2 = chi non ha mai acquistato
483
+ $count = 0;
484
+ $result = array();
485
+ $tempPurchased = array();
486
+ $tempNoPurchased = array();
487
+
488
+ if ($request->getRequest()->getParam('mailupCustomers') > 0) {
489
+ foreach ($customersFiltered as $customer) {
490
+ $result[] = $customer;
491
+
492
+ //filtro gli ordini in base al customer id
493
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
494
+
495
+ //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
496
+ if ($orders->getData()) {
497
+ $tempPurchased[] = $result[$count];
498
+ } else {
499
+ $tempNoPurchased[] = $result[$count];
500
+ }
501
+
502
+ //unsetto la variabile
503
+ unset($orders); //->unsetData();
504
+
505
+ $count++;
506
+ }
507
+
508
+ if ($request->getRequest()->getParam('mailupCustomers') == 1) {
509
+ $customersFiltered = array_intersect($tempPurchased, $customersFiltered);
510
+ } elseif ($request->getRequest()->getParam('mailupCustomers') == 2) {
511
+ $customersFiltered = array_intersect($tempNoPurchased, $customersFiltered);
512
+ }
513
+ }
514
+ //FINE FILTRO 1 ACQUISTATO: testato OK
515
+
516
+ //FILTRO 2 PRODOTTO ACQUISTATO: in base al fatto se ha acquistato un determinato prodotto
517
+ $count = 0;
518
+ $result = array();
519
+ $tempProduct = array();
520
+
521
+ if ($request->getRequest()->getParam('mailupProductSku')) {
522
+ foreach ($customersFiltered as $customer) {
523
+ $result[] = $customer;
524
+
525
+ //filtro gli ordini in base al customer id
526
+ $orders = Mage::getModel('sales/order')
527
+ ->getCollection()
528
+ ->addAttributeToFilter('customer_id', $result[$count]['entity_id'])
529
+ ;
530
+ $purchasedProduct = 0;
531
+
532
+ $mailupProductId = Mage::getModel('catalog/product')
533
+ ->getIdBySku($request->getRequest()->getParam('mailupProductSku'))
534
+ ;
535
+
536
+ foreach ($orders->getData() as $order) {
537
+ if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
538
+ $orderIncrementId = $order['increment_id'];
539
+
540
+ //carico i dati di ogni ordine
541
+ $orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
542
+ $items = $orderData->getAllItems();
543
+ $ids = array();
544
+ foreach ($items as $itemId => $item) {
545
+ $ids[] = $item->getProductId();
546
+ }
547
+
548
+ if (in_array($mailupProductId, $ids)) {
549
+ $purchasedProduct = 1;
550
+ }
551
+ }
552
+
553
+ //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
554
+ if ($purchasedProduct == 1) {
555
+ $tempProduct[] = $result[$count];
556
+ }
557
+
558
+ //unsetto la variabile
559
+ unset($orders); //->unsetData();
560
+
561
+ $count++;
562
+ }
563
+
564
+ $customersFiltered = array_intersect($tempProduct, $customersFiltered);
565
+ }
566
+ //FINE FILTRO 2 PRODOTTO ACQUISTATO: testato OK
567
+
568
+
569
+ //FILTRO 3 ACQUISTATO IN CATEGORIA: in base al fatto se ha acquistato almeno un prodotto in una determinata categoria
570
+ $count = 0;
571
+ $result = array();
572
+ $tempCategory = array();
573
+
574
+ if ($request->getRequest()->getParam('mailupCategoryId') > 0) {
575
+ foreach ($customersFiltered as $customer) {
576
+ $result[] = $customer;
577
+
578
+ //filtro gli ordini in base al customer id
579
+ $orders = Mage::getModel('sales/order')
580
+ ->getCollection()
581
+ ->addAttributeToFilter('customer_id', $result[$count]['entity_id'])
582
+ ;
583
+ $purchasedCategory = 0;
584
+
585
+ foreach ($orders->getData() as $order) {
586
+ if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
587
+ $orderIncrementId = $order['increment_id'];
588
+
589
+ //carico i dati di ogni ordine
590
+ $orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
591
+ $items = $orderData->getAllItems();
592
+ $cat_ids = array();
593
+ foreach ($items as $product) {
594
+ if (in_array($request->getRequest()->getParam('mailupCategoryId'), Mage::getResourceSingleton('catalog/product')->getCategoryIds($product))) {
595
+ $tempCategory[] = $result[$count];
596
+ break 2;
597
+ }
598
+ }
599
+ }
600
+
601
+ unset($orders);
602
+ $count++;
603
+ }
604
+
605
+ $customersFiltered = array_intersect($tempCategory, $customersFiltered);
606
+ }
607
+ //FINE FILTRO 3 ACQUISTATO IN CATEGORIA: testato ok
608
+
609
+
610
+ //FILTRO 4 GRUPPO DI CLIENTI
611
+ $count = 0;
612
+ $result = array();
613
+ $tempGroup = array();
614
+
615
+ if ($request->getRequest()->getParam('mailupCustomerGroupId') > 0) {
616
+ foreach ($customersFiltered as $customer) {
617
+ if ($customer['group_id'] == $request->getRequest()->getParam('mailupCustomerGroupId')) {
618
+ $tempGroup[] = $customer;
619
+ }
620
+ }
621
+
622
+ $customersFiltered = array_intersect($tempGroup, $customersFiltered);
623
+ }
624
+ //FINE FILTRO 4 GRUPPO DI CLIENTI: testato ok
625
+
626
+
627
+ //FILTRO 5 PAESE DI PROVENIENZA
628
+ $count = 0;
629
+ $result = array();
630
+ $tempCountry = array();
631
+
632
+ if ($request->getRequest()->getParam('mailupCountry') != '0') {
633
+ foreach ($customersFiltered as $customer) {
634
+ //ottengo la nazione del primary billing address
635
+ $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
636
+ $customerAddress = $customerItem->getPrimaryBillingAddress();
637
+ $countryId = $customerAddress['country_id'];
638
+
639
+ if ($countryId == $request->getRequest()->getParam('mailupCountry')) {
640
+ $tempCountry[] = $customer;
641
+ }
642
+
643
+ //unsetto la variabile
644
+ unset($customerItem); //->unsetData();
645
+ }
646
+
647
+ $customersFiltered = array_intersect($tempCountry, $customersFiltered);
648
+ }
649
+ //FINE FILTRO 5 PAESE DI PROVENIENZA: testato ok
650
+
651
+
652
+ //FILTRO 6 CAP DI PROVENIENZA
653
+ $count = 0;
654
+ $result = array();
655
+ $tempPostCode = array();
656
+
657
+ if ($request->getRequest()->getParam('mailupPostCode')) {
658
+ foreach ($customersFiltered as $customer) {
659
+ //ottengo la nazione del primary billing address
660
+ $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
661
+ $customerAddress = $customerItem->getPrimaryBillingAddress();
662
+ $postCode = $customerAddress['postcode'];
663
+
664
+ if ($postCode == $request->getRequest()->getParam('mailupPostCode')) {
665
+ $tempPostCode[] = $customer;
666
+ }
667
+
668
+ //unsetto la variabile
669
+ unset($customerItem); //->unsetData();
670
+ }
671
+
672
+ $customersFiltered = array_intersect($tempPostCode, $customersFiltered);
673
+ }
674
+ //FINE FILTRO 6 CAP DI PROVENIENZA: testato ok
675
+
676
+
677
+ //FILTRO 7 DATA CREAZIONE CLIENTE
678
+ $count = 0;
679
+ $result = array();
680
+ $tempDate = array();
681
+
682
+ if ($request->getRequest()->getParam('mailupCustomerStartDate') || $request->getRequest()->getParam('mailupCustomerEndDate') ) {
683
+ foreach ($customersFiltered as $customer) {
684
+ $createdAt = $customer['created_at'];
685
+ $createdAt = new DateTime($createdAt, $TIMEZONE_UTC);
686
+ $createdAt->setTimezone($TIMEZONE_STORE);
687
+ $createdAt = (string)$createdAt->format("Y-m-d H:i:s");
688
+ $filterStart = '';
689
+ $filterEnd = '';
690
+
691
+ if ($request->getRequest()->getParam('mailupCustomerStartDate')) {
692
+ $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupCustomerStartDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
693
+ $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
694
+ $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
695
+ $filterStart = "{$date['year']}-{$date['month']}-{$date['day']} 00:00:00";
696
+ }
697
+ if ($request->getRequest()->getParam('mailupCustomerEndDate')) {
698
+ $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupCustomerEndDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
699
+ $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
700
+ $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
701
+ $filterEnd = "{$date['year']}-{$date['month']}-{$date['day']} 23:59:59";
702
+ }
703
+ if ($filterStart && $filterEnd) {
704
+ //compreso tra start e end date
705
+ if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
706
+ $tempDate[] = $customer;
707
+ }
708
+ } elseif ($filterStart) {
709
+ // >= di start date
710
+ if ($createdAt >= $filterStart) {
711
+ $tempDate[] = $customer;
712
+ }
713
+ } else {
714
+ // <= di end date
715
+ if ($createdAt <= $filterEnd) {
716
+ $tempDate[] = $customer;
717
+ }
718
+ }
719
+ }
720
+
721
+ $customersFiltered = array_intersect($tempDate, $customersFiltered);
722
+ }
723
+ //FINE FILTRO 7 DATA CREAZIONE CLIENTE: testato ok
724
+
725
+
726
+ //FILTRO 8 TOTALE ACQUISTATO
727
+ $count = 0;
728
+ $result = array();
729
+ $tempTotal = array();
730
+
731
+ if ($request->getRequest()->getParam('mailupTotalAmountValue') > 0) {
732
+ foreach ($customersFiltered as $customer) {
733
+ $result[] = $customer;
734
+
735
+ //filtro gli ordini in base al customer id
736
+ $orders = Mage::getModel('sales/order')
737
+ ->getCollection()
738
+ ->addAttributeToFilter('customer_id', $result[$count]['entity_id'])
739
+ ;
740
+
741
+ $totalOrdered = 0;
742
+
743
+ foreach ($orders->getData() as $order) {
744
+ if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
745
+ $totalOrdered += $order['subtotal'];
746
+ }
747
+
748
+ if ($totalOrdered == $request->getRequest()->getParam('mailupTotalAmountValue')
749
+ && $request->getRequest()->getParam('mailupTotalAmountCond') == "eq") {
750
+ $tempTotal[] = $result[$count];
751
+ }
752
+
753
+ if ($totalOrdered > $request->getRequest()->getParam('mailupTotalAmountValue')
754
+ && $request->getRequest()->getParam('mailupTotalAmountCond') == "gt") {
755
+ $tempTotal[] = $result[$count];
756
+ }
757
+
758
+ if ($totalOrdered < $request->getRequest()->getParam('mailupTotalAmountValue')
759
+ && $request->getRequest()->getParam('mailupTotalAmountCond') == "lt" ) {
760
+ $tempTotal[] = $result[$count];
761
+ }
762
+
763
+ $count++;
764
+
765
+ //unsetto la variabile
766
+ unset($orders); //->unsetData();
767
+ }
768
+
769
+ $customersFiltered = array_intersect($tempTotal, $customersFiltered);
770
+ }
771
+ //FINE FILTRO 8 TOTALE ACQUISTATO: testato ok
772
+
773
+
774
+ //FILTRO 9 DATA ACQUISTATO
775
+ $count = 0;
776
+ $result = array();
777
+ $tempOrderedDateYes = array();
778
+ $tempOrderedDateNo = array();
779
+
780
+ if ($request->getRequest()->getParam('mailupOrderStartDate')
781
+ || $request->getRequest()->getParam('mailupOrderEndDate') ) {
782
+ foreach ($customersFiltered as $customer) {
783
+ $result[] = $customer;
784
+
785
+ //filtro gli ordini in base al customer id
786
+ $orders = Mage::getModel('sales/order')
787
+ ->getCollection()
788
+ ->addAttributeToFilter('customer_id', $result[$count]['entity_id'])
789
+ ;
790
+
791
+ $orderedDate = 0;
792
+
793
+ foreach ($orders->getData() as $order) {
794
+ if (!in_array($order["status"], array("closed", "complete", "processing"))) continue;
795
+ $createdAt = $order['created_at'];
796
+ $createdAt = new DateTime($createdAt, $TIMEZONE_UTC);
797
+ $createdAt->setTimezone($TIMEZONE_STORE);
798
+ $createdAt = (string)$createdAt->format("Y-m-d H:i:s");
799
+ $filterStart = '';
800
+ $filterEnd = '';
801
+
802
+ if ($request->getRequest()->getParam('mailupOrderStartDate')) {
803
+ $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupOrderStartDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
804
+ $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
805
+ $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
806
+ $filterStart = "{$date['year']}-{$date['month']}-{$date['day']} 00:00:00";
807
+ }
808
+ if ($request->getRequest()->getParam('mailupOrderEndDate')) {
809
+ $date = Zend_Locale_Format::getDate($request->getRequest()->getParam('mailupOrderEndDate'), array('locale'=>Mage::app()->getLocale()->getLocale(), 'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'fix_date'=>true));
810
+ $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
811
+ $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
812
+ $filterEnd = "{$date['year']}-{$date['month']}-{$date['day']} 23:59:59";
813
+ }
814
+
815
+ if ($filterStart and $filterEnd) {
816
+ //compreso tra start e end date
817
+ if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
818
+ $orderedDate = 1;
819
+ }
820
+ } elseif ($filterStart) {
821
+ // >= di start date
822
+ if ($createdAt >= $filterStart) {
823
+ $orderedDate = 1;
824
+ }
825
+ } else {
826
+ // <= di end date
827
+ if ($createdAt <= $filterEnd) {
828
+ $orderedDate = 1;
829
+ }
830
+ }
831
+
832
+ //unsetto la variabile
833
+ unset($orders); //->unsetData();
834
+ }
835
+
836
+ if ($orderedDate == 1) {
837
+ $tempOrderedDateYes[] = $result[$count];
838
+ } else {
839
+ $tempOrderedDateNo[] = $result[$count];
840
+ }
841
+
842
+ $count++;
843
+ }
844
+
845
+ if ($request->getRequest()->getParam('mailupOrderYesNo') == 'yes') {
846
+ $customersFiltered = array_intersect($tempOrderedDateYes, $customersFiltered);
847
+ } else {
848
+ $customersFiltered = array_intersect($tempOrderedDateNo, $customersFiltered);
849
+ }
850
+ }
851
+ //FINE FILTRO 9 DATA ACQUISTATO: testato ok
852
+
853
+ } else {
854
+ //GESTISCO LE MODIFICHE MANUALI
855
+ $count = 0;
856
+ $result = array();
857
+ $tempMod = array();
858
+
859
+ $emails = explode("\n", $request->getRequest()->getParam('mailupCustomerFilteredMod'));
860
+
861
+ foreach ($emails as $email) {
862
+ $email = trim($email);
863
+
864
+ if (strstr($email, '@') !== false) {
865
+ $customerModCollection = Mage::getModel('customer/customer')
866
+ ->getCollection()
867
+ ->addAttributeToSelect('email')
868
+ ->addAttributeToFilter('email', $email);
869
+
870
+ $added = 0;
871
+
872
+ foreach ($customerModCollection as $customerMod) {
873
+ $tempMod[] = $customerMod->toArray();
874
+ $added = 1;
875
+ }
876
+
877
+ if ($added == 0) {
878
+ $tempMod[] = array('entity_id'=>0, 'firstname'=>'', 'lastname'=>'', 'email'=>$email);
879
+ }
880
+ }
881
+ }
882
+
883
+ //$customersFiltered = array_intersect($tempMod, $customersFiltered);
884
+ $customersFiltered = $tempMod;
885
+ }
886
+ //FINE GESTISCO LE MODIFICHE MANUALI
887
+
888
+ return $customersFiltered;
889
+ }
890
+
891
+
892
+ public function getFilterHints() {
893
+ $filter_hints = array();
894
+ try {
895
+ // fetch write database connection that is used in Mage_Core module
896
+ $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
897
+
898
+ // now $write is an instance of Zend_Db_Adapter_Abstract
899
+ $result = $connectionRead->query("select * from mailup_filter_hints");
900
+
901
+ while ($row = $result->fetch()) {
902
+ array_push($filter_hints, array('filter_name' => $row['filter_name'], 'hints' => $row['hints']));
903
+ }
904
+ } catch (Exception $e) {
905
+ Mage::log('Exception: '.$e->getMessage(), 0);
906
+ die($e);
907
+ }
908
+
909
+ return $filter_hints;
910
+ }
911
+
912
+ public function saveFilterHint($filter_name, $post) {
913
+ try {
914
+ $hints = '';
915
+ foreach ($post as $k => $v) {
916
+ if ($v!='' && $k!='form_key') {
917
+ if ($hints!='') {
918
+ $hints .= '|';
919
+ }
920
+ $hints .= $k.'='.$v;
921
+ }
922
+ }
923
+ //(e.g. $hints = 'mailupCustomers=2|mailupSubscribed=1';)
924
+
925
+ $connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
926
+
927
+ $connectionWrite->query("INSERT INTO mailup_filter_hints (filter_name, hints) VALUES ('".$filter_name."', '".$hints."')");
928
+ } catch (Exception $e) {
929
+ Mage::log('Exception: '.$e->getMessage(), 0);
930
+ die($e);
931
+ }
932
+ }
933
+
934
+ public function deleteFilterHint($filter_name) {
935
+ try {
936
+ $connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
937
+
938
+ $connectionWrite->query("DELETE FROM mailup_filter_hints WHERE filter_name LIKE '".$filter_name."'");
939
+ } catch (Exception $e) {
940
+ Mage::log('Exception: '.$e->getMessage(), 0);
941
+ die($e);
942
+ }
943
+ }
944
+
945
+ /**
946
+ * Get Field Mapping
947
+ *
948
+ * @todo Fix to use the config for mappings, per store..
949
+ * @param int
950
+ * @return array
951
+ */
952
+ public function getFieldsMapping($storeId = NULL)
953
+ {
954
+ $config = Mage::getModel('mailup/config');
955
+ /* @var $config SevenLike_Mailup_Model_Config */
956
+ return $config->getFieldsMapping($storeId);
957
+
958
+
959
+ /*$fieldsMappings = array();
960
+ try {
961
+ $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
962
+ return $connectionRead->fetchPairs("select magento_field_name, mailup_field_id from mailup_fields_mapping");
963
+ } catch (Exception $e) {
964
+ Mage::log('Exception: '.$e->getMessage(), 0);
965
+ die($e);
966
+ }
967
+
968
+ return $fieldsMappings;*/
969
+ }
970
+
971
+ /**
972
+ * @depreciated
973
+ * @param array
974
+ */
975
+ public function saveFieldMapping($post)
976
+ {
977
+ try {
978
+ $connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
979
+ $connectionWrite->query("DELETE FROM mailup_fields_mapping");
980
+ foreach ($post as $k => $v) {
981
+ if (strlen($v) == 0) continue;
982
+ $connectionWrite->insert("mailup_fields_mapping", array(
983
+ "magento_field_name" => $k,
984
+ "mailup_field_id" => $v
985
+ ));
986
+ }
987
+ } catch (Exception $e) {
988
+ Mage::log('Exception: '.$e->getMessage(), 0);
989
+ die($e);
990
+ }
991
+ }
992
+
993
+ /**
994
+ * Get the config
995
+ *
996
+ * @return SevenLike_Mailup_Model_Config
997
+ */
998
+ protected function _config()
999
+ {
1000
+ return $this->_config;
1001
+ }
1002
  }
app/code/local/SevenLike/MailUp/Model/Mysql14/MailUp.php CHANGED
@@ -1,9 +1,9 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_Mysql4_MailUp extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
- public function _construct()
6
- {
7
- $this->_init('mailup/mailup', 'mailup_id');
8
- }
9
  }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Mysql4_MailUp extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('mailup/mailup', 'mailup_id');
8
+ }
9
  }
app/code/local/SevenLike/MailUp/Model/Mysql14/MailUp/Collection.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_Mysql4_MailUp_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
- public function _construct()
6
- {
7
- //parent::__construct();
8
- $this->_init('mailup/mailup');
9
- }
10
  }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Mysql4_MailUp_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::__construct();
8
+ $this->_init('mailup/mailup');
9
+ }
10
  }
app/code/local/SevenLike/MailUp/Model/Observer.php CHANGED
@@ -1,264 +1,348 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/Wssend.php";
5
- class SevenLike_MailUp_Model_Observer
6
- {
7
- const CRON_STRING_PATH = 'crontab/jobs/sevenlike_mailup/schedule/cron_expr';
8
-
9
- /**
10
- * Save system config event
11
- *
12
- * @param Varien_Object $observer
13
- */
14
- public function saveSystemConfig($observer)
15
- {
16
- $store = $observer->getStore();
17
- $website = $observer->getWebsite();
18
-
19
- Mage::getModel('core/config_data')
20
- ->load(self::CRON_STRING_PATH, 'path')
21
- ->setValue($this->_getSchedule())
22
- ->setPath(self::CRON_STRING_PATH)
23
- ->save();
24
- Mage::app()->cleanCache();
25
-
26
- $this->configCheck();
27
- }
28
-
29
- /**
30
- * Transform system settings option to cron schedule string
31
- *
32
- * @return string
33
- */
34
- protected function _getSchedule()
35
- {
36
- $data = Mage::app()->getRequest()->getPost('groups');
37
- $frequency = !empty($data['mailup']['fields']['mailup_cron_frequency']['value'])?
38
- $data['mailup']['fields']['mailup_cron_frequency']['value']:
39
- 0;
40
-
41
- switch ($frequency) {
42
- case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::DAILY:
43
- return "0 0 * * *";
44
- case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_2_HOURS:
45
- return "0 0,2,4,6,8,10,12,14,16,18,20,22 * * *";
46
- case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_6_HOURS:
47
- return "0 0,6,12,18 * * * *";
48
- case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_12_HOURS:
49
- return "0 0,12 * * *";
50
- case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::HOURLY:
51
- default:
52
- return "0 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *";
53
- }
54
- }
55
-
56
- public function leggiUtente($observer)
57
- {
58
- $model = $observer->getEvent()->getModel();
59
- if (empty($model)) $model = $model = $observer->getEvent()->getDataObject();
60
- if (isset($GLOBALS["__sl_mailup_leggi_utente"])) return $this;
61
- $GLOBALS["__sl_mailup_leggi_utente"] = true;
62
-
63
- try {
64
- $WSDLUrl = 'http://services.mailupnet.it/MailupReport.asmx?WSDL';
65
- $user = Mage::getStoreConfig('newsletter/mailup/username_ws');
66
- $password = Mage::getStoreConfig('newsletter/mailup/password_ws');
67
- $headers = array('User' => $user, 'Password' => $password);
68
- $header = new SOAPHeader("http://ws.mailupnet.it/", 'Authentication', $headers);
69
- $soapclient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
70
- $soapclient->__setSoapHeaders($header);
71
-
72
- $loginData = array ('user' => Mage::getStoreConfig('newsletter/mailup/username_ws'),
73
- 'pwd' => Mage::getStoreConfig('newsletter/mailup/password_ws'),
74
- 'consoleId' => substr(Mage::getStoreConfig('newsletter/mailup/username_ws'), 1));
75
- $result = get_object_vars($soapclient->LoginFromId($loginData));
76
- $xml = simplexml_load_string($result['LoginFromIdResult']);
77
- $errorCode = (string)$xml->errorCode;
78
- $errorDescription = (string)$xml->errorDescription;
79
- $accessKey = (string)$xml->accessKey;
80
-
81
- $result = $soapclient->ReportByUser(array(
82
- "accessKey" => $accessKey,
83
- "email" => $model->getEmail(),
84
- "listID" => Mage::getStoreConfig('newsletter/mailup/list'),
85
- "messageID" => 0
86
- ));
87
- $result = get_object_vars($result);
88
- $xml = simplexml_load_string($result['ReportByUserResult']);
89
-
90
- $stato_registrazione = (string)$xml->Canali->Email;
91
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("stato registrazione: " . $stato_registrazione);
92
- if ($stato_registrazione) {
93
- switch (strtolower($stato_registrazione)) {
94
- case "iscritto":
95
- Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)->save();
96
- $model->setIsSubscribed(1);
97
- $model->save();
98
- break;
99
- case "in attesa":
100
- Mage::getSingleton('core/session')->addNotice(Mage::helper("mailup")->__("Your subscription is waiting for confirmation"));
101
- break;
102
- default:
103
- Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)->save();
104
- $model->setIsSubscribed(0);
105
- $model->save();
106
- }
107
- }
108
- } catch (Exception $e) {
109
- Mage::logException($e);
110
- }
111
-
112
- return $this;
113
- }
114
-
115
- public function inviaUtente($observer)
116
- {
117
- if (isset($GLOBALS["__sl_mailup_invia_utente"])) return $this;
118
- $GLOBALS["__sl_mailup_invia_utente"] = true;
119
-
120
- $model = $observer->getEvent()->getDataObject();
121
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($model->getData());
122
- $status = Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->getStatus();
123
-
124
- $module = Mage::app()->getRequest()->getModuleName();
125
- $controller = Mage::app()->getRequest()->getControllerName();
126
- $action = Mage::app()->getRequest()->getActionName();
127
-
128
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("mailup: invia utente");
129
-
130
- if (($module == "customer" and $controller == "account" and $action == "createpost") or ($module == "checkout" and $controller == "onepage" and $action == "saveOrder")) {
131
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("SONO in registrazione, LEGGO PRIMA mailup!");
132
- //sono in registrazione, controllo lo stato di subscribe magento, se non risulto iscritto leggo lo status da mailup e se sono iscritto lo salvo su magento prima di continuare
133
- if (!$status) {
134
- //leggo l'utente da mailup
135
- $this->leggiUtente($observer);
136
- //rileggo lo status perché potrebbe essere stato modificato dalla precedente chiamata
137
- $status = Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->getStatus();
138
- // se non sono iscritto nemmeno lato mailup allora posso evitare di andare oltre
139
- if (!$status) return $this;
140
- }
141
- }
142
-
143
- $console = Mage::getStoreConfig('newsletter/mailup/url_console');
144
- $listId = Mage::getStoreConfig('newsletter/mailup/list');
145
-
146
- try {
147
- $wsImport = new MailUpWsImport();
148
- $xmlString = $wsImport->GetNlList();
149
- if (!$xmlString) return $this;
150
-
151
- $xmlString = html_entity_decode($xmlString);
152
- $startLists = strpos($xmlString, '<Lists>');
153
- $endPos = strpos($xmlString, '</Lists>');
154
- $endLists = $endPos + strlen('</Lists>') - $startLists;
155
- $xmlLists = substr($xmlString, $startLists, $endLists);
156
- $xmlLists = str_replace("&", "&amp;", $xmlLists);
157
- $xml = simplexml_load_string($xmlLists);
158
-
159
- foreach ($xml->List as $list) {
160
- if ($list['idList'] == $listId) {
161
- $listGUID = $list["listGUID"];
162
- break;
163
- }
164
- }
165
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("STATO ISCRIZIONE: $status");
166
- if ($status == 1) {
167
- $ws = "http://{$console}/frontend/Xmlsubscribe.aspx";
168
- } else {
169
- $ws = "http://{$console}/frontend/Xmlunsubscribe.aspx";
170
- }
171
-
172
- $ws .= "?ListGuid=" . rawurlencode($listGUID);
173
- $ws .= "&List=" . rawurlencode($listId);
174
- $ws .= "&Email=" . rawurlencode($model->getEmail());
175
-
176
- try {
177
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("mailup invio utente $ws");
178
- $result = @file_get_contents($ws);
179
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log("mailup risultato invio $result");
180
- } catch (Exception $e) {}
181
- } catch (Exception $e) {
182
- Mage::logException($e);
183
- }
184
-
185
- return $this;
186
- }
187
-
188
- public function configCheck()
189
- {
190
- $url_console = Mage::getStoreConfig('newsletter/mailup/url_console');
191
- $user = Mage::getStoreConfig('newsletter/mailup/username_ws');
192
- $password = Mage::getStoreConfig('newsletter/mailup/password_ws');
193
- $list = Mage::getStoreConfig('newsletter/mailup/list');
194
-
195
- if (!strlen($url_console) or !strlen($user) or !strlen($password) or !strlen($list)) {
196
- $url = Mage::getModel('adminhtml/url');
197
- $url = $url->getUrl("adminhtml/system_config/edit", array(
198
- "section" => "newsletter"
199
- ));
200
- $message = Mage::helper("mailup")->__('MailUp configuration is not complete');
201
- $message = str_replace("href=''", "href='$url'", $message);
202
- Mage::getSingleton('adminhtml/session')->addWarning($message);
203
- return;
204
- }
205
-
206
- $wsimport = new MailUpWsImport();
207
- $mapping = $wsimport->getFieldsMapping();
208
- if (empty($mapping)) {
209
- $url = Mage::getModel('adminhtml/url');
210
- $url = $url->getUrl("mailup/adminhtml_fieldsmapping");
211
- $message = Mage::helper("mailup")->__('MailUp fields mapping is not complete');
212
- $message = str_replace("href=''", "href='$url'", $message);
213
- Mage::getSingleton('adminhtml/session')->addWarning($message);
214
- return;
215
- }
216
- }
217
-
218
- public function subscribeDuringCheckout()
219
- {
220
- if (@$_REQUEST["mailup_subscribe2"]) {
221
- $order_id = Mage::getSingleton("checkout/session")->getLastRealOrderId();
222
- $order = Mage::getModel("sales/order")->loadByIncrementId($order_id);
223
- try {
224
- Mage::getModel("newsletter/subscriber")->subscribe($order->getCustomerEmail());
225
- } catch (Exception $e) {}
226
- }
227
- }
228
-
229
- public function prepareOrderForDataSync($observer)
230
- {
231
- $order = $observer->getEvent()->getOrder();
232
- $customer_id = $order->getCustomerId();
233
- if ($customer_id) self::setCustomerForDataSync($customer_id);
234
- }
235
-
236
- public function prepareCustomerForDataSync($observer)
237
- {
238
- $customer = $observer->getEvent()->getCustomer();
239
- $customer_id = $customer->getId();
240
- if ($customer_id) self::setCustomerForDataSync($customer_id);
241
- }
242
-
243
- private static function setCustomerForDataSync($customer_id)
244
- {
245
- if (!$customer_id) return false;
246
-
247
- $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
248
- try {
249
- $db_write->insert("mailup_sync", array(
250
- "customer_id" => $customer_id,
251
- "entity" => "customer",
252
- "job_id" => 0,
253
- "needs_sync" => true,
254
- "last_sync" => null
255
- ));
256
- } catch (Exception $e) {
257
- $db_write->update("mailup_sync", array(
258
- "needs_sync" => true
259
- ), "customer_id=$customer_id AND entity='customer' AND job_id=0");
260
- }
261
-
262
- return true;
263
- }
264
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once dirname(__FILE__) . "/MailUpWsImport.php";
4
+ require_once dirname(__FILE__) . "/Wssend.php";
5
+ class SevenLike_MailUp_Model_Observer
6
+ {
7
+ const CRON_STRING_PATH = 'crontab/jobs/sevenlike_mailup/schedule/cron_expr';
8
+
9
+ /**
10
+ * Save system config event
11
+ *
12
+ * @param Varien_Object $observer
13
+ */
14
+ public function saveSystemConfig($observer)
15
+ {
16
+ $store = $observer->getStore();
17
+ $website = $observer->getWebsite();
18
+
19
+ Mage::getModel('core/config_data')
20
+ ->load(self::CRON_STRING_PATH, 'path')
21
+ ->setValue($this->_getSchedule())
22
+ ->setPath(self::CRON_STRING_PATH)
23
+ ->save();
24
+ Mage::app()->cleanCache();
25
+
26
+ $this->configCheck();
27
+ }
28
+
29
+ /**
30
+ * Transform system settings option to cron schedule string
31
+ *
32
+ * @return string
33
+ */
34
+ protected function _getSchedule()
35
+ {
36
+ $data = Mage::app()->getRequest()->getPost('groups');
37
+ $frequency = !empty($data['mailup']['fields']['mailup_cron_frequency']['value'])?
38
+ $data['mailup']['fields']['mailup_cron_frequency']['value']:
39
+ 0;
40
+
41
+ switch ($frequency) {
42
+ case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::DAILY:
43
+ return "0 0 * * *";
44
+ case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_2_HOURS:
45
+ return "0 0,2,4,6,8,10,12,14,16,18,20,22 * * *";
46
+ case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_6_HOURS:
47
+ return "0 0,6,12,18 * * * *";
48
+ case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_12_HOURS:
49
+ return "0 0,12 * * *";
50
+ case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::HOURLY:
51
+ default:
52
+ return "0 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *";
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Observes: customer_customer_authenticated
58
+ *
59
+ * @param type $observer
60
+ * @return \SevenLike_MailUp_Model_Observer
61
+ */
62
+ public function leggiUtente($observer)
63
+ {
64
+ $model = $observer->getEvent()->getModel();
65
+ if (empty($model)) $model = $model = $observer->getEvent()->getDataObject();
66
+ if (isset($GLOBALS["__sl_mailup_leggi_utente"])) return $this;
67
+ $GLOBALS["__sl_mailup_leggi_utente"] = true;
68
+
69
+ try {
70
+ $WSDLUrl = 'http://services.mailupnet.it/MailupReport.asmx?WSDL';
71
+ $user = Mage::getStoreConfig('mailup_newsletter/mailup/username_ws');
72
+ $password = Mage::getStoreConfig('mailup_newsletter/mailup/password_ws');
73
+ $headers = array('User' => $user, 'Password' => $password);
74
+ $header = new SOAPHeader("http://ws.mailupnet.it/", 'Authentication', $headers);
75
+ $soapclient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
76
+ $soapclient->__setSoapHeaders($header);
77
+
78
+ $loginData = array ('user' => Mage::getStoreConfig('mailup_newsletter/mailup/username_ws'),
79
+ 'pwd' => Mage::getStoreConfig('mailup_newsletter/mailup/password_ws'),
80
+ 'consoleId' => substr(Mage::getStoreConfig('mailup_newsletter/mailup/username_ws'), 1));
81
+ $result = get_object_vars($soapclient->LoginFromId($loginData));
82
+ $xml = simplexml_load_string($result['LoginFromIdResult']);
83
+ $errorCode = (string)$xml->errorCode;
84
+ $errorDescription = (string)$xml->errorDescription;
85
+ $accessKey = (string)$xml->accessKey;
86
+
87
+ $result = $soapclient->ReportByUser(array(
88
+ "accessKey" => $accessKey,
89
+ "email" => $model->getEmail(),
90
+ "listID" => Mage::getStoreConfig('mailup_newsletter/mailup/list'),
91
+ "messageID" => 0
92
+ ));
93
+ $result = get_object_vars($result);
94
+ $xml = simplexml_load_string($result['ReportByUserResult']);
95
+
96
+ $stato_registrazione = (string)$xml->Canali->Email;
97
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) Mage::log("stato registrazione: " . $stato_registrazione);
98
+ if ($stato_registrazione) {
99
+ switch (strtolower($stato_registrazione)) {
100
+ case "iscritto":
101
+ Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)->save();
102
+ $model->setIsSubscribed(1);
103
+ $model->save();
104
+ break;
105
+ case "in attesa":
106
+ Mage::getSingleton('core/session')->addNotice(Mage::helper("mailup")->__("Your subscription is waiting for confirmation"));
107
+ break;
108
+ default:
109
+ Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)->save();
110
+ $model->setIsSubscribed(0);
111
+ $model->save();
112
+ }
113
+ }
114
+ } catch (Exception $e) {
115
+ Mage::logException($e);
116
+ }
117
+
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ *
123
+ * @see newsletter_subscriber_save_after
124
+ * @param type $observer
125
+ * @return \SevenLike_MailUp_Model_Observer
126
+ */
127
+ public function inviaUtente($observer)
128
+ {
129
+ if (isset($GLOBALS["__sl_mailup_invia_utente"])) {
130
+ return $this;
131
+ }
132
+ $GLOBALS["__sl_mailup_invia_utente"] = true;
133
+
134
+ $model = $observer->getEvent()->getDataObject();
135
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
136
+ Mage::log($model->getData());
137
+ }
138
+ $status = Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->getStatus();
139
+
140
+ $module = Mage::app()->getRequest()->getModuleName();
141
+ $controller = Mage::app()->getRequest()->getControllerName();
142
+ $action = Mage::app()->getRequest()->getActionName();
143
+
144
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
145
+ Mage::log("mailup: invia utente");
146
+ }
147
+
148
+ if (($module == "customer" and $controller == "account" and $action == "createpost") or ($module == "checkout" and $controller == "onepage" and $action == "saveOrder")) {
149
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
150
+ Mage::log("SONO in registrazione, LEGGO PRIMA mailup!");
151
+ }
152
+ //sono in registrazione, controllo lo stato di subscribe magento, se non risulto iscritto leggo lo status da mailup e se sono iscritto lo salvo su magento prima di continuare
153
+ if ( ! $status) {
154
+ //leggo l'utente da mailup
155
+ $this->leggiUtente($observer);
156
+ //rileggo lo status perché potrebbe essere stato modificato dalla precedente chiamata
157
+ $status = Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->getStatus();
158
+ // se non sono iscritto nemmeno lato mailup allora posso evitare di andare oltre
159
+ if ( ! $status) {
160
+ return $this;
161
+ }
162
+ }
163
+ }
164
+
165
+ $console = Mage::getStoreConfig('mailup_newsletter/mailup/url_console');
166
+ $listId = Mage::getStoreConfig('mailup_newsletter/mailup/list');
167
+
168
+ try {
169
+ $wsImport = new MailUpWsImport();
170
+ $xmlString = $wsImport->GetNlList();
171
+ if (!$xmlString) return $this;
172
+
173
+ $xmlString = html_entity_decode($xmlString);
174
+ $startLists = strpos($xmlString, '<Lists>');
175
+ $endPos = strpos($xmlString, '</Lists>');
176
+ $endLists = $endPos + strlen('</Lists>') - $startLists;
177
+ $xmlLists = substr($xmlString, $startLists, $endLists);
178
+ $xmlLists = str_replace("&", "&amp;", $xmlLists);
179
+ $xml = simplexml_load_string($xmlLists);
180
+
181
+ foreach ($xml->List as $list) {
182
+ if ($list['idList'] == $listId) {
183
+ $listGUID = $list["listGUID"];
184
+ break;
185
+ }
186
+ }
187
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) Mage::log("STATO ISCRIZIONE: $status");
188
+ if ($status == 1) {
189
+ $ws = "http://{$console}/frontend/Xmlsubscribe.aspx";
190
+ } else {
191
+ $ws = "http://{$console}/frontend/Xmlunsubscribe.aspx";
192
+ }
193
+
194
+ $ws .= "?ListGuid=" . rawurlencode($listGUID);
195
+ $ws .= "&List=" . rawurlencode($listId);
196
+ $ws .= "&Email=" . rawurlencode($model->getEmail());
197
+
198
+ try {
199
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
200
+ Mage::log("mailup invio utente $ws");
201
+ }
202
+ $result = @file_get_contents($ws);
203
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
204
+ Mage::log("mailup risultato invio $result");
205
+ }
206
+ } catch (Exception $e) {}
207
+ } catch (Exception $e) {
208
+ Mage::logException($e);
209
+ }
210
+
211
+ return $this;
212
+ }
213
+
214
+ /**
215
+ * Config Check
216
+ *
217
+ * @return type
218
+ */
219
+ public function configCheck()
220
+ {
221
+ $url_console = Mage::getStoreConfig('mailup_newsletter/mailup/url_console');
222
+ $user = Mage::getStoreConfig('mailup_newsletter/mailup/username_ws');
223
+ $password = Mage::getStoreConfig('mailup_newsletter/mailup/password_ws');
224
+ $list = Mage::getStoreConfig('mailup_newsletter/mailup/list');
225
+
226
+ if (!strlen($url_console) or !strlen($user) or !strlen($password) or !strlen($list)) {
227
+ $url = Mage::getModel('adminhtml/url');
228
+ $url = $url->getUrl("mailup/adminhtml_configuration");
229
+ $message = Mage::helper("mailup")->__('MailUp configuration is not complete');
230
+ $message = str_replace("href=''", "href='$url'", $message);
231
+ Mage::getSingleton('adminhtml/session')->addWarning($message);
232
+
233
+ return;
234
+ }
235
+
236
+ $wsimport = new MailUpWsImport();
237
+ $mapping = $wsimport->getFieldsMapping();
238
+ if (empty($mapping)) {
239
+ $url = Mage::getModel('adminhtml/url');
240
+ $url = $url->getUrl("mailup/adminhtml_configuration");
241
+ $message = Mage::helper("mailup")->__('MailUp fields mapping is not complete');
242
+ $message = str_replace("href=''", "href='$url'", $message);
243
+ Mage::getSingleton('adminhtml/session')->addWarning($message);
244
+
245
+ return;
246
+ }
247
+ }
248
+
249
+ public function subscribeDuringCheckout()
250
+ {
251
+ if (@$_REQUEST["mailup_subscribe2"]) {
252
+ $order_id = Mage::getSingleton("checkout/session")->getLastRealOrderId();
253
+ $order = Mage::getModel("sales/order")->loadByIncrementId($order_id);
254
+ try {
255
+ Mage::getModel("newsletter/subscriber")->subscribe($order->getCustomerEmail());
256
+ } catch (Exception $e) {}
257
+ }
258
+ }
259
+
260
+ /**
261
+ * Attach to sales_order_save_after event
262
+ *
263
+ * @see sales_order_save_after
264
+ * @param type $observer
265
+ */
266
+ public function prepareOrderForDataSync($observer)
267
+ {
268
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
269
+ Mage::log("TRIGGERED prepareOrderForDataSync");
270
+ }
271
+
272
+ $order = $observer->getEvent()->getOrder();
273
+ /* @var $order Mage_Sales_Model_Order */
274
+ $customer_id = $order->getCustomerId();
275
+
276
+ $customer = Mage::getmodel('customer/customer')->load($customer_id);
277
+ //$storeId = $customer->getStoreId(); // Is this always correct??
278
+ $storeId = $order->getStoreId();
279
+
280
+ if($customer_id) {
281
+ self::setCustomerForDataSync($customer_id, $storeId);
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Attach to customer_save_after even
287
+ *
288
+ * @see customer_save_after
289
+ */
290
+ public function prepareCustomerForDataSync($observer)
291
+ {
292
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
293
+ Mage::log("TRIGGERED prepareCustomerForDataSync");
294
+ }
295
+
296
+ $customer = $observer->getEvent()->getCustomer();
297
+ $customer_id = $customer->getId();
298
+ $storeId = $customer->getStoreId(); // Is this always correct??
299
+ /**
300
+ * Possibly getting issues here with store id not being right...
301
+ */
302
+ if($customer_id) {
303
+ self::setCustomerForDataSync($customer_id, $storeId);
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Add custom data to sync table
309
+ *
310
+ * @param int
311
+ * @param int
312
+ * @return boolean
313
+ */
314
+ private static function setCustomerForDataSync($customer_id, $storeId = NULL)
315
+ {
316
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
317
+ Mage::log("TRIGGERED setCustomerForDataSync, Store ID: {$storeId}");
318
+ }
319
+
320
+ if( ! isset($storeId)) {
321
+ $storeId = Mage::app()->getStore()->getId();
322
+ }
323
+
324
+ if( ! $customer_id) {
325
+ return false;
326
+ }
327
+
328
+ $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
329
+ try {
330
+ $db_write->insert("mailup_sync", array(
331
+ 'store_id' => $storeId,
332
+ "customer_id" => $customer_id,
333
+ "entity" => "customer",
334
+ "job_id" => 0,
335
+ "needs_sync" => true,
336
+ "last_sync" => null
337
+ ));
338
+ }
339
+ catch (Exception $e) {
340
+ $db_write->update("mailup_sync", array(
341
+ 'store_id' => $storeId,
342
+ "needs_sync" => true
343
+ ), "customer_id=$customer_id AND entity='customer' AND job_id=0");
344
+ }
345
+
346
+ return true;
347
+ }
348
+ }
app/code/local/SevenLike/MailUp/Model/Subscriber.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Subscriber.php
4
+ *
5
+ * Override Magento subscriber to allow us to enable / disable the Notifications
6
+ */
7
+ class SevenLike_MailUp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
8
+ {
9
+ /**
10
+ * Send Success Email
11
+ *
12
+ * @override
13
+ * @todo make this per store scope!
14
+ * @return SevenLike_MailUp_Model_Subscriber
15
+ */
16
+ public function sendConfirmationSuccessEmail()
17
+ {
18
+ if($this->_getConfig()->isNewsletterNotificationDisabled()) {
19
+ Mage::log("Newsletter Notification DISABLED: sendConfirmationSuccessEmail");
20
+ return $this;
21
+ }
22
+ else {
23
+ return parent::sendConfirmationSuccessEmail();
24
+ }
25
+ }
26
+
27
+
28
+ /**
29
+ * Send Confirmation request Email
30
+ *
31
+ * @override
32
+ * @todo make this per store scope!
33
+ * @return SevenLike_MailUp_Model_Subscriber
34
+ */
35
+ public function sendConfirmationRequestEmail()
36
+ {
37
+ if($this->_getConfig()->isNewsletterNotificationDisabled()) {
38
+ Mage::log("Newsletter Notification DISABLED: sendConfirmationRequestEmail");
39
+ return $this;
40
+ }
41
+ else {
42
+ return parent::sendConfirmationRequestEmail();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Send the Emails
48
+ *
49
+ * @override
50
+ * @todo make this per store scope!
51
+ * @return SevenLike_MailUp_Model_Subscriber
52
+ */
53
+ public function sendUnsubscriptionEmail()
54
+ {
55
+ if($this->_getConfig()->isNewsletterNotificationDisabled()) {
56
+ Mage::log("Newsletter Notification DISABLED: sendUnsubscriptionEmail");
57
+ return $this;
58
+ }
59
+ else {
60
+ return parent::sendUnsubscriptionEmail();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Get the config
66
+ *
67
+ * @return SevenLike_MailUp_Model_Config
68
+ */
69
+ protected function _getConfig()
70
+ {
71
+ return Mage::getModel('mailup/config');
72
+ }
73
+ }
app/code/local/SevenLike/MailUp/Model/Webserviceusernamevalidator.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_Model_Webserviceusernamevalidator extends Mage_Core_Model_Config_Data
4
- {
5
- public function save()
6
- {
7
- $value = $this->getValue();
8
- if (strlen($value) == 0) {
9
- Mage::throwException(Mage::helper("mailup")->__("Please fill the web service username"));
10
- }
11
-
12
- if (!preg_match("/a[0-9]+/", $value)) {
13
- Mage::throwException(Mage::helper("mailup")->__("Web service username is not in the right format"));
14
- }
15
-
16
- return parent::save();
17
- }
18
  }
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Webserviceusernamevalidator extends Mage_Core_Model_Config_Data
4
+ {
5
+ public function save()
6
+ {
7
+ $value = $this->getValue();
8
+ if (strlen($value) == 0) {
9
+ Mage::throwException(Mage::helper("mailup")->__("Please fill the web service username"));
10
+ }
11
+
12
+ if (!preg_match("/a[0-9]+/", $value)) {
13
+ Mage::throwException(Mage::helper("mailup")->__("Web service username is not in the right format"));
14
+ }
15
+
16
+ return parent::save();
17
+ }
18
  }
app/code/local/SevenLike/MailUp/Model/Ws.php CHANGED
@@ -1,3 +1,3 @@
1
- <?php
2
-
3
  // this file is needed for backward compatibility
1
+ <?php
2
+
3
  // this file is needed for backward compatibility
app/code/local/SevenLike/MailUp/Model/Wssend.php CHANGED
@@ -1,306 +1,349 @@
1
- <?php
2
-
3
- class MailUpWsSend
4
- {
5
- protected $WSDLUrl = 'http://services.mailupnet.it/MailupSend.asmx?WSDL';
6
- private $soapClient;
7
- private $xmlResponse;
8
- protected $domResult;
9
-
10
- function __construct() {
11
- $this->soapClient = new SoapClient($this->WSDLUrl, array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
12
- }
13
-
14
- function __destruct() {
15
- unset($this->soapClient);
16
- }
17
-
18
- public function getFunctions() {
19
- print_r($this->soapClient->__getFunctions());
20
- }
21
-
22
- public function login() {
23
- $loginData = array('user' => Mage::getStoreConfig('newsletter/mailup/user'),
24
- 'pwd' => Mage::getStoreConfig('newsletter/mailup/password'),
25
- 'url' => Mage::getStoreConfig('newsletter/mailup/url_console'));
26
-
27
- $result = get_object_vars($this->soapClient->Login($loginData));
28
- $xml = simplexml_load_string($result['LoginResult']);
29
- $xml = get_object_vars($xml);
30
-
31
- //echo $xml['errorDescription'];
32
-
33
- return $xml['errorCode'];
34
- }
35
-
36
- /**
37
- * @return $accessKey | false
38
- */
39
- public function loginFromId() {
40
- try {
41
- //login with webservice user
42
- $loginData = array ('user' => Mage::getStoreConfig('newsletter/mailup/username_ws'),
43
- 'pwd' => Mage::getStoreConfig('newsletter/mailup/password_ws'),
44
- 'consoleId' => substr(Mage::getStoreConfig('newsletter/mailup/username_ws'), 1));
45
-
46
- $result = get_object_vars($this->soapClient->LoginFromId($loginData));
47
- $xml = simplexml_load_string($result['LoginFromIdResult']);
48
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($xml);
49
-
50
- $errorCode = (string)$xml->errorCode;
51
- $errorDescription = (string)$xml->errorDescription;
52
- $accessKey = (string)$xml->accessKey;
53
-
54
- if ($errorCode != 0) {
55
- Mage::log('Error code: '.$errorCode);
56
- Mage::log('Error description: '.$errorDescription);
57
- throw new Exception($errorDescription);
58
- }
59
-
60
- return $accessKey;
61
- } catch (SoapFault $soapFault) {
62
- Mage::log('SOAP error', 0);
63
- Mage::log($soapFault, 0);
64
- $errorDescription = $soapFault;
65
- } catch (Exception $e) {
66
- Mage::log($e->getMessage(), 0);
67
- $errorDescription = $e->getMessage();
68
- }
69
-
70
- $GLOBALS["__sl_mailup_login_error"] = $errorDescription;
71
- return false;
72
- }
73
-
74
- public function GetFields($accessKey) {
75
- $fields = null;
76
-
77
- try {
78
- $result = get_object_vars($this->soapClient->GetFields(array('accessKey' => $accessKey)));
79
- $xml = simplexml_load_string($result['GetFieldsResult']);
80
-
81
- if ($xml->Error) {
82
- throw new Exception($xml->Error);
83
- }
84
-
85
- $fields = $this->_parseGetFieldsXmlResponse($xml);
86
- } catch (SoapFault $soapFault) {
87
- Mage::log('SOAP error', 0);
88
- Mage::log($soapFault, 0);
89
- } catch (Exception $e) {
90
- Mage::log('Custom exception', 0);
91
- Mage::log($e->getMessage(), 0);
92
- }
93
-
94
- return $fields;
95
- }
96
-
97
- private function _parseGetFieldsXmlResponse($xmlSimpleElement) {
98
- $fields = $this->_getFieldsDefaultConfiguration();
99
-
100
- if ($xmlSimpleElement->Fields && sizeof($xmlSimpleElement->Fields->Field) > 0) {
101
- $fields = array();
102
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log('Fields returned, overwriting default configuration', 0);
103
- foreach ($xmlSimpleElement->Fields->Field as $fieldSimpleElement) {
104
- $fields[(string)$fieldSimpleElement['Name']] = (string)$fieldSimpleElement['Id'];
105
- }
106
- }
107
- if (Mage::getStoreConfig('newsletter/mailup/enable_log')) Mage::log($fields);
108
- return $fields;
109
- }
110
-
111
- private function _getFieldsDefaultConfiguration() {
112
- $fields = array();
113
-
114
- $fields['nome'] = '1';
115
- $fields['cognome'] = '2';
116
- $fields['azienda'] = '3';
117
- $fields['città'] = '4';
118
- $fields['provincia'] = '5';
119
- $fields['cap'] = '6';
120
- $fields['regione'] = '7';
121
- $fields['paese'] = '8';
122
- $fields['indirizzo'] = '9';
123
- $fields['fax'] = '10';
124
- $fields['telefono'] = '11';
125
- $fields['IDCliente'] = '12';
126
- $fields['IDUltimoOrdine'] = '13';
127
- $fields['DataUltimoOrdine'] = '14';
128
- $fields['TotaleUltimoOrdine'] = '15';
129
- $fields['IDProdottiUltimoOrdine'] = '16';
130
- $fields['IDCategorieUltimoOrdine'] = '17';
131
- $fields['DataUltimoOrdineSpedito'] = '18';
132
- $fields['IDUltimoOrdineSpedito'] = '19';
133
- $fields['DataCarrelloAbbandonato'] = '20';
134
- $fields['TotaleCarrelloAbbandonato'] = '21';
135
- $fields['IDCarrelloAbbandonato'] = '22';
136
- $fields['TotaleFatturato'] = '23';
137
- $fields['TotaleFatturatoUltimi12Mesi'] = '24';
138
- $fields['TotaleFatturatoUltimi30gg'] = '25';
139
- $fields['IDTuttiProdottiAcquistati'] = '26';
140
-
141
- return $fields;
142
- }
143
-
144
-
145
- public function logout() {
146
- try {
147
- $this->soapClient->Logout(array('accessKey' => $this->accessKey));
148
- if ($this->readReturnCode('Logout', 'errorCode') != 0) {
149
- echo '<br /><br />Errore Logout'. $this->readReturnCode('Logout', 'errorDescription');
150
- }
151
- } catch (SoapFault $soapFault) {
152
- Mage::log('SOAP error', 0);
153
- Mage::log($soapFault, 0);
154
- }
155
- }
156
-
157
- public function getLists() {
158
- try {
159
- $this->soapClient->GetLists(array('accessKey' => $this->accessKey));
160
- if ($this->readReturnCode('GetLists', 'errorCode') != 0) {
161
- echo '<br /><br />Errore GetLists: '. $this->readReturnCode('GetLists', 'errorDescription');
162
- } else {
163
- $this->printLastResponse();
164
- }
165
- } catch (SoapFault $soapFault) {
166
- Mage::log('SOAP error', 0);
167
- Mage::log($soapFault, 0);
168
- }
169
- }
170
-
171
- public function getGroups($params) {
172
- try {
173
- $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
174
- $this->soapClient->GetGroups($params);
175
- if ($this->readReturnCode('GetGroups', 'errorCode') != 0) {
176
- echo '<br /><br />Errore GetGroups: '. $this->readReturnCode('GetGroups', 'errorDescription');
177
- } else {
178
- $this->printLastResponse();
179
- }
180
- } catch (SoapFault $soapFault) {
181
- Mage::log('SOAP error', 0);
182
- Mage::log($soapFault, 0);
183
- }
184
- }
185
-
186
- public function getNewsletters($params) {
187
- try {
188
- $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
189
- $this->soapClient->GetNewsletters($params);
190
- if ($this->readReturnCode('GetNewsletters', 'errorCode') != 0) {
191
- echo '<br /><br />Errore GetNewsletters: '. $this->readReturnCode('GetNewsletters', 'errorDescription');
192
- } else {
193
- $this->printLastResponse();
194
- }
195
- } catch (SoapFault $soapFault) {
196
- Mage::log('SOAP error', 0);
197
- Mage::log($soapFault, 0);
198
- }
199
- }
200
-
201
- public function createNewsletter($params) {
202
- try {
203
- $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
204
- $this->soapClient->createNewsletter($params);
205
-
206
- $this->printLastRequest();
207
- if ($this->readReturnCode('CreateNewsletter', 'errorCode') != 0) {
208
- echo '<br /><br />Errore CreateNewsletter: '. $this->readReturnCode('CreateNewsletter', 'errorCode') .' - '. $this->readReturnCode('CreateNewsletter', 'errorDescription');
209
- } else {
210
- $this->printLastResponse();
211
- }
212
- } catch (SoapFault $soapFault) {
213
- Mage::log('SOAP error', 0);
214
- Mage::log($soapFault, 0);
215
- }
216
- }
217
-
218
- public function sendNewsletter($params) {
219
- try {
220
- $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
221
- $this->soapClient->SendNewsletter($params);
222
- $this->printLastRequest();
223
- if ($this->readReturnCode('SendNewsletter', 'errorCode') != 0) {
224
- echo '<br /><br />Errore SendNewsletter: '. $this->readReturnCode('SendNewsletter', 'errorCode') .' - '. $this->readReturnCode('SendNewsletter', 'errorDescription');
225
- } else {
226
- $this->printLastResponse();
227
- }
228
- } catch (SoapFault $soapFault) {
229
- Mage::log('SOAP error', 0);
230
- Mage::log($soapFault, 0);
231
- }
232
- }
233
-
234
- public function sendNewsletterFast($params) {
235
- try {
236
- $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
237
- $this->soapClient->SendNewsletterFast($params);
238
- $this->printLastRequest();
239
- if ($this->readReturnCode('SendNewsletterFast', 'errorCode') != 0) {
240
- echo '<br /><br />Errore SendNewsletterFast: '. $this->readReturnCode('SendNewsletterFast', 'errorCode') .' - '. $this->readReturnCode('SendNewsletterFast', 'errorDescription');
241
- } else {
242
- $this->printLastResponse();
243
- }
244
- } catch (SoapFault $soapFault) {
245
- Mage::log('SOAP error', 0);
246
- Mage::log($soapFault, 0);
247
- }
248
- }
249
-
250
- private function readReturnCode($func, $param) {
251
- static $func_in = ''; //static variable to test xmlResponse update
252
- if ($func_in != $func) { //(!isset($this->xmlResponse))
253
- $func_in = $func;
254
- //prendi l'XML di ritorno se non l'ho gia' preso
255
- $this->xmlResponse = $this->soapClient->__getLastResponse();
256
-
257
- $dom = new DomDocument();
258
- $dom->loadXML($this->xmlResponse) or die('File XML non valido!');
259
- $xmlResult = $dom->getElementsByTagName($func.'Result');
260
-
261
- $this->domResult = new DomDocument();
262
- $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die('File XML non valido!');
263
- }
264
-
265
- $rCode = $this->domResult->getElementsByTagName($param);
266
- return $rCode->item(0)->nodeValue;
267
- }
268
-
269
- private function printLastRequest() {
270
- echo '<br />Request :<br />'. htmlentities($this->soapClient->__getLastRequest()) .'<br />';
271
- }
272
-
273
- private function printLastResponse() {
274
- echo '<br />XMLResponse: '. $this->soapClient->__getLastResponse() .'<br />'; //htmlentities();
275
- }
276
-
277
- //TODO: seems unused, remove if so
278
- public function getAccessKey() {
279
- return $this->accessKey;
280
- }
281
-
282
- public function option($key, $value) {
283
- return array('Key' => $key, 'Value' => $value);
284
- }
285
-
286
- //TODO: TEST stuff (this shouldn't be here)
287
- public function loginTest() {
288
- $loginData = array('user' => 'a7410', 'pwd' => 'GA6VAN0W', 'url' => 'g4a0.s03.it');
289
-
290
- $result = get_object_vars($this->soapClient->Login($loginData));
291
- $xml = simplexml_load_string($result['LoginResult']);
292
- $xml = get_object_vars($xml);
293
-
294
- if ($xml['errorCode'] > 0) {
295
- echo $xml['errorDescription'].'<br /><br />';
296
- }
297
-
298
- return $xml['errorCode'];
299
- }
300
-
301
- public function testSoap() {
302
- $client = new SoapClient('http://soapclient.com/xml/soapresponder.wsdl', array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
303
- //print_r($client->__getFunctions());
304
- return $client->Method1('x12qaq','c56tf3');
305
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
1
+ <?php
2
+
3
+ class MailUpWsSend
4
+ {
5
+ protected $WSDLUrl = 'http://services.mailupnet.it/MailupSend.asmx?WSDL';
6
+ private $soapClient;
7
+ private $xmlResponse;
8
+ protected $domResult;
9
+ /**
10
+ * @var int
11
+ */
12
+ protected $storeId;
13
+
14
+ function __construct($storeId = NULL)
15
+ {
16
+ $this->soapClient = new SoapClient(
17
+ $this->WSDLUrl,
18
+ array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10)
19
+ );
20
+
21
+ if($storeId === NULL) {
22
+ //$storeId = Mage::app()->getDefaultStoreView()->getStoreId();
23
+ }
24
+
25
+ $this->setStoreId($storeId);
26
+ }
27
+
28
+ /**
29
+ * Set the store ID
30
+ *
31
+ * @param int
32
+ */
33
+ public function setStoreId($id)
34
+ {
35
+ $this->storeId = $id;
36
+
37
+ return $this;
38
+ }
39
+
40
+ function __destruct()
41
+ {
42
+ unset($this->soapClient);
43
+ }
44
+
45
+ public function getFunctions()
46
+ {
47
+ print_r($this->soapClient->__getFunctions());
48
+ }
49
+
50
+ /**
51
+ * Login
52
+ *
53
+ * @return int
54
+ */
55
+ public function login()
56
+ {
57
+ $loginData = array('user' => Mage::getStoreConfig('mailup_newsletter/mailup/user', $this->storeId),
58
+ 'pwd' => Mage::getStoreConfig('mailup_newsletter/mailup/password', $this->storeId),
59
+ 'url' => Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $this->storeId));
60
+
61
+ $result = get_object_vars($this->soapClient->Login($loginData));
62
+ $xml = simplexml_load_string($result['LoginResult']);
63
+ $xml = get_object_vars($xml);
64
+
65
+ //echo $xml['errorDescription'];
66
+
67
+ return $xml['errorCode'];
68
+ }
69
+
70
+ /**
71
+ * @return $accessKey | false
72
+ */
73
+ public function loginFromId() {
74
+ try {
75
+ //login with webservice user
76
+ $loginData = array ('user' => Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId),
77
+ 'pwd' => Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $this->storeId),
78
+ 'consoleId' => substr(Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId), 1));
79
+
80
+ $result = get_object_vars($this->soapClient->LoginFromId($loginData));
81
+ $xml = simplexml_load_string($result['LoginFromIdResult']);
82
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log', $this->storeId)) Mage::log($xml);
83
+
84
+ $errorCode = (string)$xml->errorCode;
85
+ $errorDescription = (string)$xml->errorDescription;
86
+ $accessKey = (string)$xml->accessKey;
87
+
88
+ if ($errorCode != 0) {
89
+ Mage::log('Error code: '.$errorCode);
90
+ Mage::log('Error description: '.$errorDescription);
91
+ throw new Exception($errorDescription);
92
+ }
93
+
94
+ return $accessKey;
95
+ } catch (SoapFault $soapFault) {
96
+ Mage::log('SOAP error', 0);
97
+ Mage::log($soapFault, 0);
98
+ $errorDescription = $soapFault;
99
+ } catch (Exception $e) {
100
+ Mage::log($e->getMessage(), 0);
101
+ $errorDescription = $e->getMessage();
102
+ }
103
+
104
+ $GLOBALS["__sl_mailup_login_error"] = $errorDescription;
105
+ return false;
106
+ }
107
+
108
+ public function GetFields($accessKey) {
109
+ $fields = null;
110
+
111
+ try {
112
+ $result = get_object_vars($this->soapClient->GetFields(array('accessKey' => $accessKey)));
113
+ $xml = simplexml_load_string($result['GetFieldsResult']);
114
+
115
+ if ($xml->Error) {
116
+ throw new Exception($xml->Error);
117
+ }
118
+
119
+ $fields = $this->_parseGetFieldsXmlResponse($xml);
120
+ } catch (SoapFault $soapFault) {
121
+ Mage::log('SOAP error', 0);
122
+ Mage::log($soapFault, 0);
123
+ } catch (Exception $e) {
124
+ Mage::log('Custom exception', 0);
125
+ Mage::log($e->getMessage(), 0);
126
+ }
127
+
128
+ return $fields;
129
+ }
130
+
131
+ private function _parseGetFieldsXmlResponse($xmlSimpleElement) {
132
+ $fields = $this->_getFieldsDefaultConfiguration();
133
+
134
+ if ($xmlSimpleElement->Fields && sizeof($xmlSimpleElement->Fields->Field) > 0) {
135
+ $fields = array();
136
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log', $this->storeId)) Mage::log('Fields returned, overwriting default configuration', 0);
137
+ foreach ($xmlSimpleElement->Fields->Field as $fieldSimpleElement) {
138
+ $fields[(string)$fieldSimpleElement['Name']] = (string)$fieldSimpleElement['Id'];
139
+ }
140
+ }
141
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log', $this->storeId)) Mage::log($fields);
142
+ return $fields;
143
+ }
144
+
145
+ private function _getFieldsDefaultConfiguration() {
146
+ $fields = array();
147
+
148
+ $fields['nome'] = '1';
149
+ $fields['cognome'] = '2';
150
+ $fields['azienda'] = '3';
151
+ $fields['città'] = '4';
152
+ $fields['provincia'] = '5';
153
+ $fields['cap'] = '6';
154
+ $fields['regione'] = '7';
155
+ $fields['paese'] = '8';
156
+ $fields['indirizzo'] = '9';
157
+ $fields['fax'] = '10';
158
+ $fields['telefono'] = '11';
159
+ $fields['IDCliente'] = '12';
160
+ $fields['IDUltimoOrdine'] = '13';
161
+ $fields['DataUltimoOrdine'] = '14';
162
+ $fields['TotaleUltimoOrdine'] = '15';
163
+ $fields['IDProdottiUltimoOrdine'] = '16';
164
+ $fields['IDCategorieUltimoOrdine'] = '17';
165
+ $fields['DataUltimoOrdineSpedito'] = '18';
166
+ $fields['IDUltimoOrdineSpedito'] = '19';
167
+ $fields['DataCarrelloAbbandonato'] = '20';
168
+ $fields['TotaleCarrelloAbbandonato'] = '21';
169
+ $fields['IDCarrelloAbbandonato'] = '22';
170
+ $fields['TotaleFatturato'] = '23';
171
+ $fields['TotaleFatturatoUltimi12Mesi'] = '24';
172
+ $fields['TotaleFatturatoUltimi30gg'] = '25';
173
+ $fields['IDTuttiProdottiAcquistati'] = '26';
174
+
175
+ return $fields;
176
+ }
177
+
178
+
179
+ public function logout() {
180
+ try {
181
+ $this->soapClient->Logout(array('accessKey' => $this->accessKey));
182
+ if ($this->readReturnCode('Logout', 'errorCode') != 0) {
183
+ echo '<br /><br />Errore Logout'. $this->readReturnCode('Logout', 'errorDescription');
184
+ }
185
+ } catch (SoapFault $soapFault) {
186
+ Mage::log('SOAP error', 0);
187
+ Mage::log($soapFault, 0);
188
+ }
189
+ }
190
+
191
+ public function getLists() {
192
+ try {
193
+ $this->soapClient->GetLists(array('accessKey' => $this->accessKey));
194
+ if ($this->readReturnCode('GetLists', 'errorCode') != 0) {
195
+ echo '<br /><br />Errore GetLists: '. $this->readReturnCode('GetLists', 'errorDescription');
196
+ } else {
197
+ $this->printLastResponse();
198
+ }
199
+ } catch (SoapFault $soapFault) {
200
+ Mage::log('SOAP error', 0);
201
+ Mage::log($soapFault, 0);
202
+ }
203
+ }
204
+
205
+ public function getGroups($params) {
206
+ try {
207
+ $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
208
+ $this->soapClient->GetGroups($params);
209
+ if ($this->readReturnCode('GetGroups', 'errorCode') != 0) {
210
+ echo '<br /><br />Errore GetGroups: '. $this->readReturnCode('GetGroups', 'errorDescription');
211
+ } else {
212
+ $this->printLastResponse();
213
+ }
214
+ } catch (SoapFault $soapFault) {
215
+ Mage::log('SOAP error', 0);
216
+ Mage::log($soapFault, 0);
217
+ }
218
+ }
219
+
220
+ public function getNewsletters($params) {
221
+ try {
222
+ $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
223
+ $this->soapClient->GetNewsletters($params);
224
+ if ($this->readReturnCode('GetNewsletters', 'errorCode') != 0) {
225
+ echo '<br /><br />Errore GetNewsletters: '. $this->readReturnCode('GetNewsletters', 'errorDescription');
226
+ } else {
227
+ $this->printLastResponse();
228
+ }
229
+ } catch (SoapFault $soapFault) {
230
+ Mage::log('SOAP error', 0);
231
+ Mage::log($soapFault, 0);
232
+ }
233
+ }
234
+
235
+ public function createNewsletter($params) {
236
+ try {
237
+ $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
238
+ $this->soapClient->createNewsletter($params);
239
+
240
+ $this->printLastRequest();
241
+ if ($this->readReturnCode('CreateNewsletter', 'errorCode') != 0) {
242
+ echo '<br /><br />Errore CreateNewsletter: '. $this->readReturnCode('CreateNewsletter', 'errorCode') .' - '. $this->readReturnCode('CreateNewsletter', 'errorDescription');
243
+ } else {
244
+ $this->printLastResponse();
245
+ }
246
+ } catch (SoapFault $soapFault) {
247
+ Mage::log('SOAP error', 0);
248
+ Mage::log($soapFault, 0);
249
+ }
250
+ }
251
+
252
+ public function sendNewsletter($params) {
253
+ try {
254
+ $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
255
+ $this->soapClient->SendNewsletter($params);
256
+ $this->printLastRequest();
257
+ if ($this->readReturnCode('SendNewsletter', 'errorCode') != 0) {
258
+ echo '<br /><br />Errore SendNewsletter: '. $this->readReturnCode('SendNewsletter', 'errorCode') .' - '. $this->readReturnCode('SendNewsletter', 'errorDescription');
259
+ } else {
260
+ $this->printLastResponse();
261
+ }
262
+ } catch (SoapFault $soapFault) {
263
+ Mage::log('SOAP error', 0);
264
+ Mage::log($soapFault, 0);
265
+ }
266
+ }
267
+
268
+ public function sendNewsletterFast($params) {
269
+ try {
270
+ $params = array_merge((array)$params, array('accessKey' => $this->accessKey));
271
+ $this->soapClient->SendNewsletterFast($params);
272
+ $this->printLastRequest();
273
+ if ($this->readReturnCode('SendNewsletterFast', 'errorCode') != 0) {
274
+ echo '<br /><br />Errore SendNewsletterFast: '. $this->readReturnCode('SendNewsletterFast', 'errorCode') .' - '. $this->readReturnCode('SendNewsletterFast', 'errorDescription');
275
+ } else {
276
+ $this->printLastResponse();
277
+ }
278
+ } catch (SoapFault $soapFault) {
279
+ Mage::log('SOAP error', 0);
280
+ Mage::log($soapFault, 0);
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Get the return code
286
+ *
287
+ * @staticvar string $func_in
288
+ * @param type $func
289
+ * @param type $param
290
+ * @return type
291
+ */
292
+ private function readReturnCode($func, $param)
293
+ {
294
+ static $func_in = ''; //static variable to test xmlResponse update
295
+ if ($func_in != $func) { //(!isset($this->xmlResponse))
296
+ $func_in = $func;
297
+ //prendi l'XML di ritorno se non l'ho gia' preso
298
+ $this->xmlResponse = $this->soapClient->__getLastResponse();
299
+
300
+ $dom = new DomDocument();
301
+ $dom->loadXML($this->xmlResponse) or die('File XML non valido!');
302
+ $xmlResult = $dom->getElementsByTagName($func.'Result');
303
+
304
+ $this->domResult = new DomDocument();
305
+ $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die('File XML non valido!');
306
+ }
307
+
308
+ $rCode = $this->domResult->getElementsByTagName($param);
309
+ return $rCode->item(0)->nodeValue;
310
+ }
311
+
312
+ private function printLastRequest() {
313
+ echo '<br />Request :<br />'. htmlentities($this->soapClient->__getLastRequest()) .'<br />';
314
+ }
315
+
316
+ private function printLastResponse() {
317
+ echo '<br />XMLResponse: '. $this->soapClient->__getLastResponse() .'<br />'; //htmlentities();
318
+ }
319
+
320
+ //TODO: seems unused, remove if so
321
+ public function getAccessKey() {
322
+ return $this->accessKey;
323
+ }
324
+
325
+ public function option($key, $value) {
326
+ return array('Key' => $key, 'Value' => $value);
327
+ }
328
+
329
+ //TODO: TEST stuff (this shouldn't be here)
330
+ public function loginTest() {
331
+ $loginData = array('user' => 'a7410', 'pwd' => 'GA6VAN0W', 'url' => 'g4a0.s03.it');
332
+
333
+ $result = get_object_vars($this->soapClient->Login($loginData));
334
+ $xml = simplexml_load_string($result['LoginResult']);
335
+ $xml = get_object_vars($xml);
336
+
337
+ if ($xml['errorCode'] > 0) {
338
+ echo $xml['errorDescription'].'<br /><br />';
339
+ }
340
+
341
+ return $xml['errorCode'];
342
+ }
343
+
344
+ public function testSoap() {
345
+ $client = new SoapClient('http://soapclient.com/xml/soapresponder.wsdl', array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
346
+ //print_r($client->__getFunctions());
347
+ return $client->Method1('x12qaq','c56tf3');
348
+ }
349
  }
app/code/local/SevenLike/MailUp/controllers/.DS_Store DELETED
Binary file
app/code/local/SevenLike/MailUp/controllers/Adminhtml/.DS_Store DELETED
Binary file
app/code/local/SevenLike/MailUp/controllers/Adminhtml/ConfigurationController.php CHANGED
@@ -1,15 +1,15 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
- class SevenLike_MailUp_Adminhtml_ConfigurationController extends Mage_Adminhtml_Controller_Action
6
- {
7
- public function indexAction()
8
- {
9
- $url = Mage::getModel('adminhtml/url');
10
- $url = $url->getUrl("adminhtml/system_config/edit", array(
11
- "section" => "newsletter"
12
- ));
13
- Mage::app()->getResponse()->setRedirect($url);
14
- }
15
  }
1
+ <?php
2
+
3
+ require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
+ require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
+ class SevenLike_MailUp_Adminhtml_ConfigurationController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ public function indexAction()
8
+ {
9
+ $url = Mage::getModel('adminhtml/url');
10
+ $url = $url->getUrl("adminhtml/system_config/edit", array(
11
+ "section" => "mailup_newsletter"
12
+ ));
13
+ Mage::app()->getResponse()->setRedirect($url);
14
+ }
15
  }
app/code/local/SevenLike/MailUp/controllers/Adminhtml/FieldsmappingController.php CHANGED
@@ -1,28 +1,30 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
- class SevenLike_MailUp_Adminhtml_FieldsMappingController extends Mage_Adminhtml_Controller_Action
6
- {
7
- public function indexAction() {
8
- $this->loadLayout()->renderLayout();
9
- }
10
-
11
- public function saveAction() {
12
- try {
13
- $post = $this->getRequest()->getPost();
14
- unset($post["form_key"]);
15
- require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
16
- $wsImport = new MailUpWsImport();
17
- $wsImport->saveFieldMapping($post);
18
- } catch (Exception $e) {
19
- $errorMessage = $this->__('Error: unable to save current filter');
20
- Mage::getSingleton('adminhtml/session')->addError($errorMessage);
21
- }
22
-
23
- $observer = Mage::getModel("mailup/observer");
24
- $observer->configCheck();
25
-
26
- $this->_redirect('*/*');
27
- }
 
 
28
  }
1
+ <?php
2
+ /**
3
+ * @deprectiated
4
+ */
5
+ require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
6
+ require_once dirname(__FILE__) . "/../../Model/Wssend.php";
7
+ class SevenLike_MailUp_Adminhtml_FieldsMappingController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ public function indexAction() {
10
+ $this->loadLayout()->renderLayout();
11
+ }
12
+
13
+ public function saveAction() {
14
+ try {
15
+ $post = $this->getRequest()->getPost();
16
+ unset($post["form_key"]);
17
+ require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
18
+ $wsImport = new MailUpWsImport();
19
+ $wsImport->saveFieldMapping($post);
20
+ } catch (Exception $e) {
21
+ $errorMessage = $this->__('Error: unable to save current filter');
22
+ Mage::getSingleton('adminhtml/session')->addError($errorMessage);
23
+ }
24
+
25
+ $observer = Mage::getModel("mailup/observer");
26
+ $observer->configCheck();
27
+
28
+ $this->_redirect('*/*');
29
+ }
30
  }
app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php CHANGED
@@ -1,223 +1,266 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
- class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Controller_Action
6
- {
7
- public function indexAction() {
8
- $this->checkRunningImport();
9
- $this->loadLayout()->renderLayout();
10
- }
11
-
12
- public function confirmAction() {
13
- $this->checkRunningImport();
14
- $this->loadLayout()->renderLayout();
15
- }
16
-
17
- public function csvAction() {
18
- $post = $this->getRequest()->getPost();
19
- $file = '';
20
-
21
- if ($post['countPost'] > 0) {
22
- //preparo l'elenco degli iscritti da salvare nel csv
23
- $mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
24
-
25
- //require_once(dirname(__FILE__) . '/../Helper/Data.php');
26
- $customersData = SevenLike_MailUp_Helper_Data::getCustomersData();
27
-
28
- //CSV Column names
29
- $file = '"Email","First Name","Last Name"';
30
- if (Mage::getStoreConfig('newsletter/mailup/enable_mailup_synchro') == 1) {
31
- $file .= ',"Company","City","Province","Zip code","Region","Country code","Address","Fax","Phone","Customer id"';
32
- $file .= ',"Last Order id","Last Order date","Last Order total","Last order product ids","Last order category ids"';
33
- $file .= ',"Last sent order date","Last sent order id"';
34
- $file .= ',"Last abandoned cart date","Last abandoned cart total","Last abandoned cart id"';
35
- $file .= ',"Total orders amount","Last 12 months amount","Last 30 days amount","All products ids"';
36
- }
37
- $file .= ';';
38
-
39
-
40
- foreach ($mailupCustomerIds as $customerId) {
41
- foreach ($customersData as $subscriber) {
42
- if ($subscriber['email'] == $customerId['email']) {
43
- $file .= "\n";
44
- $file .= '"'.$subscriber['email'].'"';
45
- $file .= ',"'.((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') .'"';
46
- $file .= ',"'.((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') .'"';
47
-
48
- $synchroConfig = Mage::getStoreConfig('newsletter/mailup/enable_mailup_synchro') == 1;
49
-
50
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['azienda'])) ? $subscriber['azienda'] : '') .'"';
51
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['città'])) ? $subscriber['città'] : '') .'"';
52
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['provincia'])) ? $subscriber['provincia'] : '') .'"';
53
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['cap'])) ? $subscriber['cap'] : '') .'"';
54
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['regione'])) ? $subscriber['regione'] : '') .'"';
55
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['paese'])) ? $subscriber['paese'] : '') .'"';
56
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['indirizzo'])) ? $subscriber['indirizzo'] : '') .'"';
57
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['fax'])) ? $subscriber['fax'] : '') .'"';
58
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['telefono'])) ? $subscriber['telefono'] : '') .'"';
59
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCliente'])) ? $subscriber['IDCliente'] : '') .'"';
60
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdine'])) ? $subscriber['IDUltimoOrdine'] : '') .'"';
61
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdine'])) ? $subscriber['DataUltimoOrdine'] : '') .'"';
62
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleUltimoOrdine'])) ? $subscriber['TotaleUltimoOrdine'] : '') .'"';
63
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDProdottiUltimoOrdine'])) ? $subscriber['IDProdottiUltimoOrdine'] : '') .'"';
64
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCategorieUltimoOrdine'])) ? $subscriber['IDCategorieUltimoOrdine'] : '') .'"';
65
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdineSpedito'])) ? $subscriber['DataUltimoOrdineSpedito'] : '') .'"';
66
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdineSpedito'])) ? $subscriber['IDUltimoOrdineSpedito'] : '') .'"';
67
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['DataCarrelloAbbandonato'])) ? $subscriber['DataCarrelloAbbandonato'] : '') .'"';
68
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleCarrelloAbbandonato'])) ? $subscriber['TotaleCarrelloAbbandonato'] : '') .'"';
69
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCarrelloAbbandonato'])) ? $subscriber['IDCarrelloAbbandonato'] : '') .'"';
70
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturato'])) ? $subscriber['TotaleFatturato'] : '') .'"';
71
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi12Mesi'])) ? $subscriber['TotaleFatturatoUltimi12Mesi'] : '') .'"';
72
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi30gg'])) ? $subscriber['TotaleFatturatoUltimi30gg'] : '') .'"';
73
- $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDTuttiProdottiAcquistati'])) ? $subscriber['IDTuttiProdottiAcquistati'] : '') .'"';
74
- $file .= ';';
75
-
76
- continue 2;
77
- }
78
- }
79
- }
80
- }
81
-
82
- //lancio il download del file
83
- header("Content-type: application/csv");
84
- header("Content-Disposition: attachment;Filename=filtered_customers.csv");
85
- echo $file;
86
- }
87
-
88
- public function postAction() {
89
- $post = $this->getRequest()->getPost();
90
-
91
- try {
92
- if (empty($post)) {
93
- Mage::throwException($this->__('Invalid form data.'));
94
- }
95
-
96
- // creo il gruppo se necessario
97
- $post["mailupNewGroupName"] = trim($post["mailupNewGroupName"]);
98
- if ($post["mailupNewGroup"] and strlen($post["mailupNewGroupName"])) {
99
- require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
100
- $wsImport = new MailUpWsImport();
101
- $post['mailupGroupId'] = $wsImport->CreaGruppo(array(
102
- "idList" => $post['mailupIdList'],
103
- "listGUID" => $post['mailupListGUID'],
104
- "newGroupName" => $post["mailupNewGroupName"]
105
- ));
106
- }
107
-
108
- // inserisco il job
109
- $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
110
- $db_write->insert("mailup_sync_jobs", array(
111
- "mailupgroupid" => $post['mailupGroupId'],
112
- "send_optin" => $post['send_optin_email_to_new_subscribers'] ? 1 : 0,
113
- "status" => "queued",
114
- "queue_datetime" => gmdate("Y-m-d H:i:s")
115
- ));
116
- $job_id = $db_write->lastInsertId("mailup_sync_jobs");
117
-
118
- // inserisco
119
- $mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
120
- foreach ($mailupCustomerIds as $customer_id) {
121
- try {
122
- $db_write->insert("mailup_sync", array(
123
- "customer_id" => $customer_id,
124
- "entity" => "customer",
125
- "job_id" => $job_id,
126
- "needs_sync" => true,
127
- "last_sync" => null
128
- ));
129
- } catch (Exception $e) {
130
- $db_write->update("mailup_sync", array(
131
- "needs_sync" => true
132
- ), "customer_id=$customer_id AND entity='customer' AND job_id=$job_id");
133
- }
134
- }
135
-
136
- $db_write->insert(Mage::getSingleton('core/resource')->getTableName('cron_schedule'), array(
137
- "job_code" => "sevenlike_mailup",
138
- "status" => "pending",
139
- "created_at" => gmdate("Y-m-d H:i:s"),
140
- "scheduled_at" => gmdate("Y-m-d H:i:s", strtotime("+1minute"))
141
- ));
142
-
143
- $message = $this->__('Members have been sent correctly');
144
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
145
- } catch (Exception $e) {
146
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
147
- $errorMessage = $this->__('Warning: no member has been selected');
148
- Mage::getSingleton('adminhtml/session')->addError($errorMessage);
149
- }
150
-
151
- $this->_redirect('*/*');
152
- }
153
-
154
- public function saveFilterHintAction() {
155
- $this->checkRunningImport();
156
- try {
157
- $post = $this->getRequest()->getPost();
158
- $filter_name = $post['filter_name'];
159
- unset($post['filter_name']);
160
-
161
- $MailUpWsImport = Mage::getModel('mailup/ws');
162
- $wsImport = new MailUpWsImport();
163
- $wsImport->saveFilterHint($filter_name, $post);
164
- } catch (Exception $e) {
165
- $errorMessage = $this->__('Error: unable to save current filter');
166
- Mage::getSingleton('adminhtml/session')->addError($errorMessage);
167
- }
168
-
169
- $this->_redirect('*/*');
170
- }
171
-
172
- public function deleteFilterHintAction() {
173
- $this->checkRunningImport();
174
- try {
175
- $post = $this->getRequest()->getPost();
176
-
177
- $MailUpWsImport = Mage::getModel('mailup/ws');
178
- $wsImport = new MailUpWsImport();
179
- $wsImport->deleteFilterHint($post['filter_name']);
180
- } catch (Exception $e) {
181
- $errorMessage = $this->__('Error: unable to delete the filter');
182
- Mage::getSingleton('adminhtml/session')->addError($errorMessage);
183
- }
184
-
185
- $this->_redirect('*/*');
186
- }
187
-
188
- public function testCronAction() {
189
- $cron = new SevenLike_MailUp_Model_Cron();
190
- $cron->run();
191
- }
192
-
193
- public function testFieldsAction() {
194
- $wsSend = new MailUpWsSend();
195
- $accessKey = $wsSend->loginFromId();
196
-
197
- if ($accessKey !== false) {
198
- $fields = $wsSend->GetFields($accessKey);
199
- print_r($fields);
200
- die('success');
201
- } else {
202
- die('no access key returned');
203
- }
204
- }
205
-
206
- public function checkRunningImport()
207
- {
208
- $db = Mage::getSingleton("core/resource")->getConnection("core_read");
209
- $cron_schedule_table = Mage::getSingleton("core/resource")->getTableName("cron_schedule");
210
-
211
- $running_processes = $db->fetchOne("SELECT count(*) FROM $cron_schedule_table WHERE job_code='sevenlike_mailup' AND status='running'");
212
- if ($running_processes) {
213
- Mage::getSingleton("adminhtml/session")->addNotice($this->__("A MailUp import process is running."));
214
- return;
215
- }
216
-
217
- $scheduled_processes = $db->fetchOne("SELECT count(*) FROM $cron_schedule_table WHERE job_code='sevenlike_mailup' AND status='pending'");
218
- if ($scheduled_processes) {
219
- Mage::getSingleton("adminhtml/session")->addNotice($this->__("A MailUp import process is schedules and will be executed soon."));
220
- return;
221
- }
222
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
1
+ <?php
2
+
3
+ require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
+ require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
+ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ /**
8
+ * Default Action
9
+ */
10
+ public function indexAction()
11
+ {
12
+ $this->checkRunningImport();
13
+ $this->loadLayout()->renderLayout();
14
+ }
15
+
16
+ public function confirmAction() {
17
+ $this->checkRunningImport();
18
+ $this->loadLayout()->renderLayout();
19
+ }
20
+
21
+ /**
22
+ * Generate CSV
23
+ *
24
+ * @todo include stores
25
+ */
26
+ public function csvAction()
27
+ {
28
+ $post = $this->getRequest()->getPost();
29
+ $file = '';
30
+
31
+ if ($post['countPost'] > 0) {
32
+ //preparo l'elenco degli iscritti da salvare nel csv
33
+ $mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
34
+
35
+ //require_once(dirname(__FILE__) . '/../Helper/Data.php');
36
+ $customersData = SevenLike_MailUp_Helper_Data::getCustomersData();
37
+
38
+ //CSV Column names
39
+ $file = '"Email","First Name","Last Name"';
40
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_mailup_synchro') == 1) {
41
+ $file .= ',"Company","City","Province","Zip code","Region","Country code","Address","Fax","Phone","Customer id"';
42
+ $file .= ',"Last Order id","Last Order date","Last Order total","Last order product ids","Last order category ids"';
43
+ $file .= ',"Last sent order date","Last sent order id"';
44
+ $file .= ',"Last abandoned cart date","Last abandoned cart total","Last abandoned cart id"';
45
+ $file .= ',"Total orders amount","Last 12 months amount","Last 30 days amount","All products ids"';
46
+ }
47
+ $file .= ';';
48
+
49
+
50
+ foreach ($mailupCustomerIds as $customerId) {
51
+ foreach ($customersData as $subscriber) {
52
+ if ($subscriber['email'] == $customerId['email']) {
53
+ $file .= "\n";
54
+ $file .= '"'.$subscriber['email'].'"';
55
+ $file .= ',"'.((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') .'"';
56
+ $file .= ',"'.((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') .'"';
57
+
58
+ $synchroConfig = Mage::getStoreConfig('mailup_newsletter/mailup/enable_mailup_synchro') == 1;
59
+
60
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['azienda'])) ? $subscriber['azienda'] : '') .'"';
61
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['città'])) ? $subscriber['città'] : '') .'"';
62
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['provincia'])) ? $subscriber['provincia'] : '') .'"';
63
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['cap'])) ? $subscriber['cap'] : '') .'"';
64
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['regione'])) ? $subscriber['regione'] : '') .'"';
65
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['paese'])) ? $subscriber['paese'] : '') .'"';
66
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['indirizzo'])) ? $subscriber['indirizzo'] : '') .'"';
67
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['fax'])) ? $subscriber['fax'] : '') .'"';
68
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['telefono'])) ? $subscriber['telefono'] : '') .'"';
69
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCliente'])) ? $subscriber['IDCliente'] : '') .'"';
70
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdine'])) ? $subscriber['IDUltimoOrdine'] : '') .'"';
71
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdine'])) ? $subscriber['DataUltimoOrdine'] : '') .'"';
72
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleUltimoOrdine'])) ? $subscriber['TotaleUltimoOrdine'] : '') .'"';
73
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDProdottiUltimoOrdine'])) ? $subscriber['IDProdottiUltimoOrdine'] : '') .'"';
74
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCategorieUltimoOrdine'])) ? $subscriber['IDCategorieUltimoOrdine'] : '') .'"';
75
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdineSpedito'])) ? $subscriber['DataUltimoOrdineSpedito'] : '') .'"';
76
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdineSpedito'])) ? $subscriber['IDUltimoOrdineSpedito'] : '') .'"';
77
+
78
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['DataCarrelloAbbandonato'])) ? $subscriber['DataCarrelloAbbandonato'] : '') .'"';
79
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleCarrelloAbbandonato'])) ? $subscriber['TotaleCarrelloAbbandonato'] : '') .'"';
80
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCarrelloAbbandonato'])) ? $subscriber['IDCarrelloAbbandonato'] : '') .'"';
81
+
82
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturato'])) ? $subscriber['TotaleFatturato'] : '') .'"';
83
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi12Mesi'])) ? $subscriber['TotaleFatturatoUltimi12Mesi'] : '') .'"';
84
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi30gg'])) ? $subscriber['TotaleFatturatoUltimi30gg'] : '') .'"';
85
+ $file .= ',"'. ($synchroConfig && (!empty($subscriber['IDTuttiProdottiAcquistati'])) ? $subscriber['IDTuttiProdottiAcquistati'] : '') .'"';
86
+ $file .= ';';
87
+
88
+ continue 2;
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ //lancio il download del file
95
+ header("Content-type: application/csv");
96
+ header("Content-Disposition: attachment;Filename=filtered_customers.csv");
97
+ echo $file;
98
+ }
99
+
100
+ /**
101
+ * Handle Posted Data
102
+ */
103
+ public function postAction()
104
+ {
105
+ $post = $this->getRequest()->getPost();
106
+ $storeId = isset($post['store_id']) ? (int)$post['store_id'] : NULL;
107
+
108
+ try {
109
+ if (empty($post)) {
110
+ Mage::throwException($this->__('Invalid form data.'));
111
+ }
112
+
113
+ // creo il gruppo se necessario
114
+ $post["mailupNewGroupName"] = trim($post["mailupNewGroupName"]);
115
+ if ($post["mailupNewGroup"] and strlen($post["mailupNewGroupName"])) {
116
+ require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
117
+ $wsImport = new MailUpWsImport($storeId);
118
+ $post['mailupGroupId'] = $wsImport->CreaGruppo(array(
119
+ "idList" => $post['mailupIdList'],
120
+ "listGUID" => $post['mailupListGUID'],
121
+ "newGroupName" => $post["mailupNewGroupName"]
122
+ ));
123
+ }
124
+
125
+ // inserisco il job
126
+ $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
127
+ $db_write->insert("mailup_sync_jobs", array(
128
+ "mailupgroupid" => $post['mailupGroupId'],
129
+ "send_optin" => isset($post['send_optin_email_to_new_subscribers']) && ($post['send_optin_email_to_new_subscribers'] == 1) ? 1 : 0,
130
+ "status" => "queued",
131
+ "queue_datetime" => gmdate("Y-m-d H:i:s"),
132
+ 'store_id' => $storeId,
133
+ ));
134
+ $job_id = $db_write->lastInsertId("mailup_sync_jobs");
135
+
136
+ // inserisco
137
+ $mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
138
+ foreach ($mailupCustomerIds as $customer_id) {
139
+ try {
140
+ $db_write->insert("mailup_sync", array(
141
+ "customer_id" => $customer_id,
142
+ "entity" => "customer",
143
+ "job_id" => $job_id,
144
+ "needs_sync" => true,
145
+ "last_sync" => null,
146
+ 'store_id' => $storeId,
147
+ ));
148
+ } catch (Exception $e) {
149
+ $db_write->update("mailup_sync", array(
150
+ "needs_sync" => true
151
+ ), "customer_id=$customer_id AND entity='customer' AND job_id=$job_id");
152
+ }
153
+ }
154
+
155
+ $db_write->insert(Mage::getSingleton('core/resource')->getTableName('cron_schedule'), array(
156
+ "job_code" => "sevenlike_mailup",
157
+ "status" => "pending",
158
+ "created_at" => gmdate("Y-m-d H:i:s"),
159
+ "scheduled_at" => gmdate("Y-m-d H:i:s", strtotime("+1minute"))
160
+ ));
161
+
162
+ $message = $this->__('Members have been sent correctly');
163
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
164
+ } catch (Exception $e) {
165
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
166
+ $errorMessage = $this->__('Warning: no member has been selected');
167
+ Mage::getSingleton('adminhtml/session')->addError($errorMessage);
168
+ }
169
+
170
+ $this->_redirect('*/*');
171
+ }
172
+
173
+ public function saveFilterHintAction() {
174
+ $this->checkRunningImport();
175
+ try {
176
+ $post = $this->getRequest()->getPost();
177
+ $filter_name = $post['filter_name'];
178
+ unset($post['filter_name']);
179
+
180
+ $MailUpWsImport = Mage::getModel('mailup/ws');
181
+ $wsImport = new MailUpWsImport();
182
+ $wsImport->saveFilterHint($filter_name, $post);
183
+ } catch (Exception $e) {
184
+ $errorMessage = $this->__('Error: unable to save current filter');
185
+ Mage::getSingleton('adminhtml/session')->addError($errorMessage);
186
+ }
187
+
188
+ $this->_redirect('*/*');
189
+ }
190
+
191
+ public function deleteFilterHintAction() {
192
+ $this->checkRunningImport();
193
+ try {
194
+ $post = $this->getRequest()->getPost();
195
+
196
+ $MailUpWsImport = Mage::getModel('mailup/ws');
197
+ $wsImport = new MailUpWsImport();
198
+ $wsImport->deleteFilterHint($post['filter_name']);
199
+ } catch (Exception $e) {
200
+ $errorMessage = $this->__('Error: unable to delete the filter');
201
+ Mage::getSingleton('adminhtml/session')->addError($errorMessage);
202
+ }
203
+
204
+ $this->_redirect('*/*');
205
+ }
206
+
207
+ public function testCronAction() {
208
+ $cron = new SevenLike_MailUp_Model_Cron();
209
+ $cron->run();
210
+ }
211
+
212
+ public function testFieldsAction() {
213
+ $wsSend = new MailUpWsSend();
214
+ $accessKey = $wsSend->loginFromId();
215
+
216
+ if ($accessKey !== false) {
217
+ $fields = $wsSend->GetFields($accessKey);
218
+ print_r($fields);
219
+ die('success');
220
+ } else {
221
+ die('no access key returned');
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Check if an import is currently running
227
+ *
228
+ * @return type
229
+ */
230
+ public function checkRunningImport()
231
+ {
232
+ $db = Mage::getSingleton("core/resource")->getConnection("core_read");
233
+ $cron_schedule_table = Mage::getSingleton("core/resource")->getTableName("cron_schedule");
234
+
235
+ /**
236
+ * @todo check if a cron has been run in the past X minites
237
+ * notify if cron is npt up and running
238
+ */
239
+ $lastTime = $db->fetchOne("SELECT max(last_sync) FROM mailup_sync"); // 2013-04-18 19:23:55
240
+ if( ! empty($lastTime)) {
241
+ $dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $lastTime);
242
+ $lastTimeObject = clone $dateTime;
243
+ if($dateTime) {
244
+ $dateTime->modify('+30 minutes');
245
+ $now = new DateTime();
246
+ //if($dateTime < $now) {
247
+ Mage::getSingleton("adminhtml/session")
248
+ ->addNotice($this->__("Last Sync Performed: {$lastTimeObject->format('Y-m-d H:i:s e')}"))
249
+ ;
250
+ //}
251
+ }
252
+ }
253
+
254
+ $running_processes = $db->fetchOne("SELECT count(*) FROM $cron_schedule_table WHERE job_code='sevenlike_mailup' AND status='running'");
255
+ if ($running_processes) {
256
+ Mage::getSingleton("adminhtml/session")->addNotice($this->__("A MailUp import process is running."));
257
+ return;
258
+ }
259
+
260
+ $scheduled_processes = $db->fetchOne("SELECT count(*) FROM $cron_schedule_table WHERE job_code='sevenlike_mailup' AND status='pending'");
261
+ if ($scheduled_processes) {
262
+ Mage::getSingleton("adminhtml/session")->addNotice($this->__("A MailUp import process is schedules and will be executed soon."));
263
+ return;
264
+ }
265
+ }
266
  }
app/code/local/SevenLike/MailUp/controllers/Adminhtml/ViewdatatransferlogController.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
-
3
- require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
- class SevenLike_MailUp_Adminhtml_ViewdatatransferlogController extends Mage_Adminhtml_Controller_Action
6
- {
7
- public function indexAction() {
8
- $this->loadLayout()->renderLayout();
9
- }
10
-
11
- public function searchAction() {
12
- $this->loadLayout()->renderLayout();
13
- }
14
  }
1
+ <?php
2
+
3
+ require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
4
+ require_once dirname(__FILE__) . "/../../Model/Wssend.php";
5
+ class SevenLike_MailUp_Adminhtml_ViewdatatransferlogController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ public function indexAction() {
8
+ $this->loadLayout()->renderLayout();
9
+ }
10
+
11
+ public function searchAction() {
12
+ $this->loadLayout()->renderLayout();
13
+ }
14
  }
app/code/local/SevenLike/MailUp/controllers/IndexController.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IndexController.php
4
+ */
5
+ class SevenLike_MailUp_IndexController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ /**
8
+ * Default Action
9
+ */
10
+ public function indexAction()
11
+ {
12
+ return;
13
+
14
+ $config = Mage::getModel('mailup/config');
15
+ /* @var $config SevenLike_Mailup_Model_Config */
16
+
17
+ $cartCollection = Mage::getResourceModel('reports/quote_collection');
18
+ //$cartCollection->prepareForAbandonedReport(array(1));
19
+ $cartCollection->prepareForAbandonedReport($config->getAllStoreIds());
20
+ $cartCollection->addFieldToFilter('customer_id', 6);
21
+ $cartCollection->load();
22
+
23
+ $end = end($cartCollection);
24
+
25
+ var_dump($end);
26
+
27
+ $end = $cartCollection->getLastItem();
28
+
29
+ //var_dump($cartCollection);
30
+
31
+ foreach($cartCollection as $cart) {
32
+ //var_dump($cart);
33
+
34
+ echo $cart->getGrandTotal() . "<br />";
35
+
36
+ }
37
+
38
+
39
+ var_dump($end);
40
+
41
+ die('done');
42
+ }
43
+
44
+ /**
45
+ * Clean the Resource Table.
46
+ */
47
+ public function cleanAction()
48
+ {
49
+ return;
50
+
51
+ Mage::helper('mailup')->cleanResourceTable();
52
+ }
53
+
54
+ public function showAction()
55
+ {
56
+ return;
57
+
58
+ Mage::helper('mailup')->showResourceTable();
59
+ }
60
+ }
app/code/local/SevenLike/MailUp/controllers/WebhookController.php CHANGED
@@ -1,147 +1,166 @@
1
- <?php
2
-
3
- class SevenLike_MailUp_WebhookController extends Mage_Core_Controller_Front_Action
4
- {
5
- public function indexAction()
6
- {
7
- }
8
-
9
- public function subscribeAction()
10
- {
11
- $email = @$_REQUEST["customerEmail"];
12
- if (!$email) {
13
- $cryptkey = Mage::getStoreConfig('newsletter/mailup/webhook_crypt_key');
14
- foreach ($_REQUEST as $k=>$v) {
15
- $k = self::rc4($cryptkey, base64_decode($k));
16
- $parsed_vars = array();
17
- parse_str($k, $parsed_vars);
18
- if ($parsed_vars and isset($parsed_vars["customerEmail"])) {
19
- $email = $parsed_vars["customerEmail"];
20
- break;
21
- }
22
- }
23
- }
24
-
25
- if (!$email) {
26
- echo 0;
27
- die();
28
- }
29
-
30
- $model = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
31
- if (!$model->getSubscriberId()) {
32
- echo 0;
33
- die();
34
- }
35
-
36
- $GLOBALS["__sl_mailup_invia_utente"] = 1; //avoids observer
37
- $model
38
- ->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
39
- ->save();
40
-
41
- echo 1;
42
- die();
43
- }
44
-
45
- public function unsubscribeAction()
46
- {
47
- $email = @$_REQUEST["customerEmail"];
48
- if (!$email) {
49
- $cryptkey = Mage::getStoreConfig('newsletter/mailup/webhook_crypt_key');
50
- foreach ($_REQUEST as $k=>$v) {
51
- $k = self::rc4($cryptkey, base64_decode($k));
52
- $parsed_vars = array();
53
- parse_str($k, $parsed_vars);
54
- if ($parsed_vars and isset($parsed_vars["customerEmail"])) {
55
- $email = $parsed_vars["customerEmail"];
56
- break;
57
- }
58
- }
59
- }
60
-
61
- if (!$email) {
62
- echo 0;
63
- die();
64
- }
65
-
66
- $model = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
67
- if (!$model->getSubscriberId()) {
68
- echo 0;
69
- die();
70
- }
71
-
72
- $GLOBALS["__sl_mailup_invia_utente"] = 1; //avoids observer
73
- $model
74
- ->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
75
- ->save();
76
-
77
- echo 1;
78
- die();
79
- }
80
-
81
- /**
82
- * A PHP implementation of RC4 based on the original C code from
83
- * the 1994 usenet post:
84
- *
85
- * http://groups.google.com/groups?selm=sternCvKL4B.Hyy@netcom.com
86
- *
87
- * @param key_str the key as a binary string
88
- * @param data_str the data to decrypt/encrypt as a binary string
89
- * @return the result of the RC4 as a binary string
90
- * @author Michael Cutler <m@cotdp.com>
91
- * @licenses http://www.apache.org/licenses/LICENSE-2.0
92
- */
93
- public static function rc4( $key_str, $data_str ) {
94
- // convert input string(s) to array(s)
95
- $key = array();
96
- $data = array();
97
- for ( $i = 0; $i < strlen($key_str); $i++ ) {
98
- $key[] = ord($key_str{$i});
99
- }
100
- for ( $i = 0; $i < strlen($data_str); $i++ ) {
101
- $data[] = ord($data_str{$i});
102
- }
103
- // prepare key
104
- $state = array( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
105
- 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
106
- 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
107
- 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
108
- 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
109
- 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
110
- 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
111
- 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
112
- 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
113
- 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
114
- 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
115
- 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
116
- 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
117
- 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
118
- 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
119
- 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 );
120
- $len = count($key);
121
- $index1 = $index2 = 0;
122
- for( $counter = 0; $counter < 256; $counter++ ){
123
- $index2 = ( $key[$index1] + $state[$counter] + $index2 ) % 256;
124
- $tmp = $state[$counter];
125
- $state[$counter] = $state[$index2];
126
- $state[$index2] = $tmp;
127
- $index1 = ($index1 + 1) % $len;
128
- }
129
- // rc4
130
- $len = count($data);
131
- $x = $y = 0;
132
- for ($counter = 0; $counter < $len; $counter++) {
133
- $x = ($x + 1) % 256;
134
- $y = ($state[$x] + $y) % 256;
135
- $tmp = $state[$x];
136
- $state[$x] = $state[$y];
137
- $state[$y] = $tmp;
138
- $data[$counter] ^= $state[($state[$x] + $state[$y]) % 256];
139
- }
140
- // convert output back to a string
141
- $data_str = "";
142
- for ( $i = 0; $i < $len; $i++ ) {
143
- $data_str .= chr($data[$i]);
144
- }
145
- return $data_str;
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SevenLike_MailUp_WebhookController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ }
8
+
9
+ /**
10
+ * Susbscribe User from newsletter.
11
+ *
12
+ * Magento will use the current WebsiteID when subscribing
13
+ */
14
+ public function subscribeAction()
15
+ {
16
+ $email = @$_REQUEST["customerEmail"];
17
+ if (!$email) {
18
+ $cryptkey = Mage::getStoreConfig('mailup_newsletter/mailup/webhook_crypt_key');
19
+ foreach ($_REQUEST as $k=>$v) {
20
+ $k = self::rc4($cryptkey, base64_decode($k));
21
+ $parsed_vars = array();
22
+ parse_str($k, $parsed_vars);
23
+ if ($parsed_vars and isset($parsed_vars["customerEmail"])) {
24
+ $email = $parsed_vars["customerEmail"];
25
+ break;
26
+ }
27
+ }
28
+ }
29
+
30
+ if (!$email) {
31
+ echo 0;
32
+ die();
33
+ }
34
+
35
+ $model = Mage::getModel('newsletter/subscriber')
36
+ ->setStoreId(Mage::app()->getStore()->getId())
37
+ //->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
38
+ ->loadByEmail($email)
39
+ ;
40
+ if (!$model->getSubscriberId()) {
41
+ echo 0;
42
+ die();
43
+ }
44
+
45
+ $GLOBALS["__sl_mailup_invia_utente"] = 1; //avoids observer
46
+ $model
47
+ ->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
48
+ ->save();
49
+
50
+ echo 1;
51
+ die();
52
+ }
53
+
54
+ /**
55
+ * Unsubscribe User from newsletter.
56
+ *
57
+ * Magento will use the current WebsiteID when unsubscribing
58
+ */
59
+ public function unsubscribeAction()
60
+ {
61
+ $email = @$_REQUEST["customerEmail"];
62
+ if (!$email) {
63
+ $cryptkey = Mage::getStoreConfig('mailup_newsletter/mailup/webhook_crypt_key');
64
+ foreach ($_REQUEST as $k=>$v) {
65
+ $k = self::rc4($cryptkey, base64_decode($k));
66
+ $parsed_vars = array();
67
+ parse_str($k, $parsed_vars);
68
+ if ($parsed_vars and isset($parsed_vars["customerEmail"])) {
69
+ $email = $parsed_vars["customerEmail"];
70
+ break;
71
+ }
72
+ }
73
+ }
74
+
75
+ if (!$email) {
76
+ echo 0;
77
+ die();
78
+ }
79
+
80
+ $model = Mage::getModel('newsletter/subscriber')
81
+ ->setStoreId(Mage::app()->getStore()->getId())
82
+ //->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
83
+ ->loadByEmail($email)
84
+ ;
85
+
86
+ if (!$model->getSubscriberId()) {
87
+ echo 0;
88
+ die();
89
+ }
90
+
91
+ $GLOBALS["__sl_mailup_invia_utente"] = 1; //avoids observer
92
+ $model
93
+ ->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
94
+ ->save();
95
+
96
+ echo 1;
97
+ die();
98
+ }
99
+
100
+ /**
101
+ * A PHP implementation of RC4 based on the original C code from
102
+ * the 1994 usenet post:
103
+ *
104
+ * http://groups.google.com/groups?selm=sternCvKL4B.Hyy@netcom.com
105
+ *
106
+ * @param key_str the key as a binary string
107
+ * @param data_str the data to decrypt/encrypt as a binary string
108
+ * @return the result of the RC4 as a binary string
109
+ * @author Michael Cutler <m@cotdp.com>
110
+ * @licenses http://www.apache.org/licenses/LICENSE-2.0
111
+ */
112
+ public static function rc4( $key_str, $data_str ) {
113
+ // convert input string(s) to array(s)
114
+ $key = array();
115
+ $data = array();
116
+ for ( $i = 0; $i < strlen($key_str); $i++ ) {
117
+ $key[] = ord($key_str{$i});
118
+ }
119
+ for ( $i = 0; $i < strlen($data_str); $i++ ) {
120
+ $data[] = ord($data_str{$i});
121
+ }
122
+ // prepare key
123
+ $state = array( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
124
+ 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
125
+ 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
126
+ 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
127
+ 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
128
+ 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
129
+ 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
130
+ 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
131
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
132
+ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
133
+ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
134
+ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
135
+ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
136
+ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
137
+ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
138
+ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 );
139
+ $len = count($key);
140
+ $index1 = $index2 = 0;
141
+ for( $counter = 0; $counter < 256; $counter++ ){
142
+ $index2 = ( $key[$index1] + $state[$counter] + $index2 ) % 256;
143
+ $tmp = $state[$counter];
144
+ $state[$counter] = $state[$index2];
145
+ $state[$index2] = $tmp;
146
+ $index1 = ($index1 + 1) % $len;
147
+ }
148
+ // rc4
149
+ $len = count($data);
150
+ $x = $y = 0;
151
+ for ($counter = 0; $counter < $len; $counter++) {
152
+ $x = ($x + 1) % 256;
153
+ $y = ($state[$x] + $y) % 256;
154
+ $tmp = $state[$x];
155
+ $state[$x] = $state[$y];
156
+ $state[$y] = $tmp;
157
+ $data[$counter] ^= $state[($state[$x] + $state[$y]) % 256];
158
+ }
159
+ // convert output back to a string
160
+ $data_str = "";
161
+ for ( $i = 0; $i < $len; $i++ ) {
162
+ $data_str .= chr($data[$i]);
163
+ }
164
+ return $data_str;
165
+ }
166
+ }
app/code/local/SevenLike/MailUp/etc/.DS_Store DELETED
Binary file
app/code/local/SevenLike/MailUp/etc/config.xml CHANGED
@@ -1,246 +1,281 @@
1
- <?xml version="1.0"?>
2
-
3
- <config>
4
- <modules>
5
- <SevenLike_MailUp>
6
- <version>2.2.1</version>
7
- </SevenLike_MailUp>
8
- </modules>
9
-
10
- <global>
11
- <models>
12
- <mailup>
13
- <class>SevenLike_MailUp_Model</class>
14
- </mailup>
15
- </models>
16
- <blocks>
17
- <mailup>
18
- <class>SevenLike_MailUp_Block</class>
19
- </mailup>
20
- </blocks>
21
- <helpers>
22
- <mailup>
23
- <class>SevenLike_MailUp_Helper</class>
24
- </mailup>
25
- </helpers>
26
- <resources>
27
- <mailup_setup>
28
- <setup>
29
- <module>SevenLike_MailUp</module>
30
- </setup>
31
- <connection>
32
- <use>core_setup</use>
33
- </connection>
34
- </mailup_setup>
35
- <mailup_write>
36
- <connection>
37
- <use>core_write</use>
38
- </connection>
39
- </mailup_write>
40
- <mailup_read>
41
- <connection>
42
- <use>core_read</use>
43
- </connection>
44
- </mailup_read>
45
- </resources>
46
- <events>
47
- <newsletter_subscriber_save_after>
48
- <observers>
49
- <mailupinviautente_observer>
50
- <type>singleton</type>
51
- <class>SevenLike_MailUp_Model_Observer</class>
52
- <method>inviaUtente</method>
53
- </mailupinviautente_observer>
54
- </observers>
55
- </newsletter_subscriber_save_after>
56
- <customer_customer_authenticated>
57
- <observers>
58
- <mailupleggiutente_observer>
59
- <type>singleton</type>
60
- <class>SevenLike_MailUp_Model_Observer</class>
61
- <method>leggiUtente</method>
62
- </mailupleggiutente_observer>
63
- </observers>
64
- </customer_customer_authenticated>
65
- <controller_action_postdispatch_adminhtml_system_config_save>
66
- <observers>
67
- <mailupconfigsave_observer>
68
- <type>singleton</type>
69
- <class>SevenLike_MailUp_Model_Observer</class>
70
- <method>saveSystemConfig</method>
71
- </mailupconfigsave_observer>
72
- </observers>
73
- </controller_action_postdispatch_adminhtml_system_config_save>
74
- <admin_session_user_login_success>
75
- <observers>
76
- <mailupconfigtest_observer>
77
- <type>singleton</type>
78
- <class>SevenLike_MailUp_Model_Observer</class>
79
- <method>configCheck</method>
80
- </mailupconfigtest_observer>
81
- </observers>
82
- </admin_session_user_login_success>
83
- <controller_action_postdispatch_checkout_onepage_saveOrder>
84
- <observers>
85
- <mailup_subscribe_during_checkout>
86
- <type>singleton</type>
87
- <class>SevenLike_MailUp_Model_Observer</class>
88
- <method>subscribeDuringCheckout</method>
89
- </mailup_subscribe_during_checkout>
90
- </observers>
91
- </controller_action_postdispatch_checkout_onepage_saveOrder>
92
- <customer_save_after>
93
- <observers>
94
- <mailup_customer_save_after>
95
- <type>singleton</type>
96
- <class>SevenLike_MailUp_Model_Observer</class>
97
- <method>prepareCustomerForDataSync</method>
98
- </mailup_customer_save_after>
99
- </observers>
100
- </customer_save_after>
101
- <sales_order_save_after>
102
- <observers>
103
- <mailup_sales_order_save_after>
104
- <type>singleton</type>
105
- <class>SevenLike_MailUp_Model_Observer</class>
106
- <method>prepareOrderForDataSync</method>
107
- </mailup_sales_order_save_after>
108
- </observers>
109
- </sales_order_save_after>
110
- </events>
111
- </global>
112
-
113
- <admin>
114
- <routers>
115
- <mailup>
116
- <use>admin</use>
117
- <args>
118
- <module>SevenLike_MailUp</module>
119
- <frontName>mailup</frontName>
120
- </args>
121
- </mailup>
122
- </routers>
123
- </admin>
124
-
125
- <default>
126
- <newsletter>
127
- <mailup>
128
- <model>mailup/ws</model>
129
- </mailup>
130
- </newsletter>
131
- </default>
132
-
133
- <adminhtml>
134
- <menu>
135
- <newsletter>
136
- <children>
137
- <mailup translate="title">
138
- <title>MailUp</title>
139
- <children>
140
- <mailup_configuration translate="title">
141
- <title>Connect to MailUp</title>
142
- <action>mailup/adminhtml_configuration</action>
143
- <sort_order>100</sort_order>
144
- </mailup_configuration>
145
- <mailup_filters translate="title">
146
- <title>Filters</title>
147
- <action>mailup/adminhtml_filter</action>
148
- <sort_order>200</sort_order>
149
- </mailup_filters>
150
- <mailup_fieldsmapping translate="title">
151
- <title>Fields mapping</title>
152
- <action>mailup/adminhtml_fieldsmapping</action>
153
- <sort_order>300</sort_order>
154
- </mailup_fieldsmapping>
155
- <!--
156
- <mailup_viewdatatransferlog translate="title">
157
- <title>View data transfer log</title>
158
- <action>mailup/adminhtml_viewdatatransferlog</action>
159
- <sort_order>400</sort_order>
160
- </mailup_viewdatatransferlog>
161
- -->
162
- </children>
163
- </mailup>
164
- </children>
165
- </newsletter>
166
- </menu>
167
- <acl>
168
- <resources>
169
- <all>
170
- <title>Allow everything</title>
171
- </all>
172
- <admin>
173
- <children>
174
- <newsletter>
175
- <children>
176
- <mailup>
177
- <title>Mailup</title>
178
- <children>
179
- <mailup_configuration>
180
- <title>Mailup Configuration</title>
181
- </mailup_configuration>
182
- <mailup_filters>
183
- <title>Mailup Filters</title>
184
- </mailup_filters>
185
- <mailup_fieldsmapping>
186
- <title>Mailup Fields Mapping</title>
187
- </mailup_fieldsmapping>
188
- <mailup_viewdatatransferlog>
189
- <title>View data transfer log</title>
190
- </mailup_viewdatatransferlog>
191
- </children>
192
- </mailup>
193
- </children>
194
- </newsletter>
195
- </children>
196
- </admin>
197
- </resources>
198
- </acl>
199
- <layout>
200
- <updates>
201
- <mailup>
202
- <file>mailup.xml</file>
203
- </mailup>
204
- </updates>
205
- </layout>
206
- <translate>
207
- <modules>
208
- <mailup>
209
- <files>
210
- <default>SevenLike_MailUp.csv</default>
211
- </files>
212
- </mailup>
213
- </modules>
214
- </translate>
215
- </adminhtml>
216
- <frontend>
217
- <translate>
218
- <modules>
219
- <mailup>
220
- <files>
221
- <default>SevenLike_MailUp.csv</default>
222
- </files>
223
- </mailup>
224
- </modules>
225
- </translate>
226
- <layout>
227
- <updates>
228
- <mailup>
229
- <file>mailup.xml</file>
230
- </mailup>
231
- </updates>
232
- </layout>
233
- </frontend>
234
-
235
- <crontab>
236
- <jobs>
237
- <sevenlike_mailup>
238
- <run><model>mailup/Cron::run</model></run>
239
- </sevenlike_mailup>
240
- <mailup_connectionproblemsredo>
241
- <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
242
- <run><model>mailup/Cron::resendConnectionErrors</model></run>
243
- </mailup_connectionproblemsredo>
244
- </jobs>
245
- </crontab>
246
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <SevenLike_MailUp>
6
+ <version>2.3.1</version>
7
+ </SevenLike_MailUp>
8
+ </modules>
9
+
10
+ <global>
11
+ <models>
12
+ <mailup>
13
+ <class>SevenLike_MailUp_Model</class>
14
+ </mailup>
15
+ <!-- Override Subscriber so we can disable Notifiactions -->
16
+ <newsletter>
17
+ <rewrite>
18
+ <subscriber>SevenLike_MailUp_Model_Subscriber</subscriber>
19
+ </rewrite>
20
+ </newsletter>
21
+
22
+ <!--<mailup>
23
+ <class>SevenLike_MailUp_Model</class>
24
+ <resourceModel>mailup_mysql4</resourceModel>
25
+ </mailup>
26
+ <mailup_mysql4>
27
+ <class>SevenLike_MailUp_Model_Mysql4</class>
28
+ <entities>
29
+ <job>
30
+ <table>mailup_sync_jobs</table>
31
+ </job>
32
+ </entities>
33
+ </mailup_mysql4>-->
34
+
35
+ </models>
36
+ <blocks>
37
+ <mailup>
38
+ <class>SevenLike_MailUp_Block</class>
39
+ </mailup>
40
+ </blocks>
41
+ <helpers>
42
+ <mailup>
43
+ <class>SevenLike_MailUp_Helper</class>
44
+ </mailup>
45
+ </helpers>
46
+ <resources>
47
+ <mailup_setup>
48
+ <setup>
49
+ <module>SevenLike_MailUp</module>
50
+ </setup>
51
+ <connection>
52
+ <use>core_setup</use>
53
+ </connection>
54
+ </mailup_setup>
55
+ <mailup_write>
56
+ <connection>
57
+ <use>core_write</use>
58
+ </connection>
59
+ </mailup_write>
60
+ <mailup_read>
61
+ <connection>
62
+ <use>core_read</use>
63
+ </connection>
64
+ </mailup_read>
65
+ </resources>
66
+ <events>
67
+ <newsletter_subscriber_save_after>
68
+ <observers>
69
+ <mailupinviautente_observer>
70
+ <type>singleton</type>
71
+ <class>SevenLike_MailUp_Model_Observer</class>
72
+ <method>inviaUtente</method>
73
+ </mailupinviautente_observer>
74
+ </observers>
75
+ </newsletter_subscriber_save_after>
76
+ <customer_customer_authenticated>
77
+ <observers>
78
+ <mailupleggiutente_observer>
79
+ <type>singleton</type>
80
+ <class>SevenLike_MailUp_Model_Observer</class>
81
+ <method>leggiUtente</method>
82
+ </mailupleggiutente_observer>
83
+ </observers>
84
+ </customer_customer_authenticated>
85
+ <controller_action_postdispatch_adminhtml_system_config_save>
86
+ <observers>
87
+ <mailupconfigsave_observer>
88
+ <type>singleton</type>
89
+ <class>SevenLike_MailUp_Model_Observer</class>
90
+ <method>saveSystemConfig</method>
91
+ </mailupconfigsave_observer>
92
+ </observers>
93
+ </controller_action_postdispatch_adminhtml_system_config_save>
94
+ <admin_session_user_login_success>
95
+ <observers>
96
+ <mailupconfigtest_observer>
97
+ <type>singleton</type>
98
+ <class>SevenLike_MailUp_Model_Observer</class>
99
+ <method>configCheck</method>
100
+ </mailupconfigtest_observer>
101
+ </observers>
102
+ </admin_session_user_login_success>
103
+ <controller_action_postdispatch_checkout_onepage_saveOrder>
104
+ <observers>
105
+ <mailup_subscribe_during_checkout>
106
+ <type>singleton</type>
107
+ <class>SevenLike_MailUp_Model_Observer</class>
108
+ <method>subscribeDuringCheckout</method>
109
+ </mailup_subscribe_during_checkout>
110
+ </observers>
111
+ </controller_action_postdispatch_checkout_onepage_saveOrder>
112
+ <customer_save_after>
113
+ <observers>
114
+ <mailup_customer_save_after>
115
+ <type>singleton</type>
116
+ <class>SevenLike_MailUp_Model_Observer</class>
117
+ <method>prepareCustomerForDataSync</method>
118
+ </mailup_customer_save_after>
119
+ </observers>
120
+ </customer_save_after>
121
+ <sales_order_save_after>
122
+ <observers>
123
+ <mailup_sales_order_save_after>
124
+ <type>singleton</type>
125
+ <class>SevenLike_MailUp_Model_Observer</class>
126
+ <method>prepareOrderForDataSync</method>
127
+ </mailup_sales_order_save_after>
128
+ </observers>
129
+ </sales_order_save_after>
130
+ </events>
131
+ </global>
132
+
133
+ <admin>
134
+ <routers>
135
+ <mailup>
136
+ <use>admin</use>
137
+ <args>
138
+ <module>SevenLike_MailUp</module>
139
+ <frontName>mailup</frontName>
140
+ </args>
141
+ </mailup>
142
+ </routers>
143
+ </admin>
144
+
145
+ <default>
146
+ <mailup_newsletter>
147
+ <mailup>
148
+ <model>mailup/ws</model>
149
+ <disablenewslettersuccesses>1</disablenewslettersuccesses>
150
+ </mailup>
151
+ </mailup_newsletter>
152
+ </default>
153
+
154
+ <adminhtml>
155
+ <menu>
156
+ <newsletter>
157
+ <children>
158
+ <mailup translate="title">
159
+ <title>MailUp</title>
160
+ <children>
161
+ <mailup_configuration translate="title">
162
+ <title><![CDATA[Settings & Field Mapping]]></title>
163
+ <action>mailup/adminhtml_configuration</action>
164
+ <sort_order>100</sort_order>
165
+ </mailup_configuration>
166
+ <mailup_filters translate="title">
167
+ <title>Filters</title>
168
+ <action>mailup/adminhtml_filter</action>
169
+ <sort_order>200</sort_order>
170
+ </mailup_filters>
171
+ </children>
172
+ </mailup>
173
+ </children>
174
+ </newsletter>
175
+ </menu>
176
+ <acl>
177
+ <resources>
178
+ <all>
179
+ <title>Allow everything</title>
180
+ </all>
181
+ <admin>
182
+ <children>
183
+ <newsletter>
184
+ <children>
185
+ <mailup>
186
+ <title>Mailup</title>
187
+ <children>
188
+ <mailup_configuration>
189
+ <title>Mailup Configuration</title>
190
+ </mailup_configuration>
191
+ <mailup_filters>
192
+ <title>Mailup Filters</title>
193
+ </mailup_filters>
194
+ <mailup_fieldsmapping>
195
+ <title>Mailup Fields Mapping</title>
196
+ </mailup_fieldsmapping>
197
+ <mailup_viewdatatransferlog>
198
+ <title>View data transfer log</title>
199
+ </mailup_viewdatatransferlog>
200
+ </children>
201
+ </mailup>
202
+ </children>
203
+ </newsletter>
204
+
205
+ <system>
206
+ <children>
207
+ <config>
208
+ <children>
209
+ <mailup_newsletter>
210
+ <title>Mailup Newsletter</title>
211
+ </mailup_newsletter>
212
+ </children>
213
+ </config>
214
+ </children>
215
+ </system>
216
+
217
+ </children>
218
+ </admin>
219
+ </resources>
220
+ </acl>
221
+ <layout>
222
+ <updates>
223
+ <mailup>
224
+ <file>mailup.xml</file>
225
+ </mailup>
226
+ </updates>
227
+ </layout>
228
+ <translate>
229
+ <modules>
230
+ <mailup>
231
+ <files>
232
+ <default>SevenLike_MailUp.csv</default>
233
+ </files>
234
+ </mailup>
235
+ </modules>
236
+ </translate>
237
+ </adminhtml>
238
+
239
+ <frontend>
240
+
241
+ <!--<routers>
242
+ <mailup>
243
+ <use>standard</use>
244
+ <args>
245
+ <module>SevenLike_MailUp</module>
246
+ <frontName>mailup</frontName>
247
+ </args>
248
+ </mailup>
249
+ </routers>-->
250
+
251
+ <translate>
252
+ <modules>
253
+ <mailup>
254
+ <files>
255
+ <default>SevenLike_MailUp.csv</default>
256
+ </files>
257
+ </mailup>
258
+ </modules>
259
+ </translate>
260
+
261
+ <layout>
262
+ <updates>
263
+ <mailup>
264
+ <file>mailup.xml</file>
265
+ </mailup>
266
+ </updates>
267
+ </layout>
268
+ </frontend>
269
+
270
+ <crontab>
271
+ <jobs>
272
+ <sevenlike_mailup>
273
+ <run><model>mailup/Cron::run</model></run>
274
+ </sevenlike_mailup>
275
+ <mailup_connectionproblemsredo>
276
+ <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
277
+ <run><model>mailup/Cron::resendConnectionErrors</model></run>
278
+ </mailup_connectionproblemsredo>
279
+ </jobs>
280
+ </crontab>
281
+ </config>
app/code/local/SevenLike/MailUp/etc/system.xml CHANGED
@@ -1,99 +1,404 @@
1
- <?xml version="1.0"?>
2
-
3
- <config>
4
- <sections>
5
- <newsletter>
6
- <groups>
7
- <mailup translate="label">
8
- <label>MailUp Extension Settings</label>
9
- <frontend_type>text</frontend_type>
10
- <sort_order>0</sort_order>
11
- <show_in_default>1</show_in_default>
12
- <fields>
13
- <url_console translate="comment">
14
- <label>Admin Console URL</label>
15
- <frontend_type>text</frontend_type>
16
- <sort_order>10</sort_order>
17
- <show_in_default>1</show_in_default>
18
- <show_in_website>1</show_in_website>
19
- <show_in_store>1</show_in_store>
20
- <comment>It's the domain portion of the browser address field when you using the MailUp Admin console (e.g. g4a0.s03.it)</comment>
21
- <backend_model>mailup/consoleurlvalidator</backend_model>
22
- </url_console>
23
- <username_ws translate="comment">
24
- <label>Web Service Username</label>
25
- <frontend_type>text</frontend_type>
26
- <sort_order>20</sort_order>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>1</show_in_website>
29
- <show_in_store>1</show_in_store>
30
- <backend_model>mailup/webserviceusernamevalidator</backend_model>
31
- </username_ws>
32
- <password_ws translate="comment">
33
- <label>Web Service Password</label>
34
- <frontend_type>password</frontend_type>
35
- <sort_order>40</sort_order>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
- <show_in_store>1</show_in_store>
39
- <comment>For assistance visit help.mailup.com and search for "API credentials"</comment>
40
- </password_ws>
41
- <list translate="label comment">
42
- <label>List</label>
43
- <frontend_type>select</frontend_type>
44
- <source_model>mailup/lists</source_model>
45
- <sort_order>60</sort_order>
46
- <show_in_default>1</show_in_default>
47
- <show_in_website>1</show_in_website>
48
- <show_in_store>1</show_in_store>
49
- </list>
50
- <enable_subscribe_in_checkout tranlate="label comment">
51
- <label>Enable subscription checkbox during checkout</label>
52
- <frontend_type>select</frontend_type>
53
- <source_model>adminhtml/system_config_source_yesno</source_model>
54
- <sort_order>70</sort_order>
55
- <show_in_default>1</show_in_default>
56
- <show_in_website>1</show_in_website>
57
- <show_in_store>1</show_in_store>
58
- </enable_subscribe_in_checkout>
59
- <enable_cron_export tranlate="label comment">
60
- <label>Enable Automatic Data Export to MailUp</label>
61
- <frontend_type>select</frontend_type>
62
- <source_model>adminhtml/system_config_source_yesno</source_model>
63
- <sort_order>80</sort_order>
64
- <show_in_default>1</show_in_default>
65
- <show_in_website>1</show_in_website>
66
- <show_in_store>1</show_in_store>
67
- </enable_cron_export>
68
- <mailup_cron_frequency translate="label comment">
69
- <label>Export Frequency</label>
70
- <frontend_type>select</frontend_type>
71
- <source_model>mailup/adminhtml_system_source_cron_frequency</source_model>
72
- <sort_order>90</sort_order>
73
- <show_in_default>1</show_in_default>
74
- <show_in_website>1</show_in_website>
75
- <show_in_store>1</show_in_store>
76
- </mailup_cron_frequency>
77
- <webhook_crypt_key>
78
- <label>Webhook crypt key</label>
79
- <frontend_type>text</frontend_type>
80
- <sort_order>100</sort_order>
81
- <show_in_default>1</show_in_default>
82
- <show_in_website>1</show_in_website>
83
- <show_in_store>1</show_in_store>
84
- </webhook_crypt_key>
85
- <enable_log>
86
- <label>Enable module debugging log</label>
87
- <frontend_type>select</frontend_type>
88
- <source_model>adminhtml/system_config_source_yesno</source_model>
89
- <sort_order>110</sort_order>
90
- <show_in_default>1</show_in_default>
91
- <show_in_website>1</show_in_website>
92
- <show_in_store>1</show_in_store>
93
- </enable_log>
94
- </fields>
95
- </mailup>
96
- </groups>
97
- </newsletter>
98
- </sections>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  </config>
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <!-- Top Level Tabs -->
5
+ <tabs>
6
+ <mailup_tab translate="label" module="mailup">
7
+ <label>MailUP</label>
8
+ <class>mailup-tab-parent</class>
9
+ <sort_order>300</sort_order>
10
+ </mailup_tab>
11
+ </tabs>
12
+
13
+ <sections>
14
+ <mailup_newsletter>
15
+ <class>mailup-tab</class>
16
+ <!--<header_css>internetware-tab</header_css>-->
17
+ <label><![CDATA[Settings & Field Mapping]]></label>
18
+ <tab>mailup_tab</tab>
19
+ <frontend_type>text</frontend_type>
20
+ <sort_order>99999</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+
25
+ <groups>
26
+ <!-- main config section -->
27
+ <mailup translate="label">
28
+ <label>MailUp Extension Settings</label>
29
+ <frontend_type>text</frontend_type>
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
+ <fields>
35
+ <url_console translate="comment">
36
+ <label>Admin Console URL</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <comment>It's the domain portion of the browser address field when you using the MailUp Admin console (e.g. g4a0.s03.it)</comment>
43
+ <backend_model>mailup/consoleurlvalidator</backend_model>
44
+ </url_console>
45
+ <username_ws translate="comment">
46
+ <label>Web Service Username</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>20</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <backend_model>mailup/webserviceusernamevalidator</backend_model>
53
+ </username_ws>
54
+ <password_ws translate="comment">
55
+ <label>Web Service Password</label>
56
+ <frontend_type>password</frontend_type>
57
+ <sort_order>40</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <comment>For assistance visit help.mailup.com and search for "API credentials"</comment>
62
+ </password_ws>
63
+ <list translate="label comment">
64
+ <label>List</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>mailup/lists</source_model>
67
+ <sort_order>60</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </list>
72
+ <enable_subscribe_in_checkout tranlate="label comment">
73
+ <label>Enable subscription checkbox during checkout</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <sort_order>70</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </enable_subscribe_in_checkout>
81
+ <enable_cron_export tranlate="label comment">
82
+ <label>Enable Automatic Data Export to MailUp</label>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>adminhtml/system_config_source_yesno</source_model>
85
+ <sort_order>80</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
+ </enable_cron_export>
90
+ <mailup_cron_frequency translate="label comment">
91
+ <label>Export Frequency</label>
92
+ <frontend_type>select</frontend_type>
93
+ <source_model>mailup/adminhtml_system_source_cron_frequency</source_model>
94
+ <sort_order>90</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </mailup_cron_frequency>
99
+ <webhook_crypt_key>
100
+ <label>Webhook crypt key</label>
101
+ <frontend_type>text</frontend_type>
102
+ <sort_order>100</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </webhook_crypt_key>
107
+ <enable_log>
108
+ <label>Enable module debugging log</label>
109
+ <frontend_type>select</frontend_type>
110
+ <source_model>adminhtml/system_config_source_yesno</source_model>
111
+ <sort_order>110</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ </enable_log>
116
+ <disablenewslettersuccesses translate="label">
117
+ <label>Disable Newsletter Subscription Notification</label>
118
+ <frontend_type>select</frontend_type>
119
+ <source_model>adminhtml/system_config_source_yesno</source_model>
120
+ <sort_order>120</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ <comment>Disable Magento newsletter subscription notification emails</comment>
125
+ </disablenewslettersuccesses>
126
+ </fields>
127
+ </mailup>
128
+ <!-- mapping section -->
129
+ <mailup_mapping translate="label">
130
+ <label>MailUp Field Mapping</label>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>5</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ <fields>
137
+ <Name translate="comment">
138
+ <label>Name</label>
139
+ <frontend_type>select</frontend_type>
140
+ <sort_order>1</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
145
+ </Name>
146
+ <Last translate="comment">
147
+ <label>Last</label>
148
+ <frontend_type>select</frontend_type>
149
+ <sort_order>2</sort_order>
150
+ <show_in_default>1</show_in_default>
151
+ <show_in_website>1</show_in_website>
152
+ <show_in_store>1</show_in_store>
153
+ <!--<comment>test..</comment>-->
154
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
155
+ </Last>
156
+ <Email translate="comment">
157
+ <label>Email</label>
158
+ <frontend_type>select</frontend_type>
159
+ <sort_order>3</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>1</show_in_website>
162
+ <show_in_store>1</show_in_store>
163
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
164
+ </Email>
165
+ <Company translate="comment">
166
+ <label>Company</label>
167
+ <frontend_type>select</frontend_type>
168
+ <sort_order>4</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
173
+ </Company>
174
+ <Address translate="comment">
175
+ <label>Address</label>
176
+ <frontend_type>select</frontend_type>
177
+ <sort_order>5</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
182
+ </Address>
183
+ <City translate="comment">
184
+ <label>City</label>
185
+ <frontend_type>select</frontend_type>
186
+ <sort_order>6</sort_order>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>1</show_in_store>
190
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
191
+ </City>
192
+ <ZIP translate="comment">
193
+ <label>ZIP</label>
194
+ <frontend_type>select</frontend_type>
195
+ <sort_order>7</sort_order>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>1</show_in_store>
199
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
200
+ </ZIP>
201
+ <Province translate="comment">
202
+ <label>Province</label>
203
+ <frontend_type>select</frontend_type>
204
+ <sort_order>8</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
209
+ </Province>
210
+ <Region translate="comment">
211
+ <label>Region</label>
212
+ <frontend_type>select</frontend_type>
213
+ <sort_order>9</sort_order>
214
+ <show_in_default>1</show_in_default>
215
+ <show_in_website>1</show_in_website>
216
+ <show_in_store>1</show_in_store>
217
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
218
+ </Region>
219
+ <Country translate="comment">
220
+ <label>Country</label>
221
+ <frontend_type>select</frontend_type>
222
+ <sort_order>10</sort_order>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>1</show_in_website>
225
+ <show_in_store>1</show_in_store>
226
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
227
+ </Country>
228
+ <Gender translate="comment">
229
+ <label>Gender</label>
230
+ <frontend_type>select</frontend_type>
231
+ <sort_order>10</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>1</show_in_website>
234
+ <show_in_store>1</show_in_store>
235
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
236
+ </Gender>
237
+ <DateOfBirth translate="comment">
238
+ <label>DateOfBirth</label>
239
+ <frontend_type>select</frontend_type>
240
+ <sort_order>10</sort_order>
241
+ <show_in_default>1</show_in_default>
242
+ <show_in_website>1</show_in_website>
243
+ <show_in_store>1</show_in_store>
244
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
245
+ </DateOfBirth>
246
+ <CustomerID translate="comment">
247
+ <label>CustomerID</label>
248
+ <frontend_type>select</frontend_type>
249
+ <sort_order>10</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>1</show_in_store>
253
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
254
+ </CustomerID>
255
+ <Phone translate="comment">
256
+ <label>Phone</label>
257
+ <frontend_type>select</frontend_type>
258
+ <sort_order>10</sort_order>
259
+ <show_in_default>1</show_in_default>
260
+ <show_in_website>1</show_in_website>
261
+ <show_in_store>1</show_in_store>
262
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
263
+ </Phone>
264
+ <Fax translate="comment">
265
+ <label>Fax</label>
266
+ <frontend_type>select</frontend_type>
267
+ <sort_order>10</sort_order>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>1</show_in_store>
271
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
272
+ </Fax>
273
+ <LatestOrderID translate="comment">
274
+ <label>LatestOrderID</label>
275
+ <frontend_type>select</frontend_type>
276
+ <sort_order>10</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
281
+ </LatestOrderID>
282
+ <LatestOrderDate translate="comment">
283
+ <label>LatestOrderDate</label>
284
+ <frontend_type>select</frontend_type>
285
+ <sort_order>10</sort_order>
286
+ <show_in_default>1</show_in_default>
287
+ <show_in_website>1</show_in_website>
288
+ <show_in_store>1</show_in_store>
289
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
290
+ </LatestOrderDate>
291
+ <LatestOrderAmount translate="comment">
292
+ <label>LatestOrderAmount</label>
293
+ <frontend_type>select</frontend_type>
294
+ <sort_order>10</sort_order>
295
+ <show_in_default>1</show_in_default>
296
+ <show_in_website>1</show_in_website>
297
+ <show_in_store>1</show_in_store>
298
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
299
+ </LatestOrderAmount>
300
+ <LatestOrderProductIDs translate="comment">
301
+ <label>LatestOrderProductIDs</label>
302
+ <frontend_type>select</frontend_type>
303
+ <sort_order>10</sort_order>
304
+ <show_in_default>1</show_in_default>
305
+ <show_in_website>1</show_in_website>
306
+ <show_in_store>1</show_in_store>
307
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
308
+ </LatestOrderProductIDs>
309
+ <LatestOrderCategoryIDs translate="comment">
310
+ <label>LatestOrderCategoryIDs</label>
311
+ <frontend_type>select</frontend_type>
312
+ <sort_order>10</sort_order>
313
+ <show_in_default>1</show_in_default>
314
+ <show_in_website>1</show_in_website>
315
+ <show_in_store>1</show_in_store>
316
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
317
+ </LatestOrderCategoryIDs>
318
+ <LatestShippedOrderDate translate="comment">
319
+ <label>LatestShippedOrderDate</label>
320
+ <frontend_type>select</frontend_type>
321
+ <sort_order>10</sort_order>
322
+ <show_in_default>1</show_in_default>
323
+ <show_in_website>1</show_in_website>
324
+ <show_in_store>1</show_in_store>
325
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
326
+ </LatestShippedOrderDate>
327
+ <LatestShippedOrderID translate="comment">
328
+ <label>LatestShippedOrderID</label>
329
+ <frontend_type>select</frontend_type>
330
+ <sort_order>10</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <show_in_store>1</show_in_store>
334
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
335
+ </LatestShippedOrderID>
336
+ <LatestAbandonedCartDate translate="comment">
337
+ <label>LatestAbandonedCartDate</label>
338
+ <frontend_type>select</frontend_type>
339
+ <sort_order>10</sort_order>
340
+ <show_in_default>1</show_in_default>
341
+ <show_in_website>1</show_in_website>
342
+ <show_in_store>1</show_in_store>
343
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
344
+ </LatestAbandonedCartDate>
345
+ <LatestAbandonedCartTotal translate="comment">
346
+ <label>LatestAbandonedCartTotal</label>
347
+ <frontend_type>select</frontend_type>
348
+ <sort_order>10</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_website>1</show_in_website>
351
+ <show_in_store>1</show_in_store>
352
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
353
+ </LatestAbandonedCartTotal>
354
+ <LatestAbandonedCartID translate="comment">
355
+ <label>LatestAbandonedCartID</label>
356
+ <frontend_type>select</frontend_type>
357
+ <sort_order>10</sort_order>
358
+ <show_in_default>1</show_in_default>
359
+ <show_in_website>1</show_in_website>
360
+ <show_in_store>1</show_in_store>
361
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
362
+ </LatestAbandonedCartID>
363
+ <TotalOrdered translate="comment">
364
+ <label>TotalOrdered</label>
365
+ <frontend_type>select</frontend_type>
366
+ <sort_order>10</sort_order>
367
+ <show_in_default>1</show_in_default>
368
+ <show_in_website>1</show_in_website>
369
+ <show_in_store>1</show_in_store>
370
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
371
+ </TotalOrdered>
372
+ <TotalOrderedLast12m translate="comment">
373
+ <label>TotalOrderedLast12m</label>
374
+ <frontend_type>select</frontend_type>
375
+ <sort_order>10</sort_order>
376
+ <show_in_default>1</show_in_default>
377
+ <show_in_website>1</show_in_website>
378
+ <show_in_store>1</show_in_store>
379
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
380
+ </TotalOrderedLast12m>
381
+ <TotalOrderedLast30d translate="comment">
382
+ <label>TotalOrderedLast30d</label>
383
+ <frontend_type>select</frontend_type>
384
+ <sort_order>10</sort_order>
385
+ <show_in_default>1</show_in_default>
386
+ <show_in_website>1</show_in_website>
387
+ <show_in_store>1</show_in_store>
388
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
389
+ </TotalOrderedLast30d>
390
+ <AllOrderedProductIDs translate="comment">
391
+ <label>AllOrderedProductIDs</label>
392
+ <frontend_type>select</frontend_type>
393
+ <sort_order>10</sort_order>
394
+ <show_in_default>1</show_in_default>
395
+ <show_in_website>1</show_in_website>
396
+ <show_in_store>1</show_in_store>
397
+ <source_model>mailup/adminhtml_system_source_fields</source_model>
398
+ </AllOrderedProductIDs>
399
+ </fields>
400
+ </mailup_mapping>
401
+ </groups>
402
+ </mailup_newsletter>
403
+ </sections>
404
  </config>
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-0.1.0.php CHANGED
@@ -1,3 +1,3 @@
1
- <?php
2
-
3
  //do not remove this line
1
+ <?php
2
+
3
  //do not remove this line
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-2.3.0.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ $this->run("CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
6
+ `filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
7
+ `hints` varchar(255) collate utf8_unicode_ci NOT NULL,
8
+ PRIMARY KEY (`filter_name`)
9
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
10
+
11
+ $this->run("DROP TABLE IF EXISTS mailup_sync;
12
+ CREATE TABLE IF NOT EXISTS `mailup_sync` (
13
+ `store_id` int(11) DEFAULT NULL,
14
+ `customer_id` int(11) NOT NULL,
15
+ `entity` varchar(100) NOT NULL,
16
+ `job_id` int(11) NOT NULL,
17
+ `needs_sync` tinyint(1) NOT NULL,
18
+ `last_sync` datetime NULL,
19
+ PRIMARY KEY (`customer_id`,`entity`,`job_id`)
20
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
21
+
22
+ $this->run("
23
+ DROP TABLE IF EXISTS mailup_sync_jobs;
24
+ CREATE TABLE IF NOT EXISTS `mailup_sync_jobs` (
25
+ `id` int(11) NOT NULL AUTO_INCREMENT,
26
+ `store_id` int(11) DEFAULT NULL,
27
+ `mailupgroupid` int(11) NOT NULL,
28
+ `send_optin` tinyint(1) NOT NULL,
29
+ `status` varchar(20) NOT NULL,
30
+ `queue_datetime` datetime NOT NULL,
31
+ `start_datetime` datetime,
32
+ `finish_datetime` datetime,
33
+ PRIMARY KEY (`id`)
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
35
+
36
+ $this->endSetup();
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-0.1.0-1.0.0.php CHANGED
@@ -1,3 +1,3 @@
1
- <?php
2
-
3
  //do not remove this line
1
+ <?php
2
+
3
  //do not remove this line
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-0.3.0-1.0.0.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
- $this->startSetup();
4
-
5
- $this->run("CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
6
- `filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
7
- `hints` varchar(255) collate utf8_unicode_ci NOT NULL,
8
- PRIMARY KEY (`filter_name`)
9
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
10
-
11
  $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ $this->run("CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
6
+ `filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
7
+ `hints` varchar(255) collate utf8_unicode_ci NOT NULL,
8
+ PRIMARY KEY (`filter_name`)
9
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
10
+
11
  $this->endSetup();
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-1.0.0-1.5.2.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
- $this->startSetup();
4
-
5
- $this->run("CREATE TABLE IF NOT EXISTS `mailup_fields_mapping` (
6
- `magento_field_name` varchar(255) collate utf8_unicode_ci NOT NULL,
7
- `mailup_field_id` int(11) NOT NULL,
8
- PRIMARY KEY (`magento_field_name`, `mailup_field_id`)
9
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
10
-
11
  $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ $this->run("CREATE TABLE IF NOT EXISTS `mailup_fields_mapping` (
6
+ `magento_field_name` varchar(255) collate utf8_unicode_ci NOT NULL,
7
+ `mailup_field_id` int(11) NOT NULL,
8
+ PRIMARY KEY (`magento_field_name`, `mailup_field_id`)
9
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
10
+
11
  $this->endSetup();
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.1.3-2.2.0.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
-
3
- $this->startSetup();
4
-
5
- $this->run("CREATE TABLE IF NOT EXISTS `mailup_sync` (
6
- `customer_id` int(11) NOT NULL,
7
- `entity` varchar(100) NOT NULL,
8
- `job_id` int(11) NOT NULL,
9
- `needs_sync` tinyint(1) NOT NULL,
10
- `last_sync` datetime NULL,
11
- PRIMARY KEY (`customer_id`,`entity`,`job_id`)
12
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
13
-
14
- $this->run("CREATE TABLE IF NOT EXISTS `mailup_sync_jobs` (
15
- `id` int(11) NOT NULL AUTO_INCREMENT,
16
- `mailupgroupid` int(11) NOT NULL,
17
- `send_optin` tinyint(1) NOT NULL,
18
- `status` varchar(20) NOT NULL,
19
- `queue_datetime` datetime NOT NULL,
20
- `start_datetime` datetime,
21
- `finish_datetime` datetime,
22
- PRIMARY KEY (`id`)
23
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
24
-
25
  $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ $this->run("CREATE TABLE IF NOT EXISTS `mailup_sync` (
6
+ `customer_id` int(11) NOT NULL,
7
+ `entity` varchar(100) NOT NULL,
8
+ `job_id` int(11) NOT NULL,
9
+ `needs_sync` tinyint(1) NOT NULL,
10
+ `last_sync` datetime NULL,
11
+ PRIMARY KEY (`customer_id`,`entity`,`job_id`)
12
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
13
+
14
+ $this->run("CREATE TABLE IF NOT EXISTS `mailup_sync_jobs` (
15
+ `id` int(11) NOT NULL AUTO_INCREMENT,
16
+ `mailupgroupid` int(11) NOT NULL,
17
+ `send_optin` tinyint(1) NOT NULL,
18
+ `status` varchar(20) NOT NULL,
19
+ `queue_datetime` datetime NOT NULL,
20
+ `start_datetime` datetime,
21
+ `finish_datetime` datetime,
22
+ PRIMARY KEY (`id`)
23
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
24
+
25
  $this->endSetup();
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.2.0-2.3.0.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ /*$this->run("
6
+ ALTER TABLE mailup_sync_jobs
7
+ ADD `store_id` INT UNSIGNED DEFAULT NULL;
8
+ ");
9
+
10
+ $this->run("
11
+ ALTER TABLE mailup_sync
12
+ ADD `store_id` INT UNSIGNED DEFAULT NULL;
13
+ ");*/
14
+
15
+ $this->run("DROP TABLE IF EXISTS mailup_filter_hints;
16
+ CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
17
+ `filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
18
+ `hints` varchar(255) collate utf8_unicode_ci NOT NULL,
19
+ PRIMARY KEY (`filter_name`)
20
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
21
+
22
+ $this->run("DROP TABLE IF EXISTS mailup_sync;
23
+ CREATE TABLE IF NOT EXISTS `mailup_sync` (
24
+ `store_id` int(11) DEFAULT NULL,
25
+ `customer_id` int(11) NOT NULL,
26
+ `entity` varchar(100) NOT NULL,
27
+ `job_id` int(11) NOT NULL,
28
+ `needs_sync` tinyint(1) NOT NULL,
29
+ `last_sync` datetime NULL,
30
+ PRIMARY KEY (`customer_id`,`entity`,`job_id`)
31
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
32
+
33
+ $this->run("
34
+ DROP TABLE IF EXISTS mailup_sync_jobs;
35
+ CREATE TABLE IF NOT EXISTS `mailup_sync_jobs` (
36
+ `id` int(11) NOT NULL AUTO_INCREMENT,
37
+ `store_id` int(11) DEFAULT NULL,
38
+ `mailupgroupid` int(11) NOT NULL,
39
+ `send_optin` tinyint(1) NOT NULL,
40
+ `status` varchar(20) NOT NULL,
41
+ `queue_datetime` datetime NOT NULL,
42
+ `start_datetime` datetime,
43
+ `finish_datetime` datetime,
44
+ PRIMARY KEY (`id`)
45
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
46
+
47
+ $this->endSetup();
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.2.1-2.3.0.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ /*$this->run("
6
+ ALTER TABLE mailup_sync_jobs
7
+ ADD `store_id` INT UNSIGNED DEFAULT NULL;
8
+ ");
9
+
10
+ $this->run("
11
+ ALTER TABLE mailup_sync
12
+ ADD `store_id` INT UNSIGNED DEFAULT NULL;
13
+ ");*/
14
+
15
+ $this->run("DROP TABLE IF EXISTS mailup_filter_hints;
16
+ CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
17
+ `filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
18
+ `hints` varchar(255) collate utf8_unicode_ci NOT NULL,
19
+ PRIMARY KEY (`filter_name`)
20
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
21
+
22
+ $this->run("DROP TABLE IF EXISTS mailup_sync;
23
+ CREATE TABLE IF NOT EXISTS `mailup_sync` (
24
+ `store_id` int(11) DEFAULT NULL,
25
+ `customer_id` int(11) NOT NULL,
26
+ `entity` varchar(100) NOT NULL,
27
+ `job_id` int(11) NOT NULL,
28
+ `needs_sync` tinyint(1) NOT NULL,
29
+ `last_sync` datetime NULL,
30
+ PRIMARY KEY (`customer_id`,`entity`,`job_id`)
31
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
32
+
33
+ $this->run("
34
+ DROP TABLE IF EXISTS mailup_sync_jobs;
35
+ CREATE TABLE IF NOT EXISTS `mailup_sync_jobs` (
36
+ `id` int(11) NOT NULL AUTO_INCREMENT,
37
+ `store_id` int(11) DEFAULT NULL,
38
+ `mailupgroupid` int(11) NOT NULL,
39
+ `send_optin` tinyint(1) NOT NULL,
40
+ `status` varchar(20) NOT NULL,
41
+ `queue_datetime` datetime NOT NULL,
42
+ `start_datetime` datetime,
43
+ `finish_datetime` datetime,
44
+ PRIMARY KEY (`id`)
45
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
46
+
47
+ $this->endSetup();
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.0-2.3.1.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ /**
5
+ * We want to record the process id, and the number of attempts we've made at
6
+ * processing the job!
7
+ */
8
+ $this->run("
9
+ ALTER TABLE mailup_sync_jobs
10
+ ADD `process_id` INT UNSIGNED DEFAULT NULL,
11
+ ADD `tries` INT UNSIGNED DEFAULT 0;
12
+ ");
13
+
14
+ $this->endSetup();
app/design/adminhtml/default/default/layout/mailup.xml CHANGED
@@ -1,14 +1,16 @@
1
  <?xml version="1.0"?>
2
  <layout>
 
3
  <mailup_adminhtml_filter_index>
4
  <update handle="mailup_adminhtml_index"/>
5
  <reference name="content">
6
- <block type="adminhtml/template" name="filter" template="sevenlike/mailup/filter.phtml"/>
7
  </reference>
8
  <reference name="head">
9
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
10
  </reference>
11
  </mailup_adminhtml_filter_index>
 
12
  <mailup_adminhtml_filter_confirm>
13
  <update handle="mailup_adminhtml_confirm"/>
14
  <reference name="content">
@@ -18,6 +20,7 @@
18
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
19
  </reference>
20
  </mailup_adminhtml_filter_confirm>
 
21
  <mailup_adminhtml_fieldsmapping_index>
22
  <update handle="mailup_adminhtml_index" />
23
  <reference name="content">
@@ -27,6 +30,7 @@
27
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
28
  </reference>
29
  </mailup_adminhtml_fieldsmapping_index>
 
30
  <mailup_adminhtml_viewdatatransferlog_index>
31
  <update handle="mailup_adminhtml_index" />
32
  <reference name="content">
@@ -36,6 +40,7 @@
36
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
37
  </reference>
38
  </mailup_adminhtml_viewdatatransferlog_index>
 
39
  <mailup_adminhtml_viewdatatransferlog_search>
40
  <update handle="mailup_adminhtml_index" />
41
  <reference name="content">
@@ -45,4 +50,12 @@
45
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
46
  </reference>
47
  </mailup_adminhtml_viewdatatransferlog_search>
 
 
 
 
 
 
 
 
48
  </layout>
1
  <?xml version="1.0"?>
2
  <layout>
3
+
4
  <mailup_adminhtml_filter_index>
5
  <update handle="mailup_adminhtml_index"/>
6
  <reference name="content">
7
+ <block type="mailup/filters" name="filter" template="sevenlike/mailup/filter.phtml"/>
8
  </reference>
9
  <reference name="head">
10
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
11
  </reference>
12
  </mailup_adminhtml_filter_index>
13
+
14
  <mailup_adminhtml_filter_confirm>
15
  <update handle="mailup_adminhtml_confirm"/>
16
  <reference name="content">
20
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
21
  </reference>
22
  </mailup_adminhtml_filter_confirm>
23
+
24
  <mailup_adminhtml_fieldsmapping_index>
25
  <update handle="mailup_adminhtml_index" />
26
  <reference name="content">
30
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
31
  </reference>
32
  </mailup_adminhtml_fieldsmapping_index>
33
+
34
  <mailup_adminhtml_viewdatatransferlog_index>
35
  <update handle="mailup_adminhtml_index" />
36
  <reference name="content">
40
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
41
  </reference>
42
  </mailup_adminhtml_viewdatatransferlog_index>
43
+
44
  <mailup_adminhtml_viewdatatransferlog_search>
45
  <update handle="mailup_adminhtml_index" />
46
  <reference name="content">
50
  <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
51
  </reference>
52
  </mailup_adminhtml_viewdatatransferlog_search>
53
+
54
+ <!-- works but need a better image.. -->
55
+ <!--<default>
56
+ <reference name="head">
57
+ <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
58
+ </reference>
59
+ </default>-->
60
+
61
  </layout>
app/design/adminhtml/default/default/template/sevenlike/mailup/confirm.phtml CHANGED
@@ -1,181 +1,194 @@
1
- <?php
2
- //ottengo l'elenco delle liste e dei gruppi da mailup
3
- $wsImport = new MailUpWsImport();
4
-
5
- $customersFiltered = $wsImport->getCustomersFiltered($this);
6
-
7
- $xmlString = $wsImport->GetNlList();
8
- $xmlString = html_entity_decode($xmlString);
9
-
10
- $startLists = strpos($xmlString, '<Lists>');
11
- $endPos = strpos($xmlString, '</Lists>');
12
- $endLists = $endPos + strlen('</Lists>') - $startLists;
13
-
14
- $xmlLists = substr($xmlString, $startLists, $endLists);
15
- $xmlLists = str_replace("&", "&amp;", $xmlLists);
16
- $xml = simplexml_load_string($xmlLists);
17
- ?>
18
-
19
- <?php //creo il form nascosto per passare i parametri al tasto back ?>
20
- <form id="back_form" name="back_form" method="post" action="<?php echo $this->getUrl('*/*/'); ?>">
21
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
22
- <input type="hidden" name="mailupCustomers" value="<?php echo $this->getRequest()->getParam('mailupCustomers'); ?>" />
23
- <input type="hidden" name="mailupProductSku" value="<?php echo $this->getRequest()->getParam('mailupProductSku'); ?>" />
24
- <input type="hidden" name="mailupCategoryId" value="<?php echo $this->getRequest()->getParam('mailupCategoryId'); ?>" />
25
- <input type="hidden" name="mailupCustomerGroupId" value="<?php echo $this->getRequest()->getParam('mailupCustomerGroupId'); ?>" />
26
- <input type="hidden" name="mailupCountry" value="<?php echo $this->getRequest()->getParam('mailupCountry'); ?>" />
27
- <input type="hidden" name="mailupPostCode" value="<?php echo $this->getRequest()->getParam('mailupPostCode'); ?>" />
28
- <input type="hidden" name="mailupCustomerStartDate" value="<?php echo $this->getRequest()->getParam('mailupCustomerStartDate'); ?>" />
29
- <input type="hidden" name="mailupCustomerEndDate" value="<?php echo $this->getRequest()->getParam('mailupCustomerEndDate'); ?>" />
30
- <input type="hidden" name="mailupTotalAmountCond" value="<?php echo $this->getRequest()->getParam('mailupTotalAmountCond'); ?>" />
31
- <input type="hidden" name="mailupTotalAmountValue" value="<?php echo $this->getRequest()->getParam('mailupTotalAmountValue'); ?>" />
32
- <input type="hidden" name="mailupOrderStartDate" value="<?php echo $this->getRequest()->getParam('mailupOrderStartDate'); ?>" />
33
- <input type="hidden" name="mailupOrderEndDate" value="<?php echo $this->getRequest()->getParam('mailupOrderEndDate'); ?>" />
34
- <input type="hidden" name="mailupOrderYesNo" value="<?php echo $this->getRequest()->getParam('mailupOrderYesNo'); ?>" />
35
- <input type="hidden" name="mailupSubscribed" value="<?php echo $this->getRequest()->getParam('mailupSubscribed'); ?>" />
36
- </form>
37
-
38
- <form id="csv_form" name="csv_form" method="post" action="<?php echo $this->getUrl('*/*/csv'); ?>">
39
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
40
- <?php
41
- $countPost = 0;
42
- $textArea = '';
43
- $formParams = '';
44
- $mailupCustomerIds = array();
45
- //mi passo gli id di tutti i clienti filtrati
46
- foreach ($customersFiltered as $i=>$customer) {
47
- if ($i++ < 25) $textArea .= $customer['email'] . "\n";
48
- $mailupCustomerIds[$countPost] = $customer['entity_id'];
49
- $countPost++;
50
- }
51
- //salvo l'array nella sessione
52
- if ($countPost > 0) {
53
- Mage::getSingleton('core/session')->setMailupCustomerIds($mailupCustomerIds);
54
- }
55
- ?>
56
- <input name="countPost" type="hidden" value="<?php echo $countPost; ?>" />
57
- </form>
58
- <div class="content-header">
59
- <table cellspacing="0" class="grid-header">
60
- <tr>
61
- <td><h3><?php echo $this->__('MailUp')?></h3></td>
62
- <td class="a-right">
63
- <div id="mailuploading" class="mailuploading"><?php echo $this->__("Please wait for the next step to load") ?></div>
64
- <button id="mailupback" onclick="back_form.submit()" class="scalable back" type="button"><span><?php echo $this->__('Reset filters')?></span></button>
65
- <button onclick="$$('.content-header-floating').invoke('setStyle', {visibility:'hidden'});document.getElementById('mailupsend').style.display='none';document.getElementById('mailupback').style.display='none';document.getElementById('mailuploading').style.display='block';editForm.submit()" class="scalable save" type="button" id="mailupsend"><span><?php echo $this->__('Send to MailUp')?></span></button>
66
- </td>
67
- </tr>
68
- </table>
69
- </div>
70
- <div class="entry-edit">
71
- <?php
72
- //gestisco la lista selezionata in configurazione
73
- foreach($xml->List as $list) {
74
- if ($list['idList'] == Mage::getStoreConfig('newsletter/mailup/list')) {
75
- $listName = $list['listName'];
76
- $idList = $list['idList'];
77
- $listGUID = $list['listGUID'];
78
- }
79
- }
80
- ?>
81
- <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post')?>">
82
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
83
- <input name="mailupIdList" type="hidden" value="<?php echo $idList; ?>" />
84
- <input name="mailupListGUID" type="hidden" value="<?php echo $listGUID; ?>" />
85
-
86
- <h4><span id="spantitle3"><?php echo $this->__('Confirm filtered customers and select MailUp group')?></span></h4>
87
- <fieldset id="my-fieldset">
88
- <table cellspacing="0" class="form-list">
89
- <tr>
90
- <td colspan="2"><h4><?php echo $this->__('Were found')?> <strong><?php echo $countPost; ?></strong> <?php echo $this->__('records')?></h4></td>
91
- </tr>
92
- <tr>
93
- <td><?php echo $this->__('Filtered customers preview')?>:</td>
94
- </tr>
95
- <tr>
96
- <td>
97
- <textarea name="mailupCustomerFilteredView" rows="5" cols="50" disabled="disabled" class="txtar1"><?php echo $textArea ?></textarea>
98
- </td>
99
- </tr>
100
- <tr>
101
- <td colspan="2">
102
- <?php echo $this->__('Selected list')?>: <strong>
103
- <?php echo $listName; ?><br /><br /><br />
104
- </strong></td>
105
- </tr>
106
- </table>
107
-
108
- <table>
109
- <tr>
110
- <td>
111
- <h4><?php echo $this->__('Next step')?></h4>
112
- </td>
113
- </tr>
114
- <tr>
115
- <td class="label">
116
- <p class="slgrp1"><?php echo $this->__('Select group')?> <input type="radio" name="mailupNewGroup" value="0" checked="checked" /></p>
117
- </td>
118
- </tr>
119
- <tr>
120
- <td class="input-ele">
121
- <p class="istrz1"><?php echo $this->__('Select an existing group')?>:</p>
122
- <select class="required-entry slctpg1" name="mailupGroupId">
123
- <?php
124
- $groups = array();
125
- foreach($xml->List as $list) {
126
- if ($list['idList'] == Mage::getStoreConfig('newsletter/mailup/list')){
127
- foreach($list->Groups->Group as $group) {
128
- $groups[(string)$group['idGroup']] = (string)$group['groupName'];
129
- }
130
- }
131
- }
132
- @asort($groups);
133
- foreach ($groups as $tmpid=>$tmpname) {
134
- echo '<option value="'.$tmpid.'">'.htmlspecialchars($tmpname).'</option>';
135
- }
136
- ?>
137
- </select>
138
- <br /><br />
139
- </td>
140
- </tr>
141
- <tr>
142
- <td>
143
- <p class="istrz2"><?php echo $this->__('or')?></p>
144
- </td>
145
- </tr>
146
- <tr>
147
- <td class="label">
148
- <p class="slgrp1"><?php echo $this->__('Create new customer group')?> <input type="radio" name="mailupNewGroup" value="1" /></p>
149
- </td>
150
- </tr>
151
- <tr>
152
- <td>
153
- <p class="istrz1"><?php echo $this->__('Group name')?>:</p>
154
- </td>
155
- </tr>
156
- <tr>
157
- <td>
158
- <input type="text" name="mailupNewGroupName" size="60" class="inptptx2" />
159
- </td>
160
- </tr>
161
- </table>
162
-
163
- <table>
164
- <tr>
165
- <td>
166
- <h4><?php echo $this->__('Next step')?></h4>
167
- </td>
168
- </tr>
169
- <tr>
170
- <td>
171
- <input type="checkbox" name="send_optin_email_to_new_subscribers" value="1" checked="checked" /> <?php echo $this->__('Send opt-in email to new subscribers') ?>
172
- </td>
173
- </tr>
174
- </table>
175
- </fieldset>
176
- </form>
177
-
178
- </div>
179
- <script type="text/javascript">
180
- var editForm = new varienForm('edit_form');
181
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * confirm.phtml
4
+ */
5
+ $storeId = $this->getRequest()->getParam('store_id');
6
+ if(empty($storeId)) {
7
+ $storeId = NULL; //Mage::app()->getDefaultStoreView()->getStoreId();
8
+ }
9
+
10
+ //ottengo l'elenco delle liste e dei gruppi da mailup
11
+ $wsImport = new MailUpWsImport($storeId);
12
+
13
+ $customersFiltered = $wsImport->getCustomersFiltered($this, $storeId);
14
+
15
+ $xmlString = $wsImport->GetNlList();
16
+ $xmlString = html_entity_decode($xmlString);
17
+
18
+ $startLists = strpos($xmlString, '<Lists>');
19
+ $endPos = strpos($xmlString, '</Lists>');
20
+ $endLists = $endPos + strlen('</Lists>') - $startLists;
21
+
22
+ $xmlLists = substr($xmlString, $startLists, $endLists);
23
+ $xmlLists = str_replace("&", "&amp;", $xmlLists);
24
+ $xml = simplexml_load_string($xmlLists);
25
+ ?>
26
+
27
+ <?php //creo il form nascosto per passare i parametri al tasto back ?>
28
+ <form id="back_form" name="back_form" method="post" action="<?php echo $this->getUrl('*/*/'); ?>">
29
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
30
+ <input type="hidden" name="store_id" value="<?php echo $this->getRequest()->getParam('store_id'); ?>" />
31
+ <input type="hidden" name="mailupCustomers" value="<?php echo $this->getRequest()->getParam('mailupCustomers'); ?>" />
32
+ <input type="hidden" name="mailupProductSku" value="<?php echo $this->getRequest()->getParam('mailupProductSku'); ?>" />
33
+ <input type="hidden" name="mailupCategoryId" value="<?php echo $this->getRequest()->getParam('mailupCategoryId'); ?>" />
34
+ <input type="hidden" name="mailupCustomerGroupId" value="<?php echo $this->getRequest()->getParam('mailupCustomerGroupId'); ?>" />
35
+ <input type="hidden" name="mailupCountry" value="<?php echo $this->getRequest()->getParam('mailupCountry'); ?>" />
36
+ <input type="hidden" name="mailupPostCode" value="<?php echo $this->getRequest()->getParam('mailupPostCode'); ?>" />
37
+ <input type="hidden" name="mailupCustomerStartDate" value="<?php echo $this->getRequest()->getParam('mailupCustomerStartDate'); ?>" />
38
+ <input type="hidden" name="mailupCustomerEndDate" value="<?php echo $this->getRequest()->getParam('mailupCustomerEndDate'); ?>" />
39
+ <input type="hidden" name="mailupTotalAmountCond" value="<?php echo $this->getRequest()->getParam('mailupTotalAmountCond'); ?>" />
40
+ <input type="hidden" name="mailupTotalAmountValue" value="<?php echo $this->getRequest()->getParam('mailupTotalAmountValue'); ?>" />
41
+ <input type="hidden" name="mailupOrderStartDate" value="<?php echo $this->getRequest()->getParam('mailupOrderStartDate'); ?>" />
42
+ <input type="hidden" name="mailupOrderEndDate" value="<?php echo $this->getRequest()->getParam('mailupOrderEndDate'); ?>" />
43
+ <input type="hidden" name="mailupOrderYesNo" value="<?php echo $this->getRequest()->getParam('mailupOrderYesNo'); ?>" />
44
+ <input type="hidden" name="mailupSubscribed" value="<?php echo $this->getRequest()->getParam('mailupSubscribed'); ?>" />
45
+ </form>
46
+
47
+ <form id="csv_form" name="csv_form" method="post" action="<?php echo $this->getUrl('*/*/csv'); ?>">
48
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
49
+ <input type="hidden" name="store_id" value="<?php echo $this->getRequest()->getParam('store_id'); ?>" />
50
+ <?php
51
+ $countPost = 0;
52
+ $textArea = '';
53
+ $formParams = '';
54
+ $mailupCustomerIds = array();
55
+ //mi passo gli id di tutti i clienti filtrati
56
+ foreach ($customersFiltered as $i=>$customer) {
57
+ if ($i++ < 25) $textArea .= $customer['email'] . "\n";
58
+ $mailupCustomerIds[$countPost] = $customer['entity_id'];
59
+ $countPost++;
60
+ }
61
+ //salvo l'array nella sessione
62
+ if ($countPost > 0) {
63
+ Mage::getSingleton('core/session')->setMailupCustomerIds($mailupCustomerIds);
64
+ }
65
+ ?>
66
+ <input name="countPost" type="hidden" value="<?php echo $countPost; ?>" />
67
+ </form>
68
+ <div class="content-header">
69
+ <table cellspacing="0" class="grid-header">
70
+ <tr>
71
+ <td><h3><?php echo $this->__('MailUp')?></h3></td>
72
+ <td class="a-right">
73
+ <div id="mailuploading" class="mailuploading"><?php echo $this->__("Please wait for the next step to load") ?></div>
74
+ <button id="mailupback" onclick="back_form.submit()" class="scalable back" type="button"><span><?php echo $this->__('Reset filters')?></span></button>
75
+ <button onclick="$$('.content-header-floating').invoke('setStyle', {visibility:'hidden'});document.getElementById('mailupsend').style.display='none';document.getElementById('mailupback').style.display='none';document.getElementById('mailuploading').style.display='block';editForm.submit()"
76
+ class="scalable save" type="button" id="mailupsend">
77
+ <span><?php echo $this->__('Send to MailUp')?></span>
78
+ </button>
79
+ </td>
80
+ </tr>
81
+ </table>
82
+ </div>
83
+ <div class="entry-edit">
84
+ <?php foreach($xml->List as $list) : ?>
85
+ <?php /* @var $list SimpleXMLElement */ ?>
86
+ <?php $listId = (string) $list['idList'] ?>
87
+ <?php if($listId == Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId)): ?>
88
+ <?php $listName = (string) $list['listName'] ?>
89
+ <?php $idList = (string) $list['idList'] ?>
90
+ <?php $listGUID = (string) $list['listGUID'] ?>
91
+ <?php endif ?>
92
+ <?php endforeach ?>
93
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post')?>">
94
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
95
+ <input type="hidden" name="store_id" value="<?php echo $this->getRequest()->getParam('store_id'); ?>" />
96
+ <input name="mailupIdList" type="hidden" value="<?php echo $idList; ?>" />
97
+ <input name="mailupListGUID" type="hidden" value="<?php echo $listGUID; ?>" />
98
+
99
+ <h4><span id="spantitle3"><?php echo $this->__('Confirm filtered customers and select MailUp group')?></span></h4>
100
+ <fieldset id="my-fieldset">
101
+ <table cellspacing="0" class="form-list">
102
+ <tr>
103
+ <td colspan="2"><h4><?php echo $this->__('Were found')?> <strong><?php echo $countPost; ?></strong> <?php echo $this->__('records')?></h4></td>
104
+ </tr>
105
+ <tr>
106
+ <td><?php echo $this->__('Filtered customers preview')?>:</td>
107
+ </tr>
108
+ <tr>
109
+ <td>
110
+ <textarea name="mailupCustomerFilteredView" rows="5" cols="50" disabled="disabled" class="txtar1"><?php echo $textArea ?></textarea>
111
+ </td>
112
+ </tr>
113
+ <tr>
114
+ <td colspan="2">
115
+ <?php echo $this->__('Selected list')?>: <strong>
116
+ <?php echo $listName; ?><br /><br /><br />
117
+ </strong></td>
118
+ </tr>
119
+ </table>
120
+
121
+ <table>
122
+ <tr>
123
+ <td>
124
+ <h4><?php echo $this->__('Next step')?></h4>
125
+ </td>
126
+ </tr>
127
+ <tr>
128
+ <td class="label">
129
+ <p class="slgrp1"><?php echo $this->__('Select group')?> <input type="radio" name="mailupNewGroup" value="0" checked="checked" /></p>
130
+ </td>
131
+ </tr>
132
+ <tr>
133
+ <td class="input-ele">
134
+ <p class="istrz1"><?php echo $this->__('Select an existing group')?>:</p>
135
+ <select class="required-entry slctpg1" name="mailupGroupId">
136
+ <?php
137
+ $groups = array();
138
+ foreach($xml->List as $list) {
139
+ if ($list['idList'] == Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId)){
140
+ foreach($list->Groups->Group as $group) {
141
+ $groups[(string)$group['idGroup']] = (string)$group['groupName'];
142
+ }
143
+ }
144
+ }
145
+ @asort($groups);
146
+ foreach ($groups as $tmpid=>$tmpname) {
147
+ echo '<option value="'.$tmpid.'">'.htmlspecialchars($tmpname).'</option>';
148
+ }
149
+ ?>
150
+ </select>
151
+ <br /><br />
152
+ </td>
153
+ </tr>
154
+ <tr>
155
+ <td>
156
+ <p class="istrz2"><?php echo $this->__('or')?></p>
157
+ </td>
158
+ </tr>
159
+ <tr>
160
+ <td class="label">
161
+ <p class="slgrp1"><?php echo $this->__('Create new customer group')?> <input type="radio" name="mailupNewGroup" value="1" /></p>
162
+ </td>
163
+ </tr>
164
+ <tr>
165
+ <td>
166
+ <p class="istrz1"><?php echo $this->__('Group name')?>:</p>
167
+ </td>
168
+ </tr>
169
+ <tr>
170
+ <td>
171
+ <input type="text" name="mailupNewGroupName" size="60" class="inptptx2" />
172
+ </td>
173
+ </tr>
174
+ </table>
175
+
176
+ <table>
177
+ <tr>
178
+ <td>
179
+ <h4><?php echo $this->__('Next step')?></h4>
180
+ </td>
181
+ </tr>
182
+ <tr>
183
+ <td>
184
+ <input type="checkbox" name="send_optin_email_to_new_subscribers" value="1" checked="checked" /> <?php echo $this->__('Send opt-in email to new subscribers') ?>
185
+ </td>
186
+ </tr>
187
+ </table>
188
+ </fieldset>
189
+ </form>
190
+
191
+ </div>
192
+ <script type="text/javascript">
193
+ var editForm = new varienForm('edit_form');
194
+ </script>
app/design/adminhtml/default/default/template/sevenlike/mailup/fieldsmapping.phtml CHANGED
@@ -1,55 +1,61 @@
1
- <?php
2
-
3
- $allmagentofields = array("Name", "Last", "Email", "Company", "Address", "City", "ZIP", "Province", "Region", "Country", "Gender", "DateOfBirth", "CustomerID", "Phone", "Fax", "LatestOrderID", "LatestOrderDate", "LatestOrderAmount", "LatestOrderProductIDs", "LatestOrderCategoryIDs", "LatestShippedOrderDate", "LatestShippedOrderID", "LatestAbandonedCartDate", "LatestAbandonedCartTotal", "LatestAbandonedCartID", "TotalOrdered", "TotalOrderedLast12m", "TotalOrderedLast30d", "AllOrderedProductIDs");
4
- $wsSend = new MailUpWsSend();
5
- $accessKey = $wsSend->loginFromId();
6
-
7
- if ($accessKey === false) {
8
- echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
9
- } else {
10
- $wsImport = new MailUpWsImport();
11
-
12
- $wsSend = new MailUpWsSend();
13
- // campi che arrivano da mailup
14
- $wsFields = $wsSend->getFields($accessKey);
15
-
16
- //carico i mapping salvati
17
- $fields = $wsImport->getFieldsMapping();
18
- ?>
19
- <div class="content-header">
20
- <table cellspacing="0" class="grid-header">
21
- <tr>
22
- <td>
23
- <h3><?php echo $this->__('Fields mapping')?></h3>
24
- </td>
25
- <td class="a-right">
26
- <button onclick="document.forms.saveFieldsMappingForm.submit()" class="scalable save" type="button"><span><?php echo $this->__('Save configuration')?></span></button>
27
- </td>
28
- </tr>
29
- </table>
30
- </div>
31
- <p><?php echo $this->__('Associate all Magento fields with MailUp ones') ?></p>
32
- <p>&nbsp;</p>
33
- <div style="font-weight:bold">
34
- <div style="display:block;float:left;width:180px"><?php echo $this->__("Magento fields") ?></div>
35
- <div><?php echo $this->__("Mailup fields") ?></div>
36
- </div>
37
- <form name="saveFieldsMappingForm" method="post" action="<?php echo $this->getUrl('*/*/save')?>">
38
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
39
- <?php foreach ($allmagentofields as $magentofield): ?>
40
- <div>
41
- <label for="sl_<?php echo $magentofield ?>" style="display:block;float:left;width:180px;"><?php echo $magentofield ?></label>
42
- <select name="<?php echo $magentofield ?>" id="sl_<?php echo $magentofield ?>">
43
- <option value=""></option>
44
- <?php
45
- foreach ($wsFields as $nome=>$id) {
46
- $selected = ($id == $fields[$magentofield]) ? "selected='selected'" : "";
47
- $nome = htmlspecialchars($nome);
48
- echo "<option value='$id' $selected>$nome</option>";
49
- }
50
- echo '</select>';
51
- ?>
52
- </div>
53
- <?php endforeach; ?>
54
- </form>
 
 
 
 
 
 
55
  <?php } ?>
1
+ <?php
2
+ /**
3
+ * @depreciated
4
+ */
5
+ $allmagentofields = array(
6
+ "Name", "Last", "Email", "Company", "Address", "City", "ZIP", "Province", "Region", "Country", "Gender", "DateOfBirth", "CustomerID",
7
+ "Phone", "Fax", "LatestOrderID", "LatestOrderDate", "LatestOrderAmount", "LatestOrderProductIDs", "LatestOrderCategoryIDs",
8
+ "LatestShippedOrderDate", "LatestShippedOrderID", "LatestAbandonedCartDate", "LatestAbandonedCartTotal",
9
+ "LatestAbandonedCartID", "TotalOrdered", "TotalOrderedLast12m", "TotalOrderedLast30d", "AllOrderedProductIDs"
10
+ );
11
+ $wsSend = new MailUpWsSend();
12
+ $accessKey = $wsSend->loginFromId();
13
+
14
+ if ($accessKey === false) {
15
+ echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
16
+ } else {
17
+ $wsImport = new MailUpWsImport();
18
+
19
+ $wsSend = new MailUpWsSend();
20
+ // campi che arrivano da mailup
21
+ $wsFields = $wsSend->getFields($accessKey);
22
+ //carico i mapping salvati
23
+ $fields = $wsImport->getFieldsMapping();
24
+ ?>
25
+ <div class="content-header">
26
+ <table cellspacing="0" class="grid-header">
27
+ <tr>
28
+ <td>
29
+ <h3><?php echo $this->__('Fields mapping')?></h3>
30
+ </td>
31
+ <td class="a-right">
32
+ <button onclick="document.forms.saveFieldsMappingForm.submit()" class="scalable save" type="button"><span><?php echo $this->__('Save configuration')?></span></button>
33
+ </td>
34
+ </tr>
35
+ </table>
36
+ </div>
37
+ <p><?php echo $this->__('Associate all Magento fields with MailUp ones') ?></p>
38
+ <p>&nbsp;</p>
39
+ <div style="font-weight:bold">
40
+ <div style="display:block;float:left;width:180px"><?php echo $this->__("Magento fields") ?></div>
41
+ <div><?php echo $this->__("Mailup fields") ?></div>
42
+ </div>
43
+ <form name="saveFieldsMappingForm" method="post" action="<?php echo $this->getUrl('*/*/save')?>">
44
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
45
+ <?php foreach ($allmagentofields as $magentofield): ?>
46
+ <div>
47
+ <label for="sl_<?php echo $magentofield ?>" style="display:block;float:left;width:180px;"><?php echo $magentofield ?></label>
48
+ <select name="<?php echo $magentofield ?>" id="sl_<?php echo $magentofield ?>">
49
+ <option value=""></option>
50
+ <?php
51
+ foreach ($wsFields as $nome=>$id) {
52
+ $selected = ($id == $fields[$magentofield]) ? "selected='selected'" : "";
53
+ $nome = htmlspecialchars($nome);
54
+ echo "<option value='$id' $selected>$nome</option>";
55
+ }
56
+ echo '</select>';
57
+ ?>
58
+ </div>
59
+ <?php endforeach; ?>
60
+ </form>
61
  <?php } ?>
app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml CHANGED
@@ -1,497 +1,526 @@
1
- <?php
2
-
3
- $wsSend = new MailUpWsSend();
4
- $accessKey = $wsSend->loginFromId();
5
-
6
- if ($accessKey === false || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 1) {
7
- echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
8
- } else {
9
- //controllo se la lista e' stata selezionata correttamente
10
- $wsImport = new MailUpWsImport();
11
- $mailupLists = $wsImport->GetNlList();
12
-
13
- //carico i filtri salvati
14
- $filterHints = $wsImport->getFilterHints();
15
-
16
- //TODO: sembra inutilizzata
17
- //chiamata attivazione web services su MailUp
18
- //$urlWSActivation = 'http://'.Mage::getStoreConfig('newsletter/mailup/url_console').'/frontend/WSActivation.aspx?usr='.Mage::getStoreConfig('newsletter/mailup/user').'&pwd='.Mage::getStoreConfig('newsletter/mailup/password').'&nl_url='.Mage::getStoreConfig('newsletter/mailup/url_console').'&ws_name=WSMailUpImport';
19
- //fopen($urlWSActivation, 'r');
20
-
21
- //salvo i parametri in variabili
22
- $mailupCustomers = $this->getRequest()->getParam('mailupCustomers');
23
- $mailupProductSku = $this->getRequest()->getParam('mailupProductSku');
24
- $mailupCategoryId = $this->getRequest()->getParam('mailupCategoryId');
25
- $mailupCustomerGroupId = $this->getRequest()->getParam('mailupCustomerGroupId');
26
- $mailupCountry = $this->getRequest()->getParam('mailupCountry');
27
- $mailupPostCode = $this->getRequest()->getParam('mailupPostCode');
28
- $mailupCustomerStartDate = $this->getRequest()->getParam('mailupCustomerStartDate');
29
- $mailupCustomerEndDate = $this->getRequest()->getParam('mailupCustomerEndDate');
30
- $mailupTotalAmountCond = $this->getRequest()->getParam('mailupTotalAmountCond');
31
- $mailupTotalAmountValue = $this->getRequest()->getParam('mailupTotalAmountValue');
32
- $mailupOrderStartDate = $this->getRequest()->getParam('mailupOrderStartDate');
33
- $mailupOrderEndDate = $this->getRequest()->getParam('mailupOrderEndDate');
34
- $mailupOrderYesNo = $this->getRequest()->getParam('mailupOrderYesNo');
35
- $mailupSubscribed = $this->getRequest()->getParam('mailupSubscribed');
36
-
37
-
38
- function print_category($category)
39
- {
40
- if (is_numeric($category)) {
41
- $category = Mage::getModel("catalog/category")->load($category);
42
- }
43
-
44
- echo '<option value="'.$category->getData('entity_id').'">'.str_repeat("-", $category->getData("level")-2) . htmlspecialchars($category->getData('name')).'</option>';
45
- $children = $category->getChildren();
46
- if (!$children) return;
47
-
48
- $children = explode(",", $children);
49
- foreach($children as $child) {
50
- print_category($child);
51
- }
52
- }
53
- ?>
54
-
55
- <div class="content-header">
56
- <table cellspacing="0" class="grid-header">
57
- <tr>
58
- <td>
59
- <h3><?php echo $this->__('Filters')?></h3>
60
- </td>
61
- <td class="a-right">
62
- <div id="mailuploading" class="mailuploading"><?php echo $this->__("Please wait for the next step to load") ?></div>
63
- <button onclick="$$('.content-header-floating').invoke('setStyle', {visibility:'hidden'});document.getElementById('mailupsend').style.display='none';document.getElementById('mailuploading').style.display='block';editForm.submit();" class="scalable save" type="button" id="mailupsend"><div class="mailuploading"></div><span><?php echo $this->__('Apply filter')?></span></button>
64
- </td>
65
- </tr>
66
- </table>
67
- </div>
68
-
69
- <div class="entry-edit">
70
- <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/confirm')?>">
71
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
72
-
73
- <input name="filter_name" id="filter_name" type="hidden" value="" />
74
-
75
- <p id="spansugger"><a href="#ottsugg"><?php echo $this->__('Get hints')?> &rArr;</a></p>
76
- <fieldset id="my-fieldset">
77
- <table cellspacing="0" class="form-list">
78
- <tr>
79
- <td colspan="3"><?php echo $this->__('By this plugin you can import contacts registered in your eCommerce in the MailUp platform.')?></td>
80
- </tr>
81
- <tr>
82
- <td colspan="3">&nbsp;</td>
83
- </tr>
84
- <tr>
85
- <td colspan="3">
86
- <strong><?php echo $this->__('Sold products')?></strong>
87
- </td>
88
- </tr>
89
- <?php //imposto il filtro per clienti: 0 = tutti, 1 = che hanno acquistato, 2 = che non hanno mai acquistato ?>
90
- <tr>
91
- <td class="input-ele spdnpg1">
92
- <input type="radio" name="mailupCustomers" id="mailupCustomersAll" value="0" <?php if (isset($mailupCustomers) && $mailupCustomers == 0) { echo 'checked="checked"'; } ?> onclick="customerDependentFilters(false);" />&nbsp;<label for="mailupCustomersAll"><?php echo $this->__('All customers')?></label>
93
- </td>
94
-
95
- <td class="input-ele spdnpg1">
96
- <input type="radio" name="mailupCustomers" id="mailupCustomersWhoHaveBought" value="1" <?php if (isset($mailupCustomers) && $mailupCustomers == 1) { echo 'checked="checked"'; } ?> onclick="customerDependentFilters(false);" />&nbsp;<label for="mailupCustomersWhoHaveBought"><?php echo $this->__('Customers who have purchased')?></label>
97
- </td>
98
-
99
- <td class="input-ele spdnpg1">
100
- <input type="radio" name="mailupCustomers" id="mailupCustomersWhoHaventBought" value="2" <?php if (isset($mailupCustomers) && $mailupCustomers == 2) { echo 'checked="checked"'; } ?> onclick="customerDependentFilters(true);" />&nbsp;<label for="mailupCustomersWhoHaventBought"><?php echo $this->__("Customers who have not purchased")?></label>
101
- </td>
102
- </tr>
103
- <tr>
104
- <td colspan="3">
105
- <strong><?php echo $this->__('Opt-in Status')?></strong>
106
- </td>
107
- </tr>
108
- <tr>
109
- <td>
110
- <input type="radio" name="mailupSubscribed" id="mailupSubscribedOptIn" value="1" <?php if (isset($mailupSubscribed) && $mailupSubscribed == 1) { echo 'checked="checked"'; } ?> />&nbsp;<label for="mailupSubscribedOptIn"><?php echo $this->__("Opted-in Only"); ?></label>
111
- </td>
112
- <td colspan="2">
113
- <input type="radio" name="mailupSubscribed" id="mailupSubscribedAllCustomers" value="0" <?php if (isset($mailupCustomers) && $mailupCustomers == 0) { echo 'checked="checked"'; } ?> />&nbsp;<label for="mailupSubscribedAllCustomers"><?php echo $this->__("All customers")?></label>
114
- </td>
115
- </tr>
116
- </table>
117
-
118
- <br /><br />
119
-
120
- <table cellspacing="0" class="form-list">
121
- <tr>
122
- <td colspan="2">
123
- <strong><?php echo $this->__('Groups')?></strong>
124
- </td>
125
- </tr>
126
- <tr>
127
- <td class="labelpg1"><?php echo $this->__('Select customer group')?></td>
128
- <td class="input-ele">
129
- <select name="mailupCustomerGroupId" class="slctpg1">
130
- <?php
131
- $customerGroups = Mage::helper('customer')->getGroups()->toOptionArray();
132
-
133
- if ($mailupCustomerGroupId) {
134
- foreach ($customerGroups as $customerGroup) {
135
- if ($mailupCustomerGroupId == $customerGroup['value']) {
136
- echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
137
- }
138
- }
139
- }
140
- ?>
141
-
142
- <option value="0">-- <?php echo $this->__('Any')?> --</option>
143
-
144
- <?php
145
- foreach ($customerGroups as $customerGroup) {
146
- echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
147
- }
148
- ?>
149
- </select>
150
- </td>
151
- </tr>
152
-
153
- <tr>
154
- <td colspan="2">
155
- <br /><br /><strong><?php echo $this->__('Location')?></strong>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td class="labelpg1"><?php echo $this->__('Select country')?></td>
160
- <td class="input-ele">
161
- <select name="mailupCountry" class="slctpg1">
162
- <?php
163
- $countries = Mage::getResourceModel('directory/country_collection')
164
- ->loadData()
165
- ->toOptionArray(false);
166
-
167
- if ($mailupCountry) {
168
- foreach ($countries as $country){
169
- if ($country['value'] == $mailupCountry)
170
- echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
171
- }
172
- }
173
- ?>
174
-
175
- <option value="0">-- <?php echo $this->__('Any')?> --</option>
176
-
177
- <?php
178
- foreach ($countries as $country) {
179
- echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
180
- }
181
- ?>
182
- </select>
183
- </td>
184
- </tr>
185
- <tr>
186
- <td class="labelpg1"><?php echo $this->__('Zip code')?></td>
187
- <td class="input-ele">
188
- <input type="text" class="inptptx1" name="mailupPostCode" size="10" value="<?php echo $mailupPostCode; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> 12345)</span>
189
- </td>
190
- </tr>
191
- </table>
192
-
193
- <table cellspacing="0" class="form-list" id="customerDependentContainer">
194
- <tr>
195
- <td colspan="2">
196
- <br /><br /><strong><?php echo $this->__('Products and categories')?></strong>
197
- </td>
198
- </tr>
199
-
200
- <?php //select con tutti i prodotti ?>
201
- <tr>
202
- <td class="labelpg1"><?php echo $this->__('Insert product SKU')?></td>
203
- <td class="input-ele">
204
- <input type="text" class="inptptx1 customerDependent" name="mailupProductSku" size="20" value="<?php echo $mailupProductSku; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> MYSKU123)</span>
205
- </td>
206
- </tr>
207
- <?php //select con tutte le categorie ?>
208
- <tr>
209
- <td class="labelpg1"><?php echo $this->__('Select category')?></td>
210
- <td class="input-ele">
211
- <?php
212
- $categoriesCollection = Mage::getModel('catalog/category')->getCollection();
213
- $categoriesCollection->addAttributeToSelect('name');
214
- $categoriesCollection->addAttributeToSelect('entity_id');
215
- ?>
216
- <select id="mailupCategoryId" name="mailupCategoryId" class="slctpg1 customerDependent">
217
- <?php
218
- if ($mailupCategoryId) {
219
- $category = Mage::getModel('catalog/category')->load($mailupCategoryId);
220
- echo '<option value="'.$mailupCategoryId.'">'.$category->getData('name').'</option>';
221
- }
222
- ?>
223
-
224
- <option value="0">-- <?php echo $this->__('Any')?> --</option>
225
-
226
- <?php
227
- foreach ($categoriesCollection as $category) {
228
- if ($category->getLevel() == 2) {
229
- print_category($category);
230
- }
231
- }
232
- ?>
233
- </select>
234
- </td>
235
- </tr>
236
-
237
- <tr>
238
- <td colspan="2">
239
- <br /><br /><strong><?php echo $this->__('Subscription date')?></strong>
240
- </td>
241
- </tr>
242
- <tr>
243
- <td class="labelpg1"><?php echo $this->__('From')?></td>
244
- <td class="input-ele">
245
- <input type="text" class="inptptx1 customerDependent" name="mailupCustomerStartDate" id="mailupCustomerStartDate" size="20" value="<?php echo $mailupCustomerStartDate; ?>" /><img id="mailupCustomerStartDateTrig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
246
- <script type="text/javascript">
247
- Calendar.setup({
248
- inputField: "mailupCustomerStartDate",
249
- ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
250
- showsTime: false,
251
- button: "mailupCustomerStartDateTrig",
252
- align: "Bl",
253
- singleClick : true
254
- });
255
- </script>
256
- </td>
257
- </tr>
258
- <tr>
259
- <td class="labelpg1"><?php echo $this->__('To')?></td>
260
- <td class="input-ele">
261
- <input type="text" class="inptptx1 customerDependent" name="mailupCustomerEndDate" id="mailupCustomerEndDate" size="20" value="<?php echo $mailupCustomerEndDate; ?>" /><img id="mailupCustomerEndDateTrig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
262
- <script type="text/javascript">
263
- Calendar.setup({
264
- inputField: "mailupCustomerEndDate",
265
- ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
266
- showsTime: false,
267
- button: "mailupCustomerEndDateTrig",
268
- align: "Bl",
269
- singleClick : true
270
- });
271
- </script>
272
- </td>
273
- </tr>
274
- <tr>
275
- <td colspan="2">
276
- <br /><br /><strong><?php echo $this->__('Total purchased amount')?></strong>
277
- </td>
278
- </tr>
279
- <tr>
280
- <td class="labelpg1"><?php echo $this->__('Order total')?></td>
281
- <td class="input-ele">
282
- <select id="mailupTotalAmountCond" name="mailupTotalAmountCond" class="slctpg2 customerDependent">
283
- <?php
284
- if ($mailupTotalAmountCond && $mailupTotalAmountCond != 'gt') {
285
- if ($mailupTotalAmountCond == 'lt') {
286
- echo '<option value="lt"> '.$this->__('less than').' </option>';
287
- } elseif ($mailupTotalAmountCond == 'eq') {
288
- echo '<option value="eq"> '.$this->__('same as').' </option>';
289
- }
290
- }
291
- ?>
292
- <option value="gt"> <?php echo $this->__('more than')?> </option>
293
- <option value="lt"> <?php echo $this->__('less than')?> </option>
294
- <option value="eq"> <?php echo $this->__('same as')?> </option>
295
- </select>
296
-
297
- <!--label for="mailupTotalAmountValue" class="lbl1"><?php echo $this->__('Specify amount')?></label-->&nbsp;
298
- <input type="text" class="inptptx1 customerDependent" id="mailupTotalAmountValue" name="mailupTotalAmountValue" size="20" value="<?php echo $mailupTotalAmountValue; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> 50)</span>
299
- </td>
300
- </tr>
301
-
302
- <tr>
303
- <td colspan="2">
304
- <br /><br /><strong><?php echo $this->__('Date of purchase')?></strong>
305
- </td>
306
- </tr>
307
-
308
- <tr>
309
- <td><?php echo $this->__('Show customers who'); ?></td>
310
- <td>
311
- <select name="mailupOrderYesNo" class="slctpg2 customerDependent">
312
- <?php
313
- if ($mailupOrderYesNo == 'no') {
314
- echo '<option value="no">'.$this->__("Haven't purchased").'</option>';
315
- }
316
- ?>
317
- <option value="yes"> <?php echo $this->__('Have purchased'); ?> </option>
318
- <option value="no"> <?php echo $this->__("Haven't purchased"); ?> </option>
319
- </select>
320
- </td>
321
- </tr>
322
-
323
- <tr>
324
- <td class="labelpg1"><?php echo $this->__('From')?></td>
325
- <td class="input-ele">
326
- <input type="text" class="inptptx1 customerDependent" name="mailupOrderStartDate" id="mailupOrderStartDate" size="20" value="<?php echo $mailupOrderStartDate; ?>" /><img id="mailupOrderStartDateTrig" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
327
- <script type="text/javascript">
328
- Calendar.setup({
329
- inputField: "mailupOrderStartDate",
330
- ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
331
- showsTime: false,
332
- button: "mailupOrderStartDateTrig",
333
- align: "Bl",
334
- singleClick : true
335
- });
336
- </script>
337
- </td>
338
- </tr>
339
- <tr>
340
- <td class="labelpg1"><?php echo $this->__('To')?></td>
341
- <td class="input-ele">
342
- <input type="text" class="inptptx1 customerDependent" name="mailupOrderEndDate" id="mailupOrderEndDate" size="20" value="<?php echo $mailupOrderEndDate; ?>" /><img id="mailupOrderEndDateTrig" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
343
- <script type="text/javascript">
344
- Calendar.setup({
345
- inputField: "mailupOrderEndDate",
346
- ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
347
- showsTime: false,
348
- button: "mailupOrderEndDateTrig",
349
- align: "Bl",
350
- singleClick : true
351
- });
352
- </script>
353
- </td>
354
- </tr>
355
- </table>
356
- </fieldset>
357
- </form>
358
-
359
- <h4><span id="spantitle3"><a name="saveFilter"><?php echo $this->__('Save current filters as hint')?></a></span></h4>
360
- <fieldset id="my-fieldset3">
361
- <table>
362
- <tr>
363
- <td>
364
- <input name="filter_name_text" id="filter_name_text" type="text" value="" maxlength="100" size="50" />
365
- <input class="form-button" type="submit" onclick="saveFilterHint();return false;" value="<?php echo $this->__('Save hint')?>" />
366
- </td>
367
- </tr>
368
- </table>
369
- </fieldset>
370
-
371
- <h4><span id="spantitle1"><a name="ottsugg"><?php echo $this->__('Filter hints')?></a></span></h4>
372
- <fieldset id="my-fieldset2">
373
- <table cellspacing="0" class="form-list">
374
- <tr>
375
- <td><?php echo $this->__('Set and customize one of the following filters:')?></td>
376
- </tr>
377
- <tr>
378
- <td>
379
- <form action="*/*/" id="filtro1" name="filtro1" method="post">
380
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
381
- <input name="mailupCustomers" type="hidden" value="2" />
382
- <input name="mailupCustomerGroupId" type="hidden" value="2" />
383
- <p class="parscefil"><?php echo $this->__("All wholesale customers who haven't purchased yet")?> &raquo;</p>
384
- <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
385
- </form>
386
- </td>
387
- </tr>
388
- <tr>
389
- <td>
390
- <form action="*/*/" id="filtro2" name="filtro2" method="post">
391
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
392
- <input name="mailupCustomers" type="hidden" value="1" />
393
- <input name="mailupTotalAmountCond" type="hidden" value="gt" />
394
- <input name="mailupTotalAmountValue" type="hidden" value="50" />
395
- <p class="parscefil"><?php echo $this->__('More than 50 Euros orders')?> &raquo;</p>
396
- <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
397
- </form>
398
- </td>
399
- </tr>
400
- <tr>
401
- <td>
402
- <form action="*/*/" id="filtro3" name="filtro3" method="post">
403
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
404
- <input name="mailupCustomers" type="hidden" value="0" />
405
- <input name="mailupOrderYesNo" type="hidden" value="no" />
406
- <input name="mailupOrderStartDate" type="hidden" value="01/01/<?php echo date('Y'); ?>" />
407
- <p class="parscefil"><?php echo $this->__('Members with no purchase in')?> <?php echo date('Y'); ?> &raquo;</p>
408
- <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
409
- </form>
410
-
411
- </td>
412
- </tr>
413
-
414
- <?php if (!empty($filterHints)) { ?>
415
- <tr>
416
- <td>&nbsp;</td>
417
- </tr>
418
- <tr>
419
- <td><?php echo $this->__('Or choose one of those you saved:')?></td>
420
- </tr>
421
- <?php } ?>
422
-
423
- <?php
424
- foreach ($filterHints as $fh) {
425
- $filter_name = $fh['filter_name'];
426
- echo '<tr><td>';
427
- echo '<form action="*/*/" id="'.$filter_name.'" name="'.$filter_name.'" method="post">';
428
- echo '<input name="form_key" type="hidden" value="'. Mage::getSingleton('core/session')->getFormKey() .'" />';
429
- $hints = explode('|', $fh['hints']);
430
- foreach ($hints as $h) {
431
- $array = explode('=', $h);
432
- echo '<input name="'.$array[0].'" type="hidden" value="'.$array[1].'" />';
433
- }
434
- echo '<p class="parscefil">'.$filter_name.' &raquo;</p>';
435
- echo '<input class="form-button" type="submit" value="'.$this->__('Set hint').'" />';
436
- echo '</form>';
437
- echo '&nbsp;';
438
- echo '<form name="deleteForm_'.$filter_name.'" action="'.$this->getUrl('*/*/deleteFilterHint').'" method="post">';
439
- echo '<input name="form_key" type="hidden" value="'. Mage::getSingleton('core/session')->getFormKey() .'" />';
440
- echo '<input name="filter_name" type="hidden" value="'. $filter_name .'" />';
441
- echo '<input class="form-button" type="submit" name="delete" onclick="if(confirm(\''.$this->__('Do you really want to delete this filter hint?').'\')==true){this.submit();}return false;" value="'.$this->__('Delete hint').'" />';
442
- echo '</form>';
443
- echo '</td></tr>';
444
- } ?>
445
-
446
- </table>
447
- </fieldset>
448
-
449
- <!--<a href="<?php echo $this->getUrl('*/*/testCron')?>">TEST CRON</a>
450
- <a href="<?php echo $this->getUrl('*/*/testFields')?>">TEST GETFIELDS</a>-->
451
- </div>
452
- <script type="text/javascript">
453
- var editForm = new varienForm('edit_form');
454
-
455
- document.getElementsByClassName = function(className) {
456
- var retnode = [];
457
- var myclass = new RegExp('\\b'+className+'\\b');
458
- var elements = this.getElementsByTagName('*');
459
- var elementsLength = elements.length;
460
- var element = null;
461
- for (var i = 0; i < elementsLength; i++) {
462
- element = elements[i];
463
- if (myclass.test(element.className)) {
464
- retnode.push(element);
465
- }
466
- }
467
- return retnode;
468
- };
469
-
470
- function customerDependentFilters(isDisabled) {
471
- document.getElementById('customerDependentContainer').style.display = (isDisabled) ? 'none' : 'block';
472
-
473
- var elements = document.getElementsByClassName('customerDependent');
474
-
475
- var elementsLength = elements.length;
476
- for (var i=0; i < elementsLength; i++) {
477
- elements[i].disabled = isDisabled;
478
- }
479
- }
480
-
481
- function saveFilterHint() {
482
- if (document.getElementById('filter_name_text').value=='') {
483
- alert('<?php echo $this->__('Please, give your new hint a name.')?>');
484
- } else {
485
- document.getElementById('filter_name').value = document.getElementById('filter_name_text').value;
486
- document.getElementById('edit_form').action = '<?php echo $this->getUrl('*/*/saveFilterHint')?>';
487
- document.getElementById('edit_form').submit();
488
- }
489
- return false;
490
- }
491
-
492
- window.onload = function() {
493
- var isDisabled = document.getElementById('mailupCustomersWhoHaventBought').checked;
494
- customerDependentFilters(isDisabled);
495
- }
496
- </script>
497
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * filter.phtml
4
+ */
5
+ $wsSend = new MailUpWsSend(); /** @todo add in storeID, use session.. not needed really here... **/
6
+ $accessKey = $wsSend->loginFromId();
7
+
8
+ if ($accessKey === false || strlen(Mage::getStoreConfig('mailup_newsletter/mailup/list')) < 1) {
9
+ echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
10
+ } else {
11
+ //controllo se la lista e' stata selezionata correttamente
12
+ $wsImport = new MailUpWsImport();
13
+ $mailupLists = $wsImport->GetNlList();
14
+
15
+ //carico i filtri salvati
16
+ $filterHints = $wsImport->getFilterHints();
17
+
18
+ //TODO: sembra inutilizzata
19
+ //chiamata attivazione web services su MailUp
20
+ //$urlWSActivation = 'http://'.Mage::getStoreConfig('newsletter/mailup/url_console').'/frontend/WSActivation.aspx?usr='.Mage::getStoreConfig('newsletter/mailup/user').'&pwd='.Mage::getStoreConfig('newsletter/mailup/password').'&nl_url='.Mage::getStoreConfig('newsletter/mailup/url_console').'&ws_name=WSMailUpImport';
21
+ //fopen($urlWSActivation, 'r');
22
+
23
+ //salvo i parametri in variabili
24
+ $mailupCustomers = $this->getRequest()->getParam('mailupCustomers');
25
+ $mailupProductSku = $this->getRequest()->getParam('mailupProductSku');
26
+ $mailupCategoryId = $this->getRequest()->getParam('mailupCategoryId');
27
+ $mailupCustomerGroupId = $this->getRequest()->getParam('mailupCustomerGroupId');
28
+ $mailupCountry = $this->getRequest()->getParam('mailupCountry');
29
+ $mailupPostCode = $this->getRequest()->getParam('mailupPostCode');
30
+ $mailupCustomerStartDate = $this->getRequest()->getParam('mailupCustomerStartDate');
31
+ $mailupCustomerEndDate = $this->getRequest()->getParam('mailupCustomerEndDate');
32
+ $mailupTotalAmountCond = $this->getRequest()->getParam('mailupTotalAmountCond');
33
+ $mailupTotalAmountValue = $this->getRequest()->getParam('mailupTotalAmountValue');
34
+ $mailupOrderStartDate = $this->getRequest()->getParam('mailupOrderStartDate');
35
+ $mailupOrderEndDate = $this->getRequest()->getParam('mailupOrderEndDate');
36
+ $mailupOrderYesNo = $this->getRequest()->getParam('mailupOrderYesNo');
37
+ $mailupSubscribed = $this->getRequest()->getParam('mailupSubscribed');
38
+
39
+
40
+ function print_category($category)
41
+ {
42
+ if (is_numeric($category)) {
43
+ $category = Mage::getModel("catalog/category")->load($category);
44
+ }
45
+
46
+ echo '<option value="'.$category->getData('entity_id').'">'.str_repeat("-", $category->getData("level")-2) . htmlspecialchars($category->getData('name')).'</option>';
47
+ $children = $category->getChildren();
48
+ if (!$children) return;
49
+
50
+ $children = explode(",", $children);
51
+ foreach($children as $child) {
52
+ print_category($child);
53
+ }
54
+ }
55
+ ?>
56
+
57
+ <div class="content-header">
58
+ <table cellspacing="0" class="grid-header">
59
+ <tr>
60
+ <td>
61
+ <h3><?php echo $this->__('Filters')?></h3>
62
+ </td>
63
+ <td class="a-right">
64
+ <div id="mailuploading" class="mailuploading"><?php echo $this->__("Please wait for the next step to load") ?></div>
65
+ <button onclick="$$('.content-header-floating').invoke('setStyle', {visibility:'hidden'});document.getElementById('mailupsend').style.display='none';document.getElementById('mailuploading').style.display='block';editForm.submit();" class="scalable save" type="button" id="mailupsend">
66
+ <div class="mailuploading"></div><span><?php echo $this->__('Apply filter')?></span>
67
+ </button>
68
+ </td>
69
+ </tr>
70
+ </table>
71
+ </div>
72
+
73
+ <div class="entry-edit">
74
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/confirm')?>">
75
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
76
+
77
+ <input name="filter_name" id="filter_name" type="hidden" value="" />
78
+
79
+ <p id="spansugger"><a href="#ottsugg"><?php echo $this->__('Get hints')?> &rArr;</a></p>
80
+ <fieldset id="my-fieldset">
81
+ <table cellspacing="0" class="form-list">
82
+ <tr>
83
+ <td colspan="3"><?php echo $this->__('By this plugin you can import contacts registered in your eCommerce in the MailUp platform.')?></td>
84
+ </tr>
85
+ </tr>
86
+ <tr>
87
+ <td colspan="3">&nbsp;</td>
88
+ </tr>
89
+ <tr>
90
+ <td>
91
+ <strong><?php echo $this->__('Store')?></strong>
92
+ </td>
93
+ <td colspan="2">
94
+ <select name="store_id">
95
+ <?php foreach($this->_getStoresArray() as $store): ?>
96
+ <option value="<?php echo $store['id'] ?>">
97
+ <?php echo $store['name'] ?>
98
+ </option>
99
+ <?php endforeach ?>
100
+ </select>
101
+ </td>
102
+ </tr>
103
+ <tr>
104
+ <td colspan="3">&nbsp;</td>
105
+ </tr>
106
+ <tr>
107
+ <td colspan="3">
108
+ <strong><?php echo $this->__('Sold products')?></strong>
109
+ </td>
110
+ </tr>
111
+ <?php //imposto il filtro per clienti: 0 = tutti, 1 = che hanno acquistato, 2 = che non hanno mai acquistato ?>
112
+ <tr>
113
+ <td class="input-ele spdnpg1">
114
+ <input type="radio" name="mailupCustomers" id="mailupCustomersAll" value="0" <?php if (isset($mailupCustomers) && $mailupCustomers == 0) { echo 'checked="checked"'; } ?>
115
+ onclick="customerDependentFilters(false);" />&nbsp;<label for="mailupCustomersAll"><?php echo $this->__('All customers')?></label>
116
+ </td>
117
+
118
+ <td class="input-ele spdnpg1">
119
+ <input type="radio" name="mailupCustomers" id="mailupCustomersWhoHaveBought" value="1" <?php if (isset($mailupCustomers) && $mailupCustomers == 1) { echo 'checked="checked"'; } ?>
120
+ onclick="customerDependentFilters(false);" />&nbsp;<label for="mailupCustomersWhoHaveBought"><?php echo $this->__('Customers who have purchased')?></label>
121
+ </td>
122
+
123
+ <td class="input-ele spdnpg1">
124
+ <input type="radio" name="mailupCustomers" id="mailupCustomersWhoHaventBought" value="2" <?php if (isset($mailupCustomers) && $mailupCustomers == 2) { echo 'checked="checked"'; } ?>
125
+ onclick="customerDependentFilters(true);" />&nbsp;<label for="mailupCustomersWhoHaventBought"><?php echo $this->__("Customers who have not purchased")?></label>
126
+ </td>
127
+ </tr>
128
+ <tr>
129
+ <td colspan="3">
130
+ <strong><?php echo $this->__('Opt-in Status')?></strong>
131
+ </td>
132
+ </tr>
133
+ <tr>
134
+ <td>
135
+ <input type="radio" name="mailupSubscribed" id="mailupSubscribedOptIn"
136
+ value="1" <?php if (isset($mailupSubscribed) && $mailupSubscribed == 1) { echo 'checked="checked"'; } ?> />&nbsp;<label for="mailupSubscribedOptIn"><?php echo $this->__("Opted-in Only"); ?></label>
137
+ </td>
138
+ <td colspan="2">
139
+ <input type="radio" name="mailupSubscribed" id="mailupSubscribedAllCustomers"
140
+ value="0" <?php if (isset($mailupCustomers) && $mailupCustomers == 0) { echo 'checked="checked"'; } ?> />&nbsp;<label for="mailupSubscribedAllCustomers"><?php echo $this->__("All customers")?></label>
141
+ </td>
142
+ </tr>
143
+ </table>
144
+
145
+ <br /><br />
146
+
147
+ <table cellspacing="0" class="form-list">
148
+ <tr>
149
+ <td colspan="2">
150
+ <strong><?php echo $this->__('Groups')?></strong>
151
+ </td>
152
+ </tr>
153
+ <tr>
154
+ <td class="labelpg1"><?php echo $this->__('Select customer group')?></td>
155
+ <td class="input-ele">
156
+ <select name="mailupCustomerGroupId" class="slctpg1">
157
+ <?php
158
+ $customerGroups = Mage::helper('customer')->getGroups()->toOptionArray();
159
+
160
+ if ($mailupCustomerGroupId) {
161
+ foreach ($customerGroups as $customerGroup) {
162
+ if ($mailupCustomerGroupId == $customerGroup['value']) {
163
+ echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
164
+ }
165
+ }
166
+ }
167
+ ?>
168
+
169
+ <option value="0">-- <?php echo $this->__('Any')?> --</option>
170
+
171
+ <?php
172
+ foreach ($customerGroups as $customerGroup) {
173
+ echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
174
+ }
175
+ ?>
176
+ </select>
177
+ </td>
178
+ </tr>
179
+
180
+ <tr>
181
+ <td colspan="2">
182
+ <br /><br /><strong><?php echo $this->__('Location')?></strong>
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td class="labelpg1"><?php echo $this->__('Select country')?></td>
187
+ <td class="input-ele">
188
+ <select name="mailupCountry" class="slctpg1">
189
+ <?php
190
+ $countries = Mage::getResourceModel('directory/country_collection')
191
+ ->loadData()
192
+ ->toOptionArray(false);
193
+
194
+ if ($mailupCountry) {
195
+ foreach ($countries as $country){
196
+ if ($country['value'] == $mailupCountry)
197
+ echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
198
+ }
199
+ }
200
+ ?>
201
+
202
+ <option value="0">-- <?php echo $this->__('Any')?> --</option>
203
+
204
+ <?php
205
+ foreach ($countries as $country) {
206
+ echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
207
+ }
208
+ ?>
209
+ </select>
210
+ </td>
211
+ </tr>
212
+ <tr>
213
+ <td class="labelpg1"><?php echo $this->__('Zip code')?></td>
214
+ <td class="input-ele">
215
+ <input type="text" class="inptptx1" name="mailupPostCode" size="10" value="<?php echo $mailupPostCode; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> 12345)</span>
216
+ </td>
217
+ </tr>
218
+ </table>
219
+
220
+ <table cellspacing="0" class="form-list" id="customerDependentContainer">
221
+ <tr>
222
+ <td colspan="2">
223
+ <br /><br /><strong><?php echo $this->__('Products and categories')?></strong>
224
+ </td>
225
+ </tr>
226
+
227
+ <?php //select con tutti i prodotti ?>
228
+ <tr>
229
+ <td class="labelpg1"><?php echo $this->__('Insert product SKU')?></td>
230
+ <td class="input-ele">
231
+ <input type="text" class="inptptx1 customerDependent" name="mailupProductSku" size="20" value="<?php echo $mailupProductSku; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> MYSKU123)</span>
232
+ </td>
233
+ </tr>
234
+ <?php //select con tutte le categorie ?>
235
+ <tr>
236
+ <td class="labelpg1"><?php echo $this->__('Select category')?></td>
237
+ <td class="input-ele">
238
+ <?php
239
+ $categoriesCollection = Mage::getModel('catalog/category')->getCollection();
240
+ $categoriesCollection->addAttributeToSelect('name');
241
+ $categoriesCollection->addAttributeToSelect('entity_id');
242
+ ?>
243
+ <select id="mailupCategoryId" name="mailupCategoryId" class="slctpg1 customerDependent">
244
+ <?php
245
+ if ($mailupCategoryId) {
246
+ $category = Mage::getModel('catalog/category')->load($mailupCategoryId);
247
+ echo '<option value="'.$mailupCategoryId.'">'.$category->getData('name').'</option>';
248
+ }
249
+ ?>
250
+
251
+ <option value="0">-- <?php echo $this->__('Any')?> --</option>
252
+
253
+ <?php
254
+ foreach ($categoriesCollection as $category) {
255
+ if ($category->getLevel() == 2) {
256
+ print_category($category);
257
+ }
258
+ }
259
+ ?>
260
+ </select>
261
+ </td>
262
+ </tr>
263
+
264
+ <tr>
265
+ <td colspan="2">
266
+ <br /><br /><strong><?php echo $this->__('Subscription date')?></strong>
267
+ </td>
268
+ </tr>
269
+ <tr>
270
+ <td class="labelpg1"><?php echo $this->__('From')?></td>
271
+ <td class="input-ele">
272
+ <input type="text" class="inptptx1 customerDependent" name="mailupCustomerStartDate" id="mailupCustomerStartDate" size="20" value="<?php echo $mailupCustomerStartDate; ?>" />
273
+ <img id="mailupCustomerStartDateTrig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
274
+ <script type="text/javascript">
275
+ Calendar.setup({
276
+ inputField: "mailupCustomerStartDate",
277
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
278
+ showsTime: false,
279
+ button: "mailupCustomerStartDateTrig",
280
+ align: "Bl",
281
+ singleClick : true
282
+ });
283
+ </script>
284
+ </td>
285
+ </tr>
286
+ <tr>
287
+ <td class="labelpg1"><?php echo $this->__('To')?></td>
288
+ <td class="input-ele">
289
+ <input type="text" class="inptptx1 customerDependent" name="mailupCustomerEndDate" id="mailupCustomerEndDate" size="20" value="<?php echo $mailupCustomerEndDate; ?>" />
290
+ <img id="mailupCustomerEndDateTrig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
291
+ <script type="text/javascript">
292
+ Calendar.setup({
293
+ inputField: "mailupCustomerEndDate",
294
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
295
+ showsTime: false,
296
+ button: "mailupCustomerEndDateTrig",
297
+ align: "Bl",
298
+ singleClick : true
299
+ });
300
+ </script>
301
+ </td>
302
+ </tr>
303
+ <tr>
304
+ <td colspan="2">
305
+ <br /><br /><strong><?php echo $this->__('Total purchased amount')?></strong>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <td class="labelpg1"><?php echo $this->__('Order total')?></td>
310
+ <td class="input-ele">
311
+ <select id="mailupTotalAmountCond" name="mailupTotalAmountCond" class="slctpg2 customerDependent">
312
+ <?php
313
+ if ($mailupTotalAmountCond && $mailupTotalAmountCond != 'gt') {
314
+ if ($mailupTotalAmountCond == 'lt') {
315
+ echo '<option value="lt"> '.$this->__('less than').' </option>';
316
+ } elseif ($mailupTotalAmountCond == 'eq') {
317
+ echo '<option value="eq"> '.$this->__('same as').' </option>';
318
+ }
319
+ }
320
+ ?>
321
+ <option value="gt"> <?php echo $this->__('more than')?> </option>
322
+ <option value="lt"> <?php echo $this->__('less than')?> </option>
323
+ <option value="eq"> <?php echo $this->__('same as')?> </option>
324
+ </select>
325
+
326
+ <!--label for="mailupTotalAmountValue" class="lbl1"><?php echo $this->__('Specify amount')?></label-->&nbsp;
327
+ <input type="text" class="inptptx1 customerDependent" id="mailupTotalAmountValue" name="mailupTotalAmountValue" size="20" value="<?php echo $mailupTotalAmountValue; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> 50)</span>
328
+ </td>
329
+ </tr>
330
+
331
+ <tr>
332
+ <td colspan="2">
333
+ <br /><br /><strong><?php echo $this->__('Date of purchase')?></strong>
334
+ </td>
335
+ </tr>
336
+
337
+ <tr>
338
+ <td><?php echo $this->__('Show customers who'); ?></td>
339
+ <td>
340
+ <select name="mailupOrderYesNo" class="slctpg2 customerDependent">
341
+ <?php
342
+ if ($mailupOrderYesNo == 'no') {
343
+ echo '<option value="no">'.$this->__("Haven't purchased").'</option>';
344
+ }
345
+ ?>
346
+ <option value="yes"> <?php echo $this->__('Have purchased'); ?> </option>
347
+ <option value="no"> <?php echo $this->__("Haven't purchased"); ?> </option>
348
+ </select>
349
+ </td>
350
+ </tr>
351
+
352
+ <tr>
353
+ <td class="labelpg1"><?php echo $this->__('From')?></td>
354
+ <td class="input-ele">
355
+ <input type="text" class="inptptx1 customerDependent" name="mailupOrderStartDate" id="mailupOrderStartDate" size="20" value="<?php echo $mailupOrderStartDate; ?>" /><img id="mailupOrderStartDateTrig" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
356
+ <script type="text/javascript">
357
+ Calendar.setup({
358
+ inputField: "mailupOrderStartDate",
359
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
360
+ showsTime: false,
361
+ button: "mailupOrderStartDateTrig",
362
+ align: "Bl",
363
+ singleClick : true
364
+ });
365
+ </script>
366
+ </td>
367
+ </tr>
368
+ <tr>
369
+ <td class="labelpg1"><?php echo $this->__('To')?></td>
370
+ <td class="input-ele">
371
+ <input type="text" class="inptptx1 customerDependent" name="mailupOrderEndDate" id="mailupOrderEndDate" size="20" value="<?php echo $mailupOrderEndDate; ?>" /><img id="mailupOrderEndDateTrig" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
372
+ <script type="text/javascript">
373
+ Calendar.setup({
374
+ inputField: "mailupOrderEndDate",
375
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
376
+ showsTime: false,
377
+ button: "mailupOrderEndDateTrig",
378
+ align: "Bl",
379
+ singleClick : true
380
+ });
381
+ </script>
382
+ </td>
383
+ </tr>
384
+ </table>
385
+ </fieldset>
386
+ </form>
387
+
388
+ <h4><span id="spantitle3"><a name="saveFilter"><?php echo $this->__('Save current filters as hint')?></a></span></h4>
389
+ <fieldset id="my-fieldset3">
390
+ <table>
391
+ <tr>
392
+ <td>
393
+ <input name="filter_name_text" id="filter_name_text" type="text" value="" maxlength="100" size="50" />
394
+ <input class="form-button" type="submit" onclick="saveFilterHint();return false;" value="<?php echo $this->__('Save hint')?>" />
395
+ </td>
396
+ </tr>
397
+ </table>
398
+ </fieldset>
399
+
400
+ <h4><span id="spantitle1"><a name="ottsugg"><?php echo $this->__('Filter hints')?></a></span></h4>
401
+ <fieldset id="my-fieldset2">
402
+ <table cellspacing="0" class="form-list">
403
+ <tr>
404
+ <td><?php echo $this->__('Set and customize one of the following filters:')?></td>
405
+ </tr>
406
+ <tr>
407
+ <td>
408
+ <form action="*/*/" id="filtro1" name="filtro1" method="post">
409
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
410
+ <input name="mailupCustomers" type="hidden" value="2" />
411
+ <input name="mailupCustomerGroupId" type="hidden" value="2" />
412
+ <p class="parscefil"><?php echo $this->__("All wholesale customers who haven't purchased yet")?> &raquo;</p>
413
+ <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
414
+ </form>
415
+ </td>
416
+ </tr>
417
+ <tr>
418
+ <td>
419
+ <form action="*/*/" id="filtro2" name="filtro2" method="post">
420
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
421
+ <input name="mailupCustomers" type="hidden" value="1" />
422
+ <input name="mailupTotalAmountCond" type="hidden" value="gt" />
423
+ <input name="mailupTotalAmountValue" type="hidden" value="50" />
424
+ <p class="parscefil"><?php echo $this->__('More than 50 Euros orders')?> &raquo;</p>
425
+ <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
426
+ </form>
427
+ </td>
428
+ </tr>
429
+ <tr>
430
+ <td>
431
+ <form action="*/*/" id="filtro3" name="filtro3" method="post">
432
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
433
+ <input name="mailupCustomers" type="hidden" value="0" />
434
+ <input name="mailupOrderYesNo" type="hidden" value="no" />
435
+ <input name="mailupOrderStartDate" type="hidden" value="01/01/<?php echo date('Y'); ?>" />
436
+ <p class="parscefil"><?php echo $this->__('Members with no purchase in')?> <?php echo date('Y'); ?> &raquo;</p>
437
+ <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
438
+ </form>
439
+
440
+ </td>
441
+ </tr>
442
+
443
+ <?php if(!empty($filterHints)): ?>
444
+ <tr>
445
+ <td>&nbsp;</td>
446
+ </tr>
447
+ <tr>
448
+ <td><?php echo $this->__('Or choose one of those you saved:')?></td>
449
+ </tr>
450
+ <?php endif ?>
451
+
452
+ <?php
453
+ foreach ($filterHints as $fh) {
454
+ $filter_name = $fh['filter_name'];
455
+ echo '<tr><td>';
456
+ echo '<form action="*/*/" id="'.$filter_name.'" name="'.$filter_name.'" method="post">';
457
+ echo '<input name="form_key" type="hidden" value="'. Mage::getSingleton('core/session')->getFormKey() .'" />';
458
+ $hints = explode('|', $fh['hints']);
459
+ foreach ($hints as $h) {
460
+ $array = explode('=', $h);
461
+ echo '<input name="'.$array[0].'" type="hidden" value="'.$array[1].'" />';
462
+ }
463
+ echo '<p class="parscefil">'.$filter_name.' &raquo;</p>';
464
+ echo '<input class="form-button" type="submit" value="'.$this->__('Set hint').'" />';
465
+ echo '</form>';
466
+ echo '&nbsp;';
467
+ echo '<form name="deleteForm_'.$filter_name.'" action="'.$this->getUrl('*/*/deleteFilterHint').'" method="post">';
468
+ echo '<input name="form_key" type="hidden" value="'. Mage::getSingleton('core/session')->getFormKey() .'" />';
469
+ echo '<input name="filter_name" type="hidden" value="'. $filter_name .'" />';
470
+ echo '<input class="form-button" type="submit" name="delete" onclick="if(confirm(\''.$this->__('Do you really want to delete this filter hint?').'\')==true){this.submit();}return false;" value="'.$this->__('Delete hint').'" />';
471
+ echo '</form>';
472
+ echo '</td></tr>';
473
+ } ?>
474
+
475
+ </table>
476
+ </fieldset>
477
+
478
+ <!--<a href="<?php echo $this->getUrl('*/*/testCron')?>">TEST CRON</a>
479
+ <a href="<?php echo $this->getUrl('*/*/testFields')?>">TEST GETFIELDS</a>-->
480
+ </div>
481
+ <script type="text/javascript">
482
+ var editForm = new varienForm('edit_form');
483
+
484
+ document.getElementsByClassName = function(className) {
485
+ var retnode = [];
486
+ var myclass = new RegExp('\\b'+className+'\\b');
487
+ var elements = this.getElementsByTagName('*');
488
+ var elementsLength = elements.length;
489
+ var element = null;
490
+ for (var i = 0; i < elementsLength; i++) {
491
+ element = elements[i];
492
+ if (myclass.test(element.className)) {
493
+ retnode.push(element);
494
+ }
495
+ }
496
+ return retnode;
497
+ };
498
+
499
+ function customerDependentFilters(isDisabled) {
500
+ document.getElementById('customerDependentContainer').style.display = (isDisabled) ? 'none' : 'block';
501
+
502
+ var elements = document.getElementsByClassName('customerDependent');
503
+
504
+ var elementsLength = elements.length;
505
+ for (var i=0; i < elementsLength; i++) {
506
+ elements[i].disabled = isDisabled;
507
+ }
508
+ }
509
+
510
+ function saveFilterHint() {
511
+ if (document.getElementById('filter_name_text').value=='') {
512
+ alert('<?php echo $this->__('Please, give your new hint a name.')?>');
513
+ } else {
514
+ document.getElementById('filter_name').value = document.getElementById('filter_name_text').value;
515
+ document.getElementById('edit_form').action = '<?php echo $this->getUrl('*/*/saveFilterHint')?>';
516
+ document.getElementById('edit_form').submit();
517
+ }
518
+ return false;
519
+ }
520
+
521
+ window.onload = function() {
522
+ var isDisabled = document.getElementById('mailupCustomersWhoHaventBought').checked;
523
+ customerDependentFilters(isDisabled);
524
+ }
525
+ </script>
526
+ <?php } ?>
app/design/adminhtml/default/default/template/sevenlike/mailup/filter_.phtml ADDED
@@ -0,0 +1,526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * filter.phtml
4
+ */
5
+ $wsSend = new MailUpWsSend(); /** @todo add in storeID, use session.. **/
6
+ $accessKey = $wsSend->loginFromId();
7
+
8
+ if ($accessKey === false || strlen(Mage::getStoreConfig('mailup_newsletter/mailup/list')) < 1) {
9
+ echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
10
+ } else {
11
+ //controllo se la lista e' stata selezionata correttamente
12
+ $wsImport = new MailUpWsImport();
13
+ $mailupLists = $wsImport->GetNlList();
14
+
15
+ //carico i filtri salvati
16
+ $filterHints = $wsImport->getFilterHints();
17
+
18
+ //TODO: sembra inutilizzata
19
+ //chiamata attivazione web services su MailUp
20
+ //$urlWSActivation = 'http://'.Mage::getStoreConfig('newsletter/mailup/url_console').'/frontend/WSActivation.aspx?usr='.Mage::getStoreConfig('newsletter/mailup/user').'&pwd='.Mage::getStoreConfig('newsletter/mailup/password').'&nl_url='.Mage::getStoreConfig('newsletter/mailup/url_console').'&ws_name=WSMailUpImport';
21
+ //fopen($urlWSActivation, 'r');
22
+
23
+ //salvo i parametri in variabili
24
+ $mailupCustomers = $this->getRequest()->getParam('mailupCustomers');
25
+ $mailupProductSku = $this->getRequest()->getParam('mailupProductSku');
26
+ $mailupCategoryId = $this->getRequest()->getParam('mailupCategoryId');
27
+ $mailupCustomerGroupId = $this->getRequest()->getParam('mailupCustomerGroupId');
28
+ $mailupCountry = $this->getRequest()->getParam('mailupCountry');
29
+ $mailupPostCode = $this->getRequest()->getParam('mailupPostCode');
30
+ $mailupCustomerStartDate = $this->getRequest()->getParam('mailupCustomerStartDate');
31
+ $mailupCustomerEndDate = $this->getRequest()->getParam('mailupCustomerEndDate');
32
+ $mailupTotalAmountCond = $this->getRequest()->getParam('mailupTotalAmountCond');
33
+ $mailupTotalAmountValue = $this->getRequest()->getParam('mailupTotalAmountValue');
34
+ $mailupOrderStartDate = $this->getRequest()->getParam('mailupOrderStartDate');
35
+ $mailupOrderEndDate = $this->getRequest()->getParam('mailupOrderEndDate');
36
+ $mailupOrderYesNo = $this->getRequest()->getParam('mailupOrderYesNo');
37
+ $mailupSubscribed = $this->getRequest()->getParam('mailupSubscribed');
38
+
39
+
40
+ function print_category($category)
41
+ {
42
+ if (is_numeric($category)) {
43
+ $category = Mage::getModel("catalog/category")->load($category);
44
+ }
45
+
46
+ echo '<option value="'.$category->getData('entity_id').'">'.str_repeat("-", $category->getData("level")-2) . htmlspecialchars($category->getData('name')).'</option>';
47
+ $children = $category->getChildren();
48
+ if (!$children) return;
49
+
50
+ $children = explode(",", $children);
51
+ foreach($children as $child) {
52
+ print_category($child);
53
+ }
54
+ }
55
+ ?>
56
+
57
+ <div class="content-header">
58
+ <table cellspacing="0" class="grid-header">
59
+ <tr>
60
+ <td>
61
+ <h3><?php echo $this->__('Filters')?></h3>
62
+ </td>
63
+ <td class="a-right">
64
+ <div id="mailuploading" class="mailuploading"><?php echo $this->__("Please wait for the next step to load") ?></div>
65
+ <button onclick="$$('.content-header-floating').invoke('setStyle', {visibility:'hidden'});document.getElementById('mailupsend').style.display='none';document.getElementById('mailuploading').style.display='block';editForm.submit();" class="scalable save" type="button" id="mailupsend">
66
+ <div class="mailuploading"></div><span><?php echo $this->__('Apply filter')?></span>
67
+ </button>
68
+ </td>
69
+ </tr>
70
+ </table>
71
+ </div>
72
+
73
+ <div class="entry-edit">
74
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/confirm')?>">
75
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
76
+
77
+ <input name="filter_name" id="filter_name" type="hidden" value="" />
78
+
79
+ <p id="spansugger"><a href="#ottsugg"><?php echo $this->__('Get hints')?> &rArr;</a></p>
80
+ <fieldset id="my-fieldset">
81
+ <table cellspacing="0" class="form-list</td>
82
+ <td colspan="2">
83
+ <input type="radio" name="mailupSubscribed" id="mailupSubscribedAllCustomers"
84
+ value="0" <?php if (isset($mailupCustomers) && $mailupCustomers == 0) { echo 'checked="checked"'; } ?> />&nbsp;<label for="mailupSubscribedAllCustomers"><?php echo $this->__("All customers")?></label>
85
+ </td>
86
+ </tr>
87
+ </table>
88
+
89
+ <br /><br />
90
+
91
+ <table cellspacing="0" class="form-list">
92
+ <tr>
93
+ <td colspan="2">
94
+ <strong><?php echo $this->__('Groups')?></strong>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <td class="labelpg1"><?php echo $this->__('Select customer group')?></td>
99
+ <td class="input-ele">
100
+ <select name="mailupCustomerGroupId" class="slctpg1">
101
+ <?php
102
+ $customerGroups = Mage::helper('customer')->getGroups()->toOptionArray();
103
+
104
+ ">
105
+ <tr>
106
+ <td colspan="3"><?php echo $this->__('By this plugin you can import contacts registered in your eCommerce in the MailUp platform.')?></td>
107
+ </tr>
108
+ </tr>
109
+ <tr>
110
+ <td colspan="3">&nbsp;</td>
111
+ </tr>
112
+ <tr>
113
+ <td>
114
+ <strong><?php echo $this->__('Store')?></strong>
115
+ </td>
116
+ <td colspan="2">
117
+ <select name="store_id">
118
+ <?php foreach($this->_getStoresArray() as $store): ?>
119
+ <option value="<?php echo $store['id'] ?>">
120
+ <?php echo $store['name'] ?>
121
+ </option>
122
+ <?php endforeach ?>
123
+ </select>
124
+ </td>
125
+ </tr>
126
+ <tr>
127
+ <td colspan="3">&nbsp;</td>
128
+ </tr>
129
+ <tr>
130
+ <td colspan="3">
131
+ <strong><?php echo $this->__('Sold products')?></strong>
132
+ </td>
133
+ </tr>
134
+ <?php //imposto il filtro per clienti: 0 = tutti, 1 = che hanno acquistato, 2 = che non hanno mai acquistato ?>
135
+ <tr>
136
+ <td class="input-ele spdnpg1">
137
+ <input type="radio" name="mailupCustomers" id="mailupCustomersAll" value="0" <?php if (isset($mailupCustomers) && $mailupCustomers == 0) { echo 'checked="checked"'; } ?>
138
+ onclick="customerDependentFilters(false);" />&nbsp;<label for="mailupCustomersAll"><?php echo $this->__('All customers')?></label>
139
+ </td>
140
+
141
+ <td class="input-ele spdnpg1">
142
+ <input type="radio" name="mailupCustomers" id="mailupCustomersWhoHaveBought" value="1" <?php if (isset($mailupCustomers) && $mailupCustomers == 1) { echo 'checked="checked"'; } ?>
143
+ onclick="customerDependentFilters(false);" />&nbsp;<label for="mailupCustomersWhoHaveBought"><?php echo $this->__('Customers who have purchased')?></label>
144
+ </td>
145
+
146
+ <td class="input-ele spdnpg1">
147
+ <input type="radio" name="mailupCustomers" id="mailupCustomersWhoHaventBought" value="2" <?php if (isset($mailupCustomers) && $mailupCustomers == 2) { echo 'checked="checked"'; } ?>
148
+ onclick="customerDependentFilters(true);" />&nbsp;<label for="mailupCustomersWhoHaventBought"><?php echo $this->__("Customers who have not purchased")?></label>
149
+ </td>
150
+ </tr>
151
+ <tr>
152
+ <td colspan="3">
153
+ <strong><?php echo $this->__('Opt-in Status')?></strong>
154
+ </td>
155
+ </tr>
156
+ <tr>
157
+ <td>
158
+ <input type="radio" name="mailupSubscribed" id="mailupSubscribedOptIn"
159
+ value="1" <?php if (isset($mailupSubscribed) && $mailupSubscribed == 1) { echo 'checked="checked"'; } ?> />&nbsp;<label for="mailupSubscribedOptIn"><?php echo $this->__("Opted-in Only"); ?></label>
160
+ if ($mailupCustomerGroupId) {
161
+ foreach ($customerGroups as $customerGroup) {
162
+ if ($mailupCustomerGroupId == $customerGroup['value']) {
163
+ echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
164
+ }
165
+ }
166
+ }
167
+ ?>
168
+
169
+ <option value="0">-- <?php echo $this->__('Any')?> --</option>
170
+
171
+ <?php
172
+ foreach ($customerGroups as $customerGroup) {
173
+ echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
174
+ }
175
+ ?>
176
+ </select>
177
+ </td>
178
+ </tr>
179
+
180
+ <tr>
181
+ <td colspan="2">
182
+ <br /><br /><strong><?php echo $this->__('Location')?></strong>
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td class="labelpg1"><?php echo $this->__('Select country')?></td>
187
+ <td class="input-ele">
188
+ <select name="mailupCountry" class="slctpg1">
189
+ <?php
190
+ $countries = Mage::getResourceModel('directory/country_collection')
191
+ ->loadData()
192
+ ->toOptionArray(false);
193
+
194
+ if ($mailupCountry) {
195
+ foreach ($countries as $country){
196
+ if ($country['value'] == $mailupCountry)
197
+ echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
198
+ }
199
+ }
200
+ ?>
201
+
202
+ <option value="0">-- <?php echo $this->__('Any')?> --</option>
203
+
204
+ <?php
205
+ foreach ($countries as $country) {
206
+ echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
207
+ }
208
+ ?>
209
+ </select>
210
+ </td>
211
+ </tr>
212
+ <tr>
213
+ <td class="labelpg1"><?php echo $this->__('Zip code')?></td>
214
+ <td class="input-ele">
215
+ <input type="text" class="inptptx1" name="mailupPostCode" size="10" value="<?php echo $mailupPostCode; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> 12345)</span>
216
+ </td>
217
+ </tr>
218
+ </table>
219
+
220
+ <table cellspacing="0" class="form-list" id="customerDependentContainer">
221
+ <tr>
222
+ <td colspan="2">
223
+ <br /><br /><strong><?php echo $this->__('Products and categories')?></strong>
224
+ </td>
225
+ </tr>
226
+
227
+ <?php //select con tutti i prodotti ?>
228
+ <tr>
229
+ <td class="labelpg1"><?php echo $this->__('Insert product SKU')?></td>
230
+ <td class="input-ele">
231
+ <input type="text" class="inptptx1 customerDependent" name="mailupProductSku" size="20" value="<?php echo $mailupProductSku; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> MYSKU123)</span>
232
+ </td>
233
+ </tr>
234
+ <?php //select con tutte le categorie ?>
235
+ <tr>
236
+ <td class="labelpg1"><?php echo $this->__('Select category')?></td>
237
+ <td class="input-ele">
238
+ <?php
239
+ $categoriesCollection = Mage::getModel('catalog/category')->getCollection();
240
+ $categoriesCollection->addAttributeToSelect('name');
241
+ $categoriesCollection->addAttributeToSelect('entity_id');
242
+ ?>
243
+ <select id="mailupCategoryId" name="mailupCategoryId" class="slctpg1 customerDependent">
244
+ <?php
245
+ if ($mailupCategoryId) {
246
+ $category = Mage::getModel('catalog/category')->load($mailupCategoryId);
247
+ echo '<option value="'.$mailupCategoryId.'">'.$category->getData('name').'</option>';
248
+ }
249
+ ?>
250
+
251
+ <option value="0">-- <?php echo $this->__('Any')?> --</option>
252
+
253
+ <?php
254
+ foreach ($categoriesCollection as $category) {
255
+ if ($category->getLevel() == 2) {
256
+ print_category($category);
257
+ }
258
+ }
259
+ ?>
260
+ </select>
261
+ </td>
262
+ </tr>
263
+
264
+ <tr>
265
+ <td colspan="2">
266
+ <br /><br /><strong><?php echo $this->__('Subscription date')?></strong>
267
+ </td>
268
+ </tr>
269
+ <tr>
270
+ <td class="labelpg1"><?php echo $this->__('From')?></td>
271
+ <td class="input-ele">
272
+ <input type="text" class="inptptx1 customerDependent" name="mailupCustomerStartDate" id="mailupCustomerStartDate" size="20" value="<?php echo $mailupCustomerStartDate; ?>" />
273
+ <img id="mailupCustomerStartDateTrig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
274
+ <script type="text/javascript">
275
+ Calendar.setup({
276
+ inputField: "mailupCustomerStartDate",
277
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
278
+ showsTime: false,
279
+ button: "mailupCustomerStartDateTrig",
280
+ align: "Bl",
281
+ singleClick : true
282
+ });
283
+ </script>
284
+ </td>
285
+ </tr>
286
+ <tr>
287
+ <td class="labelpg1"><?php echo $this->__('To')?></td>
288
+ <td class="input-ele">
289
+ <input type="text" class="inptptx1 customerDependent" name="mailupCustomerEndDate" id="mailupCustomerEndDate" size="20" value="<?php echo $mailupCustomerEndDate; ?>" />
290
+ <img id="mailupCustomerEndDateTrig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
291
+ <script type="text/javascript">
292
+ Calendar.setup({
293
+ inputField: "mailupCustomerEndDate",
294
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
295
+ showsTime: false,
296
+ button: "mailupCustomerEndDateTrig",
297
+ align: "Bl",
298
+ singleClick : true
299
+ });
300
+ </script>
301
+ </td>
302
+ </tr>
303
+ <tr>
304
+ <td colspan="2">
305
+ <br /><br /><strong><?php echo $this->__('Total purchased amount')?></strong>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <td class="labelpg1"><?php echo $this->__('Order total')?></td>
310
+ <td class="input-ele">
311
+ <select id="mailupTotalAmountCond" name="mailupTotalAmountCond" class="slctpg2 customerDependent">
312
+ <?php
313
+ if ($mailupTotalAmountCond && $mailupTotalAmountCond != 'gt') {
314
+ if ($mailupTotalAmountCond == 'lt') {
315
+ echo '<option value="lt"> '.$this->__('less than').' </option>';
316
+ } elseif ($mailupTotalAmountCond == 'eq') {
317
+ echo '<option value="eq"> '.$this->__('same as').' </option>';
318
+ }
319
+ }
320
+ ?>
321
+ <option value="gt"> <?php echo $this->__('more than')?> </option>
322
+ <option value="lt"> <?php echo $this->__('less than')?> </option>
323
+ <option value="eq"> <?php echo $this->__('same as')?> </option>
324
+ </select>
325
+
326
+ <!--label for="mailupTotalAmountValue" class="lbl1"><?php echo $this->__('Specify amount')?></label-->&nbsp;
327
+ <input type="text" class="inptptx1 customerDependent" id="mailupTotalAmountValue" name="mailupTotalAmountValue" size="20" value="<?php echo $mailupTotalAmountValue; ?>" /> <span class="tip">(<?php echo $this->__('e.g.')?> 50)</span>
328
+ </td>
329
+ </tr>
330
+
331
+ <tr>
332
+ <td colspan="2">
333
+ <br /><br /><strong><?php echo $this->__('Date of purchase')?></strong>
334
+ </td>
335
+ </tr>
336
+
337
+ <tr>
338
+ <td><?php echo $this->__('Show customers who'); ?></td>
339
+ <td>
340
+ <select name="mailupOrderYesNo" class="slctpg2 customerDependent">
341
+ <?php
342
+ if ($mailupOrderYesNo == 'no') {
343
+ echo '<option value="no">'.$this->__("Haven't purchased").'</option>';
344
+ }
345
+ ?>
346
+ <option value="yes"> <?php echo $this->__('Have purchased'); ?> </option>
347
+ <option value="no"> <?php echo $this->__("Haven't purchased"); ?> </option>
348
+ </select>
349
+ </td>
350
+ </tr>
351
+
352
+ <tr>
353
+ <td class="labelpg1"><?php echo $this->__('From')?></td>
354
+ <td class="input-ele">
355
+ <input type="text" class="inptptx1 customerDependent" name="mailupOrderStartDate" id="mailupOrderStartDate" size="20" value="<?php echo $mailupOrderStartDate; ?>" /><img id="mailupOrderStartDateTrig" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
356
+ <script type="text/javascript">
357
+ Calendar.setup({
358
+ inputField: "mailupOrderStartDate",
359
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
360
+ showsTime: false,
361
+ button: "mailupOrderStartDateTrig",
362
+ align: "Bl",
363
+ singleClick : true
364
+ });
365
+ </script>
366
+ </td>
367
+ </tr>
368
+ <tr>
369
+ <td class="labelpg1"><?php echo $this->__('To')?></td>
370
+ <td class="input-ele">
371
+ <input type="text" class="inptptx1 customerDependent" name="mailupOrderEndDate" id="mailupOrderEndDate" size="20" value="<?php echo $mailupOrderEndDate; ?>" /><img id="mailupOrderEndDateTrig" class="v-middle" alt="" src="/skin/adminhtml/default/default/images/grid-cal.gif"> <span class="tip">(<?php echo Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>)</span>
372
+ <script type="text/javascript">
373
+ Calendar.setup({
374
+ inputField: "mailupOrderEndDate",
375
+ ifFormat: "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
376
+ showsTime: false,
377
+ button: "mailupOrderEndDateTrig",
378
+ align: "Bl",
379
+ singleClick : true
380
+ });
381
+ </script>
382
+ </td>
383
+ </tr>
384
+ </table>
385
+ </fieldset>
386
+ </form>
387
+
388
+ <h4><span id="spantitle3"><a name="saveFilter"><?php echo $this->__('Save current filters as hint')?></a></span></h4>
389
+ <fieldset id="my-fieldset3">
390
+ <table>
391
+ <tr>
392
+ <td>
393
+ <input name="filter_name_text" id="filter_name_text" type="text" value="" maxlength="100" size="50" />
394
+ <input class="form-button" type="submit" onclick="saveFilterHint();return false;" value="<?php echo $this->__('Save hint')?>" />
395
+ </td>
396
+ </tr>
397
+ </table>
398
+ </fieldset>
399
+
400
+ <h4><span id="spantitle1"><a name="ottsugg"><?php echo $this->__('Filter hints')?></a></span></h4>
401
+ <fieldset id="my-fieldset2">
402
+ <table cellspacing="0" class="form-list">
403
+ <tr>
404
+ <td><?php echo $this->__('Set and customize one of the following filters:')?></td>
405
+ </tr>
406
+ <tr>
407
+ <td>
408
+ <form action="*/*/" id="filtro1" name="filtro1" method="post">
409
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
410
+ <input name="mailupCustomers" type="hidden" value="2" />
411
+ <input name="mailupCustomerGroupId" type="hidden" value="2" />
412
+ <p class="parscefil"><?php echo $this->__("All wholesale customers who haven't purchased yet")?> &raquo;</p>
413
+ <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
414
+ </form>
415
+ </td>
416
+ </tr>
417
+ <tr>
418
+ <td>
419
+ <form action="*/*/" id="filtro2" name="filtro2" method="post">
420
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
421
+ <input name="mailupCustomers" type="hidden" value="1" />
422
+ <input name="mailupTotalAmountCond" type="hidden" value="gt" />
423
+ <input name="mailupTotalAmountValue" type="hidden" value="50" />
424
+ <p class="parscefil"><?php echo $this->__('More than 50 Euros orders')?> &raquo;</p>
425
+ <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
426
+ </form>
427
+ </td>
428
+ </tr>
429
+ <tr>
430
+ <td>
431
+ <form action="*/*/" id="filtro3" name="filtro3" method="post">
432
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
433
+ <input name="mailupCustomers" type="hidden" value="0" />
434
+ <input name="mailupOrderYesNo" type="hidden" value="no" />
435
+ <input name="mailupOrderStartDate" type="hidden" value="01/01/<?php echo date('Y'); ?>" />
436
+ <p class="parscefil"><?php echo $this->__('Members with no purchase in')?> <?php echo date('Y'); ?> &raquo;</p>
437
+ <input class="form-button" type="submit" value="<?php echo $this->__('Set hint')?>" />
438
+ </form>
439
+
440
+ </td>
441
+ </tr>
442
+
443
+ <?php if(!empty($filterHints)): ?>
444
+ <tr>
445
+ <td>&nbsp;</td>
446
+ </tr>
447
+ <tr>
448
+ <td><?php echo $this->__('Or choose one of those you saved:')?></td>
449
+ </tr>
450
+ <?php endif ?>
451
+
452
+ <?php
453
+ foreach ($filterHints as $fh) {
454
+ $filter_name = $fh['filter_name'];
455
+ echo '<tr><td>';
456
+ echo '<form action="*/*/" id="'.$filter_name.'" name="'.$filter_name.'" method="post">';
457
+ echo '<input name="form_key" type="hidden" value="'. Mage::getSingleton('core/session')->getFormKey() .'" />';
458
+ $hints = explode('|', $fh['hints']);
459
+ foreach ($hints as $h) {
460
+ $array = explode('=', $h);
461
+ echo '<input name="'.$array[0].'" type="hidden" value="'.$array[1].'" />';
462
+ }
463
+ echo '<p class="parscefil">'.$filter_name.' &raquo;</p>';
464
+ echo '<input class="form-button" type="submit" value="'.$this->__('Set hint').'" />';
465
+ echo '</form>';
466
+ echo '&nbsp;';
467
+ echo '<form name="deleteForm_'.$filter_name.'" action="'.$this->getUrl('*/*/deleteFilterHint').'" method="post">';
468
+ echo '<input name="form_key" type="hidden" value="'. Mage::getSingleton('core/session')->getFormKey() .'" />';
469
+ echo '<input name="filter_name" type="hidden" value="'. $filter_name .'" />';
470
+ echo '<input class="form-button" type="submit" name="delete" onclick="if(confirm(\''.$this->__('Do you really want to delete this filter hint?').'\')==true){this.submit();}return false;" value="'.$this->__('Delete hint').'" />';
471
+ echo '</form>';
472
+ echo '</td></tr>';
473
+ } ?>
474
+
475
+ </table>
476
+ </fieldset>
477
+
478
+ <!--<a href="<?php echo $this->getUrl('*/*/testCron')?>">TEST CRON</a>
479
+ <a href="<?php echo $this->getUrl('*/*/testFields')?>">TEST GETFIELDS</a>-->
480
+ </div>
481
+ <script type="text/javascript">
482
+ var editForm = new varienForm('edit_form');
483
+
484
+ document.getElementsByClassName = function(className) {
485
+ var retnode = [];
486
+ var myclass = new RegExp('\\b'+className+'\\b');
487
+ var elements = this.getElementsByTagName('*');
488
+ var elementsLength = elements.length;
489
+ var element = null;
490
+ for (var i = 0; i < elementsLength; i++) {
491
+ element = elements[i];
492
+ if (myclass.test(element.className)) {
493
+ retnode.push(element);
494
+ }
495
+ }
496
+ return retnode;
497
+ };
498
+
499
+ function customerDependentFilters(isDisabled) {
500
+ document.getElementById('customerDependentContainer').style.display = (isDisabled) ? 'none' : 'block';
501
+
502
+ var elements = document.getElementsByClassName('customerDependent');
503
+
504
+ var elementsLength = elements.length;
505
+ for (var i=0; i < elementsLength; i++) {
506
+ elements[i].disabled = isDisabled;
507
+ }
508
+ }
509
+
510
+ function saveFilterHint() {
511
+ if (document.getElementById('filter_name_text').value=='') {
512
+ alert('<?php echo $this->__('Please, give your new hint a name.')?>');
513
+ } else {
514
+ document.getElementById('filter_name').value = document.getElementById('filter_name_text').value;
515
+ document.getElementById('edit_form').action = '<?php echo $this->getUrl('*/*/saveFilterHint')?>';
516
+ document.getElementById('edit_form').submit();
517
+ }
518
+ return false;
519
+ }
520
+
521
+ window.onload = function() {
522
+ var isDisabled = document.getElementById('mailupCustomersWhoHaventBought').checked;
523
+ customerDependentFilters(isDisabled);
524
+ }
525
+ </script>
526
+ <?php } ?>
app/design/adminhtml/default/default/template/sevenlike/mailup/viewdatatransferlog.phtml CHANGED
@@ -1,72 +1,72 @@
1
- <form name="viewdatatransferlog_form" action="<?php echo $this->getUrl('*/*/search') ?>" method="post">
2
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
3
- <div class="content-header">
4
- <table cellspacing="0" class="grid-header">
5
- <tr>
6
- <td style="width:50%">
7
- <h3><?php echo $this->__("View data transfer log") ?></h3>
8
- </td>
9
- <td class="form-buttons">
10
- <button onclick="searchForm.submit()"><?php echo $this->__("Search") ?></button>
11
- </td>
12
- </tr>
13
- </table>
14
- </div>
15
- <div class="grid">
16
- <div class="hor-scroll">
17
- <table class="data" cellspacing="0">
18
- <thead>
19
- <tr class="headings">
20
- <th><span class="nobr"><?php echo $this->__("Date/time") ?></span></th>
21
- <th><span class="nobr"><?php echo $this->__("Type") ?></span></th>
22
- <th><span class="nobr"><?php echo $this->__("Result") ?></span></th>
23
- <th class="last"><span class="nobr"><?php echo $this->__("N. updated records") ?></span></th>
24
- </tr>
25
- <tr class="filter">
26
- <th><div class="range"><div class="range-line date">
27
- <span class="label"><?php echo $this->__("From") ?>:</span>
28
- <input type="text" class="input-text no-changes" value="" id="sales_order_grid_filter_created_at1354009617.6284_from" name="date_from">
29
- <img title="" id="sales_order_grid_filter_created_at1354009617.6284_from_trig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif">
30
- </div><div class="range-line date">
31
- <span class="label"><?php echo $this->__("To") ?>:</span>
32
- <input type="text" class="input-text no-changes" value="" id="sales_order_grid_filter_created_at1354009617.6284_to" name="date_to">
33
- <img title="" id="sales_order_grid_filter_created_at1354009617.6284_to_trig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif">
34
- </div></div><input type="hidden" value="it_IT" name="created_at[locale]"><script type="text/javascript">
35
- Calendar.setup({
36
- inputField : "sales_order_grid_filter_created_at1354009617.6284_from",
37
- ifFormat : "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
38
- button : "sales_order_grid_filter_created_at1354009617.6284_from_trig",
39
- showsTime: false,
40
- align : "Bl",
41
- singleClick : true
42
- });
43
- Calendar.setup({
44
- inputField : "sales_order_grid_filter_created_at1354009617.6284_to",
45
- ifFormat : "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
46
- button : "sales_order_grid_filter_created_at1354009617.6284_to_trig",
47
- showsTime: false,
48
- align : "Bl",
49
- singleClick : true
50
- });
51
- </script></th>
52
- <th><select name="type">
53
- <option selected="selected" value=""></option>
54
- <option value="automatic"><?php echo $this->__("Automatic") ?></option>
55
- <option value="manual"><?php echo $this->__("Manual") ?></option>
56
- </select></th>
57
- <th><select name="result">
58
- <option selected="selected" value=""></option>
59
- <option value="completed"><?php echo $this->__("Completed") ?></option>
60
- <option value="partial"><?php echo $this->__("Partial") ?></option>
61
- <option value="failed"><?php echo $this->__("Failed") ?></option>
62
- </select></th>
63
- <th class="last">&nbsp;</th>
64
- </tr>
65
- </thead>
66
- </table>
67
- </div>
68
- </div>
69
- </form>
70
- <script type="text/javascript">
71
- var searchForm = new varienForm('viewdatatransferlog_form');
72
  </script>
1
+ <form name="viewdatatransferlog_form" action="<?php echo $this->getUrl('*/*/search') ?>" method="post">
2
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
3
+ <div class="content-header">
4
+ <table cellspacing="0" class="grid-header">
5
+ <tr>
6
+ <td style="width:50%">
7
+ <h3><?php echo $this->__("View data transfer log") ?></h3>
8
+ </td>
9
+ <td class="form-buttons">
10
+ <button onclick="searchForm.submit()"><?php echo $this->__("Search") ?></button>
11
+ </td>
12
+ </tr>
13
+ </table>
14
+ </div>
15
+ <div class="grid">
16
+ <div class="hor-scroll">
17
+ <table class="data" cellspacing="0">
18
+ <thead>
19
+ <tr class="headings">
20
+ <th><span class="nobr"><?php echo $this->__("Date/time") ?></span></th>
21
+ <th><span class="nobr"><?php echo $this->__("Type") ?></span></th>
22
+ <th><span class="nobr"><?php echo $this->__("Result") ?></span></th>
23
+ <th class="last"><span class="nobr"><?php echo $this->__("N. updated records") ?></span></th>
24
+ </tr>
25
+ <tr class="filter">
26
+ <th><div class="range"><div class="range-line date">
27
+ <span class="label"><?php echo $this->__("From") ?>:</span>
28
+ <input type="text" class="input-text no-changes" value="" id="sales_order_grid_filter_created_at1354009617.6284_from" name="date_from">
29
+ <img title="" id="sales_order_grid_filter_created_at1354009617.6284_from_trig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif">
30
+ </div><div class="range-line date">
31
+ <span class="label"><?php echo $this->__("To") ?>:</span>
32
+ <input type="text" class="input-text no-changes" value="" id="sales_order_grid_filter_created_at1354009617.6284_to" name="date_to">
33
+ <img title="" id="sales_order_grid_filter_created_at1354009617.6284_to_trig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>/adminhtml/default/default/images/grid-cal.gif">
34
+ </div></div><input type="hidden" value="it_IT" name="created_at[locale]"><script type="text/javascript">
35
+ Calendar.setup({
36
+ inputField : "sales_order_grid_filter_created_at1354009617.6284_from",
37
+ ifFormat : "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
38
+ button : "sales_order_grid_filter_created_at1354009617.6284_from_trig",
39
+ showsTime: false,
40
+ align : "Bl",
41
+ singleClick : true
42
+ });
43
+ Calendar.setup({
44
+ inputField : "sales_order_grid_filter_created_at1354009617.6284_to",
45
+ ifFormat : "<?php echo Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ?>",
46
+ button : "sales_order_grid_filter_created_at1354009617.6284_to_trig",
47
+ showsTime: false,
48
+ align : "Bl",
49
+ singleClick : true
50
+ });
51
+ </script></th>
52
+ <th><select name="type">
53
+ <option selected="selected" value=""></option>
54
+ <option value="automatic"><?php echo $this->__("Automatic") ?></option>
55
+ <option value="manual"><?php echo $this->__("Manual") ?></option>
56
+ </select></th>
57
+ <th><select name="result">
58
+ <option selected="selected" value=""></option>
59
+ <option value="completed"><?php echo $this->__("Completed") ?></option>
60
+ <option value="partial"><?php echo $this->__("Partial") ?></option>
61
+ <option value="failed"><?php echo $this->__("Failed") ?></option>
62
+ </select></th>
63
+ <th class="last">&nbsp;</th>
64
+ </tr>
65
+ </thead>
66
+ </table>
67
+ </div>
68
+ </div>
69
+ </form>
70
+ <script type="text/javascript">
71
+ var searchForm = new varienForm('viewdatatransferlog_form');
72
  </script>
app/design/frontend/base/default/layout/mailup.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <checkout_onepage_review>
4
+ <reference name="checkout.onepage.review.info.items.after">
5
+ <block type="mailup/checkout_subscribe" name="mailup.subscribe" template="mailup/subscribe.phtml" />
6
+ </reference>
7
+ </checkout_onepage_review>
8
+ </layout>
app/design/frontend/base/default/template/mailup/subscribe.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $storeId = Mage::app()->getStore()->getStoreId();
3
+ $display_checkbox = false;
4
+ if (Mage::getStoreConfig("mailup_newsletter/mailup/enable_subscribe_in_checkout", $storeId) == 1) {
5
+ if (Mage::helper('customer')->isLoggedIn()) {
6
+ $email = Mage::helper('customer')->getCustomer()->getEmail();
7
+ $newsletter_subscriber_model = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
8
+ if ($newsletter_subscriber_model->getSubscriberStatus() != 1) {
9
+ $display_checkbox = true;
10
+ }
11
+ } else {
12
+ $display_checkbox = true;
13
+ }
14
+ }
15
+
16
+ ?>
17
+
18
+ <?php if ($display_checkbox): ?>
19
+ <div class="buttons-set">
20
+ <label>
21
+ <input type="checkbox" onchange="mailupModifyPost()" name="mailup_subscribe" id="mailup_subscribe" value="1" title="<?php echo $this->htmlEscape($this->__('Sign Up for Newsletter')) ?>" checked="checked" />
22
+ <?php echo $this->htmlEscape($this->__('Sign Up for Newsletter')) ?>
23
+ </label>
24
+ </div>
25
+ <script type="text/javascript">
26
+ mailupModifyPost = function () {
27
+ if ($('mailup_subscribe2')) $('mailup_subscribe2').remove();
28
+ if ($('mailup_subscribe').checked) {
29
+ var newinput = new Element("input", {name: "mailup_subscribe2", id: "mailup_subscribe2", value: "1", type: "hidden"});
30
+ try {
31
+ Element.insert(Form.findFirstElement(payment.form), newinput);
32
+ } catch (e) {
33
+ $("co-payment-form").insert(newinput);
34
+ }
35
+ }
36
+ }
37
+ mailupModifyPost();
38
+ </script>
39
+ <?php endif; ?>
app/design/frontend/enterprise/default/layout/mailup.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <checkout_onepage_review>
4
+ <reference name="checkout.onepage.review.info.items.after">
5
+ <block type="mailup/checkout_subscribe" name="mailup.subscribe" template="mailup/subscribe.phtml" />
6
+ </reference>
7
+ </checkout_onepage_review>
8
+ </layout>
app/design/frontend/enterprise/default/template/mailup/subscribe.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $storeId = Mage::app()->getStore()->getStoreId();
3
+ $display_checkbox = false;
4
+ if (Mage::getStoreConfig("mailup_newsletter/mailup/enable_subscribe_in_checkout", $storeId) == 1) {
5
+ if (Mage::helper('customer')->isLoggedIn()) {
6
+ $email = Mage::helper('customer')->getCustomer()->getEmail();
7
+ $newsletter_subscriber_model = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
8
+ if ($newsletter_subscriber_model->getSubscriberStatus() != 1) {
9
+ $display_checkbox = true;
10
+ }
11
+ } else {
12
+ $display_checkbox = true;
13
+ }
14
+ }
15
+
16
+ ?>
17
+
18
+ <?php if ($display_checkbox): ?>
19
+ <div class="buttons-set">
20
+ <label>
21
+ <input type="checkbox" onchange="mailupModifyPost()" name="mailup_subscribe" id="mailup_subscribe" value="1" title="<?php echo $this->htmlEscape($this->__('Sign Up for Newsletter')) ?>" checked="checked" />
22
+ <?php echo $this->htmlEscape($this->__('Sign Up for Newsletter')) ?>
23
+ </label>
24
+ </div>
25
+ <script type="text/javascript">
26
+ mailupModifyPost = function () {
27
+ if ($('mailup_subscribe2')) $('mailup_subscribe2').remove();
28
+ if ($('mailup_subscribe').checked) {
29
+ var newinput = new Element("input", {name: "mailup_subscribe2", id: "mailup_subscribe2", value: "1", type: "hidden"});
30
+ try {
31
+ Element.insert(Form.findFirstElement(payment.form), newinput);
32
+ } catch (e) {
33
+ $("co-payment-form").insert(newinput);
34
+ }
35
+ }
36
+ }
37
+ mailupModifyPost();
38
+ </script>
39
+ <?php endif; ?>
package.xml CHANGED
@@ -1,106 +1,61 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MailUp</name>
4
- <version>2.2.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Filter customers based on profile and sales history, and send them targeted messages. Support automatic messages too.</summary>
10
- <description>&lt;p&gt;MailUp is a multi-channel marketing platform, used by thousands of companies around the world to send targeted email and text messages.&lt;/p&gt;&#xD;
11
- &#xD;
12
- &lt;p&gt;Robust and scalable, MailUp can handles large volumes and has long-term relationships with all the major international ISPs, including automatic Feedback Loop management and support for List-Unsubscribe. Over 10 billion messages were sent with MailUp in 2010.&lt;/p&gt;&#xD;
13
- &#xD;
14
- &lt;p&gt;Using MailUp with your Magento store ensures a high level of deliverability for your emails.&lt;/p&gt;&#xD;
15
- &#xD;
16
- &lt;p&gt;Once you install the MailUp extension, you will be able to run professional email marketing campaigns by easily filtering customers and seemlessly passing the data to MailUp, which will handle the sending and tracking of the messages.&lt;/p&gt;&#xD;
17
- &#xD;
18
- &lt;p&gt;The MailUp extension requires a MailUp account. If you are not already a customer, setup a free trial to check it out!&lt;/p&gt;&#xD;
19
- &#xD;
20
- &#xD;
21
- &#xD;
22
- &lt;p&gt;For more advanced marketing campaigns, leverage MailUp&#x2019;s optional Marketing+ feature. It allows you to create &#x201C;event-based&#x201D; messages that are sent automatically when a certain condition occurs (e.g. automatically send a discount to your customers on their birthday). Features include:&lt;/p&gt;&#xD;
23
- &#xD;
24
- &lt;ul&gt;&#xD;
25
- &#xD;
26
- &lt;li&gt;create unlimited &#x201C;event-based&#x201D; messages&lt;/li&gt;&#xD;
27
- &#xD;
28
- &lt;li&gt;easily turn them on/off&lt;/li&gt;&#xD;
29
- &#xD;
30
- &lt;li&gt;specify how often the system will check for the condition to occur (e.g. daily, monthly, annually, one-time)&lt;/li&gt;&#xD;
31
- &#xD;
32
- &lt;li&gt;combine multiple filters to define the condition that will trigger the message (e.g. send a second &#x201C;Welcome&#x201D; message N days after the customer subscribed)&lt;/li&gt;&#xD;
33
- &#xD;
34
- &lt;li&gt;send a message to a specific group or any subscriber&lt;/li&gt;&#xD;
35
- &#xD;
36
- &lt;li&gt;create conditions that are based on customer behavior (e.g. whether a previous message was opened or not)&lt;/li&gt;&#xD;
37
- &#xD;
38
- &lt;li&gt;use ecommerce data to as a condition to trigger messages (e.g. total amount purchased; days since last purchase; etc.)&lt;/li&gt;&#xD;
39
- &#xD;
40
- &lt;li&gt;use the same feature to send text messages (SMS) too!&lt;/li&gt;&#xD;
41
- &#xD;
42
- &lt;/ul&gt;&#xD;
43
- &#xD;
44
- &lt;p&gt;For example, store the date of the last order in a MailUp custom field, then send a discount to promote a new purchase 60 days after that last order was placed.&lt;/p&gt;&#xD;
45
- &#xD;
46
- &#xD;
47
- &#xD;
48
- &lt;p&gt;===========================================================&lt;/p&gt;&#xD;
49
- &#xD;
50
- &#xD;
51
- &#xD;
52
- &lt;p&gt;MailUp &#xE8; un servizio nato nel 2002, totalmente "web based" , che consente l'invio di e-mail, newsletter, sms, fax, lettere cartacee e messaggi vocali pre-registrati.&lt;/p&gt;&#xD;
53
- &#xD;
54
- &lt;p&gt;La soluzione &#xE8; studiata appositamente per la gestione professionale e l'invio di elevati quantitativi di messaggi, con gestione della banda, invii di test e gestione delle code di uscita.&lt;/p&gt;&#xD;
55
- &#xD;
56
- &lt;p&gt;Le e-mail vengono inviate dai server di MailUp, questo garantisce elevati tassi di deliverability, evitando che le mail vengano bloccate dai filtri antispam.&lt;/p&gt;&#xD;
57
- &#xD;
58
- &lt;p&gt;Installando questo Plugin per Magento potrete importare nella piattaforma MailUP i nominativi registrati nel vostro eCommerce.&lt;/p&gt;&#xD;
59
- &#xD;
60
- &lt;p&gt;Prova gratuitamente MailUp per 30 giorni&lt;/p&gt;&#xD;
61
- &#xD;
62
- &#xD;
63
- &#xD;
64
- &lt;p&gt;Con la funzione INVII AUTOMATICI contenuta nel pacchetto opzionale Marketing+ &#xE8; possibile inviare in automatico email e sms, a seconda del verificarsi di condizioni o eventi. Si potranno inviare alert, auguri di compleanno, reminder, solleciti tramite email e/o sms in base a regole predefinite, per esempio in prossimit&#xE0; della scadenza di un contratto o un anniversario.&lt;br /&gt;&lt;br /&gt;Tramite l'opzione INVII AUTOMATICI, &#xE8; possibile&lt;/p&gt;&#xD;
65
- &#xD;
66
- &lt;ul&gt;&#xD;
67
- &#xD;
68
- &lt;li&gt;creare infiniti messaggi email o sms;&lt;/li&gt;&#xD;
69
- &#xD;
70
- &lt;li&gt;stabilire il periodo in cui devono essere abilitati o meno;&lt;/li&gt;&#xD;
71
- &#xD;
72
- &lt;li&gt;la frequenza di invio (es. giornaliera, mensile o annuale);&lt;/li&gt;&#xD;
73
- &#xD;
74
- &lt;li&gt;stabilire le condizioni tramite l'utilizzo dei filtri anagrafica (es. compleanno, campi vuoti) o attivit&#xE0; (es. iscrizione oppure se un utente non ha aperto il messaggio si pu&#xF2; programmare un invio automatico di un secondo messaggio)&lt;/li&gt;&#xD;
75
- &#xD;
76
- &lt;li&gt;stabilire se inviare ad un gruppo specifico di utenti o a tutto il mio database&lt;/li&gt;&#xD;
77
- &#xD;
78
- &lt;li&gt;alimentare la banca dati tramite API o web service o procedure batch ftp notturne;&lt;/li&gt;&#xD;
79
- &#xD;
80
- &lt;li&gt;gestire e configurare automatismi tramite una intuitiva interfaccia web.&lt;/li&gt;&#xD;
81
- &#xD;
82
- &lt;/ul&gt;&#xD;
83
- &#xD;
84
- &lt;p&gt;&lt;br /&gt;Ad esempio un sito di ecommerce potrebbe alimentare il DB di MailUp con informazioni sugli acquisti e MailUp potr&#xE0; quindi inviare, ad esempio dopo 7 giorni dall'acquisto, un messaggio di costumer satisfaction oppure l'invito ad acquistare un prodotto correlato.&lt;/p&gt;</description>
85
- <notes>Changelog:&lt;br /&gt;&#xD;
86
- &#xD;
87
- &lt;ul&gt;&#xD;
88
- &#xD;
89
- &lt;li&gt;you can now show the subscription checkbox during checkout&lt;/li&gt;&#xD;
90
- &#xD;
91
- &lt;li&gt;MailUp webhooks are now supported to manage realtime subscribe/unsubscribe&lt;/li&gt;&#xD;
92
- &#xD;
93
- &lt;li&gt;incremental sync was implemented, so that now only modified users are transferred to mailup during scheduled transmissions&lt;/li&gt;&#xD;
94
- &#xD;
95
- &lt;li&gt;logs can now be disabled&lt;/li&gt;&#xD;
96
- &#xD;
97
- &lt;li&gt;small interface tweeks&lt;/li&gt;&#xD;
98
- &#xD;
99
- &lt;/ul&gt;</notes>
100
- <authors><author><name>Sevenlike</name><user>sevenlike</user><email>moduli-magento@sevenlike.com</email></author></authors>
101
- <date>2013-03-26</date>
102
- <time>2013-03-26</time>
103
- <contents><target name="magelocal"><dir name="SevenLike"><dir name="MailUp"><dir name="Block"><dir name="Checkout"><file name="Subscribe.php" hash="ccfe2351962ae4aa4c2962cee2e8e1af"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Helper"><file name="Data.php" hash="678302968f4aa70cdb06aaebb66d97b6"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Source"><dir name="Cron"><file name="Frequency.php" hash="6883a8ed591fb256b13452a1c95571f9"/><file name="Hours.php" hash="a29b9482b58cd4d492535323e957e74e"/></dir></dir></dir></dir><file name="Consoleurlvalidator.php" hash="445cea54aeca48b1e6197d85d0dfe524"/><file name="Cron.php" hash="f79da19fe6ef26bf6f261ad6bfb75ae1"/><file name="Lists.php" hash="c226fd4e9facd46bfc95c8d55adeffd5"/><file name="MailUp.php" hash="eb0517043c0dddcc22f2bd6c9c2bb27c"/><file name="MailUpWsImport.php" hash="1d2cbcf20bfa2b2a0f883f631fb7faec"/><dir name="Mysql14"><dir name="MailUp"><file name="Collection.php" hash="0b655573c6ed02bb67d7ff9241a1fd73"/></dir><file name="MailUp.php" hash="5a261952db1cedf7cdc7888e2ced7e16"/></dir><file name="Observer.php" hash="4b373a553ce4e77cd2282904469d4b80"/><file name="Webserviceusernamevalidator.php" hash="f6cbe6394f685a93206ace6ed33ff2fa"/><file name="Ws.php" hash="c61719e82030d4117ff2badbed12ff43"/><file name="Wssend.php" hash="7e7e53d76085ab1f2085d3f719ae44f5"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigurationController.php" hash="2172562c17ac532894faf5e77ca9c9e0"/><file name="FieldsmappingController.php" hash="99b01856290d58f1b0f2d0f9f2c0389a"/><file name="FilterController.php" hash="fe56870180812ae67d01d3fc14e55da1"/><file name="ViewdatatransferlogController.php" hash="b6fd65804c91b8386a10579dc1d6cf1e"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="WebhookController.php" hash="52369ec7a70c7245e55bf215d1bee187"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="f1345b7c9839ec68f876adba46d64f07"/><file name="system.xml" hash="7e68ebaf83dfe2b3201f775eaf0f66ea"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="sql"><dir name="mailup_setup"><file name="mysql4-install-0.1.0.php" hash="43f2d3f43e10d493e748a6732bb4f5c5"/><file name="mysql4-upgrade-0.1.0-1.0.0.php" hash="43f2d3f43e10d493e748a6732bb4f5c5"/><file name="mysql4-upgrade-0.3.0-1.0.0.php" hash="0a6a28082e3d589cf32516b44bcd9408"/><file name="mysql4-upgrade-1.0.0-1.5.2.php" hash="4ab5fd71fbc9ba8e6cce8e974bfed2fc"/><file name="mysql4-upgrade-2.1.3-2.2.0.php" hash="577c0690622460d5ebb8d5df35bab9db"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="sevenlike"><dir name="mailup"><file name="confirm.phtml" hash="32a6593e1692c5596fffea44723c94b0"/><file name="fieldsmapping.phtml" hash="ea1f418f8cb7fb2a842b091562296417"/><file name="filter.phtml" hash="9efaec8fa3e1a44b36127113274a90dd"/><file name="viewdatatransferlog.phtml" hash="746289040d75fef7b4d61bba560e294c"/></dir></dir></dir><dir name="layout"><file name="mailup.xml" hash="ab6fbb5efccb497cfd9a3721ecc161a9"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SevenLike_MailUp.xml" hash="8377b55193e7524ca9572ed4dc2dca62"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sevenlike"><dir name="mailup"><dir name="images"><file name="titoli.png" hash="95a7996cd77d3413fd048018095aec6e"/></dir><file name="mailup.css" hash="5be195046fd49a2ade184a10786a5a58"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="SevenLike_MailUp.csv" hash="f411a2106aab75fac44c681fd7ba995e"/></dir><dir name="it_IT"><file name="SevenLike_MailUp.csv" hash="c5bf7b0d7c9951153ec355bd9e1be6aa"/></dir></target></contents>
104
  <compatible/>
105
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
106
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MailUp</name>
4
+ <version>2.3.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Filter customers based on profile and sales history, and send them targeted messages. Support automatic messages too.</summary>
10
+ <description>&amp;lt;p&amp;gt;MailUp is a multi-channel marketing platform, used by thousands of companies around the world to send targeted email and text messages.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
11
+ &amp;lt;p&amp;gt;Robust and scalable, MailUp can handles large volumes and has long-term relationships with all the major international ISPs, including automatic Feedback Loop management and support for List-Unsubscribe. Over 10 billion messages were sent with MailUp in 2010.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
12
+ &amp;lt;p&amp;gt;Using MailUp with your Magento store ensures a high level of deliverability for your emails.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
13
+ &amp;lt;p&amp;gt;Once you install the MailUp extension, you will be able to run professional email marketing campaigns by easily filtering customers and seemlessly passing the data to MailUp, which will handle the sending and tracking of the messages.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
14
+ &amp;lt;p&amp;gt;The MailUp extension requires a MailUp account. If you are not already a customer, setup a free trial to check it out!&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
15
+ &amp;#xD;&#xD;
16
+ &amp;lt;p&amp;gt;For more advanced marketing campaigns, leverage MailUp&amp;#x2019;s optional Marketing+ feature. It allows you to create &amp;#x201C;event-based&amp;#x201D; messages that are sent automatically when a certain condition occurs (e.g. automatically send a discount to your customers on their birthday). Features include:&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
17
+ &amp;lt;ul&amp;gt;&amp;#xD;&#xD;
18
+ &amp;lt;li&amp;gt;create unlimited &amp;#x201C;event-based&amp;#x201D; messages&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
19
+ &amp;lt;li&amp;gt;easily turn them on/off&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
20
+ &amp;lt;li&amp;gt;specify how often the system will check for the condition to occur (e.g. daily, monthly, annually, one-time)&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
21
+ &amp;lt;li&amp;gt;combine multiple filters to define the condition that will trigger the message (e.g. send a second &amp;#x201C;Welcome&amp;#x201D; message N days after the customer subscribed)&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
22
+ &amp;lt;li&amp;gt;send a message to a specific group or any subscriber&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
23
+ &amp;lt;li&amp;gt;create conditions that are based on customer behavior (e.g. whether a previous message was opened or not)&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
24
+ &amp;lt;li&amp;gt;use ecommerce data to as a condition to trigger messages (e.g. total amount purchased; days since last purchase; etc.)&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
25
+ &amp;lt;li&amp;gt;use the same feature to send text messages (SMS) too!&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
26
+ &amp;lt;/ul&amp;gt;&amp;#xD;&#xD;
27
+ &amp;lt;p&amp;gt;For example, store the date of the last order in a MailUp custom field, then send a discount to promote a new purchase 60 days after that last order was placed.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
28
+ &amp;#xD;&#xD;
29
+ &amp;lt;p&amp;gt;===========================================================&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
30
+ &amp;#xD;&#xD;
31
+ &amp;lt;p&amp;gt;MailUp &amp;amp;egrave; un servizio nato nel 2002, totalmente "web based" , che consente l'invio di e-mail, newsletter, sms, fax, lettere cartacee e messaggi vocali pre-registrati.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
32
+ &amp;lt;p&amp;gt;La soluzione &amp;amp;egrave; studiata appositamente per la gestione professionale e l'invio di elevati quantitativi di messaggi, con gestione della banda, invii di test e gestione delle code di uscita.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
33
+ &amp;lt;p&amp;gt;Le e-mail vengono inviate dai server di MailUp, questo garantisce elevati tassi di deliverability, evitando che le mail vengano bloccate dai filtri antispam.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
34
+ &amp;lt;p&amp;gt;Installando questo Plugin per Magento potrete importare nella piattaforma MailUP i nominativi registrati nel vostro eCommerce.&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
35
+ &amp;lt;p&amp;gt;Prova gratuitamente MailUp per 30 giorni&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
36
+ &amp;#xD;&#xD;
37
+ &amp;lt;p&amp;gt;Con la funzione INVII AUTOMATICI contenuta nel pacchetto opzionale Marketing+ &amp;amp;egrave; possibile inviare in automatico email e sms, a seconda del verificarsi di condizioni o eventi. Si potranno inviare alert, auguri di compleanno, reminder, solleciti tramite email e/o sms in base a regole predefinite, per esempio in prossimit&amp;amp;agrave; della scadenza di un contratto o un anniversario.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;Tramite l'opzione INVII AUTOMATICI, &amp;amp;egrave; possibile&amp;lt;/p&amp;gt;&amp;#xD;&#xD;
38
+ &amp;lt;ul&amp;gt;&amp;#xD;&#xD;
39
+ &amp;lt;li&amp;gt;creare infiniti messaggi email o sms;&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
40
+ &amp;lt;li&amp;gt;stabilire il periodo in cui devono essere abilitati o meno;&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
41
+ &amp;lt;li&amp;gt;la frequenza di invio (es. giornaliera, mensile o annuale);&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
42
+ &amp;lt;li&amp;gt;stabilire le condizioni tramite l'utilizzo dei filtri anagrafica (es. compleanno, campi vuoti) o attivit&amp;amp;agrave; (es. iscrizione oppure se un utente non ha aperto il messaggio si pu&amp;amp;ograve; programmare un invio automatico di un secondo messaggio)&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
43
+ &amp;lt;li&amp;gt;stabilire se inviare ad un gruppo specifico di utenti o a tutto il mio database&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
44
+ &amp;lt;li&amp;gt;alimentare la banca dati tramite API o web service o procedure batch ftp notturne;&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
45
+ &amp;lt;li&amp;gt;gestire e configurare automatismi tramite una intuitiva interfaccia web.&amp;lt;/li&amp;gt;&amp;#xD;&#xD;
46
+ &amp;lt;/ul&amp;gt;&amp;#xD;&#xD;
47
+ &amp;lt;p&amp;gt;&amp;lt;br /&amp;gt;Ad esempio un sito di ecommerce potrebbe alimentare il DB di MailUp con informazioni sugli acquisti e MailUp potr&amp;amp;agrave; quindi inviare, ad esempio dopo 7 giorni dall'acquisto, un messaggio di costumer satisfaction oppure l'invito ad acquistare un prodotto correlato.&amp;lt;/p&amp;gt;</description>
48
+ <notes>Added support for multi-store installations&#xD;
49
+ &#xD;
50
+ Settings, including field mappings, can now be set at the store view level&#xD;
51
+ &#xD;
52
+ Added date/time stamp of latest data sync&#xD;
53
+ &#xD;
54
+ Updated some areas of the extension to improve performance</notes>
55
+ <authors><author><name>Mailup</name><user>Mailup</user><email>sales@mailup.com</email></author></authors>
56
+ <date>2013-05-13</date>
57
+ <time>23:41:16</time>
58
+ <contents><target name="magelocal"><dir name="SevenLike"><dir name="MailUp"><dir name="Block"><dir name="Checkout"><file name="Subscribe.php" hash="ccfe2351962ae4aa4c2962cee2e8e1af"/></dir><file name="Filters.php" hash="f881a202a8d2e3c34b3f1b4094852b2c"/></dir><dir name="Helper"><file name="Data.php" hash="7e6bd06a0d10e4d8e7cb75baee5228d5"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Source"><dir name="Cron"><file name="Frequency.php" hash="2f874a2d82957748f2f249658c7e96f1"/><file name="Hours.php" hash="99b0428a6e88248bf15007396f48b0fc"/></dir><file name="Fields.php" hash="aea6ab58900926fa94b3da61b0da65c5"/></dir></dir></dir><file name="Config.php" hash="80017331d635ebebfe19fd67af60092a"/><file name="Consoleurlvalidator.php" hash="2cd27b9d21570e39ef6a5a0bbf3f97c5"/><file name="Cron.php" hash="c87a038a773674a20abcd2450e8ae009"/><file name="Lists.php" hash="6e9aaf93b1d64d203f6980ab29d843c1"/><file name="MailUp.php" hash="1b552b40a7bf6f4c915667adbe164140"/><file name="MailUpWsImport.php" hash="52b9b5edbe3b0409fb0ea2b5711e7794"/><dir name="Mysql14"><dir name="MailUp"><file name="Collection.php" hash="256485c1ba69eff42ae109d3218c89ff"/></dir><file name="MailUp.php" hash="d06606483ac4c35e42f9cb449a36c1c5"/></dir><file name="Observer.php" hash="b74abe86c62ff36880bf81c80dea40af"/><file name="Subscriber.php" hash="877fe0e81d86e8b9b0d9c23ccd5378f2"/><file name="Webserviceusernamevalidator.php" hash="9650aed034726d621968f18371d554bc"/><file name="Ws.php" hash="21ef21afcf35867d0ec8ff345babeab6"/><file name="Wssend.php" hash="aeffbd2966158bd1f3571bf84d883723"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigurationController.php" hash="240d526f2c944b93b78d00d85d4b6c47"/><file name="FieldsmappingController.php" hash="66f0598c537f9518433b99cb7aa9acfe"/><file name="FilterController.php" hash="0a2ae9ab0d3af61eddb0c77dc392e45a"/><file name="ViewdatatransferlogController.php" hash="eec948994f2d1491ead736578deabf92"/></dir><file name="IndexController.php" hash="bf072545b2cdf54f9de150da72b3ecfd"/><file name="WebhookController.php" hash="ef72fa5602b3f9fec0eae41eb34638a1"/></dir><dir name="etc"><file name="config.xml" hash="9879e6dee178c150b8dab4c74fdb2ead"/><file name="system.xml" hash="ef08678b58c1970ab6361b45e9a48f28"/></dir><dir name="sql"><dir name="mailup_setup"><file name="mysql4-install-0.1.0.php" hash="8e52462c1d0d28f39c1c3f67c3748d26"/><file name="mysql4-install-2.3.0.php" hash="46254c3531adc6c2d0c3484d03c98ec5"/><file name="mysql4-upgrade-0.1.0-1.0.0.php" hash="8e52462c1d0d28f39c1c3f67c3748d26"/><file name="mysql4-upgrade-0.3.0-1.0.0.php" hash="97e4f8e3ba9e2ab4d5c5757efb3a47de"/><file name="mysql4-upgrade-1.0.0-1.5.2.php" hash="4fda0e9178a6cba85631f4f24faaf71b"/><file name="mysql4-upgrade-2.1.3-2.2.0.php" hash="9d4c89357d75bc526c0a38c8b7108611"/><file name="mysql4-upgrade-2.2.0-2.3.0.php" hash="6b838a9491a8a3d8cd66ec8399667fe3"/><file name="mysql4-upgrade-2.2.1-2.3.0.php" hash="6b838a9491a8a3d8cd66ec8399667fe3"/><file name="mysql4-upgrade-2.3.0-2.3.1.php" hash="26ce891beb0783a8cb821f09746793cf"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mailup.xml" hash="4861bbab4174cf5cfc71aeb0b4eb46a1"/></dir><dir name="template"><dir name="sevenlike"><dir name="mailup"><file name="confirm.phtml" hash="e62248a72dbf31af2bc571039c11601a"/><file name="fieldsmapping.phtml" hash="b0b22c19bc6f9c97b22754dc7a0103ba"/><file name="filter.phtml" hash="50685ed4ab63c238e3db7d47aafdb706"/><file name="filter_.phtml" hash="132650faf3903ccae5e3e5784ee27741"/><file name="viewdatatransferlog.phtml" hash="fcc13d34146e22630d1a170888b2cc73"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mailup.xml" hash="dfb8fa89ec00b1b07264d9e2153e097d"/></dir><dir name="template"><dir name="mailup"><file name="subscribe.phtml" hash="a102e2e0dc4c836bc78eb044bf13e172"/></dir></dir></dir></dir><dir name="enterprise"><dir name="default"><dir name="layout"><file name="mailup.xml" hash="dfb8fa89ec00b1b07264d9e2153e097d"/></dir><dir name="template"><dir name="mailup"><file name="subscribe.phtml" hash="a102e2e0dc4c836bc78eb044bf13e172"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SevenLike_MailUp.xml" hash="8377b55193e7524ca9572ed4dc2dca62"/></dir></target><target name="magelocale"><dir name="en_US"><file name="SevenLike_MailUp.csv" hash="f411a2106aab75fac44c681fd7ba995e"/></dir><dir name="it_IT"><file name="SevenLike_MailUp.csv" hash="c5bf7b0d7c9951153ec355bd9e1be6aa"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sevenlike"><dir name="mailup"><dir name="images"><file name="MailUp_300_200_transparent_small.png" hash="fcaf7d0876af346b01e40f3c1eeaa721"/><file name="titoli.png" hash="95a7996cd77d3413fd048018095aec6e"/></dir><file name="mailup.css" hash="cd3e7f45f619c6172de923d688d21dc3"/></dir></dir></dir></dir></dir></target></contents>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <compatible/>
60
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
61
  </package>
skin/adminhtml/default/default/sevenlike/mailup/images/MailUp_300_200_transparent_small.png ADDED
Binary file
skin/adminhtml/default/default/sevenlike/mailup/mailup.css CHANGED
@@ -1,21 +1 @@
1
- h4 { font-size: 1.05em; margin-bottom: 0.6em; overflow: hidden; }
2
- #spantitle1, #spantitle2, #spantitle3, #spantitle4 { height: 31px; padding: 0 0 0 15px; line-height: 31px; font-size: 18px; display: block; background: #025B63; color: #fff; width: 100%; }
3
- #spantitle1 a, #spantitle3 a { text-decoration: none; font-weight: bold; color: #fff; }
4
- #spansugger { display: block; padding: 7px 0 0 0; }
5
- .parscefil { float: left; width: 310px; }
6
- .spdnpg1 { height: 50px; padding: 0 25px 0 0; }
7
- td.labelpg1 { width: 170px; }
8
- .slctpg1 { width: 350px; padding: 4px; }
9
- .slctpg2 { width: 200px; padding: 4px; }
10
- .lbl1 { padding: 0 4px 0 30px; }
11
- .inptptx1 { padding: 4px; }
12
- .inptptx2 { width: 340px; padding: 4px; }
13
- .txtar1 { padding: 4px; width: 340px; }
14
- .slgrp1 { margin: 0 0 10px 0; }
15
- .slgrp2 { margin: 10px 0 20px 0; }
16
- .istrz1 { font: 12px Verdana, Geneva, sans-serif; font-style: italic; }
17
- .istrz2 { font: 12px Verdana, Geneva, sans-serif; font-style: italic; margin: 0 0 20px 0; }
18
- input, select { margin-bottom: 5px; }
19
- span.tip { font-style: italic; }
20
-
21
- .mailuploading {display:none;padding-left:20px;float:right;background:url(data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==) top left no-repeat;}
22
  background: url(./images/MailUp_300_200_transparent_small.png) 10px 0 no-repeat;
23
  text-indent: -9999px;
24
  overflow: hidden;
1
+ h4 { font-size: 1.05em; margin-bottom: 0.6em; overflow: hidden; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  background: url(./images/MailUp_300_200_transparent_small.png) 10px 0 no-repeat;
3
  text-indent: -9999px;
4
  overflow: hidden;