MailUp - Version 0.1.5

Version Notes

New feature: SOAP error report

Download this release

Release Info

Developer Magento Core Team
Extension MailUp
Version 0.1.5
Comparing to
See all releases


Version 0.1.5

app/code/local/SevenLike/MailUp/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
1
+ <?php
2
+ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract {
3
+
4
+ }
5
+ ?>
app/code/local/SevenLike/MailUp/Model/Lists.php ADDED
@@ -0,0 +1,64 @@
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Model_Lists
4
+ {
5
+
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+
14
+ if (Mage::getStoreConfig('newsletter/mailup/url_console') && Mage::getStoreConfig('newsletter/mailup/user') && Mage::getStoreConfig('newsletter/mailup/password')){
15
+
16
+ $MailUpWsSend = Mage::getModel('mailup/wssend');
17
+ $wsSend = new MailUpWsSend();
18
+ $login = $wsSend->login();
19
+
20
+ if ($login == 0) {
21
+
22
+ //chiamata attivazione web services su MailUp
23
+ $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";
24
+ fopen($urlWSActivation, "r");
25
+
26
+ $MailUpWsImport = Mage::getModel('mailup/ws');
27
+
28
+ $wsImport = new MailUpWsImport();
29
+
30
+ $xmlString = $wsImport->GetNlList();
31
+
32
+ if ($xmlString){
33
+
34
+ $xmlString = html_entity_decode($xmlString);
35
+
36
+ $startLists = strpos($xmlString, '<Lists>');
37
+ $endPos = strpos($xmlString, '</Lists>');
38
+ $endLists = $endPos + strlen('</Lists>') - $startLists;
39
+
40
+ $xmlLists = substr($xmlString, $startLists, $endLists);
41
+ $xml = simplexml_load_string($xmlLists);
42
+
43
+ $magentoList = 0;
44
+
45
+ //genero la select per Magento
46
+ $selectLists = array();
47
+ $selectLists[0] = array('value' => 0, 'label'=>'-----');
48
+ $count = 1;
49
+
50
+ foreach($xml->List as $list) {
51
+ $selectLists[$count] = array('value' => $list['listGUID'], 'label'=> $list['listName']);
52
+ $count++;
53
+ }
54
+
55
+ return $selectLists;
56
+
57
+ }
58
+
59
+ }
60
+
61
+ }
62
+ }
63
+
64
+ }
app/code/local/SevenLike/MailUp/Model/MailUp.php ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ class SevenLike_MailUp_Model_MailUp extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('mailup/mailup');
8
+ }
9
+
10
+ }
11
+ ?>
app/code/local/SevenLike/MailUp/Model/Mysql14/MailUp.php ADDED
@@ -0,0 +1,9 @@
1
+ <?php
2
+ class SevenLike_MailUp_Model_Mysql4_MailUp extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('mailup/mailup', 'mailup_id');
7
+ }
8
+ }
9
+ ?>
app/code/local/SevenLike/MailUp/Model/Mysql14/MailUp/Collection.php ADDED
@@ -0,0 +1,10 @@
1
+ <?php
2
+ class SevenLike_MailUp_Model_Mysql4_MailUp_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ //parent::__construct();
7
+ $this->_init('mailup/mailup');
8
+ }
9
+ }
10
+ ?>
app/code/local/SevenLike/MailUp/Model/Ws.php ADDED
@@ -0,0 +1,517 @@
1
+ <?php
2
+ //ini_set(�soap.wsdl_cache_enabled�, �0�);
3
+
4
+ class MailUpWsImport {
5
+
6
+ protected $ns = "http://ws.mailupnet.it/";
7
+
8
+ //protected $WSDLUrl = "http://g4a0.s03.it/services/WSMailUpImport.asmx?WSDL";
9
+ //protected $headers = array("User" => "a7410", "Password" => "GA6VAN0W");
10
+ protected $rCode;
11
+ private $soapClient;
12
+ private $xmlResponse;
13
+ protected $domResult;
14
+
15
+
16
+ function __construct() {
17
+
18
+ $urlConsole = Mage::getStoreConfig('newsletter/mailup/url_console');
19
+ $WSDLUrl = "http://".$urlConsole."/services/WSMailUpImport.asmx?WSDL";
20
+ $user = Mage::getStoreConfig('newsletter/mailup/user');
21
+ $password = Mage::getStoreConfig('newsletter/mailup/password');
22
+ $headers = array("User" => $user, "Password" => $password);
23
+ $this->header = new SOAPHeader($this->ns, "Authentication", $headers);
24
+ $this->soapClient = new SoapClient($WSDLUrl,
25
+ array("trace" => 1,
26
+ "exceptions" => 0));
27
+
28
+ $this->soapClient->__setSoapHeaders($this->header);
29
+
30
+
31
+
32
+ }
33
+
34
+ function __destruct() {
35
+ unset($this->soapClient);
36
+ }
37
+
38
+ public function getFunctions() {
39
+ print_r($this->soapClient->__getFunctions());
40
+ }
41
+
42
+ public function creaGruppo($newGroup) {
43
+ try {
44
+
45
+ $this->soapClient->CreateGroup($newGroup);
46
+ $this-> printLastRequest();
47
+ $this->printLastResponse();
48
+ return $this->readReturnCode("CreateGroup","ReturnCode");
49
+
50
+
51
+ } catch (SoapFault $soapFault) {
52
+ var_dump($soapFault);
53
+ }
54
+ }
55
+
56
+ public function GetNlList() {
57
+ try {
58
+ $this->soapClient->GetNlLists();
59
+ $this->printLastRequest();
60
+ $this->printLastResponse();
61
+ return $this->soapClient->__getLastResponse();
62
+
63
+ } catch (SoapFault $soapFault) {
64
+ var_dump($soapFault);
65
+ }
66
+ }
67
+
68
+ public function newImportProcess($importProcessData) {
69
+ try {
70
+ $this->soapClient->NewImportProcess($importProcessData);
71
+ return $this->readReturnCode("NewImportProcess","ReturnCode");
72
+ } catch (SoapFault $soapFault) {
73
+ var_dump($soapFault);
74
+ }
75
+ }
76
+
77
+ public function startProcess($processData) {
78
+ try {
79
+ $this->soapClient->StartProcess($processData);
80
+ //echo "<br />ReturnCode: ". $this->readReturnCode("StartProcess","ReturnCode")."<br />";
81
+
82
+ } catch (SoapFault $soapFault) {
83
+ var_dump($soapFault);
84
+ }
85
+ }
86
+
87
+ public function getProcessDetail($processData) {
88
+ try {
89
+ $this->soapClient->GetProcessDetails($processData);
90
+ //echo "<br />ReturnCode: ". $this->readReturnCode("GetProcessDetails","ReturnCode")."<br />";
91
+ //echo "<br />IsRunning: ". $this->readReturnCode("GetProcessDetails","IsRunning")."<br />";
92
+ //echo "<br />StartDate: ". $this->readReturnCode("GetProcessDetails","StartDate")."<br />";
93
+
94
+ } catch (SoapFault $soapFault) {
95
+ var_dump($soapFault);
96
+ }
97
+ }
98
+
99
+ public function startImportProcesses($processData) {
100
+ try {
101
+ $this->soapClient->StartImportProcesses($processData);
102
+ $this-> printLastRequest();
103
+ $this->printLastResponse();
104
+ //echo "<br />ReturnCode: ". $this->readReturnCode("StartImportProcesses","ReturnCode")."<br />";
105
+
106
+ } catch (SoapFault $soapFault) {
107
+ var_dump($soapFault);
108
+ }
109
+ }
110
+
111
+ private function readReturnCode($func, $param) {
112
+ static $func_in = ""; //static variable to test xmlResponse update
113
+ if ($func_in != $func) {//(!isset($this->xmlResponse))
114
+ $func_in = $func;
115
+ //prendi l'XML di ritorno se non l'ho gi� preso
116
+ $this->xmlResponse = $this->soapClient->__getLastResponse();
117
+
118
+ $dom = new DomDocument();
119
+ $dom->loadXML($this->xmlResponse) or die("File XML non valido!");
120
+ $xmlResult = $dom->getElementsByTagName($func."Result");
121
+
122
+ $this->domResult = new DomDocument();
123
+ $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die("File XML1 non valido!");;
124
+ }
125
+ $rCode = $this->domResult->getElementsByTagName($param);
126
+ return $rCode->item(0)->nodeValue;
127
+ }
128
+
129
+ private function printLastRequest() {
130
+ //echo "<br>Request :<br>". htmlentities($this->soapClient->__getLastRequest()). "<br>";
131
+ }
132
+
133
+ private function printLastResponse() {
134
+ //echo "<br />XMLResponse: " . $this->soapClient->__getLastResponse() . "<br />";
135
+ }
136
+
137
+ public function getCustomersFiltered($request)
138
+ {
139
+ if (!$request->getRequest()->getParam('mailupCustomerFilteredMod')) {
140
+ //ottengo la collection con tutti i clienti
141
+ $customerCollection = Mage::getModel('customer/customer')
142
+ ->getCollection()
143
+ ->addAttributeToSelect('entity_id')
144
+ ->addAttributeToSelect('group_id')
145
+ ->addAttributeToSelect('created_at');
146
+
147
+ //inizializzo l'array dei clienti filtrati con tutti i clienti
148
+ $customersFiltered = array();
149
+ foreach ($customerCollection as $customer) {
150
+ $customersFiltered[] = $customer->toArray();
151
+ }
152
+
153
+ //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
154
+ $count = 0;
155
+ $result = array();
156
+ $tempPurchased = array();
157
+ $tempNoPurchased = array();
158
+
159
+ if ($request->getRequest()->getParam('mailupCustomers') > 0 ) {
160
+ foreach ($customersFiltered as $customer) {
161
+ $result[] = $customer;
162
+
163
+ //filtro gli ordini in base al customer id
164
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
165
+
166
+ $ordered = 0;
167
+
168
+ foreach($orders->getData() as $order){
169
+ $ordered = 1;
170
+ }
171
+ //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
172
+ if ($ordered == 1)
173
+ $tempPurchased[] = $result[$count];
174
+ else
175
+ $tempNoPurchased[] = $result[$count];
176
+
177
+ $count++;
178
+ }
179
+
180
+ if ($request->getRequest()->getParam('mailupCustomers') == 1)
181
+ $customersFiltered = $tempPurchased;
182
+ elseif ($request->getRequest()->getParam('mailupCustomers') == 2)
183
+ $customersFiltered = $tempNoPurchased;
184
+
185
+ }
186
+ //FINE FILTRO 1 ACQUISTATO: testato OK
187
+
188
+
189
+ //FILTRO 2 PRODOTTO ACQUISTATO: in base al fatto se ha acquistato un determinato prodotto
190
+ $count = 0;
191
+ $result = array();
192
+ $tempProduct = array();
193
+
194
+ if ($request->getRequest()->getParam('mailupProductId') > 0 ) {
195
+ foreach ($customersFiltered as $customer) {
196
+ $result[] = $customer;
197
+
198
+ //filtro gli ordini in base al customer id
199
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
200
+ $purchasedProduct = 0;
201
+
202
+ foreach($orders->getData() as $order){
203
+ $orderIncrementId = $order['increment_id'];
204
+
205
+ //carico i dati di ogni ordine
206
+ $orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
207
+ $items = $orderData->getAllItems();
208
+ $ids=array();
209
+ foreach ($items as $itemId => $item){
210
+ $ids[]=$item->getProductId();
211
+ }
212
+
213
+ if (in_array($request->getRequest()->getParam('mailupProductId'), $ids)) {
214
+ $purchasedProduct = 1;
215
+ }
216
+
217
+ }
218
+ //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
219
+ if ($purchasedProduct == 1)
220
+ $tempProduct[] = $result[$count];
221
+
222
+ $count++;
223
+ }
224
+
225
+ $customersFiltered = $tempProduct;
226
+
227
+
228
+ }
229
+ //FINE FILTRO 2 PRODOTTO ACQUISTATO: testato OK
230
+
231
+
232
+ //FILTRO 3 ACQUISTATO IN CATEGORIA: in base al fatto se ha acquistato almeno un prodotto in una determinata categoria
233
+ $count = 0;
234
+ $result = array();
235
+ $tempCategory = array();
236
+
237
+ if ($request->getRequest()->getParam('mailupCategoryId') > 0 ) {
238
+ foreach ($customersFiltered as $customer) {
239
+ $result[] = $customer;
240
+
241
+ //filtro gli ordini in base al customer id
242
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
243
+ $purchasedCategory = 0;
244
+
245
+ foreach($orders->getData() as $order){
246
+ $orderIncrementId = $order['increment_id'];
247
+
248
+ //carico i dati di ogni ordine
249
+ $orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
250
+ $items = $orderData->getAllItems();
251
+ $ids=array();
252
+ foreach ($items as $product){
253
+ $cat_ids = Mage::getResourceSingleton('catalog/product')->getCategoryIds($product);
254
+ }
255
+
256
+ if (in_array($request->getRequest()->getParam('mailupCategoryId'), $cat_ids)) {
257
+ $purchasedCategory = 1;
258
+ }
259
+
260
+ }
261
+ //aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
262
+ if ($purchasedCategory == 1)
263
+ $tempCategory[] = $result[$count];
264
+
265
+ $count++;
266
+ }
267
+
268
+ $customersFiltered = $tempCategory;
269
+
270
+
271
+ }
272
+ //FINE FILTRO 3 ACQUISTATO IN CATEGORIA: testato ok
273
+
274
+
275
+ //FILTRO 4 GRUPPO DI CLIENTI
276
+ $count = 0;
277
+ $result = array();
278
+ $tempGroup = array();
279
+
280
+ if ($request->getRequest()->getParam('mailupCustomerGroupId') > 0 ) {
281
+
282
+ foreach ($customersFiltered as $customer) {
283
+
284
+ if ($customer['group_id'] == $request->getRequest()->getParam('mailupCustomerGroupId'))
285
+ $tempGroup[] = $customer;
286
+ }
287
+
288
+ $customersFiltered = $tempGroup;
289
+ }
290
+ //FINE FILTRO 4 GRUPPO DI CLIENTI: testato ok
291
+
292
+
293
+ //FILTRO 5 PAESE DI PROVENIENZA
294
+ $count = 0;
295
+ $result = array();
296
+ $tempCountry = array();
297
+
298
+ if ($request->getRequest()->getParam('mailupCountry') != "0" ) {
299
+
300
+ foreach ($customersFiltered as $customer) {
301
+
302
+ //ottengo la nazione del primary billing address
303
+ $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
304
+ $customerAddress = $customerItem->getPrimaryBillingAddress();
305
+ $countryId = $customerAddress['country_id'];
306
+
307
+
308
+ if ($countryId == $request->getRequest()->getParam('mailupCountry'))
309
+ $tempCountry[] = $customer;
310
+ }
311
+
312
+ $customersFiltered = $tempCountry;
313
+ }
314
+ //FINE FILTRO 5 PAESE DI PROVENIENZA: testato ok
315
+
316
+
317
+ //FILTRO 6 CAP DI PROVENIENZA
318
+ $count = 0;
319
+ $result = array();
320
+ $tempPostCode = array();
321
+
322
+ if ($request->getRequest()->getParam('mailupPostCode')) {
323
+
324
+ foreach ($customersFiltered as $customer) {
325
+
326
+ //ottengo la nazione del primary billing address
327
+ $customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
328
+ $customerAddress = $customerItem->getPrimaryBillingAddress();
329
+ $postCode = $customerAddress['postcode'];
330
+
331
+ if ($postCode == $request->getRequest()->getParam('mailupPostCode'))
332
+ $tempPostCode[] = $customer;
333
+ }
334
+
335
+ $customersFiltered = $tempPostCode;
336
+ }
337
+ //FINE FILTRO 6 CAP DI PROVENIENZA: testato ok
338
+
339
+
340
+ //FILTRO 7 DATA CREAZIONE CLIENTE
341
+ $count = 0;
342
+ $result = array();
343
+ $tempDate = array();
344
+
345
+ if ($request->getRequest()->getParam('mailupCustomerStartDate') || $request->getRequest()->getParam('mailupCustomerEndDate') ) {
346
+
347
+ foreach ($customersFiltered as $customer) {
348
+
349
+ //trasformo tutte le date in aaaammgg
350
+ $createdAt = substr(str_replace("-","", $customer['created_at']), 0, 8);
351
+ $filterStart = '';
352
+ $filterEnd = '';
353
+
354
+ if($request->getRequest()->getParam('mailupCustomerStartDate'))
355
+ $filterStart = substr($request->getRequest()->getParam('mailupCustomerStartDate'), 6, 4).substr($request->getRequest()->getParam('mailupCustomerStartDate'), 3, 2).substr($request->getRequest()->getParam('mailupCustomerStartDate'), 0, 2);
356
+
357
+ if($request->getRequest()->getParam('mailupCustomerEndDate'))
358
+ $filterEnd = substr($request->getRequest()->getParam('mailupCustomerEndDate'), 6, 4).substr($request->getRequest()->getParam('mailupCustomerEndDate'), 3, 2).substr($request->getRequest()->getParam('mailupCustomerEndDate'), 0, 2);
359
+
360
+ if($filterStart && $filterEnd) {
361
+ //compreso tra start e end date
362
+ if ($createdAt >= $filterStart && $createdAt <= $filterEnd)
363
+ $tempDate[] = $customer;
364
+ } elseif ($filterStart) {
365
+ // >= di start date
366
+ if ($createdAt >= $filterStart)
367
+ $tempDate[] = $customer;
368
+ } else {
369
+ // <= di end date
370
+ if ($createdAt <= $filterEnd)
371
+ $tempDate[] = $customer;
372
+ }
373
+
374
+ }
375
+
376
+ $customersFiltered = $tempDate;
377
+ }
378
+ //FINE FILTRO 7 DATA CREAZIONE CLIENTE: testato ok
379
+
380
+
381
+ //FILTRO 8 TOTALE ACQUISTATO
382
+ $count = 0;
383
+ $result = array();
384
+ $tempTotal = array();
385
+
386
+ if ($request->getRequest()->getParam('mailupTotalAmountValue') > 0 ) {
387
+ foreach ($customersFiltered as $customer) {
388
+ $result[] = $customer;
389
+
390
+ //filtro gli ordini in base al customer id
391
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
392
+
393
+ $totalOrdered = 0;
394
+
395
+ foreach($orders->getData() as $order){
396
+ $totalOrdered += $order['subtotal'];
397
+ }
398
+
399
+ if ($totalOrdered == $request->getRequest()->getParam('mailupTotalAmountValue') && $request->getRequest()->getParam('mailupTotalAmountCond') == "eq" )
400
+ $tempTotal[] = $result[$count];
401
+
402
+ if ($totalOrdered > $request->getRequest()->getParam('mailupTotalAmountValue') && $request->getRequest()->getParam('mailupTotalAmountCond') == "gt" )
403
+ $tempTotal[] = $result[$count];
404
+
405
+ if ($totalOrdered < $request->getRequest()->getParam('mailupTotalAmountValue') && $request->getRequest()->getParam('mailupTotalAmountCond') == "lt" )
406
+ $tempTotal[] = $result[$count];
407
+
408
+ $count++;
409
+ }
410
+
411
+ $customersFiltered = $tempTotal;
412
+ }
413
+ //FINE FILTRO 8 TOTALE ACQUISTATO: testato ok
414
+
415
+
416
+ //FILTRO 9 DATA ACQUISTATO
417
+ $count = 0;
418
+ $result = array();
419
+ $tempOrderedDateYes = array();
420
+ $tempOrderedDateNo = array();
421
+
422
+ if ($request->getRequest()->getParam('mailupOrderStartDate') || $request->getRequest()->getParam('mailupOrderEndDate') ) {
423
+ foreach ($customersFiltered as $customer) {
424
+ $result[] = $customer;
425
+
426
+ //filtro gli ordini in base al customer id
427
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
428
+
429
+ $orderedDate = 0;
430
+
431
+ foreach($orders->getData() as $order){
432
+ $createdAt = substr(str_replace("-","", $order['created_at']), 0, 8);
433
+
434
+ $filterStart = '';
435
+ $filterEnd = '';
436
+
437
+ if($request->getRequest()->getParam('mailupOrderStartDate'))
438
+ $filterStart = substr($request->getRequest()->getParam('mailupOrderStartDate'), 6, 4).substr($request->getRequest()->getParam('mailupOrderStartDate'), 3, 2).substr($request->getRequest()->getParam('mailupOrderStartDate'), 0, 2);
439
+
440
+ if($request->getRequest()->getParam('mailupOrderEndDate'))
441
+ $filterEnd = substr($request->getRequest()->getParam('mailupOrderEndDate'), 6, 4).substr($request->getRequest()->getParam('mailupOrderEndDate'), 3, 2).substr($request->getRequest()->getParam('mailupOrderEndDate'), 0, 2);
442
+
443
+ if($filterStart && $filterEnd) {
444
+ //compreso tra start e end date
445
+ if ($createdAt >= $filterStart && $createdAt <= $filterEnd)
446
+ $orderedDate = 1;
447
+ } elseif ($filterStart) {
448
+ // >= di start date
449
+ if ($createdAt >= $filterStart)
450
+ $orderedDate = 1;
451
+ } else {
452
+ // <= di end date
453
+ if ($createdAt <= $filterEnd)
454
+ $orderedDate = 1;
455
+ }
456
+ }
457
+
458
+ if ($orderedDate == 1)
459
+ $tempOrderedDateYes[] = $result[$count];
460
+ else
461
+ $tempOrderedDateNo[] = $result[$count];
462
+
463
+ $count++;
464
+ }
465
+
466
+ if ($request->getRequest()->getParam('mailupOrderYesNo') == 'yes')
467
+ $customersFiltered = $tempOrderedDateYes;
468
+ else
469
+ $customersFiltered = $tempOrderedDateNo;
470
+ }
471
+ //FINE FILTRO 9 DATA ACQUISTATO: testato ok
472
+
473
+
474
+ }
475
+
476
+ else {
477
+ //GESTISCO LE MODIFICHE MANUALI
478
+ $count = 0;
479
+ $result = array();
480
+ $tempMod = array();
481
+
482
+ $emails = explode('
483
+ ', $request->getRequest()->getParam('mailupCustomerFilteredMod'));
484
+
485
+ foreach ($emails as $email) {
486
+
487
+ $email = trim($email);
488
+
489
+ if (strstr($email, '@')) {
490
+ $customerModCollection = Mage::getModel('customer/customer')
491
+ ->getCollection()
492
+ ->addAttributeToSelect('email')
493
+ ->addAttributeToFilter('email',$email);
494
+
495
+ $added = 0;
496
+
497
+ foreach($customerModCollection as $customerMod) {
498
+ $tempMod[] = $customerMod->toArray();
499
+ $added = 1;
500
+ }
501
+
502
+ if ($added == 0)
503
+ $tempMod[] = array('entity_id'=>0,'firstname'=>'','lastname'=>'','email'=>$email);;
504
+
505
+
506
+ }
507
+ }
508
+
509
+ $customersFiltered = $tempMod;
510
+ }
511
+ //FINE GESTISCO LE MODIFICHE MANUALI
512
+
513
+ return $customersFiltered;
514
+
515
+ }
516
+
517
+ }
app/code/local/SevenLike/MailUp/Model/Wssend.php ADDED
@@ -0,0 +1,201 @@
1
+ <?php
2
+ class MailUpWsSend {
3
+
4
+ protected $WSDLUrl = "http://services.mailupnet.it/MailupSend.asmx?WSDL";
5
+ private $soapClient;
6
+ private $xmlResponse;
7
+ protected $domResult;
8
+
9
+ function __construct() {
10
+ $this->soapClient = new SoapClient($this->WSDLUrl,
11
+ array("trace" => 1,
12
+ "exceptions" => 0));
13
+ }
14
+
15
+ function __destruct() {
16
+ unset($this->soapClient);
17
+ }
18
+
19
+ public function getFunctions() {
20
+ print_r($this->soapClient->__getFunctions());
21
+ }
22
+
23
+ public function login() {
24
+
25
+ $loginData = array("user" => Mage::getStoreConfig('newsletter/mailup/user'),
26
+ "pwd" => Mage::getStoreConfig('newsletter/mailup/password'),
27
+ "url" => Mage::getStoreConfig('newsletter/mailup/url_console'));
28
+
29
+ $result = get_object_vars($this->soapClient->Login($loginData));
30
+ $xml = simplexml_load_string($result['LoginResult']);
31
+ $xml = get_object_vars($xml);
32
+
33
+ //echo $xml['errorDescription'];
34
+
35
+ return $xml['errorCode'];
36
+
37
+ /* echo strlen($result['LoginResult']);
38
+ if (strlen($result['LoginResult']) == 295)
39
+ return 0;
40
+ else
41
+ return 1;
42
+ */
43
+ }
44
+
45
+ public function loginTest() {
46
+
47
+ $loginData = array("user" => "a7410",
48
+ "pwd" => "GA6VAN0W",
49
+ "url" => "g4a0.s03.it");
50
+
51
+ $result = get_object_vars($this->soapClient->Login($loginData));
52
+ $xml = simplexml_load_string($result['LoginResult']);
53
+ $xml = get_object_vars($xml);
54
+
55
+ if ($xml['errorCode'] > 0)
56
+ echo $xml['errorDescription'].'<br /><br />';
57
+
58
+ return $xml['errorCode'];
59
+
60
+ /* echo strlen($result['LoginResult']);
61
+ if (strlen($result['LoginResult']) == 295)
62
+ return 0;
63
+ else
64
+ return 1;
65
+ */
66
+ }
67
+
68
+ public function testSoap() {
69
+ $client = new SoapClient('http://soapclient.com/xml/soapresponder.wsdl');
70
+ //print_r($client->__getFunctions());
71
+ return $client->Method1('x12qaq','c56tf3');
72
+ }
73
+
74
+ public function logout() {
75
+ try {
76
+ $this->soapClient->Logout(array("accessKey" => $this->accessKey));
77
+ if ($this->readReturnCode("Logout","errorCode") != 0)
78
+ echo "<br /><br />Errore Logout". $this->readReturnCode("Logout","errorDescription");
79
+ } catch (SoapFault $soapFault) {
80
+ var_dump($soapFault);
81
+ }
82
+ }
83
+
84
+ public function getLists() {
85
+ try {
86
+ $this->soapClient->GetLists(array("accessKey" => $this->accessKey));
87
+ if ($this->readReturnCode("GetLists","errorCode") != 0)
88
+ echo "<br /><br />Errore GetLists: ". $this->readReturnCode("GetLists","errorDescription");
89
+ else $this->printLastResponse();
90
+
91
+ } catch (SoapFault $soapFault) {
92
+ var_dump($soapFault);
93
+ }
94
+ }
95
+
96
+ public function getGroups($params) {
97
+ try {
98
+ $params = array_merge((array)$params, array("accessKey" => $this->accessKey));
99
+ $this->soapClient->GetGroups($params);
100
+ if ($this->readReturnCode("GetGroups","errorCode") != 0)
101
+ echo "<br /><br />Errore GetGroups: ". $this->readReturnCode("GetGroups","errorDescription");
102
+ else $this->printLastResponse();
103
+
104
+ } catch (SoapFault $soapFault) {
105
+ var_dump($soapFault);
106
+ }
107
+ }
108
+
109
+ public function getNewsletters($params) {
110
+ try {
111
+ $params = array_merge((array)$params, array("accessKey" => $this->accessKey));
112
+ $this->soapClient->GetNewsletters($params);
113
+ if ($this->readReturnCode("GetNewsletters","errorCode") != 0)
114
+ echo "<br /><br />Errore GetNewsletters: ". $this->readReturnCode("GetNewsletters","errorDescription");
115
+ else $this->printLastResponse();
116
+
117
+ } catch (SoapFault $soapFault) {
118
+ var_dump($soapFault);
119
+ }
120
+ }
121
+
122
+ public function createNewsletter($params) {
123
+ try {
124
+ $params = array_merge((array)$params, array("accessKey" => $this->accessKey));
125
+ $this->soapClient->createNewsletter($params);
126
+ $this->printLastRequest();
127
+ if ($this->readReturnCode("CreateNewsletter","errorCode") != 0)
128
+ echo "<br /><br />Errore CreateNewsletter: ". $this->readReturnCode("CreateNewsletter","errorCode") ." - " . $this->readReturnCode("CreateNewsletter","errorDescription");
129
+ else $this->printLastResponse();
130
+
131
+ } catch (SoapFault $soapFault) {
132
+ var_dump($soapFault);
133
+ }
134
+ }
135
+
136
+ public function sendNewsletter($params) {
137
+ try {
138
+ $params = array_merge((array)$params, array("accessKey" => $this->accessKey));
139
+ $this->soapClient->SendNewsletter($params);
140
+ var_dump($params);
141
+ $this->printLastRequest();
142
+ if ($this->readReturnCode("SendNewsletter","errorCode") != 0)
143
+ echo "<br /><br />Errore SendNewsletter: ". $this->readReturnCode("SendNewsletter","errorCode") ." - " .$this->readReturnCode("SendNewsletter","errorDescription");
144
+ else $this->printLastResponse();
145
+
146
+ } catch (SoapFault $soapFault) {
147
+ var_dump($soapFault);
148
+ }
149
+ }
150
+
151
+ public function sendNewsletterFast($params) {
152
+ try {
153
+ $params = array_merge((array)$params, array("accessKey" => $this->accessKey));
154
+ $this->soapClient->SendNewsletterFast($params);
155
+
156
+ $this->printLastRequest();
157
+ if ($this->readReturnCode("SendNewsletterFast","errorCode") != 0)
158
+ echo "<br /><br />Errore SendNewsletterFast: ". $this->readReturnCode("SendNewsletterFast","errorCode") ." - " .$this->readReturnCode("SendNewsletterFast","errorDescription");
159
+ else $this->printLastResponse();
160
+
161
+ } catch (SoapFault $soapFault) {
162
+ var_dump($soapFault);
163
+ }
164
+ }
165
+
166
+ private function readReturnCode($func, $param) {
167
+ static $func_in = ""; //static variable to test xmlResponse update
168
+ if ($func_in != $func) {//(!isset($this->xmlResponse))
169
+ $func_in = $func;
170
+ //prendi l'XML di ritorno se non l'ho gi� preso
171
+ $this->xmlResponse = $this->soapClient->__getLastResponse();
172
+
173
+ $dom = new DomDocument();
174
+ $dom->loadXML($this->xmlResponse) or die("File XML non valido!");
175
+ $xmlResult = $dom->getElementsByTagName($func."Result");
176
+
177
+ $this->domResult = new DomDocument();
178
+ $this->domResult->LoadXML(html_entity_decode($xmlResult->item(0)->nodeValue)) or die("File XML1 non valido!");;
179
+ }
180
+ $rCode = $this->domResult->getElementsByTagName($param);
181
+ return $rCode->item(0)->nodeValue;
182
+ }
183
+
184
+ private function printLastRequest() {
185
+ echo "<br>Request :<br>". htmlentities($this->soapClient->__getLastRequest()). "<br>";
186
+ }
187
+
188
+ private function printLastResponse() {
189
+ echo "<br />XMLResponse: " . $this->soapClient->__getLastResponse() . "<br />"; //htmlentities();
190
+ }
191
+
192
+ public function getAcessKey() {
193
+ return $this->accessKey;
194
+ }
195
+
196
+ public function option($key, $value) {
197
+ return array("Key" => $key, "Value" => $value);
198
+ }
199
+
200
+ }
201
+ ?>
app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php ADDED
@@ -0,0 +1,148 @@
1
+ <?php
2
+
3
+ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout()->renderLayout();
8
+ }
9
+
10
+ public function confirmAction()
11
+ {
12
+ $this->loadLayout()->renderLayout();
13
+ }
14
+
15
+ public function csvAction()
16
+ {
17
+ $post = $this->getRequest()->getPost();
18
+ $mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
19
+ $subscribers = array();
20
+ $file = '';
21
+
22
+ if ($post['countPost'] > 0){
23
+ //preparo l'elenco degli iscritti da salvare nel csv
24
+ foreach ($mailupCustomerIds as $customerId) {
25
+ if ($customerId['entity_id'] > 0) {
26
+ $customer = Mage::getModel('customer/customer')->load($customerId['entity_id']);
27
+ $subscriber = $customer->toArray();
28
+ $file .= '"'.$subscriber['firstname'].'";"'.$subscriber['lastname'].'";"'.$subscriber['email'].'"
29
+ ';
30
+ } else {
31
+ $subscriber = array('firstname'=>'','lastname'=>'','email'=>$customerId['email']);
32
+ $file .= '"'.$subscriber['firstname'].'";"'.$subscriber['lastname'].'";"'.$subscriber['email'].'"
33
+ ';
34
+ }
35
+
36
+ }
37
+
38
+ /*
39
+ foreach ($subscribers as $subscriber) {
40
+ $file .= '"'.$subscriber['firstname'].'";"'.$subscriber['lastname'].'";"'.$subscriber['email'].'"
41
+ ';
42
+ }
43
+ */
44
+
45
+ }
46
+
47
+ //lancio il download del file
48
+ header("Content-Disposition: attachment;Filename=clienti_filtrati.csv");
49
+ echo $file;
50
+
51
+ }
52
+
53
+ public function postAction()
54
+ {
55
+ $post = $this->getRequest()->getPost();
56
+ $mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
57
+ try {
58
+ if (empty($post)) {
59
+ Mage::throwException($this->__('Invalid form data.'));
60
+ }
61
+
62
+ //preparo l'xml degli iscritti da inviare a mailup (da gestire in base ai filtri)
63
+ $xmlData = '<subscribers>';
64
+
65
+ foreach ($mailupCustomerIds as $customerId) {
66
+ if ($customerId['entity_id'] > 0) {
67
+ $customer = Mage::getModel('customer/customer')->load($customerId['entity_id']);
68
+ $subscriber = $customer->toArray();
69
+ $xmlData .= '<subscriber email="'.$subscriber['email'].'" Number="" Name=""><campo1>'.$subscriber['firstname'].'</campo1><campo2>'.$subscriber['lastname'].'</campo2></subscriber>';
70
+ } else {
71
+ $subscriber = array('firstname'=>'','lastname'=>'','email'=>$customerId['email']);
72
+ $xmlData .= '<subscriber email="'.$subscriber['email'].'" Number="" Name=""><campo1>'.$subscriber['firstname'].'</campo1><campo2>'.$subscriber['lastname'].'</campo2></subscriber>';
73
+ }
74
+
75
+ }
76
+
77
+ /*foreach ($post['mailupCustomerIds'] as $customerId) {
78
+ $customer = Mage::getModel('customer/customer')->load($customerId);
79
+ $subscribers[] = $customer->toArray();
80
+ }*/
81
+
82
+ //$xmlData = '<subscribers>';
83
+
84
+ /*
85
+ foreach ($subscribers as $subscriber) {
86
+ $xmlData .= '<subscriber email="'.$subscriber['email'].'" Number="" Name=""><campo1>'.$subscriber['firstname'].'</campo1><campo2>'.$subscriber['lastname'].'</campo2></subscriber>';
87
+ }
88
+ */
89
+
90
+ $xmlData .= '</subscribers>';
91
+
92
+ //invio a mailup gli iscritti da aggiungere al gruppo scelto
93
+ $MailUpWsImport = Mage::getModel('mailup/ws');
94
+ $wsImport = new MailUpWsImport();
95
+
96
+ //definisco il gruppo a cui aggiungere gli iscritti
97
+ $groupId = $post['mailupGroupId'];
98
+ $listGUID = $post['mailupListGUID'];
99
+ $idList = $post['mailupIdList'];
100
+
101
+ if ($post['mailupNewGroup'] == 1){
102
+ $newGroup = array("idList" => $idList,
103
+ "listGUID" => $listGUID,
104
+ "newGroupName" => $post['mailupNewGroupName']);
105
+
106
+ $groupId = $wsImport->CreaGruppo($newGroup);
107
+ }
108
+
109
+ $importProcessData = array("idList" => $idList,
110
+ "listGUID" => $listGUID,
111
+ "idGroup" => $groupId,
112
+ "xmlDoc" => $xmlData,
113
+ "idGroups" => $groupId,
114
+ "importType" => "3",
115
+ "mobileInputType" => "2",
116
+ "asPending" => "0",
117
+ "ConfirmEmail" => "0",
118
+ "asOptOut" => "0",
119
+ "forceOptIn" => "0",
120
+ "replaceGroups" => "0",
121
+ "idConfirmNL" => "0");
122
+
123
+ //echo '<br /><br />Subscribers: ';
124
+ //print_r($importProcessData);
125
+
126
+ //avvio l'importazione su mailup
127
+ $processID = $wsImport->newImportProcess($importProcessData);
128
+
129
+ $process = array("idList" => $post['mailupIdList'],
130
+ "listGUID" => $post['mailupListGUID'],
131
+ "idProcess" => $processID );
132
+
133
+ $wsImport->startProcess($process);
134
+
135
+ //echo $wsImport->getProcessDetail($process);
136
+
137
+ //fine processo
138
+
139
+ $message = $this->__('Gli iscritti sono stati inviati correttamente');
140
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
141
+ } catch (Exception $e) {
142
+ $errorMessage = $this->__('Attenzione: non hai inviato nessun iscritto');
143
+ Mage::getSingleton('adminhtml/session')->addError($errorMessage);
144
+ }
145
+ $this->_redirect('*/*');
146
+ }
147
+ }
148
+ ?>
app/code/local/SevenLike/MailUp/etc/config.xml ADDED
@@ -0,0 +1,136 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Campaign Monitor Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com and you will be sent a copy immediately.
15
+ *
16
+ * @category Fontis
17
+ * @package Fontis_CampaignMonitor
18
+ * @author Peter Spiller
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+
26
+ <modules>
27
+ <SevenLike_MailUp>
28
+ <version>0.1.5</version>
29
+ </SevenLike_MailUp>
30
+ </modules>
31
+
32
+ <global>
33
+ <models>
34
+ <mailup>
35
+ <class>SevenLike_MailUp_Model</class>
36
+ </mailup>
37
+ </models>
38
+ <blocks>
39
+ <mailup>
40
+ <class>SevenLike_MailUp_Block</class>
41
+ </mailup>
42
+ </blocks>
43
+ <helpers>
44
+ <sintax>
45
+ <class>SevenLike_MailUp_Helper</class>
46
+ </sintax>
47
+ </helpers>
48
+ <resources>
49
+ <mailup_setup>
50
+ <setup>
51
+ <module>SevenLike_MailUp</module>
52
+ </setup>
53
+ <connection>
54
+ <use>core_setup</use>
55
+ </connection>
56
+ </mailup_setup>
57
+ <mailup_write>
58
+ <connection>
59
+ <use>core_write</use>
60
+ </connection>
61
+ </mailup_write>
62
+ <mailup_read>
63
+ <connection>
64
+ <use>core_read</use>
65
+ </connection>
66
+ </mailup_read>
67
+ </resources>
68
+ </global>
69
+
70
+ <admin>
71
+ <routers>
72
+ <mailup>
73
+ <use>admin</use>
74
+ <args>
75
+ <module>SevenLike_MailUp</module>
76
+ <frontName>mailup</frontName>
77
+ </args>
78
+ </mailup>
79
+ </routers>
80
+ </admin>
81
+
82
+ <default>
83
+ <newsletter>
84
+ <mailup>
85
+ <model>mailup/ws</model>
86
+ </mailup>
87
+ </newsletter>
88
+ </default>
89
+
90
+ <adminhtml>
91
+ <menu>
92
+ <newsletter>
93
+ <children>
94
+ <mailup_groups translate="title" module="newsletter">
95
+ <title>MailUp</title>
96
+ <action>mailup/adminhtml_filter</action>
97
+ </mailup_groups>
98
+ </children>
99
+ </newsletter>
100
+ </menu>
101
+ <acl>
102
+ <resources>
103
+ <admin>
104
+ <children>
105
+ <catalog>
106
+ <children>
107
+ <mailup_groups>
108
+ <title>Mailup</title>
109
+ </mailup_groups>
110
+ </children>
111
+ </catalog>
112
+ </children>
113
+ </admin>
114
+ </resources>
115
+ </acl>
116
+
117
+ <layout>
118
+ <updates>
119
+ <mailup>
120
+ <file>mailup.xml</file>
121
+ </mailup>
122
+ </updates>
123
+ </layout>
124
+
125
+ <translate>
126
+ <modules>
127
+ <mailup>
128
+ <files>
129
+ <default>SevenLike_MailUp.csv</default>
130
+ </files>
131
+ </mailup>
132
+ </modules>
133
+ </translate>
134
+ </adminhtml>
135
+
136
+ </config>
app/code/local/SevenLike/MailUp/etc/system.xml ADDED
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Campaign Monitor Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com and you will be sent a copy immediately.
15
+ *
16
+ * @category Fontis
17
+ * @package Fontis_CampaignMonitor
18
+ * @author Peter Spiller
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <sections>
26
+ <newsletter>
27
+ <groups>
28
+ <mailup translate="label">
29
+ <label>MailUp Settings</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <url_console translate="comment">
37
+ <label>URL Console</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>10</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <comment>You can find it on your browser url bar (e.g. g4a0.s03.it)</comment>
44
+ </url_console>
45
+ <user translate="label">
46
+ <label>User API</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>40</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
+ </user>
53
+ <password translate="label">
54
+ <label>Password API</label>
55
+ <frontend_type>password</frontend_type>
56
+ <sort_order>50</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </password>
61
+ <list translate="comment">
62
+ <label>List</label>
63
+ <frontend_type>select</frontend_type>
64
+ <source_model>mailup/lists</source_model>
65
+ <sort_order>60</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <comment>If you haven't yet, we suggest you to create a DEM list directly from your mailup console</comment>
70
+ </list>
71
+ </fields>
72
+ </mailup>
73
+ </groups>
74
+ </newsletter>
75
+ </sections>
76
+ </config>
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ //creo la tabella per salvare i filtri
3
+ /*
4
+ $this->startSetup();
5
+ $this->run("
6
+
7
+ -- DROP TABLE IF EXISTS {$this->getTable('mailup')};
8
+ CREATE TABLE {$this->getTable('mailup')} (
9
+ `mailup_id` int(11) unsigned NOT NULL auto_increment,
10
+ `title` varchar(255) NOT NULL default '',
11
+ `content` text NOT NULL default '',
12
+ `status` smallint(6) NOT NULL default '0',
13
+ `created_time` datetime NULL,
14
+ `update_time` datetime NULL,
15
+ PRIMARY KEY (`mailup_id`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
+
18
+ ");
19
+ $this->endSetup();
20
+ */
21
+ ?>
app/design/adminhtml/default/default/layout/mailup.xml ADDED
@@ -0,0 +1,21 @@
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">
15
+ <block type="adminhtml/template" name="filter" template="sevenlike/mailup/confirm.phtml"/>
16
+ </reference>
17
+ <reference name="head">
18
+ <action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
19
+ </reference>
20
+ </mailup_adminhtml_filter_confirm>
21
+ </layout>
app/design/adminhtml/default/default/template/sevenlike/mailup/confirm.phtml ADDED
@@ -0,0 +1,197 @@
1
+ <?php
2
+ /**
3
+ Author: Sevenlike www.sevenlike.com
4
+ */
5
+ ?>
6
+ <?php
7
+
8
+
9
+ //ottengo l'elenco delle liste e dei gruppi da mailup
10
+ $MailUpWsImport = Mage::getModel('mailup/ws');
11
+ $wsImport = new MailUpWsImport();
12
+
13
+ $customersFiltered = $wsImport->getCustomersFiltered($this);
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
+ $xml = simplexml_load_string($xmlLists);
24
+
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="mailupCustomers" value="<?php echo $this->getRequest()->getParam('mailupCustomers'); ?>" />
31
+ <input type="hidden" name="mailupProductId" value="<?php echo $this->getRequest()->getParam('mailupProductId'); ?>" />
32
+ <input type="hidden" name="mailupCategoryId" value="<?php echo $this->getRequest()->getParam('mailupCategoryId'); ?>" />
33
+ <input type="hidden" name="mailupCustomerGroupId" value="<?php echo $this->getRequest()->getParam('mailupCustomerGroupId'); ?>" />
34
+ <input type="hidden" name="mailupCountry" value="<?php echo $this->getRequest()->getParam('mailupCountry'); ?>" />
35
+ <input type="hidden" name="mailupPostCode" value="<?php echo $this->getRequest()->getParam('mailupPostCode'); ?>" />
36
+ <input type="hidden" name="mailupCustomerStartDate" value="<?php echo $this->getRequest()->getParam('mailupCustomerStartDate'); ?>" />
37
+ <input type="hidden" name="mailupCustomerEndDate" value="<?php echo $this->getRequest()->getParam('mailupCustomerEndDate'); ?>" />
38
+ <input type="hidden" name="mailupTotalAmountCond" value="<?php echo $this->getRequest()->getParam('mailupTotalAmountCond'); ?>" />
39
+ <input type="hidden" name="mailupTotalAmountValue" value="<?php echo $this->getRequest()->getParam('mailupTotalAmountValue'); ?>" />
40
+ <input type="hidden" name="mailupOrderStartDate" value="<?php echo $this->getRequest()->getParam('mailupOrderStartDate'); ?>" />
41
+ <input type="hidden" name="mailupOrderEndDate" value="<?php echo $this->getRequest()->getParam('mailupOrderEndDate'); ?>" />
42
+ <input type="hidden" name="mailupOrderYesNo" value="<?php echo $this->getRequest()->getParam('mailupOrderYesNo'); ?>" />
43
+ </form>
44
+
45
+ <form id="csv_form" name="csv_form" method="post" action="<?php echo $this->getUrl('*/*/csv'); ?>">
46
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
47
+ <?php
48
+ $countPost = 0;
49
+ $textArea = "";
50
+ $formParams = "";
51
+ //mi passo gli id di tutti i clienti filtrati
52
+ foreach ($customersFiltered as $customer) {
53
+ //echo '<input name="mailupCustomerIds['.$countPost.'][entity_id]" type="hidden" value="'.$customer['entity_id'].'" />';
54
+ //echo '<input name="mailupCustomerIds['.$countPost.'][email]" type="hidden" value="'.$customer['email'].'" />';
55
+ $textArea .= $customer['email'].'
56
+ ';
57
+ $mailupCustomerIds[$countPost]['entity_id'] = $customer['entity_id'];
58
+ $mailupCustomerIds[$countPost]['email'] = $customer['email'];
59
+ $countPost++;
60
+ }
61
+ //salvo l'array nella sessione
62
+ if (($countPost) > 0)
63
+ Mage::getSingleton('core/session')->setMailupCustomerIds($mailupCustomerIds);
64
+ ?>
65
+ <input name="countPost" type="hidden" value="<?php echo $countPost; ?>" />
66
+ </form>
67
+ <div class="content-header">
68
+ <table cellspacing="0" class="grid-header">
69
+ <tr>
70
+ <td><h3><?=$this->__('MailUp')?></h3></td>
71
+ <td class="a-right">
72
+ <button onclick="back_form.submit()" class="scalable back" type="button"><span><?=$this->__('Reset filters')?></span></button>
73
+ <button onclick="csv_form.submit()" class="scalable save" type="button"><span><?=$this->__('Export to CSV')?></span></button>
74
+ <button onclick="editForm.submit()" class="scalable save" type="button"><span><?=$this->__('Send to MailUp')?></span></button>
75
+ </td>
76
+ </tr>
77
+ </table>
78
+ </div>
79
+ <div class="entry-edit">
80
+ <?php
81
+ //gestisco la lista selezionata in configurazione
82
+ foreach($xml->List as $list) {
83
+ if ($list['listGUID'] == Mage::getStoreConfig('newsletter/mailup/list')){
84
+ $listName = $list['listName'];
85
+ $idList = $list['idList'];
86
+ $listGUID = $list['listGUID'];
87
+ }
88
+ }
89
+ ?>
90
+ <form id="edit_form" name="edit_form" method="post" action="<?=$this->getUrl('*/*/post')?>">
91
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
92
+ <input name="mailupIdList" type="hidden" value="<?php echo $idList; ?>" />
93
+ <input name="mailupListGUID" type="hidden" value="<?php echo $listGUID; ?>" />
94
+
95
+ <h4><span id="spantitle3"><?=$this->__('Confirm filtered customers and select MailUp group')?></span></h4>
96
+ <fieldset id="my-fieldset">
97
+ <table cellspacing="0" class="form-list">
98
+ <tr>
99
+ <td colspan="2"><h4><?=$this->__('Were found')?> <strong><?php echo $countPost; ?></strong> <?=$this->__('records')?></h4></td>
100
+ </tr>
101
+ <tr>
102
+ <td><?=$this->__('Filtered customers')?>:</td>
103
+ </tr>
104
+ <tr>
105
+ <td>
106
+ <textarea name="mailupCustomerFilteredView" rows="5" cols="50" disabled="disabled" class="txtar1"><?php
107
+ /*foreach ($customersFiltered as $customer) {
108
+ echo $customer['email'].'&#10;';
109
+ }*/
110
+ echo $textArea;
111
+ ?></textarea>
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td colspan="2">
116
+ <?=$this->__('Selected list')?>: <strong>
117
+ <?php echo $listName; ?><br /><br /><br />
118
+ </strong></td>
119
+ </tr>
120
+ </table>
121
+ <table>
122
+ <tr>
123
+ <td>
124
+ <h4><?=$this->__('Next Step')?></h4>
125
+ </td>
126
+ </tr>
127
+ <tr>
128
+ <td class="label"><p class="slgrp1"><?=$this->__('Select group')?> <input type="radio" name="mailupNewGroup" value="0" checked="checked" /></p></td>
129
+ </tr>
130
+ <tr>
131
+ <td class="input-ele">
132
+ <p class="istrz1"><?=$this->__('Select an existing group')?>:</p>
133
+ <select class="required-entry slctpg1" name="mailupGroupId">
134
+ <?php
135
+ foreach($xml->List as $list) {
136
+ if ($list['listGUID'] == Mage::getStoreConfig('newsletter/mailup/list')){
137
+ foreach($list->Groups->Group as $group) {
138
+ echo '<option value="'.$group['idGroup'].'">'.$group['groupName'].'</option>';
139
+ }
140
+ }
141
+ }
142
+ ?>
143
+ </select><br /><br />
144
+ </td>
145
+ </tr>
146
+
147
+ <tr>
148
+ <td>
149
+ <p class="istrz2"><?=$this->__('or')?></p>
150
+ </td>
151
+ </tr>
152
+ <tr>
153
+ <td class="label"><p class="slgrp1"><?=$this->__('Create new customer group')?> <input type="radio" name="mailupNewGroup" value="1" /></p></td>
154
+ </tr>
155
+ <tr>
156
+ <td>
157
+ <p class="istrz1"><?=$this->__('Group name')?>:</p>
158
+ </td>
159
+ </tr>
160
+ <tr>
161
+ <td>
162
+ <input type="text" name="mailupNewGroupName" size="60" class="inptptx2" />
163
+ </td>
164
+ </tr>
165
+ </table>
166
+ </fieldset>
167
+ </form>
168
+
169
+ <?php //form per la modifica manuale delle email ?>
170
+ <form id="manual_form" name="manual_form" method="post" action="<?=$this->getUrl('*/*/confirm')?>">
171
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
172
+ <h4><span id="spantitle4"><?=$this->__('Add a new e-mail address or select adresses to be removed from list')?></span></h4>
173
+ <fieldset id="my-fieldset">
174
+ <table cellspacing="5" class="form-list">
175
+ <tr>
176
+ <td><?=$this->__('Change members list: please add one email adress per row')?></td>
177
+ <td>
178
+ <textarea name="mailupCustomerFilteredMod" rows="20" cols="50" class="txtar1"><?php
179
+ /*foreach ($customersFiltered as $customer) {
180
+ echo $customer['email'].'&#10;';
181
+ }*/
182
+ echo $textArea;
183
+ ?></textarea>
184
+ </td>
185
+ </tr>
186
+ <tr>
187
+ <td></td>
188
+ <td> <button onclick="manual_form.submit()" class="scalable save" type="button"><span><?=$this->__('Save changes')?></span></button><!-- <input type="submit" value="Applica modifiche"> --></td>
189
+ </tr>
190
+ </table>
191
+ </fieldset>
192
+ </form>
193
+
194
+ </div>
195
+ <script type="text/javascript">
196
+ var editForm = new varienForm('edit_form');
197
+ </script>
app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml ADDED
@@ -0,0 +1,412 @@
1
+ <?php
2
+ /**
3
+ Author: Sevenlike www.sevenlike.com
4
+ */
5
+ ?>
6
+
7
+ <?php
8
+
9
+ $MailUpWsSend = Mage::getModel('mailup/wssend');
10
+ $wsSend = new MailUpWsSend();
11
+ $login = $wsSend->login();
12
+ $loginTest = $wsSend->loginTest();
13
+ $soap = $wsSend->testSoap();
14
+
15
+ if (!strpos($soap, 'x12qaq')){
16
+ echo $this->__('WARNING: your server may not support SOAP communications').'<br /><br />';
17
+ }
18
+
19
+ if ($loginTest > 0){
20
+ echo $this->__('WARNING: your server may not support MailUp SOAP communications').'<br /><br />';
21
+ }
22
+
23
+ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
24
+ echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
25
+ } else {
26
+ //controllo se la lista � stata selezionata correttamente
27
+ $MailUpWsImport = Mage::getModel('mailup/ws');
28
+ $wsImport = new MailUpWsImport();
29
+ $mailupLists = $wsImport->GetNlList();
30
+
31
+ //chiamata attivazione web services su MailUp
32
+ $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";
33
+ fopen($urlWSActivation, "r");
34
+
35
+ //salvo i parametri in variabili
36
+ $mailupCustomers = $this->getRequest()->getParam('mailupCustomers');
37
+ $mailupProductId = $this->getRequest()->getParam('mailupProductId');
38
+ $mailupCategoryId = $this->getRequest()->getParam('mailupCategoryId');
39
+ $mailupCustomerGroupId = $this->getRequest()->getParam('mailupCustomerGroupId');
40
+ $mailupCountry = $this->getRequest()->getParam('mailupCountry');
41
+ $mailupPostCode = $this->getRequest()->getParam('mailupPostCode');
42
+ $mailupCustomerStartDate = $this->getRequest()->getParam('mailupCustomerStartDate');
43
+ $mailupCustomerEndDate = $this->getRequest()->getParam('mailupCustomerEndDate');
44
+ $mailupTotalAmountCond = $this->getRequest()->getParam('mailupTotalAmountCond');
45
+ $mailupTotalAmountValue = $this->getRequest()->getParam('mailupTotalAmountValue');
46
+ $mailupOrderStartDate = $this->getRequest()->getParam('mailupOrderStartDate');
47
+ $mailupOrderEndDate = $this->getRequest()->getParam('mailupOrderEndDate');
48
+ $mailupOrderYesNo = $this->getRequest()->getParam('mailupOrderYesNo');
49
+ ?>
50
+
51
+ <div class="content-header">
52
+ <table cellspacing="0" class="grid-header">
53
+ <tr>
54
+ <td><h3><?=$this->__('MailUp')?></h3></td>
55
+ <td class="a-right">
56
+ <button onclick="editForm.submit()" class="scalable save" type="button"><span><?=$this->__('Apply filter')?></span></button>
57
+ </td>
58
+ </tr>
59
+ </table>
60
+ </div>
61
+ <div class="entry-edit">
62
+
63
+ <form id="edit_form" name="edit_form" method="post" action="<?=$this->getUrl('*/*/confirm')?>">
64
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
65
+ <h4><span id="spantitle2"><?=$this->__('Filter customers')?></span><span id="spansugger"><a href="#ottsugg"><?=$this->__('Get hints')?> &rArr;</a></span></h4>
66
+ <div style="clear: both;"></div>
67
+ <fieldset id="my-fieldset">
68
+ <table cellspacing="0" class="form-list">
69
+ <tr>
70
+ <td colspan="3"><?=$this->__('By this plugin you can import contacts registered in your eCommerce in the MailUp platform.')?></td>
71
+ </tr>
72
+ <tr>
73
+ <td colspan="3">
74
+ <strong>
75
+ <?=$this->__('Sold products')?>
76
+ </strong></td>
77
+ </tr>
78
+ <?php //imposto il filtro per clienti: 0 = tutti, 1 = che hanno acquistato, 2 = che non hanno mai acquistato ?>
79
+ <tr>
80
+
81
+ <td class="input-ele spdnpg1">
82
+ <input type="radio" name="mailupCustomers" value="0" onclick="makeEnable('mailupProductId','mailupCategoryId','mailupTotalAmountCond','mailupTotalAmountValue')" <?php if($mailupCustomers == 0 || !$mailupCustomers) echo 'checked="checked"'; ?> />
83
+ <?=$this->__('All customers')?>
84
+ </td>
85
+
86
+ <td class="input-ele spdnpg1">
87
+ <input type="radio" name="mailupCustomers" value="1" onclick="makeEnable('mailupProductId','mailupCategoryId','mailupTotalAmountCond','mailupTotalAmountValue')" <?php if($mailupCustomers == 1) echo 'checked="checked"'; ?> />
88
+ <?=$this->__('Customers who have purchased')?>
89
+ </td>
90
+
91
+ <td class="input-ele spdnpg1">
92
+ <input type="radio" name="mailupCustomers" value="2" onclick="makeDisable('mailupProductId','mailupCategoryId','mailupTotalAmountCond','mailupTotalAmountValue')" <?php if($mailupCustomers == 2) echo 'checked="checked"'; ?> />
93
+ <?=$this->__("Customers who haven't purchased yet")?>
94
+ </td>
95
+ </tr>
96
+
97
+ </table>
98
+
99
+ <table cellspacing="0" class="form-list">
100
+
101
+ <?php //select con tutti i prodotti ?>
102
+ <tr>
103
+ <td class="labelpg1"><?=$this->__('Select product')?></td>
104
+ <td class="input-ele">
105
+ <?php
106
+ $productsCollection = Mage::getModel('catalog/product')->getCollection();
107
+ $productsCollection->addAttributeToSelect('name');
108
+ $productsCollection->addAttributeToSelect('entity_id');
109
+ /*
110
+ foreach ($collection as $product) {
111
+ var_dump($product);
112
+ }
113
+ */
114
+ ?>
115
+ <select id="mailupProductId" name="mailupProductId" class="slctpg1">
116
+
117
+ <?php
118
+ if($mailupProductId) {
119
+ $product = Mage::getModel('catalog/product')->load($mailupProductId);
120
+ ?>
121
+ <option value="<?php echo $mailupProductId; ?>"><?php echo $product->getData('name'); ?></option>
122
+ <?php } ?>
123
+
124
+ <option value="0">-- <?php echo $this->__('Any'); ?> --</option>
125
+
126
+ <?php
127
+ foreach ($productsCollection as $product) {
128
+ echo '<option value="'.$product->getData('entity_id').'">'.($product->getData('name')).'</option>';
129
+ }
130
+ ?>
131
+ </select>
132
+ </td>
133
+ </tr>
134
+ <?php //select con tutte le categorie ?>
135
+ <tr>
136
+ <td class="labelpg1"><?=$this->__('Select category')?></td>
137
+ <td class="input-ele">
138
+ <?php
139
+ $categoriesCollection = Mage::getModel('catalog/category')->getCollection();
140
+ $categoriesCollection->addAttributeToSelect('name');
141
+ $categoriesCollection->addAttributeToSelect('entity_id');
142
+ /*
143
+ foreach ($categoriesCollection as $category) {
144
+ var_dump($category);
145
+ }
146
+ */
147
+
148
+ ?>
149
+ <select id="mailupCategoryId" name="mailupCategoryId" class="slctpg1">
150
+
151
+ <?php
152
+ if($mailupCategoryId) {
153
+ $category = Mage::getModel('catalog/category')->load($mailupCategoryId);
154
+ ?>
155
+ <option value="<?php echo $mailupCategoryId; ?>"><?php echo $category->getData('name'); ?></option>
156
+ <?php } ?>
157
+
158
+ <option value="0">-- <?=$this->__('Any')?> --</option>
159
+
160
+ <?php
161
+ foreach ($categoriesCollection as $category) {
162
+ //var_dump($product);
163
+ echo '<option value="'.$category->getData('entity_id').'">'.($category->getData('name')).'</option>';
164
+ }
165
+ ?>
166
+ </select>
167
+ </td>
168
+ </tr>
169
+
170
+ <tr>
171
+ <td colspan="2">
172
+ <strong><br /><br />
173
+ <?=$this->__('Groups')?>
174
+ </strong></td>
175
+ </tr>
176
+ <tr>
177
+ <td class="labelpg1"><?=$this->__('Select customer group')?></td>
178
+ <td class="input-ele">
179
+ <select name="mailupCustomerGroupId" class="slctpg1">
180
+
181
+ <?php
182
+ $customerGroups = Mage::helper('customer')->getGroups()->toOptionArray();
183
+
184
+ if($mailupCustomerGroupId) {
185
+ foreach ($customerGroups as $customerGroup){
186
+ if($mailupCustomerGroupId == $customerGroup['value'])
187
+ echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
188
+ }
189
+
190
+ } ?>
191
+
192
+ <option value="0">-- <?=$this->__('Any')?> --</option>
193
+
194
+ <?php
195
+ foreach ($customerGroups as $customerGroup){
196
+ echo '<option value="'.$customerGroup['value'].'">'.$customerGroup['label'].'</option>';
197
+ }
198
+ ?>
199
+ </select>
200
+ </td>
201
+ </tr>
202
+
203
+ <tr>
204
+ <td colspan="2">
205
+ <strong><br /><br />
206
+ <?=$this->__('Country')?>
207
+ </strong></td>
208
+ </tr>
209
+ <tr>
210
+ <td class="labelpg1"><?=$this->__('Select country')?></td>
211
+ <td class="input-ele">
212
+ <select name="mailupCountry" class="slctpg1">
213
+
214
+ <?php
215
+
216
+ $countries = Mage::getResourceModel('directory/country_collection')
217
+ ->loadData()
218
+ ->toOptionArray(false);
219
+
220
+ if($mailupCountry) {
221
+
222
+ foreach ($countries as $country){
223
+ if ($country['value'] == $mailupCountry)
224
+ echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
225
+ }
226
+
227
+ }
228
+ ?>
229
+
230
+ <option value="0">-- <?=$this->__('Any')?> --</option>
231
+
232
+ <?php
233
+ foreach ($countries as $country){
234
+ echo '<option value="'.$country['value'].'">'.$country['label'].'</option>';
235
+ }
236
+ ?>
237
+ </select>
238
+ </td>
239
+ </tr>
240
+ <tr>
241
+ <td class="labelpg1"><?=$this->__('Zip code')?></td>
242
+ <td class="input-ele">
243
+ <input type="text" class="inptptx1" name="mailupPostCode" size="10" value="<?php echo $mailupPostCode; ?>" />
244
+ </td>
245
+ </tr>
246
+
247
+ <tr>
248
+ <td colspan="2">
249
+ <strong><br /><br />
250
+ <?=$this->__('Subscritpion date')?>
251
+ </strong></td>
252
+ </tr>
253
+ <tr>
254
+ <td class="labelpg1"><?=$this->__('From')?></td>
255
+ <td class="input-ele">
256
+ <input type="text" class="inptptx1" name="mailupCustomerStartDate" size="20" value="<?php echo $mailupCustomerStartDate; ?>" /> (dd/mm/yyyy)
257
+ </td>
258
+ </tr>
259
+ <tr>
260
+ <td class="labelpg1"><?=$this->__('To')?></td>
261
+ <td class="input-ele">
262
+ <input type="text" class="inptptx1" name="mailupCustomerEndDate" size="20" value="<?php echo $mailupCustomerEndDate; ?>" /> (dd/mm/yyyy)
263
+ </td>
264
+ </tr>
265
+
266
+ <tr>
267
+ <td colspan="2">
268
+ <strong><br /><br />
269
+ <?=$this->__('Total purchased amount')?>
270
+ </strong></td>
271
+ </tr>
272
+ <tr>
273
+ <td class="labelpg1"><?=$this->__('Order total')?></td>
274
+ <td class="input-ele">
275
+ <select id="mailupTotalAmountCond" name="mailupTotalAmountCond" class="slctpg2">
276
+
277
+ <?php
278
+ if ($mailupTotalAmountCond && $mailupTotalAmountCond != 'gt'){
279
+ if ($mailupTotalAmountCond == 'lt')
280
+ echo '<option value="lt"> '.$this->__('less than').' </option>';
281
+ elseif ($mailupTotalAmountCond == 'eq')
282
+ echo '<option value="eq"> '.$this->__('same as').' </option>';
283
+ }
284
+ ?>
285
+ <option value="gt"> <?=$this->__('more than')?> </option>
286
+ <option value="lt"> <?=$this->__('less than')?> </option>
287
+ <option value="eq"> <?=$this->__('same as')?> </option>
288
+ </select>
289
+ <label for="mailupTotalAmountValue" class="lbl1"><?=$this->__('Specify amount')?></label>
290
+ <input type="text" class="inptptx1" id="mailupTotalAmountValue" name="mailupTotalAmountValue" size="20" value="<?php echo $mailupTotalAmountValue; ?>" />
291
+ </td>
292
+ </tr>
293
+
294
+ <tr>
295
+ <td colspan="2">
296
+ <strong><br /><br />
297
+ <?=$this->__('Date of purchase')?>
298
+ </strong></td>
299
+ </tr>
300
+
301
+ <tr>
302
+ <td><?=$this->__('Show customers who'); ?></td>
303
+ <td>
304
+ <select name="mailupOrderYesNo" class="slctpg2">
305
+ <?php
306
+ if ($mailupOrderYesNo == 'no'){
307
+ echo '<option value="no">'.$this->__("Haven't purchased").'</option>';
308
+ }
309
+ ?>
310
+ <option value="yes"> <?=$this->__('Have purchased'); ?> </option>
311
+ <option value="no"> <?=$this->__("Haven't purchased"); ?> </option>
312
+ </select>
313
+ </td>
314
+ </tr>
315
+ <tr>
316
+ <td colspan="2"><?=$this->__('In this period'); ?>:</td>
317
+ </tr>
318
+
319
+ <tr>
320
+ <td class="labelpg1"><?=$this->__('From')?></td>
321
+ <td class="input-ele">
322
+ <input type="text" class="inptptx1" name="mailupOrderStartDate" size="20" value="<?php echo $mailupOrderStartDate; ?>" /> (dd/mm/yyyy)
323
+ </td>
324
+ </tr>
325
+ <tr>
326
+ <td class="labelpg1"><?=$this->__('To')?></td>
327
+ <td class="input-ele">
328
+ <input type="text" class="inptptx1" name="mailupOrderEndDate" size="20" value="<?php echo $mailupOrderEndDate; ?>" /> (dd/mm/yyyy)
329
+ </td>
330
+ </tr>
331
+
332
+ </table>
333
+ </fieldset>
334
+ </form>
335
+
336
+ <!-- Secondo blocco -->
337
+ <h4><span id="spantitle1"><a name="ottsugg"><?=$this->__('Filter hints')?></a></span></h4>
338
+ <fieldset id="my-fieldset">
339
+ <table cellspacing="0" class="form-list">
340
+ <tr>
341
+ <td><?=$this->__('Set and customize one of the following filters:')?></td>
342
+ </tr>
343
+ <tr>
344
+ <td>
345
+ <form action="*/*/" id="filtro1" name="filtro1" method="post">
346
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
347
+ <input name="mailupCustomers" type="hidden" value="2" />
348
+ <input name="mailupCustomerGroupId" type="hidden" value="2" />
349
+ <p class="parscefil"><?=$this->__("All wholesale customers who haven't purchased yet")?> &raquo;</p>
350
+ <input type="submit" value="<?=$this->__('Set filter')?>" />
351
+ <!--<<button onclick="filtro1.submit()" class="scalable save" type="button"><span><?=$this->__('Set filter')?></span></button>
352
+ input type="submit" value="Imposta filtro" />-->
353
+ </form>
354
+ </td>
355
+ </tr>
356
+ <tr>
357
+ <td>
358
+ <form action="*/*/" id="filtro2" name="filtro2" method="post">
359
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
360
+ <input name="mailupCustomers" type="hidden" value="1" />
361
+ <input name="mailupTotalAmountCond" type="hidden" value="gt" />
362
+ <input name="mailupTotalAmountValue" type="hidden" value="50" />
363
+ <p class="parscefil"><?=$this->__('More than 50 Euros orders')?> &raquo;</p>
364
+ <input type="submit" value="<?=$this->__('Set filter')?>" />
365
+ <!-- <button onclick="filtro2.submit()" class="scalable save" type="button"><span><?=$this->__('Set filter')?></span></button>
366
+ <input type="submit" value="Imposta filtro" /> -->
367
+ </form>
368
+ </td>
369
+ </tr>
370
+ <tr>
371
+ <td>
372
+ <form action="*/*/" id="filtro3" name="filtro2" method="post">
373
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
374
+ <input name="mailupCustomers" type="hidden" value="0" />
375
+ <input name="mailupOrderYesNo" type="hidden" value="no" />
376
+ <input name="mailupOrderStartDate" type="hidden" value="01/01/<?php echo date('Y'); ?>" />
377
+ <p class="parscefil"><?=$this->__('Members with no purchase in')?> <?php echo date('Y'); ?> &raquo;</p>
378
+ <input type="submit" value="<?=$this->__('Set filter')?>" />
379
+ <!-- <button onclick="filtro3.submit()" class="scalable save" type="button"><span><?=$this->__('Set filter')?></span></button>
380
+ <input type="submit" value="Imposta filtro" /> -->
381
+ </form>
382
+ </td>
383
+ </tr>
384
+ </table>
385
+ </fieldset>
386
+ </div>
387
+ <script type="text/javascript">
388
+ var editForm = new varienForm('edit_form');
389
+ </script>
390
+ <script type="text/javascript">
391
+ function makeDisable($ID1,$ID2,$ID3,$ID4){
392
+ var x=document.getElementById($ID1)
393
+ var y=document.getElementById($ID2)
394
+ var z=document.getElementById($ID3)
395
+ var t=document.getElementById($ID4)
396
+ x.disabled=true
397
+ y.disabled=true
398
+ z.disabled=true
399
+ t.disabled=true
400
+ }
401
+ function makeEnable($ID1,$ID2,$ID3,$ID4){
402
+ var x=document.getElementById($ID1)
403
+ var y=document.getElementById($ID2)
404
+ var z=document.getElementById($ID3)
405
+ var t=document.getElementById($ID4)
406
+ x.disabled=false
407
+ y.disabled=false
408
+ z.disabled=false
409
+ t.disabled=false
410
+ }
411
+ </script>
412
+ <?php } ?>
app/etc/modules/SevenLike_MailUp.xml ADDED
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SevenLike_MailUp>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Newsletter />
9
+ </depends>
10
+ </SevenLike_MailUp>
11
+ </modules>
12
+ </config>
app/locale/en_US/SevenLike_MailUp.csv ADDED
@@ -0,0 +1,58 @@
1
+ "Members have not been sent correctly","Members have not been sent correctly"
2
+ "Warning: no member has been selected","Warning: no member has been selected"
3
+ "WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp","WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp"
4
+ "Apply filter","Apply filter"
5
+ "Get hints","Get hints"
6
+ "Sold products","Sold products"
7
+ "All customers","All customers"
8
+ "Customers who have purchased","Customers who have purchased"
9
+ "Customers who haven't purchased yet","Customers who haven't purchased yet"
10
+ "Select product","Select product"
11
+ "Any","Any"
12
+ "Select category","Select category"
13
+ "Groups","Groups"
14
+ "Select customer group","Select customer group"
15
+ "Country","Country"
16
+ "Select country","Select country"
17
+ "Zip code","Zip code"
18
+ "Subscritpion date","Subscritpion date"
19
+ "From","From"
20
+ "To","To"
21
+ "Total purchased amount","Total purchased amount"
22
+ "Order total","Order total"
23
+ "less than","less than"
24
+ "same as","same as"
25
+ "more than","more than"
26
+ "Specify amount","Specify amount"
27
+ "Date of purchase","Date of purchase"
28
+ "Show customers who","Show customers who"
29
+ "Haven't purchased","Haven't purchased"
30
+ "Have purchased","Have purchased"
31
+ "In this period","In this period"
32
+ "Filter hints","Filter hints"
33
+ "All wholesale customers who haven't purchased yet","All wholesale customers who haven't purchased yet"
34
+ "Set filter","Set filter"
35
+ "More than 50 Euros orders","More than 50 Euros orders"
36
+ "Members with no purchase in","Members with no purchase in"
37
+ "Reset filters","Reset filters"
38
+ "Export to CSV","Export to CSV"
39
+ "Send to MailUp","Send to MailUp"
40
+ "Confirm filtered customers and select MailUp group","Confirm filtered customers and select MailUp group"
41
+ "Were found","Were found"
42
+ "records","records"
43
+ "Filtered customers","Filtered customers"
44
+ "Selected list","Selected list"
45
+ "Next step","Next step"
46
+ "Select group","Select group"
47
+ "Select an existing group","Select an existing group"
48
+ "or","or"
49
+ "Create new customer group","Create new customer group"
50
+ "Group name","Group name"
51
+ "Add a new e-mail address or select adresses to be removed from list","Add a new e-mail address or select adresses to be removed from list"
52
+ "Change members list: please add one email adress per row","Change members list: please add one email address per row"
53
+ "Save changes","Save changes"
54
+ "By this plugin you can import contacts registered in your eCommerce to the MailUp platform.","By this plugin you can