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.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.3.1 to 2.4.1
- app/code/local/SevenLike/MailUp/Block/Adminhtml/Log.php +19 -0
- app/code/local/SevenLike/MailUp/Block/Adminhtml/Log/Grid.php +160 -0
- app/code/local/SevenLike/MailUp/Block/Adminhtml/Mailup/Grid.php +247 -0
- app/code/local/SevenLike/MailUp/Block/Adminhtml/Mailupbackend.php +19 -0
- app/code/local/SevenLike/MailUp/Block/Adminhtml/Sync.php +19 -0
- app/code/local/SevenLike/MailUp/Block/Adminhtml/Sync/Grid.php +181 -0
- app/code/local/SevenLike/MailUp/Block/Checkout/Subscribe.php +4 -2
- app/code/local/SevenLike/MailUp/Block/Index.php +11 -0
- app/code/local/SevenLike/MailUp/Helper/Data.php +567 -239
- app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Fields.php +0 -6
- app/code/local/SevenLike/MailUp/Model/Config.php +87 -0
- app/code/local/SevenLike/MailUp/Model/Cron.php +140 -89
- app/code/local/SevenLike/MailUp/Model/Job.php +188 -0
- app/code/local/SevenLike/MailUp/Model/Lists.php +136 -12
- app/code/local/SevenLike/MailUp/Model/Log.php +20 -0
- app/code/local/SevenLike/MailUp/Model/MailUpWsImport.php +267 -129
- app/code/local/SevenLike/MailUp/Model/Mysql14/Job.php +30 -0
- app/code/local/SevenLike/MailUp/Model/Mysql14/Job/Collection.php +11 -0
- app/code/local/SevenLike/MailUp/Model/Mysql4/Job.php +30 -0
- app/code/local/SevenLike/MailUp/Model/Mysql4/Job/Collection.php +11 -0
- app/code/local/SevenLike/MailUp/Model/Mysql4/Log.php +25 -0
- app/code/local/SevenLike/MailUp/Model/Mysql4/Log/Collection.php +11 -0
- app/code/local/SevenLike/MailUp/Model/Mysql4/Sync.php +70 -0
- app/code/local/SevenLike/MailUp/Model/Mysql4/Sync/Collection.php +11 -0
- app/code/local/SevenLike/MailUp/Model/Observer.php +133 -32
- app/code/local/SevenLike/MailUp/Model/Source/Store.php +59 -0
- app/code/local/SevenLike/MailUp/Model/Sync.php +125 -0
- app/code/local/SevenLike/MailUp/Model/Wssend.php +94 -37
- app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php +287 -98
- app/code/local/SevenLike/MailUp/controllers/Adminhtml/LogController.php +16 -0
- app/code/local/SevenLike/MailUp/controllers/Adminhtml/MailupbackendController.php +220 -0
- app/code/local/SevenLike/MailUp/controllers/Adminhtml/SyncController.php +37 -0
- app/code/local/SevenLike/MailUp/controllers/IndexController.php +17 -27
- app/code/local/SevenLike/MailUp/controllers/TestController.php +177 -0
- app/code/local/SevenLike/MailUp/etc/config.xml +98 -54
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-2.3.0.php +13 -9
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-2.4.0.php +69 -0
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.0-2.3.1.php +2 -1
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.1-2.3.2.php +39 -0
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.2-2.4.0.php +69 -0
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.4.0-2.4.1.php +34 -0
- app/design/adminhtml/default/default/layout/mailup.xml +20 -0
- app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml +7 -2
- app/design/adminhtml/default/default/template/sevenlike/mailup/filter_.phtml +526 -526
- app/design/frontend/base/default/layout/mailup.xml +12 -0
- app/design/frontend/base/default/template/mailup/index.phtml +0 -0
- app/design/frontend/base/default/template/mailup/subscribe.phtml +0 -1
- app/etc/modules/SevenLike_MailUp.xml +1 -12
- package.xml +4 -4
- skin/adminhtml/default/default/sevenlike/mailup/mailup.css +1 -1
app/code/local/SevenLike/MailUp/Block/Adminhtml/Log.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Log.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
|
6 |
+
{
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
$this->_controller = 'adminhtml_log';
|
10 |
+
$this->_blockGroup = 'mailup';
|
11 |
+
|
12 |
+
$this->_headerText = Mage::helper('mailup')->__('MailUp Logs');
|
13 |
+
//$this->_addButtonLabel = Mage::helper('mailup')->__('Add Item');
|
14 |
+
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$this->_removeButton('add');
|
18 |
+
}
|
19 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Adminhtml/Log/Grid.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Grid.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Constructor
|
9 |
+
*/
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('MailUpLogGrid');
|
14 |
+
$this->setDefaultSort('id');
|
15 |
+
$this->setDefaultDir('ASC');
|
16 |
+
$this->setSaveParametersInSession(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Prepare Collection
|
21 |
+
*
|
22 |
+
* @return
|
23 |
+
*/
|
24 |
+
protected function _prepareCollection()
|
25 |
+
{
|
26 |
+
$collection = Mage::getModel('mailup/log')->getCollection();
|
27 |
+
$this->setCollection($collection);
|
28 |
+
|
29 |
+
//var_dump(Mage::getModel('mailup/job')->load(1));
|
30 |
+
|
31 |
+
return parent::_prepareCollection();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Prepare Grid Columns
|
36 |
+
*/
|
37 |
+
protected function _prepareColumns()
|
38 |
+
{
|
39 |
+
$this->addColumn('id', array(
|
40 |
+
'header' => Mage::helper('mailup')->__('ID'),
|
41 |
+
//'align' =>'right',
|
42 |
+
'width' => '80px',
|
43 |
+
'index' => 'id',
|
44 |
+
));
|
45 |
+
|
46 |
+
$this->addColumn('store_id', array(
|
47 |
+
'header' => Mage::helper('mailup')->__('Store'),
|
48 |
+
'align' => 'left',
|
49 |
+
//'width' => '150px',
|
50 |
+
'index' => 'store_id',
|
51 |
+
'type' => 'options',
|
52 |
+
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
|
53 |
+
));
|
54 |
+
|
55 |
+
$this->addColumn('type', array(
|
56 |
+
'header' => Mage::helper('mailup')->__('Type'),
|
57 |
+
//'align' =>'right',
|
58 |
+
//'width' => '80px',
|
59 |
+
'index' => 'type',
|
60 |
+
));
|
61 |
+
|
62 |
+
$this->addColumn('job_id', array(
|
63 |
+
'header' => Mage::helper('mailup')->__('Job ID'),
|
64 |
+
//'align' =>'right',
|
65 |
+
'width' => '80px',
|
66 |
+
'index' => 'job_id',
|
67 |
+
));
|
68 |
+
|
69 |
+
// Not really in use yet!
|
70 |
+
/*$this->addColumn('status', array(
|
71 |
+
'header' => Mage::helper('mailup')->__('Status'),
|
72 |
+
//'align' =>'right',
|
73 |
+
//'width' => '80px',
|
74 |
+
'index' => 'status',
|
75 |
+
));*/
|
76 |
+
|
77 |
+
$this->addColumn('data', array(
|
78 |
+
'header' => Mage::helper('mailup')->__('Info'),
|
79 |
+
//'align' =>'right',
|
80 |
+
//'width' => '80px',
|
81 |
+
'index' => 'data',
|
82 |
+
));
|
83 |
+
|
84 |
+
$this->addColumn('event_time', array(
|
85 |
+
'header' => Mage::helper('mailup')->__('Event Time'),
|
86 |
+
'type' => 'datetime', // Add in Date Picker
|
87 |
+
//'type' => 'timestamp',
|
88 |
+
//'align' => 'center',
|
89 |
+
'width' => '180px',
|
90 |
+
'index' => 'event_time',
|
91 |
+
//'gmtoffset' => true
|
92 |
+
));
|
93 |
+
|
94 |
+
//
|
95 |
+
//
|
96 |
+
// $this->addColumn('status', array(
|
97 |
+
// 'header' => Mage::helper('importer')->__('Status'),
|
98 |
+
// 'align' => 'left',
|
99 |
+
// 'width' => '80px',
|
100 |
+
// 'index' => 'status',
|
101 |
+
// 'type' => 'options',
|
102 |
+
// 'options' => array(
|
103 |
+
// 1 => 'Enabled',
|
104 |
+
// 2 => 'Disabled',
|
105 |
+
// ),
|
106 |
+
// ));
|
107 |
+
//
|
108 |
+
|
109 |
+
// $this->addColumn('action',
|
110 |
+
// array(
|
111 |
+
// 'header' => Mage::helper('mailup')->__('Action'),
|
112 |
+
// 'width' => '100',
|
113 |
+
// 'type' => 'action',
|
114 |
+
// 'getter' => 'getId',
|
115 |
+
// 'actions' => array(
|
116 |
+
// array(
|
117 |
+
// 'caption' => Mage::helper('mailup')->__('Sync'),
|
118 |
+
// 'url' => array('base'=> '*/*/sync'),
|
119 |
+
// 'field' => 'id'
|
120 |
+
// )
|
121 |
+
// ),
|
122 |
+
// 'filter' => false,
|
123 |
+
// 'sortable' => false,
|
124 |
+
// 'index' => 'stores',
|
125 |
+
// 'is_system' => true,
|
126 |
+
// ));
|
127 |
+
|
128 |
+
return parent::_prepareColumns();
|
129 |
+
}
|
130 |
+
|
131 |
+
// /**
|
132 |
+
// * Prepare Mass Action
|
133 |
+
// */
|
134 |
+
// protected function _prepareMassaction()
|
135 |
+
// {
|
136 |
+
// $this->setMassactionIdField('id');
|
137 |
+
// $this->getMassactionBlock()->setFormFieldName('importer');
|
138 |
+
//
|
139 |
+
// $this->getMassactionBlock()->addItem('delete', array(
|
140 |
+
// 'label' => Mage::helper('importer')->__('Delete'),
|
141 |
+
// 'url' => $this->getUrl('*/*/massDelete'),
|
142 |
+
// 'confirm' => Mage::helper('importer')->__('Are you sure?')
|
143 |
+
// ));
|
144 |
+
//
|
145 |
+
// $statuses = Mage::getSingleton('importer/import')->getOptionArray();
|
146 |
+
// array_unshift($statuses, array('label'=>'', 'value'=>''));
|
147 |
+
//
|
148 |
+
// return $this;
|
149 |
+
// }
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Get row url - None editable
|
153 |
+
*/
|
154 |
+
public function getRowUrl($row)
|
155 |
+
{
|
156 |
+
return '';
|
157 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Adminhtml/Mailup/Grid.php
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Grid.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Constructor
|
9 |
+
*/
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('MailUpGrid');
|
14 |
+
$this->setDefaultSort('id');
|
15 |
+
$this->setDefaultDir('ASC');
|
16 |
+
$this->setSaveParametersInSession(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Prepare Collection
|
21 |
+
*
|
22 |
+
* @return
|
23 |
+
*/
|
24 |
+
protected function _prepareCollection()
|
25 |
+
{
|
26 |
+
$collection = Mage::getModel('mailup/job')->getCollection();
|
27 |
+
$this->setCollection($collection);
|
28 |
+
|
29 |
+
//var_dump(Mage::getModel('mailup/job')->load(1));
|
30 |
+
|
31 |
+
return parent::_prepareCollection();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Prepare Grid Columns
|
36 |
+
*/
|
37 |
+
protected function _prepareColumns()
|
38 |
+
{
|
39 |
+
$this->addColumn('id', array(
|
40 |
+
'header' => Mage::helper('mailup')->__('ID'),
|
41 |
+
//'align' =>'right',
|
42 |
+
'width' => '80px',
|
43 |
+
'index' => 'id',
|
44 |
+
));
|
45 |
+
|
46 |
+
$this->addColumn('type', array(
|
47 |
+
'header' => Mage::helper('mailup')->__('Type'),
|
48 |
+
'align' => 'left',
|
49 |
+
'index' => 'type',
|
50 |
+
'type' => 'options',
|
51 |
+
'options' => array(
|
52 |
+
0 => 'Manual Sync',
|
53 |
+
1 => 'Auto Sync',
|
54 |
+
//2 => 'Disabled',
|
55 |
+
),
|
56 |
+
));
|
57 |
+
|
58 |
+
$this->addColumn('store_id', array(
|
59 |
+
'header' => Mage::helper('mailup')->__('Store'),
|
60 |
+
'align' => 'left',
|
61 |
+
//'width' => '150px',
|
62 |
+
'index' => 'store_id',
|
63 |
+
'type' => 'options',
|
64 |
+
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
|
65 |
+
));
|
66 |
+
|
67 |
+
/*$this->addColumn('store_id', array(
|
68 |
+
'header' => Mage::helper('mailup')->__('Store ID'),
|
69 |
+
//'align' =>'right',
|
70 |
+
'width' => '80px',
|
71 |
+
'index' => 'store_id',
|
72 |
+
));*/
|
73 |
+
|
74 |
+
$this->addColumn('mailupgroupid', array(
|
75 |
+
'header' => Mage::helper('mailup')->__('Mailup Group ID'),
|
76 |
+
//'align' =>'right',
|
77 |
+
'width' => '80px',
|
78 |
+
'index' => 'mailupgroupid',
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('list_id', array(
|
82 |
+
'header' => Mage::helper('mailup')->__('Mailup List ID'),
|
83 |
+
//'align' =>'right',
|
84 |
+
'width' => '80px',
|
85 |
+
'index' => 'list_id',
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('list_guid', array(
|
89 |
+
'header' => Mage::helper('mailup')->__('Mailup List GUID'),
|
90 |
+
'index' => 'list_guid',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('send_optin', array(
|
94 |
+
'header' => Mage::helper('mailup')->__('Opt In'),
|
95 |
+
'align' => 'left',
|
96 |
+
'index' => 'send_optin',
|
97 |
+
'type' => 'options',
|
98 |
+
'options' => array(
|
99 |
+
0 => 'No',
|
100 |
+
1 => 'Yes',
|
101 |
+
),
|
102 |
+
));
|
103 |
+
|
104 |
+
$this->addColumn('as_pending', array(
|
105 |
+
'header' => Mage::helper('mailup')->__('As Pending'),
|
106 |
+
'align' => 'left',
|
107 |
+
'index' => 'as_pending',
|
108 |
+
'type' => 'options',
|
109 |
+
'options' => array(
|
110 |
+
0 => 'No',
|
111 |
+
1 => 'Yes',
|
112 |
+
),
|
113 |
+
));
|
114 |
+
|
115 |
+
$this->addColumn('status', array(
|
116 |
+
'header' => Mage::helper('mailup')->__('Status'),
|
117 |
+
//'align' =>'right',
|
118 |
+
'index' => 'status',
|
119 |
+
));
|
120 |
+
|
121 |
+
$this->addColumn('process_id', array(
|
122 |
+
'header' => Mage::helper('mailup')->__('Process ID'),
|
123 |
+
//'align' =>'right',
|
124 |
+
'width' => '80px',
|
125 |
+
'index' => 'process_id',
|
126 |
+
));
|
127 |
+
|
128 |
+
$this->addColumn('tries', array(
|
129 |
+
'header' => Mage::helper('mailup')->__('Tries'),
|
130 |
+
//'align' =>'right',
|
131 |
+
'width' => '50px',
|
132 |
+
'index' => 'tries',
|
133 |
+
));
|
134 |
+
|
135 |
+
$this->addColumn('queue_datetime', array(
|
136 |
+
'header' => Mage::helper('mailup')->__('Queue Time'),
|
137 |
+
'type' => 'datetime', // Add in Date Picker
|
138 |
+
//'type' => 'timestamp',
|
139 |
+
//'align' => 'center',
|
140 |
+
'width' => '180px',
|
141 |
+
'index' => 'queue_datetime',
|
142 |
+
//'gmtoffset' => true
|
143 |
+
));
|
144 |
+
|
145 |
+
$this->addColumn('start_datetime', array(
|
146 |
+
'header' => Mage::helper('mailup')->__('Started'),
|
147 |
+
'type' => 'datetime', // Add in Date Picker
|
148 |
+
//'type' => 'timestamp',
|
149 |
+
//'align' => 'center',
|
150 |
+
'width' => '180px',
|
151 |
+
'index' => 'start_datetime',
|
152 |
+
//'gmtoffset' => true
|
153 |
+
));
|
154 |
+
|
155 |
+
$this->addColumn('finish_datetime', array(
|
156 |
+
'header' => Mage::helper('mailup')->__('Finished'),
|
157 |
+
'type' => 'datetime', // Add in Date Picker
|
158 |
+
//'type' => 'timestamp',
|
159 |
+
//'align' => 'center',
|
160 |
+
'width' => '180px',
|
161 |
+
'index' => 'finish_datetime',
|
162 |
+
//'gmtoffset' => true
|
163 |
+
));
|
164 |
+
|
165 |
+
//
|
166 |
+
//
|
167 |
+
// $this->addColumn('status', array(
|
168 |
+
// 'header' => Mage::helper('importer')->__('Status'),
|
169 |
+
// 'align' => 'left',
|
170 |
+
// 'width' => '80px',
|
171 |
+
// 'index' => 'status',
|
172 |
+
// 'type' => 'options',
|
173 |
+
// 'options' => array(
|
174 |
+
// 1 => 'Enabled',
|
175 |
+
// 2 => 'Disabled',
|
176 |
+
// ),
|
177 |
+
// ));
|
178 |
+
//
|
179 |
+
|
180 |
+
$this->addColumn('action',
|
181 |
+
array(
|
182 |
+
'header' => Mage::helper('mailup')->__('Action'),
|
183 |
+
'width' => '100',
|
184 |
+
'type' => 'action',
|
185 |
+
'getter' => 'getId',
|
186 |
+
'actions' => array(
|
187 |
+
array(
|
188 |
+
'caption' => Mage::helper('mailup')->__('Run'),
|
189 |
+
'url' => array('base'=> '*/*/runjob'),
|
190 |
+
'field' => 'id'
|
191 |
+
),
|
192 |
+
array(
|
193 |
+
'caption' => Mage::helper('mailup')->__('StartProcess'),
|
194 |
+
'url' => array('base'=> '*/*/startProcess'),
|
195 |
+
'field' => 'id'
|
196 |
+
),
|
197 |
+
array(
|
198 |
+
'caption' => Mage::helper('mailup')->__('GetProcessDetail'),
|
199 |
+
'url' => array('base'=> '*/*/getProcessDetail'),
|
200 |
+
'field' => 'id'
|
201 |
+
),
|
202 |
+
array(
|
203 |
+
'caption' => Mage::helper('mailup')->__('Delete'),
|
204 |
+
'url' => array('base'=> '*/*/delete'),
|
205 |
+
'field' => 'id'
|
206 |
+
),
|
207 |
+
),
|
208 |
+
'filter' => false,
|
209 |
+
'sortable' => false,
|
210 |
+
'index' => 'stores',
|
211 |
+
'is_system' => true,
|
212 |
+
));
|
213 |
+
|
214 |
+
|
215 |
+
return parent::_prepareColumns();
|
216 |
+
}
|
217 |
+
|
218 |
+
// /**
|
219 |
+
// * Prepare Mass Action
|
220 |
+
// */
|
221 |
+
// protected function _prepareMassaction()
|
222 |
+
// {
|
223 |
+
// $this->setMassactionIdField('id');
|
224 |
+
// $this->getMassactionBlock()->setFormFieldName('importer');
|
225 |
+
//
|
226 |
+
// $this->getMassactionBlock()->addItem('delete', array(
|
227 |
+
// 'label' => Mage::helper('importer')->__('Delete'),
|
228 |
+
// 'url' => $this->getUrl('*/*/massDelete'),
|
229 |
+
// 'confirm' => Mage::helper('importer')->__('Are you sure?')
|
230 |
+
// ));
|
231 |
+
//
|
232 |
+
// $statuses = Mage::getSingleton('importer/import')->getOptionArray();
|
233 |
+
// array_unshift($statuses, array('label'=>'', 'value'=>''));
|
234 |
+
//
|
235 |
+
// return $this;
|
236 |
+
// }
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Get row url - None editable
|
240 |
+
*/
|
241 |
+
public function getRowUrl($row)
|
242 |
+
{
|
243 |
+
return '';
|
244 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
245 |
+
}
|
246 |
+
|
247 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Adminhtml/Mailupbackend.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mailupbackend.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Adminhtml_Mailupbackend extends Mage_Adminhtml_Block_Widget_Grid_Container
|
6 |
+
{
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
$this->_controller = 'adminhtml_mailup';
|
10 |
+
$this->_blockGroup = 'mailup';
|
11 |
+
|
12 |
+
$this->_headerText = Mage::helper('mailup')->__('MailUp Scheduled Tasks');
|
13 |
+
//$this->_addButtonLabel = Mage::helper('mailup')->__('Add Item');
|
14 |
+
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$this->_removeButton('add');
|
18 |
+
}
|
19 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Adminhtml/Sync.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sync.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_Widget_Grid_Container
|
6 |
+
{
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
$this->_controller = 'adminhtml_sync';
|
10 |
+
$this->_blockGroup = 'mailup';
|
11 |
+
|
12 |
+
$this->_headerText = Mage::helper('mailup')->__('MailUp Task Data');
|
13 |
+
//$this->_addButtonLabel = Mage::helper('mailup')->__('Add Item');
|
14 |
+
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$this->_removeButton('add');
|
18 |
+
}
|
19 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Adminhtml/Sync/Grid.php
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Grid.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Adminhtml_Sync_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Constructor
|
9 |
+
*/
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('MailUpSyncGrid');
|
14 |
+
$this->setDefaultSort('id');
|
15 |
+
$this->setDefaultDir('ASC');
|
16 |
+
$this->setSaveParametersInSession(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Prepare Collection
|
21 |
+
*
|
22 |
+
* @return
|
23 |
+
*/
|
24 |
+
protected function _prepareCollection()
|
25 |
+
{
|
26 |
+
$collection = Mage::getModel('mailup/sync')->getCollection();
|
27 |
+
$this->setCollection($collection);
|
28 |
+
|
29 |
+
//var_dump(Mage::getModel('mailup/job')->load(1));
|
30 |
+
|
31 |
+
return parent::_prepareCollection();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Prepare Grid Columns
|
36 |
+
*/
|
37 |
+
protected function _prepareColumns()
|
38 |
+
{
|
39 |
+
$this->addColumn('id', array(
|
40 |
+
'header' => Mage::helper('mailup')->__('ID'),
|
41 |
+
//'align' =>'right',
|
42 |
+
'width' => '80px',
|
43 |
+
'index' => 'id',
|
44 |
+
));
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
$this->addColumn('store_id', array(
|
49 |
+
'header' => Mage::helper('mailup')->__('Store'),
|
50 |
+
'align' => 'left',
|
51 |
+
//'width' => '150px',
|
52 |
+
'index' => 'store_id',
|
53 |
+
'type' => 'options',
|
54 |
+
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
|
55 |
+
));
|
56 |
+
|
57 |
+
/*$this->addColumn('store_id', array(
|
58 |
+
'header' => Mage::helper('mailup')->__('Store ID'),
|
59 |
+
//'align' =>'right',
|
60 |
+
'width' => '80px',
|
61 |
+
'index' => 'store_id',
|
62 |
+
));*/
|
63 |
+
|
64 |
+
$this->addColumn('customer_id', array(
|
65 |
+
'header' => Mage::helper('mailup')->__('Customer ID'),
|
66 |
+
//'align' =>'right',
|
67 |
+
'width' => '80px',
|
68 |
+
'index' => 'customer_id',
|
69 |
+
));
|
70 |
+
|
71 |
+
$this->addColumn('entity', array(
|
72 |
+
'header' => Mage::helper('mailup')->__('Entity'),
|
73 |
+
//'align' =>'right',
|
74 |
+
//'width' => '80px',
|
75 |
+
'index' => 'entity',
|
76 |
+
));
|
77 |
+
|
78 |
+
$this->addColumn('job_id', array(
|
79 |
+
'header' => Mage::helper('mailup')->__('Job ID'),
|
80 |
+
//'align' =>'right',
|
81 |
+
'width' => '80px',
|
82 |
+
'index' => 'job_id',
|
83 |
+
));
|
84 |
+
|
85 |
+
$this->addColumn('needs_sync', array(
|
86 |
+
'header' => Mage::helper('mailup')->__('Needs Sync'),
|
87 |
+
'align' => 'left',
|
88 |
+
'index' => 'needs_sync',
|
89 |
+
'type' => 'options',
|
90 |
+
'options' => array(
|
91 |
+
0 => 'No',
|
92 |
+
1 => 'Yes',
|
93 |
+
),
|
94 |
+
));
|
95 |
+
|
96 |
+
$this->addColumn('created', array(
|
97 |
+
'header' => Mage::helper('mailup')->__('Created'),
|
98 |
+
'type' => 'timestamp',
|
99 |
+
//'align' => 'center',
|
100 |
+
'width' => '180px',
|
101 |
+
'index' => 'created',
|
102 |
+
//'gmtoffset' => true
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->addColumn('last_sync', array(
|
106 |
+
'header' => Mage::helper('mailup')->__('Last Sync Time'),
|
107 |
+
'type' => 'datetime', // Add in Date Picker
|
108 |
+
//'type' => 'timestamp',
|
109 |
+
//'align' => 'center',
|
110 |
+
'width' => '180px',
|
111 |
+
'index' => 'last_sync',
|
112 |
+
//'gmtoffset' => true
|
113 |
+
));
|
114 |
+
|
115 |
+
//
|
116 |
+
//
|
117 |
+
// $this->addColumn('status', array(
|
118 |
+
// 'header' => Mage::helper('importer')->__('Status'),
|
119 |
+
// 'align' => 'left',
|
120 |
+
// 'width' => '80px',
|
121 |
+
// 'index' => 'status',
|
122 |
+
// 'type' => 'options',
|
123 |
+
// 'options' => array(
|
124 |
+
// 1 => 'Enabled',
|
125 |
+
// 2 => 'Disabled',
|
126 |
+
// ),
|
127 |
+
// ));
|
128 |
+
//
|
129 |
+
|
130 |
+
// $this->addColumn('action',
|
131 |
+
// array(
|
132 |
+
// 'header' => Mage::helper('mailup')->__('Action'),
|
133 |
+
// 'width' => '100',
|
134 |
+
// 'type' => 'action',
|
135 |
+
// 'getter' => 'getId',
|
136 |
+
// 'actions' => array(
|
137 |
+
// array(
|
138 |
+
// 'caption' => Mage::helper('mailup')->__('Sync'),
|
139 |
+
// 'url' => array('base'=> '*/*/sync'),
|
140 |
+
// 'field' => 'id'
|
141 |
+
// )
|
142 |
+
// ),
|
143 |
+
// 'filter' => false,
|
144 |
+
// 'sortable' => false,
|
145 |
+
// 'index' => 'stores',
|
146 |
+
// 'is_system' => true,
|
147 |
+
// ));
|
148 |
+
|
149 |
+
return parent::_prepareColumns();
|
150 |
+
}
|
151 |
+
|
152 |
+
// /**
|
153 |
+
// * Prepare Mass Action
|
154 |
+
// */
|
155 |
+
// protected function _prepareMassaction()
|
156 |
+
// {
|
157 |
+
// $this->setMassactionIdField('id');
|
158 |
+
// $this->getMassactionBlock()->setFormFieldName('importer');
|
159 |
+
//
|
160 |
+
// $this->getMassactionBlock()->addItem('delete', array(
|
161 |
+
// 'label' => Mage::helper('importer')->__('Delete'),
|
162 |
+
// 'url' => $this->getUrl('*/*/massDelete'),
|
163 |
+
// 'confirm' => Mage::helper('importer')->__('Are you sure?')
|
164 |
+
// ));
|
165 |
+
//
|
166 |
+
// $statuses = Mage::getSingleton('importer/import')->getOptionArray();
|
167 |
+
// array_unshift($statuses, array('label'=>'', 'value'=>''));
|
168 |
+
//
|
169 |
+
// return $this;
|
170 |
+
// }
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Get row url - None editable
|
174 |
+
*/
|
175 |
+
public function getRowUrl($row)
|
176 |
+
{
|
177 |
+
return '';
|
178 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
179 |
+
}
|
180 |
+
|
181 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Checkout/Subscribe.php
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
3 |
class SevenLike_MailUp_Block_Checkout_Subscribe extends Mage_Core_Block_Template
|
4 |
{
|
5 |
public function _toHtml()
|
6 |
{
|
7 |
return parent::_toHtml();
|
8 |
}
|
9 |
-
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Subscribe.php
|
4 |
+
*/
|
5 |
class SevenLike_MailUp_Block_Checkout_Subscribe extends Mage_Core_Block_Template
|
6 |
{
|
7 |
public function _toHtml()
|
8 |
{
|
9 |
return parent::_toHtml();
|
10 |
}
|
11 |
+
}
|
app/code/local/SevenLike/MailUp/Block/Index.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Index.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Block_Index extends Mage_Core_Block_Template
|
6 |
+
{
|
7 |
+
public function _toHtml()
|
8 |
+
{
|
9 |
+
return parent::_toHtml();
|
10 |
+
}
|
11 |
+
}
|
app/code/local/SevenLike/MailUp/Helper/Data.php
CHANGED
@@ -1,19 +1,34 @@
|
|
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 |
-
|
12 |
}
|
13 |
|
14 |
if(is_array($customerCollection) && empty($customerCollection)) {
|
15 |
if ($config->isLogEnabled()) {
|
16 |
-
|
17 |
}
|
18 |
}
|
19 |
|
@@ -31,7 +46,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
31 |
$customerCollection = Mage::getModel('customer/customer')->getCollection();
|
32 |
$parseSubscribers = true;
|
33 |
if ($config->isLogEnabled()) {
|
34 |
-
|
35 |
}
|
36 |
}
|
37 |
foreach ($customerCollection as $currentCustomerId) {
|
@@ -41,15 +56,16 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
41 |
|
42 |
if( ! $currentCustomerId) {
|
43 |
if($config->isLogEnabled()) {
|
44 |
-
|
45 |
continue;
|
46 |
}
|
47 |
}
|
48 |
|
49 |
if($config->isLogEnabled()) {
|
50 |
-
|
51 |
}
|
52 |
$customer = Mage::getModel('customer/customer')->load($currentCustomerId);
|
|
|
53 |
$i = $customer->getEmail();
|
54 |
|
55 |
//recupero gli ordini del cliente corrente
|
@@ -64,7 +80,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
64 |
$lastShipmentOrderDate = null;
|
65 |
|
66 |
if($config->isLogEnabled()) {
|
67 |
-
|
68 |
}
|
69 |
$orders = Mage::getModel('sales/order')
|
70 |
->getCollection()
|
@@ -72,7 +88,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
72 |
;
|
73 |
foreach($orders as $order) {
|
74 |
if($config->isLogEnabled()) {
|
75 |
-
|
76 |
}
|
77 |
if( ! in_array($order->getStatus(), array("closed", "complete", "processing"))) {
|
78 |
continue;
|
@@ -83,14 +99,12 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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;
|
@@ -117,7 +131,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
117 |
|
118 |
//recupero i carrelli abbandonati del cliente
|
119 |
if($config->isLogEnabled()) {
|
120 |
-
|
121 |
}
|
122 |
$cartCollection = Mage::getResourceModel('reports/quote_collection');
|
123 |
$cartCollection->prepareForAbandonedReport($config->getAllStoreIds());
|
@@ -132,8 +146,8 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
132 |
$toSend[$i]['IDCarrelloAbbandonato'] = '';
|
133 |
|
134 |
if ( ! empty($lastCart)) {
|
135 |
-
if (
|
136 |
-
|
137 |
}
|
138 |
$datetimeCart = $lastCart->getUpdatedAt();
|
139 |
//$toSend[$i]['TotaleCarrelloAbbandonato'] = self::_formatPrice($lastCart->getGrandTotal());
|
@@ -143,13 +157,13 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
143 |
}
|
144 |
else {
|
145 |
if ($config->isLogEnabled()) {
|
146 |
-
|
147 |
}
|
148 |
}
|
149 |
}
|
150 |
else {
|
151 |
if ($config->isLogEnabled()) {
|
152 |
-
|
153 |
}
|
154 |
}
|
155 |
|
@@ -163,7 +177,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
163 |
|| ($datetimeCart && $datetimeCart > $lastDateTime))
|
164 |
{
|
165 |
if ($config->isLogEnabled()) {
|
166 |
-
|
167 |
}
|
168 |
|
169 |
$toSend[$i]['nome'] = $customer->getFirstname();
|
@@ -198,6 +212,17 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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);
|
@@ -220,10 +245,17 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
220 |
}
|
221 |
|
222 |
$toSend[$i]['IDProdottiUltimoOrdine'] = implode(',', $productIds);
|
223 |
-
if ($toSend[$i]['IDProdottiUltimoOrdine'])
|
|
|
|
|
224 |
$toSend[$i]['IDCategorieUltimoOrdine'] = implode(',', $categoryIds);
|
225 |
-
if ($toSend[$i]['IDCategorieUltimoOrdine'])
|
|
|
|
|
226 |
}
|
|
|
|
|
|
|
227 |
|
228 |
//unsetto la variabile
|
229 |
unset($customer);
|
@@ -252,22 +284,21 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
252 |
*/
|
253 |
|
254 |
if($config->isLogEnabled()) {
|
255 |
-
|
256 |
}
|
257 |
|
258 |
return $toSend;
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
-
*
|
263 |
*
|
264 |
-
* @param
|
265 |
-
* @param
|
266 |
-
* @param type $newsletter_subscribers
|
267 |
* @param int
|
268 |
-
* @return
|
269 |
*/
|
270 |
-
public static function generateAndSendCustomers($mailupCustomerIds, $post = null, $
|
271 |
{
|
272 |
$config = Mage::getModel('mailup/config');
|
273 |
/* @var $config SevenLike_Mailup_Model_Config */
|
@@ -279,57 +310,20 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
279 |
|
280 |
if (empty($mailupCustomerIds)) {
|
281 |
if($config->isLogEnabled($storeId)) {
|
282 |
-
|
283 |
}
|
284 |
-
return
|
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 |
-
|
295 |
-
|
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 |
-
|
333 |
$fields_mapping = $wsImport->getFieldsMapping($storeId); // Pass StoreId
|
334 |
|
335 |
//definisco il gruppo a cui aggiungere gli iscritti
|
@@ -337,214 +331,403 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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 |
-
"
|
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 |
-
|
386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
$subscribers_counter = 0;
|
388 |
-
$
|
389 |
foreach ($mailupCustomerIds as $customerId) {
|
390 |
-
$tmp = array();
|
391 |
$subscribers_counter++;
|
392 |
-
|
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 |
-
|
476 |
-
|
|
|
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 |
-
|
|
|
|
|
|
|
487 |
if($config->isLogEnabled($storeId)) {
|
488 |
-
|
489 |
}
|
490 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
494 |
-
if (
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
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 |
-
*
|
519 |
*/
|
520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
|
522 |
-
|
523 |
-
|
524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
|
526 |
-
|
527 |
-
|
528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
}
|
530 |
|
531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
|
533 |
-
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
}
|
|
|
|
|
536 |
|
537 |
-
|
538 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
|
540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
return number_format($price, 2, ',', '');
|
542 |
}
|
543 |
|
544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
{
|
@@ -569,6 +752,8 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
569 |
|
570 |
/**
|
571 |
* Clean the Resource Table
|
|
|
|
|
572 |
*/
|
573 |
public function cleanResourceTable()
|
574 |
{
|
@@ -579,12 +764,14 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
579 |
die('deleted module in core_resource!');
|
580 |
}
|
581 |
catch(Exception $e){
|
582 |
-
|
583 |
}
|
584 |
}
|
585 |
|
586 |
/**
|
587 |
* Clean the Resource Table
|
|
|
|
|
588 |
*/
|
589 |
public function showResourceTable()
|
590 |
{
|
@@ -600,4 +787,145 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
|
600 |
echo $e->getMessage();
|
601 |
}
|
602 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Data.php
|
4 |
+
*
|
5 |
+
* @todo get rid of these static methods!
|
6 |
+
*/
|
7 |
class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
|
8 |
{
|
9 |
+
/**
|
10 |
+
* split customers into batches
|
11 |
+
*/
|
12 |
+
const BATCH_SIZE = 2000;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get the Customer Data
|
16 |
+
*
|
17 |
+
* @param array
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
public static function getCustomersData($customerCollection = null)
|
21 |
{
|
22 |
$config = Mage::getModel('mailup/config');
|
23 |
/* @var $config SevenLike_Mailup_Model_Config */
|
24 |
|
25 |
if ($config->isLogEnabled()) {
|
26 |
+
$config->log('Getting customers data');
|
27 |
}
|
28 |
|
29 |
if(is_array($customerCollection) && empty($customerCollection)) {
|
30 |
if ($config->isLogEnabled()) {
|
31 |
+
$config->log('CustomerCollection is Empty!');
|
32 |
}
|
33 |
}
|
34 |
|
46 |
$customerCollection = Mage::getModel('customer/customer')->getCollection();
|
47 |
$parseSubscribers = true;
|
48 |
if ($config->isLogEnabled()) {
|
49 |
+
$config->log('Parsing Subscribers, NULL collection passed.');
|
50 |
}
|
51 |
}
|
52 |
foreach ($customerCollection as $currentCustomerId) {
|
56 |
|
57 |
if( ! $currentCustomerId) {
|
58 |
if($config->isLogEnabled()) {
|
59 |
+
$config->log('Skipping Empty Customer ID!');
|
60 |
continue;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
if($config->isLogEnabled()) {
|
65 |
+
$config->log('Customer with id '.$currentCustomerId);
|
66 |
}
|
67 |
$customer = Mage::getModel('customer/customer')->load($currentCustomerId);
|
68 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
69 |
$i = $customer->getEmail();
|
70 |
|
71 |
//recupero gli ordini del cliente corrente
|
80 |
$lastShipmentOrderDate = null;
|
81 |
|
82 |
if($config->isLogEnabled()) {
|
83 |
+
$config->log('Parsing orders of customer with id '.$currentCustomerId);
|
84 |
}
|
85 |
$orders = Mage::getModel('sales/order')
|
86 |
->getCollection()
|
88 |
;
|
89 |
foreach($orders as $order) {
|
90 |
if($config->isLogEnabled()) {
|
91 |
+
$config->log("ORDINE IN STATUS: " . $order->getStatus());
|
92 |
}
|
93 |
if( ! in_array($order->getStatus(), array("closed", "complete", "processing"))) {
|
94 |
continue;
|
99 |
$currentOrderCreationDate = $order->getCreatedAt();
|
100 |
if ($currentOrderCreationDate > $thirtyDaysAgo) {
|
101 |
$last30daysOrdersAmount += $currentOrderTotal;
|
|
|
102 |
}
|
103 |
if ($currentOrderCreationDate > $twelveMonthsAgo) {
|
104 |
$last12monthsOrdersAmount += $currentOrderTotal;
|
105 |
}
|
106 |
|
107 |
$currentOrderTotal = self::_formatPrice($currentOrderTotal);
|
|
|
108 |
$currentOrderId = $order->getIncrementId();
|
109 |
$allOrdersTotals[$currentOrderId] = $currentOrderTotal;
|
110 |
$allOrdersDateTimes[$currentOrderId] = $currentOrderCreationDate;
|
131 |
|
132 |
//recupero i carrelli abbandonati del cliente
|
133 |
if($config->isLogEnabled()) {
|
134 |
+
$config->log('Parsing abandoned carts of customer with id '.$currentCustomerId);
|
135 |
}
|
136 |
$cartCollection = Mage::getResourceModel('reports/quote_collection');
|
137 |
$cartCollection->prepareForAbandonedReport($config->getAllStoreIds());
|
146 |
$toSend[$i]['IDCarrelloAbbandonato'] = '';
|
147 |
|
148 |
if ( ! empty($lastCart)) {
|
149 |
+
if ($config->isLogEnabled()) {
|
150 |
+
$config->log('Customer with id '.$currentCustomerId .' has abandoned cart');
|
151 |
}
|
152 |
$datetimeCart = $lastCart->getUpdatedAt();
|
153 |
//$toSend[$i]['TotaleCarrelloAbbandonato'] = self::_formatPrice($lastCart->getGrandTotal());
|
157 |
}
|
158 |
else {
|
159 |
if ($config->isLogEnabled()) {
|
160 |
+
$config->log('Customer with id '.$currentCustomerId .' has empty LAST CART');
|
161 |
}
|
162 |
}
|
163 |
}
|
164 |
else {
|
165 |
if ($config->isLogEnabled()) {
|
166 |
+
$config->log('Customer id '.$currentCustomerId .' has empty abandoned cart collection');
|
167 |
}
|
168 |
}
|
169 |
|
177 |
|| ($datetimeCart && $datetimeCart > $lastDateTime))
|
178 |
{
|
179 |
if ($config->isLogEnabled()) {
|
180 |
+
$config->log('Adding customer with id '.$currentCustomerId);
|
181 |
}
|
182 |
|
183 |
$toSend[$i]['nome'] = $customer->getFirstname();
|
212 |
$toSend[$i]['fax'] = $address->getData('fax');
|
213 |
$toSend[$i]['telefono'] = $address->getData('telephone');
|
214 |
}
|
215 |
+
else {
|
216 |
+
$toSend[$i]['azienda'] = '';
|
217 |
+
$toSend[$i]['paese'] = '';
|
218 |
+
$toSend[$i]['città'] = '';
|
219 |
+
$toSend[$i]['regione'] = '';
|
220 |
+
$toSend[$i]['provincia'] = '';
|
221 |
+
$toSend[$i]['cap'] = '';
|
222 |
+
$toSend[$i]['indirizzo'] = '';
|
223 |
+
$toSend[$i]['fax'] = '';
|
224 |
+
$toSend[$i]['telefono'] = '';
|
225 |
+
}
|
226 |
|
227 |
$toSend[$i]['DataUltimoOrdine'] = self::_retriveDateFromDatetime($lastOrderDateTime);
|
228 |
$toSend[$i]['TotaleUltimoOrdine'] = end($allOrdersTotals);
|
245 |
}
|
246 |
|
247 |
$toSend[$i]['IDProdottiUltimoOrdine'] = implode(',', $productIds);
|
248 |
+
if ($toSend[$i]['IDProdottiUltimoOrdine']) {
|
249 |
+
$toSend[$i]['IDProdottiUltimoOrdine'] = ",{$toSend[$i]['IDProdottiUltimoOrdine']},";
|
250 |
+
}
|
251 |
$toSend[$i]['IDCategorieUltimoOrdine'] = implode(',', $categoryIds);
|
252 |
+
if ($toSend[$i]['IDCategorieUltimoOrdine']) {
|
253 |
+
$toSend[$i]['IDCategorieUltimoOrdine'] = ",{$toSend[$i]['IDCategorieUltimoOrdine']},";
|
254 |
+
}
|
255 |
}
|
256 |
+
|
257 |
+
$toSend[$i]['DateOfBirth'] = self::_retriveDobFromDatetime($customer->getDob());
|
258 |
+
$toSend[$i]['Gender'] = $customer->getAttribute('gender')->getSource()->getOptionText($customer->getGender());
|
259 |
|
260 |
//unsetto la variabile
|
261 |
unset($customer);
|
284 |
*/
|
285 |
|
286 |
if($config->isLogEnabled()) {
|
287 |
+
$config->log('End getting customers data');
|
288 |
}
|
289 |
|
290 |
return $toSend;
|
291 |
}
|
292 |
|
293 |
/**
|
294 |
+
* Send Customer Data
|
295 |
*
|
296 |
+
* @param array $mailupCustomerIds
|
297 |
+
* @param array
|
|
|
298 |
* @param int
|
299 |
+
* @return int|FALSE ReturnCode
|
300 |
*/
|
301 |
+
public static function generateAndSendCustomers($mailupCustomerIds, $post = null, $storeId = NULL)
|
302 |
{
|
303 |
$config = Mage::getModel('mailup/config');
|
304 |
/* @var $config SevenLike_Mailup_Model_Config */
|
310 |
|
311 |
if (empty($mailupCustomerIds)) {
|
312 |
if($config->isLogEnabled($storeId)) {
|
313 |
+
$config->log('generateAndSendCustomers [Empty Customer ID Array]');
|
314 |
}
|
315 |
+
return FALSE;
|
316 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
+
$jobId = $post['id'];
|
319 |
+
$jobModel = Mage::getModel('mailup/job')->load($post['id']);
|
320 |
+
/* @var $jobModel SevenLike_Mailup_Model_Job */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
if ($accessKey === false) {
|
323 |
Mage::throwException('no access key returned');
|
324 |
}
|
325 |
|
326 |
+
//$fields = $wsSend->GetFields($accessKey);
|
327 |
$fields_mapping = $wsImport->getFieldsMapping($storeId); // Pass StoreId
|
328 |
|
329 |
//definisco il gruppo a cui aggiungere gli iscritti
|
331 |
$listGUID = $post['mailupListGUID'];
|
332 |
$idList = $post['mailupIdList'];
|
333 |
|
334 |
+
/**
|
335 |
+
* Create a new Mailup Group.
|
336 |
+
*/
|
337 |
if ($post['mailupNewGroup'] == 1) {
|
338 |
$newGroup = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
"idList" => $idList,
|
340 |
"listGUID" => $listGUID,
|
341 |
+
"newGroupName" => $post['mailupNewGroupName']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
);
|
343 |
+
$groupId = $wsImport->CreaGruppo($newGroup);
|
344 |
}
|
345 |
|
346 |
+
$importProcessData = array(
|
347 |
+
"idList" => $idList,
|
348 |
+
"listGUID" => $listGUID,
|
349 |
+
"idGroup" => $groupId,
|
350 |
+
"xmlDoc" => "",
|
351 |
+
"idGroups" => $groupId,
|
352 |
+
"importType" => 1,
|
353 |
+
"mobileInputType" => 2,
|
354 |
+
"asPending" => $jobModel->getAsPending() ? 1 : 0,
|
355 |
+
"ConfirmEmail" => $jobModel->getSendOptin() ? 1 : 0,
|
356 |
+
"asOptOut" => 0,
|
357 |
+
"forceOptIn" => 0, //1,
|
358 |
+
"replaceGroups" => 0,
|
359 |
+
"idConfirmNL" => 0
|
360 |
+
);
|
361 |
+
|
362 |
+
$xmlData = '';
|
363 |
$subscribers_counter = 0;
|
364 |
+
$totalCustomers = sizeof($mailupCustomerIds);
|
365 |
foreach ($mailupCustomerIds as $customerId) {
|
|
|
366 |
$subscribers_counter++;
|
367 |
+
$xmlData .= self::_getCustomerXml($customerId, $fields_mapping, $storeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
+
/**
|
370 |
+
* We have Valid Data to send
|
371 |
+
*/
|
372 |
+
if(strlen($xmlData)) {
|
373 |
$importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
|
|
|
374 |
$xmlData = "";
|
375 |
$subscribers_counter = 0;
|
376 |
+
/*if($config->isLogEnabled($storeId)) {
|
377 |
Mage::log('ImportProcessData');
|
378 |
Mage::log($importProcessData, 0);
|
379 |
+
}*/
|
380 |
$processID = $wsImport->newImportProcess($importProcessData);
|
381 |
+
/**
|
382 |
+
* Failure
|
383 |
+
*/
|
384 |
+
if($processID === FALSE | $processID < 0) {
|
385 |
if($config->isLogEnabled($storeId)) {
|
386 |
+
$config->dbLog(sprintf('newImportProcess [ERROR] [%d]', $processID), $jobId, $storeId);
|
387 |
}
|
388 |
+
return $processID;
|
389 |
+
}
|
390 |
+
/**
|
391 |
+
* Success
|
392 |
+
*/
|
393 |
+
else {
|
394 |
+
$config->dbLog(sprintf("newImportProcess [SUCCESS] [ProcessID: %d]", $processID), $jobId, $storeId);
|
395 |
+
$jobModel->setProcessId($processID);
|
396 |
}
|
397 |
}
|
398 |
+
/**
|
399 |
+
* Build Data for StartImportProcesses
|
400 |
+
*/
|
401 |
+
$startImportProcessesData = array(
|
402 |
+
'listsIDs' => $post['mailupIdList'],
|
403 |
+
'listsGUIDs' => $post['mailupListGUID'],
|
404 |
+
'groupsIDs' => $groupId,
|
405 |
+
"idList" => $idList,
|
406 |
+
"importType" => 1,
|
407 |
+
"mobileInputType" => 2,
|
408 |
+
"asPending" => $jobModel->getAsPending() ? 1 : 0,
|
409 |
+
"ConfirmEmail" => $jobModel->getSendOptin() ? 1 : 0,
|
410 |
+
"asOptOut" => 0,
|
411 |
+
"forceOptIn" => 0, //1,
|
412 |
+
"replaceGroups" => 0,
|
413 |
+
"idConfirmNL" => 0
|
414 |
+
);
|
415 |
|
416 |
+
if ($config->isLogEnabled($storeId)) {
|
417 |
+
$config->log("mailup: StartImportProcesses (STORE: {$storeId})", $storeId);
|
418 |
+
$config->log($startImportProcessesData);
|
419 |
+
}
|
420 |
+
$startProcessesReturnCode = $wsImport->StartImportProcesses($startImportProcessesData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
/**
|
422 |
+
* Save the Job Model, and update the tries as we've just tried to Start the Process
|
423 |
*/
|
424 |
+
$jobModel->incrementTries();
|
425 |
+
try {
|
426 |
+
$jobModel->save();
|
427 |
+
}
|
428 |
+
catch(Exception $e) {
|
429 |
+
Mage::log($e->getMessage());
|
430 |
+
}
|
431 |
+
if ($config->isLogEnabled($storeId)) {
|
432 |
+
if($startProcessesReturnCode < 0) {
|
433 |
+
$config->dbLog(sprintf("StartImportProcesses [ReturnCode] [ERROR] [%d]", $startProcessesReturnCode), $jobId, $storeId);
|
434 |
+
}
|
435 |
+
else {
|
436 |
+
$config->dbLog(sprintf("StartImportProcesses [ReturnCode] [SUCCESS] [%d]", $startProcessesReturnCode), $jobId, $storeId);
|
437 |
+
}
|
438 |
+
}
|
439 |
|
440 |
+
return (int) $startProcessesReturnCode;
|
441 |
+
}
|
442 |
+
|
443 |
+
public function newImportProcess()
|
444 |
+
{
|
445 |
+
|
446 |
+
}
|
447 |
+
|
448 |
+
public function startImportProcess()
|
449 |
+
{
|
450 |
+
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Get a single customers XML data.
|
455 |
+
*
|
456 |
+
* @param int
|
457 |
+
* @param array
|
458 |
+
* @param int
|
459 |
+
* @return string
|
460 |
+
*/
|
461 |
+
protected static function _getCustomerXml($customerId, $fields_mapping, $storeId)
|
462 |
+
{
|
463 |
+
$config = Mage::getModel('mailup/config');
|
464 |
+
/* @var $config SevenLike_Mailup_Model_Config */
|
465 |
+
$xmlData = '';
|
466 |
+
$tmp = array();
|
467 |
+
$subscriber = self::getCustomersData(array($customerId));
|
468 |
+
|
469 |
+
if(is_array($subscriber) && empty($subscriber)) {
|
470 |
+
if($config->isLogEnabled($storeId)) {
|
471 |
+
$config->log('getCustomersData [EMPTY]');
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
$subscriber = array_values($subscriber);
|
476 |
+
$subscriber = $subscriber[0];
|
477 |
|
478 |
+
$subscriber["DataCarrelloAbbandonato"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataCarrelloAbbandonato"]);
|
479 |
+
$subscriber["DataUltimoOrdineSpedito"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataUltimoOrdineSpedito"]);
|
480 |
+
$subscriber["registeredDate"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["registeredDate"]);
|
481 |
+
$subscriber["DataUltimoOrdine"] = self::_convertUTCToStoreTimezoneAndFormatForMailup($subscriber["DataUltimoOrdine"]);
|
482 |
+
|
483 |
+
/**
|
484 |
+
* As mobileInputType = 2 we need this format: Prefix="+001" Number="8889624587"
|
485 |
+
*/
|
486 |
+
$xmlData .= '<subscriber email="'.$subscriber['email'].'" Prefix="" Number="" Name="">';
|
487 |
+
|
488 |
+
foreach($subscriber as $k => $v) {
|
489 |
+
if ( ! strlen($subscriber[$k])) {
|
490 |
+
$subscriber[$k] = ' '; // blank it out in mailup
|
491 |
+
}
|
492 |
+
else {
|
493 |
+
$subscriber[$k] = str_replace(array("\r\n", "\r", "\n"), " ", $v);
|
494 |
+
}
|
495 |
}
|
496 |
|
497 |
+
/**
|
498 |
+
* Map from Customer Data to Mailup Fields.
|
499 |
+
*
|
500 |
+
* @todo Need to map Gener field
|
501 |
+
*/
|
502 |
+
$mappings = array(
|
503 |
+
'Name' => 'nome',
|
504 |
+
'Last' => 'cognome',
|
505 |
+
"Company" => 'azienda',
|
506 |
+
"City" => 'città',
|
507 |
+
"Province" => 'provincia',
|
508 |
+
"ZIP" => 'cap',
|
509 |
+
"Region" => 'regione',
|
510 |
+
"Country" => 'paese',
|
511 |
+
"Address" => 'indirizzo',
|
512 |
+
"Fax" => 'fax',
|
513 |
+
"Phone" => 'telefono',
|
514 |
+
"CustomerID" => 'IDCliente',
|
515 |
+
"LatestOrderID" => 'IDUltimoOrdine',
|
516 |
+
"LatestOrderDate" => 'DataUltimoOrdine',
|
517 |
+
"LatestOrderAmount" => 'TotaleUltimoOrdine',
|
518 |
+
"LatestOrderProductIDs" => 'IDProdottiUltimoOrdine',
|
519 |
+
"LatestOrderCategoryIDs" => 'IDCategorieUltimoOrdine',
|
520 |
+
"LatestShippedOrderDate" => 'DataUltimoOrdineSpedito',
|
521 |
+
"LatestShippedOrderID" => 'IDUltimoOrdineSpedito',
|
522 |
+
"LatestAbandonedCartDate" => 'DataCarrelloAbbandonato',
|
523 |
+
"LatestAbandonedCartTotal" => 'TotaleCarrelloAbbandonato',
|
524 |
+
"LatestAbandonedCartID" => 'IDCarrelloAbbandonato',
|
525 |
+
"TotalOrdered" => 'TotaleFatturato',
|
526 |
+
"TotalOrderedLast12m" => 'TotaleFatturatoUltimi12Mesi',
|
527 |
+
"TotalOrderedLast30d" => 'TotaleFatturatoUltimi30gg',
|
528 |
+
"AllOrderedProductIDs" => 'IDTuttiProdottiAcquistati',
|
529 |
+
'DateOfBirth' => 'DateOfBirth',
|
530 |
+
'Gender' => 'Gender',
|
531 |
+
);
|
532 |
|
533 |
+
foreach($mappings as $mapTo => $mapFrom) {
|
534 |
+
if(isset($fields_mapping[$mapTo]) && ! empty($fields_mapping[$mapTo])) {
|
535 |
+
$tmp[$fields_mapping[$mapTo]] = '<campo'.$fields_mapping[$mapTo].'>'. "<![CDATA[". $subscriber[$mapFrom] ."]]>". '</campo'.$fields_mapping[$mapTo].'>';
|
536 |
+
}
|
537 |
+
elseif( ! empty($fields_mapping[$mapTo])) {
|
538 |
+
$tmp[$fields_mapping[$mapTo]] = '<campo'.$fields_mapping[$mapTo].'>'. '" "'. '</campo'.$fields_mapping[$mapTo].'>';
|
539 |
+
}
|
540 |
+
//else {}
|
541 |
}
|
542 |
+
|
543 |
+
$last_field = max(array_keys($tmp));
|
544 |
|
545 |
+
for($i=1; $i < $last_field; $i++) {
|
546 |
+
if( ! isset($tmp[$i]) && ! empty($i)) {
|
547 |
+
/**
|
548 |
+
* If we leave a space it will blank the value out in mail up.
|
549 |
+
* if we leave it empty, it will leave the old value alone!
|
550 |
+
*/
|
551 |
+
$tmp[$i] = "<campo{$i}>" ." ". "</campo{$i}>";
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
ksort($tmp);
|
556 |
+
$tmp = implode("", $tmp);
|
557 |
+
/** All field values are handled as strings, character '|' (pipe) is not allowed and may lead to "-402" error codes **/
|
558 |
+
//$tmp = str_replace('|', '', $tmp);
|
559 |
+
$xmlData .= $tmp;
|
560 |
+
$xmlData .= "</subscriber>\n";
|
561 |
|
562 |
+
/**
|
563 |
+
* @todo REMOVE
|
564 |
+
*/
|
565 |
+
$config->log($xmlData);
|
566 |
+
|
567 |
+
return $xmlData;
|
568 |
+
}
|
569 |
+
|
570 |
+
/**
|
571 |
+
* Run a particular job
|
572 |
+
*
|
573 |
+
* @param int
|
574 |
+
*/
|
575 |
+
public function runJob($jobId)
|
576 |
+
{
|
577 |
+
$config = Mage::getModel('mailup/config');
|
578 |
+
/* @var $config SevenLike_Mailup_Model_Config */
|
579 |
+
require_once dirname(__FILE__) . '/../Helper/Data.php';
|
580 |
+
$db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
581 |
+
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
582 |
+
$syncTableName = Mage::getSingleton('core/resource')->getTableName('mailup/sync');
|
583 |
+
$jobsTableName = Mage::getSingleton('core/resource')->getTableName('mailup/job');
|
584 |
+
$lastsync = gmdate("Y-m-d H:i:s");
|
585 |
+
// reading customers (jobid == 0, their updates)
|
586 |
+
$customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
|
587 |
+
$jobModel = Mage::getModel('mailup/job')->load($jobId);
|
588 |
+
/* @var $jobModel SevenLike_MailUp_Model_Job */
|
589 |
+
|
590 |
+
if( ! $jobModel) {
|
591 |
+
throw new Mage_Exception('No Job Exists: ' . $jobId);
|
592 |
+
}
|
593 |
+
|
594 |
+
$job = $jobModel->getData();
|
595 |
+
$stmt = $db_write->query(
|
596 |
+
"UPDATE {$jobsTableName}
|
597 |
+
SET status='started', start_datetime='" . gmdate("Y-m-d H:i:s") . "'
|
598 |
+
WHERE id={$job["id"]}"
|
599 |
+
);
|
600 |
+
$storeId = isset($job['store_id']) ? $job['store_id'] : NULL;
|
601 |
+
//$storeId = Mage::app()->getDefaultStoreView()->getStoreId(); // Fallback incase not set?!?
|
602 |
+
$customers = array();
|
603 |
+
$job['mailupNewGroup'] = 0;
|
604 |
+
$job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
|
605 |
+
$job["mailupGroupId"] = $job["mailupgroupid"];
|
606 |
+
$job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
|
607 |
+
|
608 |
+
$tmp = new SevenLike_MailUp_Model_Lists;
|
609 |
+
$tmp = $tmp->toOptionArray($storeId); // pass store id!
|
610 |
+
foreach ($tmp as $t) {
|
611 |
+
if ($t["value"] == $job['mailupIdList']) {
|
612 |
+
$job['mailupListGUID'] = $t["guid"];
|
613 |
+
$job["groups"] = $t["groups"];
|
614 |
+
break;
|
615 |
+
}
|
616 |
+
}
|
617 |
+
unset($tmp);
|
618 |
+
unset($t);
|
619 |
+
$stmt = $db_read->query("
|
620 |
+
SELECT ms.*, ce.email
|
621 |
+
FROM {$syncTableName} ms
|
622 |
+
JOIN $customer_entity_table_name ce
|
623 |
+
ON (ms.customer_id = ce.entity_id)
|
624 |
+
WHERE ms.needs_sync=1
|
625 |
+
AND ms.entity='customer'
|
626 |
+
AND job_id={$job["id"]}"
|
627 |
+
);
|
628 |
+
while ($row = $stmt->fetch()) {
|
629 |
+
$customers[] = $row["customer_id"];
|
630 |
+
}
|
631 |
+
/**
|
632 |
+
* Send the Data!
|
633 |
+
*/
|
634 |
+
$returnCode = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
|
635 |
+
/**
|
636 |
+
* Check return OK
|
637 |
+
*/
|
638 |
+
if($returnCode === 0) {
|
639 |
+
$customerCount = count($customers);
|
640 |
+
$db_write->query("
|
641 |
+
UPDATE {$syncTableName} SET needs_sync=0, last_sync='$lastsync'
|
642 |
+
WHERE job_id = {$job["id"]}
|
643 |
+
AND entity='customer'"
|
644 |
+
);
|
645 |
+
$config->dbLog("Job Task [update] [Synced] [customer count:{$customerCount}]", $job["id"], $storeId);
|
646 |
+
// finishing the job also
|
647 |
+
$db_write->query("
|
648 |
+
UPDATE {$jobsTableName} SET status='finished', finish_datetime='" . gmdate("Y-m-d H:i:s") . "'
|
649 |
+
WHERE id={$job["id"]}"
|
650 |
+
);
|
651 |
+
$config->dbLog("Jobs [Update] [Complete] [{$job["id"]}]", $job["id"], $storeId);
|
652 |
+
}
|
653 |
+
/**
|
654 |
+
* Only successfull if we get 0 back. False is also a fail.
|
655 |
+
*/
|
656 |
+
else {
|
657 |
+
$stmt = $db_write->query(
|
658 |
+
"UPDATE {$jobsTableName} SET status='queued' WHERE id={$job["id"]}"
|
659 |
+
);
|
660 |
+
if($config->isLogEnabled()) {
|
661 |
+
$config->dbLog(sprintf("generateAndSendCustomers [ReturnCode] [ERROR] [%d]", $returnCode), $job["id"], $storeId);
|
662 |
+
}
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Get sub Categories of a Category
|
668 |
+
*
|
669 |
+
* @param int
|
670 |
+
* @return array|string
|
671 |
+
*/
|
672 |
+
public function getSubCategories($categoryId)
|
673 |
+
{
|
674 |
+
// Not sure what version this was introduced.
|
675 |
+
$parent = Mage::getModel('catalog/category')->load($categoryId);
|
676 |
+
$children = $parent->getAllChildren(TRUE);
|
677 |
+
|
678 |
+
if( ! empty($children) && is_array($children)) {
|
679 |
+
return $children;
|
680 |
+
}
|
681 |
+
|
682 |
+
return array();
|
683 |
+
|
684 |
+
// // Maybe fall back to this in older versions?
|
685 |
+
// $ids = array();
|
686 |
+
// $children = Mage::getModel('catalog/category')->getCategories($categoryId);
|
687 |
+
// foreach ($children as $category) {
|
688 |
+
// /* @var $category Mage_Catalog_Model_Category */
|
689 |
+
// $ids[] = $category->getId();
|
690 |
+
// }
|
691 |
+
//
|
692 |
+
// return $ids;
|
693 |
+
}
|
694 |
+
|
695 |
+
/**
|
696 |
+
* Format the Price
|
697 |
+
*
|
698 |
+
* @param float
|
699 |
+
* @return string
|
700 |
+
*/
|
701 |
+
private static function _formatPrice($price)
|
702 |
+
{
|
703 |
return number_format($price, 2, ',', '');
|
704 |
}
|
705 |
|
706 |
+
/**
|
707 |
+
* Get Date from DateTime
|
708 |
+
*
|
709 |
+
* @param type $datetime
|
710 |
+
* @return string
|
711 |
+
*/
|
712 |
+
private static function _retriveDateFromDatetime($datetime)
|
713 |
+
{
|
714 |
if (empty($datetime)) return "";
|
715 |
return date("Y-m-d H:i:s", strtotime($datetime));
|
716 |
}
|
717 |
+
|
718 |
+
/**
|
719 |
+
* Get DOB Format from DateTime
|
720 |
+
*
|
721 |
+
* @param string $datetime
|
722 |
+
* @return string
|
723 |
+
*/
|
724 |
+
private static function _retriveDobFromDatetime($datetime)
|
725 |
+
{
|
726 |
+
if (empty($datetime)) {
|
727 |
+
return "";
|
728 |
+
}
|
729 |
+
return date("d/m/Y", strtotime($datetime));
|
730 |
+
}
|
731 |
|
732 |
public static function _convertUTCToStoreTimezone($datetime)
|
733 |
{
|
752 |
|
753 |
/**
|
754 |
* Clean the Resource Table
|
755 |
+
*
|
756 |
+
* @return void
|
757 |
*/
|
758 |
public function cleanResourceTable()
|
759 |
{
|
764 |
die('deleted module in core_resource!');
|
765 |
}
|
766 |
catch(Exception $e){
|
767 |
+
Mage::log($e->getMessage());
|
768 |
}
|
769 |
}
|
770 |
|
771 |
/**
|
772 |
* Clean the Resource Table
|
773 |
+
*
|
774 |
+
* @return void
|
775 |
*/
|
776 |
public function showResourceTable()
|
777 |
{
|
787 |
echo $e->getMessage();
|
788 |
}
|
789 |
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Get all product attributes
|
793 |
+
*
|
794 |
+
* Note if we don't use a keyed array below the first item with key 0
|
795 |
+
* gets replaced by an empty option by magento. this results in a missing attribute
|
796 |
+
* from the list!
|
797 |
+
*
|
798 |
+
* @reutrn array
|
799 |
+
*/
|
800 |
+
public function getAllProductAttributes()
|
801 |
+
{
|
802 |
+
//$attributes = Mage::getModel('catalog/product')->getAttributes();
|
803 |
+
$attributes = Mage::getSingleton('eav/config')
|
804 |
+
->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection()
|
805 |
+
;
|
806 |
+
// Localize attribute label (if you need it)
|
807 |
+
$attributes->addStoreLabel(Mage::app()->getStore()->getId());
|
808 |
+
$attributeArray = array();
|
809 |
+
foreach($attributes as $att) {
|
810 |
+
/* @var $att Mage_Catalog_Model_Resource_Eav_Attribute */
|
811 |
+
if($att->getIsVisible()) {
|
812 |
+
$attributeArray[$att->getAttributeCode()] = array(
|
813 |
+
'value' => $att->getAttributeCode(),
|
814 |
+
'label' => $att->getStoreLabel() ? $att->getStoreLabel() : $att->getFrontendLabel()
|
815 |
+
);
|
816 |
+
}
|
817 |
+
}
|
818 |
+
return $attributeArray;
|
819 |
+
}
|
820 |
+
|
821 |
+
/**
|
822 |
+
* Get all product attributes
|
823 |
+
*
|
824 |
+
* Note if we don't use a keyed array below the first item with key 0
|
825 |
+
* gets replaced by an empty option by magento. this results in a missing attribute
|
826 |
+
* from the list!
|
827 |
+
*
|
828 |
+
* @reutrn array
|
829 |
+
*/
|
830 |
+
public function getAllCustomerAttributes()
|
831 |
+
{
|
832 |
+
//$attributes = Mage::getModel('catalog/product')->getAttributes();
|
833 |
+
$attributes = Mage::getSingleton('eav/config')
|
834 |
+
->getEntityType('customer')->getAttributeCollection()
|
835 |
+
;
|
836 |
+
// Localize attribute label (if you need it)
|
837 |
+
$attributes->addStoreLabel(Mage::app()->getStore()->getId());
|
838 |
+
$attributeArray = array();
|
839 |
+
foreach($attributes as $att) {
|
840 |
+
/* @var $att Mage_Catalog_Model_Resource_Eav_Attribute */
|
841 |
+
if($att->getIsVisible()) {
|
842 |
+
$attributeArray[$att->getAttributeCode()] = array(
|
843 |
+
'value' => $att->getAttributeCode(),
|
844 |
+
'label' => $att->getStoreLabel() ? $att->getStoreLabel() : $att->getFrontendLabel()
|
845 |
+
);
|
846 |
+
}
|
847 |
+
}
|
848 |
+
return $attributeArray;
|
849 |
+
}
|
850 |
+
|
851 |
+
/**
|
852 |
+
* Is Someone a subscriber?
|
853 |
+
*
|
854 |
+
* @param int
|
855 |
+
* @param int
|
856 |
+
* @return bool
|
857 |
+
*/
|
858 |
+
public function isSubscriber($customerId, $storeId)
|
859 |
+
{
|
860 |
+
$customerId = (int) $customerId;
|
861 |
+
$storeId = (int) $storeId;
|
862 |
+
$table = Mage::getSingleton('core/resource')->getTableName('newsletter_subscriber');
|
863 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
864 |
+
//$sql = "SELECT * FROM {$table} WHERE customer_id = '{$customerId}' AND store_id = '{$storeId}'";
|
865 |
+
// Issue with magento, it seems to only subscribe on a websote leve, not store level!
|
866 |
+
$sql = "SELECT * FROM {$table} WHERE customer_id = '{$customerId}'";
|
867 |
+
try {
|
868 |
+
$result = $connection->fetchAll($sql); // array
|
869 |
+
if(count($result) == 0) {
|
870 |
+
return FALSE;
|
871 |
+
}
|
872 |
+
$result = $result[0];
|
873 |
+
|
874 |
+
return $result['subscriber_status'] == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED;
|
875 |
+
}
|
876 |
+
catch(Exception $e){
|
877 |
+
Mage::log($e->getMessage());
|
878 |
+
}
|
879 |
+
|
880 |
+
return FALSE;
|
881 |
+
}
|
882 |
+
|
883 |
+
/**
|
884 |
+
* Schedule a Task
|
885 |
+
*
|
886 |
+
* @param string
|
887 |
+
* @param string
|
888 |
+
*/
|
889 |
+
public function scheduleTask($when, $type = 'sevenlike_mailup')
|
890 |
+
{
|
891 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
892 |
+
$write->insert(Mage::getSingleton('core/resource')->getTableName('cron_schedule'), array(
|
893 |
+
"job_code" => $type,
|
894 |
+
"status" => "pending",
|
895 |
+
"created_at" => gmdate("Y-m-d H:i:s"),
|
896 |
+
"scheduled_at" => $when
|
897 |
+
));
|
898 |
+
|
899 |
+
/*$schedule = Mage::getModel('cron/schedule');
|
900 |
+
$schedule->setJobCode($jobCode)
|
901 |
+
->setCreatedAt($timecreated)
|
902 |
+
->setScheduledAt($timescheduled)
|
903 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
904 |
+
->save();*/
|
905 |
+
}
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Retrieve Attribute Id Data By Id or Code
|
909 |
+
*
|
910 |
+
* @param mixed
|
911 |
+
* @param int
|
912 |
+
* @return int
|
913 |
+
*/
|
914 |
+
public function getAttributeId($id, $entityTypeId = NULL)
|
915 |
+
{
|
916 |
+
if($entityTypeId == NULL) {
|
917 |
+
$entityTypeId = Mage::getModel('catalog/product')->getResource()->getEntityType()->getId();
|
918 |
+
}
|
919 |
+
|
920 |
+
$installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
|
921 |
+
if ( ! is_numeric($id)) {
|
922 |
+
$id = $installer->getAttribute($entityTypeId, $id, 'attribute_id');
|
923 |
+
}
|
924 |
+
if ( ! is_numeric($id)) {
|
925 |
+
//throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Wrong attribute ID.'));
|
926 |
+
return FALSE;
|
927 |
+
}
|
928 |
+
|
929 |
+
return $id;
|
930 |
+
}
|
931 |
}
|
app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Fields.php
CHANGED
@@ -31,12 +31,6 @@ class SevenLike_MailUp_Model_Adminhtml_System_Source_Fields
|
|
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);
|
31 |
//$storeId = Mage::app()->getDefaultStoreView()->getStoreId();
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
$options = array(array('value' => '', 'label' => ''));
|
35 |
if(false !== ($data = Mage::app()->getCache()->load($cacheId))) {
|
36 |
$options = unserialize($data);
|
app/code/local/SevenLike/MailUp/Model/Config.php
CHANGED
@@ -22,6 +22,7 @@ class SevenLike_MailUp_Model_Config
|
|
22 |
/**
|
23 |
* Is the log enabled?
|
24 |
*
|
|
|
25 |
* @return bool
|
26 |
*/
|
27 |
public function isLogEnabled($storeId = NULL)
|
@@ -29,6 +30,61 @@ class SevenLike_MailUp_Model_Config
|
|
29 |
return (int) Mage::getStoreConfig(self::XML_LOG_ENABLE, $storeId);
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* Disable Magnetos Newsletter Subscription Notifiactions??
|
34 |
*
|
@@ -51,6 +107,17 @@ class SevenLike_MailUp_Model_Config
|
|
51 |
return Mage::getStoreConfig(self::XML_CONSOLE, $storeId);
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
/**
|
55 |
* Is the cron enabled?
|
56 |
*
|
@@ -138,6 +205,26 @@ class SevenLike_MailUp_Model_Config
|
|
138 |
return $return;*/
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
/**
|
142 |
* Get an array of Stores, for use in a dropdown.
|
143 |
*
|
22 |
/**
|
23 |
* Is the log enabled?
|
24 |
*
|
25 |
+
* @param int
|
26 |
* @return bool
|
27 |
*/
|
28 |
public function isLogEnabled($storeId = NULL)
|
30 |
return (int) Mage::getStoreConfig(self::XML_LOG_ENABLE, $storeId);
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Write a log entry it enabled.
|
35 |
+
*
|
36 |
+
* @param string
|
37 |
+
* @param int
|
38 |
+
* @return bool
|
39 |
+
*/
|
40 |
+
public function log($message, $storeId = NULL)
|
41 |
+
{
|
42 |
+
if( ! $this->isLogEnabled($storeId)) {
|
43 |
+
return ;
|
44 |
+
}
|
45 |
+
|
46 |
+
Mage::log($message, null, 'mailup.log');
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Write a log entry it enabled.
|
51 |
+
*
|
52 |
+
* @param string
|
53 |
+
* @param int
|
54 |
+
* @param int
|
55 |
+
* @param string
|
56 |
+
* @param string
|
57 |
+
* @return bool
|
58 |
+
*/
|
59 |
+
public function dbLog($info, $jobId = 0, $storeId = NULL, $status = 'DEBUG', $type = 'DEBUG')
|
60 |
+
{
|
61 |
+
if( ! $this->isLogEnabled($storeId)) {
|
62 |
+
return ;
|
63 |
+
}
|
64 |
+
|
65 |
+
if( ! isset($storeId)) {
|
66 |
+
$storeId = Mage::app()->getStore()->getId();
|
67 |
+
}
|
68 |
+
|
69 |
+
$log = Mage::getModel('mailup/log');
|
70 |
+
/* @var $log SevenLike_MailUp_Model_Log */
|
71 |
+
$log->setData(array(
|
72 |
+
'store_id' => $storeId,
|
73 |
+
'job_id' => $jobId,
|
74 |
+
'type' => $type,
|
75 |
+
'status' => $status,
|
76 |
+
'data' => $info,
|
77 |
+
'event_time' => date("Y-m-d H:i:s"),
|
78 |
+
));
|
79 |
+
|
80 |
+
try {
|
81 |
+
$log->save();
|
82 |
+
}
|
83 |
+
catch(Exception $e) {
|
84 |
+
$this->log($e->getMessage(), $storeId);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
/**
|
89 |
* Disable Magnetos Newsletter Subscription Notifiactions??
|
90 |
*
|
107 |
return Mage::getStoreConfig(self::XML_CONSOLE, $storeId);
|
108 |
}
|
109 |
|
110 |
+
/**
|
111 |
+
* Get the WSDL Url.
|
112 |
+
*
|
113 |
+
* @param int $storeId
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public function getWsdlUrl($storeId)
|
117 |
+
{
|
118 |
+
return 'http://'. $this->getUrlConsole($storeId) .'/services/WSMailUpImport.asmx?WSDL';
|
119 |
+
}
|
120 |
+
|
121 |
/**
|
122 |
* Is the cron enabled?
|
123 |
*
|
205 |
return $return;*/
|
206 |
}
|
207 |
|
208 |
+
/**
|
209 |
+
* Get the name of the Sync Table
|
210 |
+
*
|
211 |
+
* @return string
|
212 |
+
*/
|
213 |
+
public function getSyncTableName()
|
214 |
+
{
|
215 |
+
return Mage::getSingleton('core/resource')->getTableName('mailup/sync');
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Get the name of the Jobs Table
|
220 |
+
*
|
221 |
+
* @return string
|
222 |
+
*/
|
223 |
+
public function getJobsTableName()
|
224 |
+
{
|
225 |
+
return Mage::getSingleton('core/resource')->getTableName('mailup/job');
|
226 |
+
}
|
227 |
+
|
228 |
/**
|
229 |
* Get an array of Stores, for use in a dropdown.
|
230 |
*
|
app/code/local/SevenLike/MailUp/Model/Cron.php
CHANGED
@@ -1,95 +1,62 @@
|
|
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
|
13 |
-
|
14 |
}
|
15 |
|
16 |
-
if (
|
|
|
|
|
|
|
17 |
$indexProcess = new Mage_Index_Model_Process();
|
18 |
$indexProcess->setId("mailupcronrun");
|
19 |
if ($indexProcess->isLocked()) {
|
20 |
-
|
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 |
-
*
|
51 |
*/
|
52 |
-
foreach(
|
53 |
-
$
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
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 |
-
|
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);
|
@@ -105,10 +72,11 @@ class SevenLike_MailUp_Model_Cron
|
|
105 |
break;
|
106 |
}
|
107 |
}
|
108 |
-
unset($tmp);
|
|
|
109 |
$stmt = $db_read->query("
|
110 |
SELECT ms.*, ce.email
|
111 |
-
FROM
|
112 |
JOIN $customer_entity_table_name ce
|
113 |
ON (ms.customer_id = ce.entity_id)
|
114 |
WHERE ms.needs_sync=1
|
@@ -118,45 +86,128 @@ class SevenLike_MailUp_Model_Cron
|
|
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 |
-
*
|
126 |
-
* we do not want to mark this ask Synced! we need to retry..
|
127 |
*/
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
138 |
// finishing the job also
|
139 |
$db_write->query("
|
140 |
-
UPDATE
|
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 (
|
155 |
-
|
156 |
}
|
157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
|
|
|
|
|
|
|
|
|
|
159 |
public static function resendConnectionErrors()
|
160 |
{
|
|
|
161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* Cron.php
|
4 |
+
*
|
5 |
+
* Scheduled Task handler.
|
6 |
*/
|
7 |
require_once dirname(__FILE__) . "/MailUpWsImport.php";
|
8 |
require_once dirname(__FILE__) . "/Wssend.php";
|
9 |
|
10 |
class SevenLike_MailUp_Model_Cron
|
11 |
{
|
12 |
+
/**
|
13 |
+
* Run the Task
|
14 |
+
*
|
15 |
+
* IF ANY Job we run fails, due to another processes being run we should
|
16 |
+
* gracefully exit and wait our next go!
|
17 |
+
*
|
18 |
+
* Also change auto sync to just create a job, and run a single job Queue!
|
19 |
+
*/
|
20 |
public function run()
|
21 |
{
|
22 |
+
if($this->_config()->isLogEnabled()) {
|
23 |
+
$this->_config()->dbLog("Cron [Triggered]");
|
24 |
}
|
25 |
|
26 |
+
if ($this->_config()->isCronExportEnabled()) {
|
27 |
+
/**
|
28 |
+
* This doesn't exist in 1.3.2!
|
29 |
+
*/
|
30 |
$indexProcess = new Mage_Index_Model_Process();
|
31 |
$indexProcess->setId("mailupcronrun");
|
32 |
if ($indexProcess->isLocked()) {
|
33 |
+
$this->_config()->log('MAILUP: cron already running or locked');
|
34 |
return false;
|
35 |
}
|
36 |
$indexProcess->lockAndBlock();
|
37 |
+
|
38 |
require_once dirname(__FILE__) . '/../Helper/Data.php';
|
39 |
$db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
40 |
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
41 |
+
$syncTableName = Mage::getSingleton('core/resource')->getTableName('mailup/sync');
|
42 |
+
$jobsTableName = Mage::getSingleton('core/resource')->getTableName('mailup/job');
|
43 |
$lastsync = gmdate("Y-m-d H:i:s");
|
|
|
|
|
|
|
|
|
|
|
44 |
// reading customers (jobid == 0, their updates)
|
45 |
$customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
+
* Now Handle Jobs we need to Sync, and all customers attached to each job
|
49 |
*/
|
50 |
+
foreach(Mage::getModel('mailup/job')->fetchQueuedJobsCollection() as $jobModel) {
|
51 |
+
/* @var $jobModel SevenLike_MailUp_Model_Job */
|
52 |
+
$job = $jobModel->getData();
|
53 |
+
$stmt = $db_write->query(
|
54 |
+
"UPDATE {$jobsTableName}
|
55 |
+
SET status='started', start_datetime='" . gmdate("Y-m-d H:i:s") . "'
|
56 |
+
WHERE id={$job["id"]}"
|
57 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
$storeId = isset($job['store_id']) ? $job['store_id'] : NULL;
|
59 |
+
//$storeId = Mage::app()->getDefaultStoreView()->getStoreId(); // Fallback incase not set?!?
|
|
|
|
|
|
|
|
|
60 |
$customers = array();
|
61 |
$job['mailupNewGroup'] = 0;
|
62 |
$job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
|
72 |
break;
|
73 |
}
|
74 |
}
|
75 |
+
unset($tmp);
|
76 |
+
unset($t);
|
77 |
$stmt = $db_read->query("
|
78 |
SELECT ms.*, ce.email
|
79 |
+
FROM {$syncTableName} ms
|
80 |
JOIN $customer_entity_table_name ce
|
81 |
ON (ms.customer_id = ce.entity_id)
|
82 |
WHERE ms.needs_sync=1
|
86 |
while ($row = $stmt->fetch()) {
|
87 |
$customers[] = $row["customer_id"];
|
88 |
}
|
|
|
|
|
|
|
89 |
/**
|
90 |
+
* Send the Data!
|
|
|
91 |
*/
|
92 |
+
$returnCode = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
|
93 |
+
/**
|
94 |
+
* Check return OK
|
95 |
+
*/
|
96 |
+
if($returnCode === 0) {
|
97 |
+
$customerCount = count($customers);
|
98 |
+
$db_write->query("
|
99 |
+
UPDATE {$syncTableName} SET needs_sync=0, last_sync='$lastsync'
|
100 |
+
WHERE job_id = {$job["id"]}
|
101 |
+
AND entity='customer'"
|
102 |
+
);
|
103 |
+
$this->_config()->dbLog("Job Task [update] [Synced] [customer count:{$customerCount}]", $job["id"], $storeId);
|
104 |
// finishing the job also
|
105 |
$db_write->query("
|
106 |
+
UPDATE {$jobsTableName} SET status='finished', finish_datetime='" . gmdate("Y-m-d H:i:s") . "'
|
107 |
WHERE id={$job["id"]}"
|
108 |
);
|
109 |
+
$this->_config()->dbLog("Jobs [Update] [Complete] [{$job["id"]}]", $job["id"], $storeId);
|
110 |
}
|
111 |
+
/**
|
112 |
+
* Only successfull if we get 0 back. False is also a fail.
|
113 |
+
*/
|
114 |
+
else {
|
115 |
+
$stmt = $db_write->query(
|
116 |
+
"UPDATE {$jobsTableName} SET status='queued' WHERE id={$job["id"]}"
|
117 |
+
);
|
118 |
+
if($this->_config()->isLogEnabled()) {
|
119 |
+
$this->_config()->dbLog(sprintf("generateAndSendCustomers [ReturnCode] [ERROR] [%d]", $returnCode), $job["id"], $storeId);
|
120 |
+
}
|
121 |
+
}
|
122 |
}
|
123 |
|
124 |
$indexProcess->unlock();
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
+
|
127 |
+
if ($this->_config()->isLogEnabled()) {
|
128 |
+
$this->_config()->dbLog("Cron [Completed]");
|
129 |
}
|
130 |
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Run Auto Sync Jobs
|
134 |
+
*/
|
135 |
+
public function autoSync()
|
136 |
+
{
|
137 |
+
// Only run Auto Sync Jobs
|
138 |
+
$job = Mage::getModel('mailup/job');
|
139 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
140 |
+
|
141 |
+
foreach($job->fetchAutoSyncQueuedJobsCollection() as $job) {
|
142 |
+
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Run Manual Sync Jobs
|
148 |
+
*/
|
149 |
+
public function manualSync()
|
150 |
+
{
|
151 |
+
// Only run Auto Sync Jobs
|
152 |
+
|
153 |
+
$job = Mage::getModel('mailup/job');
|
154 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
155 |
+
|
156 |
+
foreach($job->fetchManualSyncQueuedJobsCollection() as $job) {
|
157 |
+
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Start the next job in the Queue!
|
163 |
+
*/
|
164 |
+
public function startNextJob()
|
165 |
+
{
|
166 |
+
$jobModel = Mage::getModel('mailup/job');
|
167 |
+
/* @var $jobModel SevenLike_MailUp_Model_Job */
|
168 |
+
foreach($jobModel->fetchQueuedJobsCollection() as $job) {
|
169 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Try and Start it... if it fails, we can try the next one!
|
173 |
+
*/
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Add the jobs to the import queue on Mailup.
|
179 |
+
*/
|
180 |
+
public function newImportProcesses()
|
181 |
+
{
|
182 |
+
|
183 |
+
}
|
184 |
|
185 |
+
/**
|
186 |
+
* handle connection issues
|
187 |
+
*
|
188 |
+
* @todo implement
|
189 |
+
*/
|
190 |
public static function resendConnectionErrors()
|
191 |
{
|
192 |
+
// never implemented.
|
193 |
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* @var SevenLike_MailUp_Model_Config
|
197 |
+
*/
|
198 |
+
protected $_config;
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Get the config
|
202 |
+
*
|
203 |
+
* @reutrn SevenLike_MailUp_Model_Config
|
204 |
+
*/
|
205 |
+
protected function _config()
|
206 |
+
{
|
207 |
+
if(NULL === $this->_config) {
|
208 |
+
$this->_config = Mage::getModel('mailup/config');
|
209 |
+
}
|
210 |
+
|
211 |
+
return $this->_config;
|
212 |
+
}
|
213 |
}
|
app/code/local/SevenLike/MailUp/Model/Job.php
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mailupjob.php
|
4 |
+
*
|
5 |
+
* @method int getStoreId()
|
6 |
+
* @method string getListGuid()
|
7 |
+
* @method string getListid()
|
8 |
+
* @method int getProcessId()
|
9 |
+
* @method int getAsPending()
|
10 |
+
* @method void setStoreId(int $storeId) Set the Store ID
|
11 |
+
* @method void setProcessId(int $id) Set the Mailedup Process ID
|
12 |
+
* @method void setSendOptin(int $yesOrNo) Set weather we're opting in or not.
|
13 |
+
* @method void setStatus(string $status)
|
14 |
+
* @method void setTries(int $num) How many times we've tried.
|
15 |
+
* @method void setType(string $type) What type of job?
|
16 |
+
* @method void setAsPending(int $int) Set the customers in this job to pending state or not
|
17 |
+
* @method void setQueueDatetime(string $dateTime) Set the Datetime the job was queued.
|
18 |
+
* @method void setStartDatetime(string $dateTime) Set when the job was started
|
19 |
+
* @method void setFinishDatetime(string $dateTime) Set when the job was finished / completed
|
20 |
+
*/
|
21 |
+
class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
|
22 |
+
{
|
23 |
+
const STATUS_FINISHED = 'finished';
|
24 |
+
const STATUS_QUEUED = 'queued';
|
25 |
+
const STATUS_STARTED = 'started';
|
26 |
+
const STATUS_IMPORTED = 'imported'; // NewImportProccess has been called
|
27 |
+
|
28 |
+
const TYPE_MANUAL_SYNC = 0;
|
29 |
+
const TYPE_AUTO_SYNC = 1;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Constructor
|
33 |
+
*/
|
34 |
+
protected function _construct()
|
35 |
+
{
|
36 |
+
parent::_construct();
|
37 |
+
$this->_init("mailup/job");
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Increment the number of tries we've attempted.
|
42 |
+
*
|
43 |
+
* @return int
|
44 |
+
*/
|
45 |
+
public function incrementTries()
|
46 |
+
{
|
47 |
+
$tries = (int) $this->getTries();
|
48 |
+
$tries++;
|
49 |
+
$this->setTries($tries);
|
50 |
+
|
51 |
+
return $tries;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Mark as finished
|
56 |
+
*
|
57 |
+
* @return \SevenLike_MailUp_Model_Job
|
58 |
+
*/
|
59 |
+
public function finished()
|
60 |
+
{
|
61 |
+
$this->setStatus(self::STATUS_FINISHED);
|
62 |
+
$this->setFinishDatetime(gmdate("Y-m-d H:i:s"));
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Mark as Queued
|
69 |
+
*
|
70 |
+
* @return \SevenLike_MailUp_Model_Job
|
71 |
+
*/
|
72 |
+
public function queue()
|
73 |
+
{
|
74 |
+
$this->setStatus(self::STATUS_QUEUED);
|
75 |
+
$this->setQueueDatetime(gmdate("Y-m-d H:i:s"));
|
76 |
+
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Is this job finished?
|
82 |
+
*
|
83 |
+
* @return bool
|
84 |
+
*/
|
85 |
+
public function isFinished()
|
86 |
+
{
|
87 |
+
return $this->getStatus() == self::STATUS_FINISHED;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Is this job queued?
|
92 |
+
*
|
93 |
+
* @return bool
|
94 |
+
*/
|
95 |
+
public function isQueued()
|
96 |
+
{
|
97 |
+
return $this->getStatus() == self::STATUS_QUEUED;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Process the job / Start
|
102 |
+
*
|
103 |
+
* @return bool
|
104 |
+
*/
|
105 |
+
public function process()
|
106 |
+
{
|
107 |
+
$this->setStatus(self::STATUS_STARTED);
|
108 |
+
$this->setStartDatetime(gmdate("Y-m-d H:i:s"));
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Now we need to do the heavy lifting!
|
112 |
+
*/
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Get a collection of jobs in the Queue
|
117 |
+
*
|
118 |
+
* @param int
|
119 |
+
* @return SevenLike_MailUp_Model_Mysql4_Job_Collection
|
120 |
+
*/
|
121 |
+
public function fetchQueuedJobsCollection($type = NULL)
|
122 |
+
{
|
123 |
+
$collection = $this->getCollection();
|
124 |
+
/* @var $collection SevenLike_MailUp_Model_Mysql4_Job_Collection */
|
125 |
+
$collection
|
126 |
+
->addFieldToSelect('*')
|
127 |
+
->addFieldToFilter('status', array('eq' => self::STATUS_QUEUED))
|
128 |
+
;
|
129 |
+
|
130 |
+
if($type !== NULL) {
|
131 |
+
$collection->addFieldToFilter('type', array('eq' => (int) $type));
|
132 |
+
}
|
133 |
+
|
134 |
+
return $collection;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Get a collection of jobs in the Queue
|
139 |
+
*
|
140 |
+
* @return SevenLike_MailUp_Model_Mysql4_Job_Collection
|
141 |
+
*/
|
142 |
+
public function fetchManualSyncQueuedJobsCollection()
|
143 |
+
{
|
144 |
+
return $this->fetchQueuedJobsCollection(self::TYPE_MANUAL_SYNC);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get a collection of jobs in the Queue
|
149 |
+
*
|
150 |
+
* @return SevenLike_MailUp_Model_Mysql4_Job_Collection
|
151 |
+
*/
|
152 |
+
public function fetchAutoSyncQueuedJobsCollection()
|
153 |
+
{
|
154 |
+
return $this->fetchQueuedJobsCollection(self::TYPE_AUTO_SYNC);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Get associated job data (customers to sync)
|
159 |
+
*
|
160 |
+
* @return array
|
161 |
+
*/
|
162 |
+
public function getJobData()
|
163 |
+
{
|
164 |
+
$jobTasks = Mage::getModel('mailup/sync');
|
165 |
+
/* @var $jobTasks SevenLike_MailUp_Model_Sync */
|
166 |
+
return $jobTasks->fetchByJobId($this->getId());
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Mark as an Auto Sync Job
|
171 |
+
*/
|
172 |
+
public function setAsAutoSync()
|
173 |
+
{
|
174 |
+
$this->setType(self::TYPE_AUTO_SYNC);
|
175 |
+
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Mark as an Manul Sync Job, done using Sync/Segment feature.
|
181 |
+
*/
|
182 |
+
public function setAsManualSync()
|
183 |
+
{
|
184 |
+
$this->setType(self::TYPE_MANUAL_SYNC);
|
185 |
+
|
186 |
+
return $this;
|
187 |
+
}
|
188 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Lists.php
CHANGED
@@ -7,10 +7,25 @@ require_once dirname(__FILE__) . "/Wssend.php";
|
|
7 |
|
8 |
class SevenLike_MailUp_Model_Lists
|
9 |
{
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* Get as options
|
12 |
*
|
13 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
* @return array
|
15 |
*/
|
16 |
public function toOptionArray($storeId = NULL)
|
@@ -19,7 +34,7 @@ class SevenLike_MailUp_Model_Lists
|
|
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();
|
@@ -57,19 +72,14 @@ class SevenLike_MailUp_Model_Lists
|
|
57 |
|
58 |
$selectLists[0] = array('value' => 0, 'label'=>'-- Select a list (if any) --');
|
59 |
|
60 |
-
if
|
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("&", "&", $xmlLists);
|
70 |
-
|
71 |
$xml = simplexml_load_string($xmlLists);
|
72 |
-
|
73 |
$count = 1;
|
74 |
foreach ($xml->List as $list) {
|
75 |
$groups = array();
|
@@ -77,10 +87,10 @@ class SevenLike_MailUp_Model_Lists
|
|
77 |
$groups[(string)$tmp["idGroup"]] = (string)$tmp["groupName"];
|
78 |
}
|
79 |
$selectLists[$count] = array(
|
80 |
-
'value'
|
81 |
-
'label'=> (string)$list['listName'],
|
82 |
-
'guid'=>(string)$list['listGUID'],
|
83 |
-
"groups"
|
84 |
);
|
85 |
$count++;
|
86 |
}
|
@@ -93,4 +103,118 @@ class SevenLike_MailUp_Model_Lists
|
|
93 |
|
94 |
return $selectLists;
|
95 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
7 |
|
8 |
class SevenLike_MailUp_Model_Lists
|
9 |
{
|
10 |
+
/**
|
11 |
+
* @var array
|
12 |
+
*/
|
13 |
+
protected $_cache = array();
|
14 |
+
|
15 |
/**
|
16 |
* Get as options
|
17 |
*
|
18 |
+
* array(
|
19 |
+
* array(
|
20 |
+
* 'value' => (string)$list['idList'],
|
21 |
+
'label' => (string)$list['listName'],
|
22 |
+
'guid' =>(string)$list['listGUID'],
|
23 |
+
"groups" => array(
|
24 |
+
* ...
|
25 |
+
* )
|
26 |
+
* )
|
27 |
+
* )
|
28 |
+
*
|
29 |
* @return array
|
30 |
*/
|
31 |
public function toOptionArray($storeId = NULL)
|
34 |
$storeCode = Mage::app()->getRequest()->getParam('store');
|
35 |
|
36 |
if(isset($storeId) && $storeId != FALSE) {
|
37 |
+
$storeId = $storeId; // ?
|
38 |
}
|
39 |
elseif($storeCode) {
|
40 |
$storeId = Mage::app()->getStore($storeCode)->getId();
|
72 |
|
73 |
$selectLists[0] = array('value' => 0, 'label'=>'-- Select a list (if any) --');
|
74 |
|
75 |
+
if($xmlString) {
|
76 |
$xmlString = html_entity_decode($xmlString);
|
|
|
77 |
$startLists = strpos($xmlString, '<Lists>');
|
78 |
$endPos = strpos($xmlString, '</Lists>');
|
79 |
$endLists = $endPos + strlen('</Lists>') - $startLists;
|
|
|
80 |
$xmlLists = substr($xmlString, $startLists, $endLists);
|
|
|
81 |
$xmlLists = str_replace("&", "&", $xmlLists);
|
|
|
82 |
$xml = simplexml_load_string($xmlLists);
|
|
|
83 |
$count = 1;
|
84 |
foreach ($xml->List as $list) {
|
85 |
$groups = array();
|
87 |
$groups[(string)$tmp["idGroup"]] = (string)$tmp["groupName"];
|
88 |
}
|
89 |
$selectLists[$count] = array(
|
90 |
+
'value' => (string)$list['idList'],
|
91 |
+
'label' => (string)$list['listName'],
|
92 |
+
'guid' =>(string)$list['listGUID'],
|
93 |
+
"groups" => $groups
|
94 |
);
|
95 |
$count++;
|
96 |
}
|
103 |
|
104 |
return $selectLists;
|
105 |
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get an array of list data, and it's groups.
|
109 |
+
*
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
|
113 |
+
public function getListDataArray($listId, $storeId)
|
114 |
+
{
|
115 |
+
$listData = $this->getDataArray($storeId);
|
116 |
+
if(isset($listData[$listId])) {
|
117 |
+
return $listData[$listId];
|
118 |
+
}
|
119 |
+
|
120 |
+
throw new Mage_Exception('Invalid List ID: ' . $listId);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get an array of all lists, and their groups!
|
125 |
+
*
|
126 |
+
* @return array
|
127 |
+
*/
|
128 |
+
|
129 |
+
public function getDataArray($storeId)
|
130 |
+
{
|
131 |
+
$selectLists = array();
|
132 |
+
|
133 |
+
if( ! isset($this->_cache[$storeId])) {
|
134 |
+
if($this->_config()->getUrlConsole($storeId) && $this->_config()->getUsername($storeId)
|
135 |
+
&& $this->_config()->getPassword($storeId)) {
|
136 |
+
$wsSend = new MailUpWsSend($storeId);
|
137 |
+
$accessKey = $wsSend->loginFromId();
|
138 |
+
if($accessKey !== false) {
|
139 |
+
require_once dirname(__FILE__) . "/MailUpWsImport.php";
|
140 |
+
$wsImport = new MailUpWsImport($storeId);
|
141 |
+
$xmlString = $wsImport->GetNlList();
|
142 |
+
if($xmlString) {
|
143 |
+
$xmlString = html_entity_decode($xmlString);
|
144 |
+
$startLists = strpos($xmlString, '<Lists>');
|
145 |
+
$endPos = strpos($xmlString, '</Lists>');
|
146 |
+
$endLists = $endPos + strlen('</Lists>') - $startLists;
|
147 |
+
$xmlLists = substr($xmlString, $startLists, $endLists);
|
148 |
+
$xmlLists = str_replace("&", "&", $xmlLists);
|
149 |
+
$xml = simplexml_load_string($xmlLists);
|
150 |
+
foreach ($xml->List as $list) {
|
151 |
+
$groups = array();
|
152 |
+
foreach ($list->Groups->Group as $tmp) {
|
153 |
+
$groups[(string)$tmp["idGroup"]] = (string)$tmp["groupName"];
|
154 |
+
}
|
155 |
+
$selectLists[(string)$list['idList']] = array(
|
156 |
+
'idList' => (string)$list['idList'],
|
157 |
+
'listName' => (string)$list['listName'],
|
158 |
+
'listGUID' =>(string)$list['listGUID'],
|
159 |
+
"groups" => $groups
|
160 |
+
);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
$this->_cache[$storeId] = $selectLists;
|
167 |
+
}
|
168 |
+
|
169 |
+
return $this->_cache[$storeId];
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Get a List Guid
|
174 |
+
*
|
175 |
+
* @param int
|
176 |
+
* @param int
|
177 |
+
* @return string
|
178 |
+
*/
|
179 |
+
public function getListGuid($listId, $storeId)
|
180 |
+
{
|
181 |
+
$listData = $this->getListDataArray($listId, $storeId);
|
182 |
+
|
183 |
+
if( ! isset($listData['listGUID'])) {
|
184 |
+
throw new Mage_Exception("Cant find ListGuid for List [{$listId}] Store [{$storeId}]");
|
185 |
+
}
|
186 |
+
|
187 |
+
return $listData['listGUID'];
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Get the groups for a given list.
|
192 |
+
*
|
193 |
+
* @param int
|
194 |
+
*/
|
195 |
+
public function getListGroups($listId, $storeId)
|
196 |
+
{
|
197 |
+
$listData = $this->getListDataArray($listId, $storeId);
|
198 |
+
|
199 |
+
return $listData['groups'];
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @var SevenLike_MailUp_Model_Config
|
204 |
+
*/
|
205 |
+
protected $_config;
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Get the config
|
209 |
+
*
|
210 |
+
* @reutrn SevenLike_MailUp_Model_Config
|
211 |
+
*/
|
212 |
+
protected function _config()
|
213 |
+
{
|
214 |
+
if(NULL === $this->_config) {
|
215 |
+
$this->_config = Mage::getModel('mailup/config');
|
216 |
+
}
|
217 |
+
|
218 |
+
return $this->_config;
|
219 |
+
}
|
220 |
}
|
app/code/local/SevenLike/MailUp/Model/Log.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Log.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Log extends Mage_Core_Model_Abstract
|
6 |
+
{
|
7 |
+
const TYPE_DEBUG = 'DEBUG';
|
8 |
+
const TYPE_API = 'API';
|
9 |
+
const TYPE_JOB = 'JOB';
|
10 |
+
const TYPE_JOB_DATA = 'SYNC';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init("mailup/log");
|
19 |
+
}
|
20 |
+
}
|
app/code/local/SevenLike/MailUp/Model/MailUpWsImport.php
CHANGED
@@ -22,6 +22,21 @@ class MailUpWsImport
|
|
22 |
const ERROR_CHECKING_PROCESS_STATUS = -603;
|
23 |
const ERROR_STARTING_PROCESS_JOB = -604;
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* @var string
|
27 |
*/
|
@@ -65,10 +80,12 @@ class MailUpWsImport
|
|
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(
|
|
|
|
|
|
|
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 |
}
|
@@ -93,23 +110,16 @@ class MailUpWsImport
|
|
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 |
*/
|
@@ -119,15 +129,19 @@ class MailUpWsImport
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
catch (SoapFault $soapFault) {
|
133 |
Mage::log('SOAP error', 0);
|
@@ -138,7 +152,12 @@ class MailUpWsImport
|
|
138 |
/**
|
139 |
* GetNlList
|
140 |
*
|
141 |
-
*
|
|
|
|
|
|
|
|
|
|
|
142 |
*/
|
143 |
public function GetNlList()
|
144 |
{
|
@@ -151,7 +170,7 @@ class MailUpWsImport
|
|
151 |
$this->printLastResponse();
|
152 |
$result = $this->soapClient->__getLastResponse();
|
153 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
154 |
-
|
155 |
}
|
156 |
return $result;
|
157 |
}
|
@@ -166,7 +185,7 @@ class MailUpWsImport
|
|
166 |
*
|
167 |
* @see http://help.mailup.com/display/mailupapi/WSMailUpImport.NewImportProcess
|
168 |
* @param type $importProcessData
|
169 |
-
* @return
|
170 |
*/
|
171 |
public function newImportProcess($importProcessData)
|
172 |
{
|
@@ -185,7 +204,7 @@ class MailUpWsImport
|
|
185 |
*/
|
186 |
$returncode = $this->readReturnCode('NewImportProcess', 'ReturnCode');
|
187 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
188 |
-
|
189 |
}
|
190 |
return $returncode;
|
191 |
}
|
@@ -199,6 +218,8 @@ class MailUpWsImport
|
|
199 |
/**
|
200 |
* Start Process
|
201 |
*
|
|
|
|
|
202 |
* @see http://help.mailup.com/display/mailupapi/WSMailUpImport.StartProcess
|
203 |
* @param type $processData
|
204 |
* @return boolean
|
@@ -211,23 +232,27 @@ class MailUpWsImport
|
|
211 |
try {
|
212 |
$this->soapClient->StartProcess($processData);
|
213 |
$this->printLastResponse();
|
214 |
-
|
215 |
-
|
|
|
216 |
}
|
217 |
-
|
|
|
218 |
}
|
219 |
catch (SoapFault $soapFault) {
|
220 |
Mage::log('SOAP error', 0);
|
221 |
Mage::log($soapFault, 0);
|
222 |
-
return
|
223 |
}
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
* Process Detail
|
228 |
*
|
229 |
-
*
|
230 |
-
*
|
|
|
|
|
231 |
*/
|
232 |
public function getProcessDetail($processData)
|
233 |
{
|
@@ -236,13 +261,16 @@ class MailUpWsImport
|
|
236 |
}
|
237 |
try {
|
238 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
239 |
-
|
|
|
|
|
|
|
240 |
}
|
241 |
}
|
242 |
catch (SoapFault $soapFault) {
|
243 |
Mage::log('SOAP error', 0);
|
244 |
Mage::log($soapFault, 0);
|
245 |
-
}
|
246 |
}
|
247 |
|
248 |
/**
|
@@ -250,7 +278,7 @@ class MailUpWsImport
|
|
250 |
*
|
251 |
* @see http://help.mailup.com/display/mailupapi/WSMailUpImport.StartImportProcesses
|
252 |
* @param type $processData
|
253 |
-
* @return
|
254 |
*/
|
255 |
public function startImportProcesses($processData)
|
256 |
{
|
@@ -260,16 +288,21 @@ class MailUpWsImport
|
|
260 |
try {
|
261 |
$this->soapClient->StartImportProcesses($processData);
|
262 |
$returnCode = $this->_getStartImportProcessResult();
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
|
|
|
|
267 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
268 |
-
|
|
|
|
|
269 |
}
|
270 |
$this->printLastRequest();
|
271 |
$this->printLastResponse();
|
272 |
-
|
|
|
273 |
}
|
274 |
catch (SoapFault $soapFault) {
|
275 |
Mage::log('SOAP error', 0);
|
@@ -317,10 +350,11 @@ class MailUpWsImport
|
|
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 |
-
|
|
|
324 |
return 9999;
|
325 |
}
|
326 |
|
@@ -330,11 +364,27 @@ class MailUpWsImport
|
|
330 |
/**
|
331 |
* Get the result form the Import Process
|
332 |
*
|
333 |
-
* An array of status code
|
334 |
* but may be followed by return codes for each process started.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
*
|
336 |
* @param string
|
337 |
-
* @return
|
338 |
*/
|
339 |
protected function _getStartImportProcessResult($param = 'ReturnCode')
|
340 |
{
|
@@ -358,10 +408,32 @@ class MailUpWsImport
|
|
358 |
$returnCodes[] = $node->nodeValue;
|
359 |
}
|
360 |
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
}
|
363 |
else {
|
364 |
-
|
365 |
return 9999;
|
366 |
}
|
367 |
|
@@ -373,9 +445,6 @@ class MailUpWsImport
|
|
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 |
*/
|
@@ -399,7 +468,7 @@ class MailUpWsImport
|
|
399 |
return $rCode->nodeValue;
|
400 |
}
|
401 |
else {
|
402 |
-
|
403 |
return 9999;
|
404 |
}
|
405 |
|
@@ -413,7 +482,8 @@ class MailUpWsImport
|
|
413 |
*/
|
414 |
private function printLastRequest()
|
415 |
{
|
416 |
-
return
|
|
|
417 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
418 |
$this->soapClient->__getLastRequest();
|
419 |
}
|
@@ -424,19 +494,19 @@ class MailUpWsImport
|
|
424 |
*/
|
425 |
private function printLastResponse()
|
426 |
{
|
427 |
-
//return "";
|
428 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
429 |
-
Mage::log('
|
430 |
Mage::log($this->soapClient->__getLastResponse());
|
431 |
}
|
432 |
}
|
433 |
|
434 |
/**
|
435 |
-
* Get filtered customers
|
436 |
*
|
437 |
-
* @todo refactor
|
438 |
* @param
|
439 |
-
* @
|
|
|
440 |
*/
|
441 |
public function getCustomersFiltered($request, $storeId = NULL)
|
442 |
{
|
@@ -454,14 +524,23 @@ class MailUpWsImport
|
|
454 |
->addAttributeToSelect('group_id')
|
455 |
->addAttributeToSelect('created_at')
|
456 |
->addAttributeToSelect('store_id')
|
457 |
-
->
|
458 |
-
->getSelect()->query()
|
459 |
;
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
|
466 |
while ($row = $customerCollection->fetch()) {
|
467 |
$customersFiltered[] = $row;
|
@@ -478,8 +557,10 @@ class MailUpWsImport
|
|
478 |
}
|
479 |
$customersFiltered = array_intersect($tempSubscribed, $customersFiltered);
|
480 |
}
|
481 |
-
|
482 |
-
|
|
|
|
|
483 |
$count = 0;
|
484 |
$result = array();
|
485 |
$tempPurchased = array();
|
@@ -488,32 +569,30 @@ class MailUpWsImport
|
|
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 |
-
}
|
|
|
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 |
-
}
|
|
|
511 |
$customersFiltered = array_intersect($tempNoPurchased, $customersFiltered);
|
512 |
}
|
513 |
}
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
$count = 0;
|
518 |
$result = array();
|
519 |
$tempProduct = array();
|
@@ -534,7 +613,9 @@ class MailUpWsImport
|
|
534 |
;
|
535 |
|
536 |
foreach ($orders->getData() as $order) {
|
537 |
-
|
|
|
|
|
538 |
$orderIncrementId = $order['increment_id'];
|
539 |
|
540 |
//carico i dati di ogni ordine
|
@@ -563,51 +644,52 @@ class MailUpWsImport
|
|
563 |
|
564 |
$customersFiltered = array_intersect($tempProduct, $customersFiltered);
|
565 |
}
|
566 |
-
|
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 |
-
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
593 |
foreach ($items as $product) {
|
594 |
-
|
595 |
-
|
|
|
|
|
|
|
596 |
break 2;
|
597 |
-
|
598 |
}
|
599 |
}
|
600 |
-
|
601 |
unset($orders);
|
602 |
$count++;
|
603 |
}
|
604 |
-
|
605 |
$customersFiltered = array_intersect($tempCategory, $customersFiltered);
|
606 |
}
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
$count = 0;
|
612 |
$result = array();
|
613 |
$tempGroup = array();
|
@@ -689,13 +771,27 @@ class MailUpWsImport
|
|
689 |
$filterEnd = '';
|
690 |
|
691 |
if ($request->getRequest()->getParam('mailupCustomerStartDate')) {
|
692 |
-
$date = Zend_Locale_Format::getDate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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";
|
@@ -705,12 +801,14 @@ class MailUpWsImport
|
|
705 |
if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
|
706 |
$tempDate[] = $customer;
|
707 |
}
|
708 |
-
}
|
|
|
709 |
// >= di start date
|
710 |
if ($createdAt >= $filterStart) {
|
711 |
$tempDate[] = $customer;
|
712 |
}
|
713 |
-
}
|
|
|
714 |
// <= di end date
|
715 |
if ($createdAt <= $filterEnd) {
|
716 |
$tempDate[] = $customer;
|
@@ -741,7 +839,9 @@ class MailUpWsImport
|
|
741 |
$totalOrdered = 0;
|
742 |
|
743 |
foreach ($orders->getData() as $order) {
|
744 |
-
if
|
|
|
|
|
745 |
$totalOrdered += $order['subtotal'];
|
746 |
}
|
747 |
|
@@ -791,7 +891,9 @@ class MailUpWsImport
|
|
791 |
$orderedDate = 0;
|
792 |
|
793 |
foreach ($orders->getData() as $order) {
|
794 |
-
|
|
|
|
|
795 |
$createdAt = $order['created_at'];
|
796 |
$createdAt = new DateTime($createdAt, $TIMEZONE_UTC);
|
797 |
$createdAt->setTimezone($TIMEZONE_STORE);
|
@@ -800,13 +902,27 @@ class MailUpWsImport
|
|
800 |
$filterEnd = '';
|
801 |
|
802 |
if ($request->getRequest()->getParam('mailupOrderStartDate')) {
|
803 |
-
$date = Zend_Locale_Format::getDate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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";
|
@@ -817,12 +933,14 @@ class MailUpWsImport
|
|
817 |
if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
|
818 |
$orderedDate = 1;
|
819 |
}
|
820 |
-
}
|
|
|
821 |
// >= di start date
|
822 |
if ($createdAt >= $filterStart) {
|
823 |
$orderedDate = 1;
|
824 |
}
|
825 |
-
}
|
|
|
826 |
// <= di end date
|
827 |
if ($createdAt <= $filterEnd) {
|
828 |
$orderedDate = 1;
|
@@ -835,7 +953,8 @@ class MailUpWsImport
|
|
835 |
|
836 |
if ($orderedDate == 1) {
|
837 |
$tempOrderedDateYes[] = $result[$count];
|
838 |
-
}
|
|
|
839 |
$tempOrderedDateNo[] = $result[$count];
|
840 |
}
|
841 |
|
@@ -844,13 +963,14 @@ class MailUpWsImport
|
|
844 |
|
845 |
if ($request->getRequest()->getParam('mailupOrderYesNo') == 'yes') {
|
846 |
$customersFiltered = array_intersect($tempOrderedDateYes, $customersFiltered);
|
847 |
-
}
|
|
|
848 |
$customersFiltered = array_intersect($tempOrderedDateNo, $customersFiltered);
|
849 |
}
|
850 |
}
|
851 |
//FINE FILTRO 9 DATA ACQUISTATO: testato ok
|
852 |
-
|
853 |
-
|
854 |
//GESTISCO LE MODIFICHE MANUALI
|
855 |
$count = 0;
|
856 |
$result = array();
|
@@ -888,8 +1008,13 @@ class MailUpWsImport
|
|
888 |
return $customersFiltered;
|
889 |
}
|
890 |
|
891 |
-
|
892 |
-
|
|
|
|
|
|
|
|
|
|
|
893 |
$filter_hints = array();
|
894 |
try {
|
895 |
// fetch write database connection that is used in Mage_Core module
|
@@ -909,7 +1034,14 @@ class MailUpWsImport
|
|
909 |
return $filter_hints;
|
910 |
}
|
911 |
|
912 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
913 |
try {
|
914 |
$hints = '';
|
915 |
foreach ($post as $k => $v) {
|
@@ -921,22 +1053,27 @@ class MailUpWsImport
|
|
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 |
-
}
|
|
|
929 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
930 |
die($e);
|
931 |
}
|
932 |
}
|
933 |
|
934 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
}
|
|
|
940 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
941 |
die($e);
|
942 |
}
|
@@ -954,18 +1091,6 @@ class MailUpWsImport
|
|
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 |
/**
|
@@ -999,4 +1124,17 @@ class MailUpWsImport
|
|
999 |
{
|
1000 |
return $this->_config;
|
1001 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1002 |
}
|
22 |
const ERROR_CHECKING_PROCESS_STATUS = -603;
|
23 |
const ERROR_STARTING_PROCESS_JOB = -604;
|
24 |
|
25 |
+
const STARTIMPORTPROCESSES_SUCCESS = 0;
|
26 |
+
|
27 |
+
/*protected $_messages = array(
|
28 |
+
'ERROR_UNRECOGNISED' => -400,
|
29 |
+
'ERROR_XML_EMPTY' => 401,
|
30 |
+
'ERROR_XML_TO_CSV_FAILED' => -402,
|
31 |
+
'ERROR_NEW_IMPORT_PROCESS_FAILED' => -403,
|
32 |
+
'ERROR_CONFIRMATION_EMAIL' => -410,
|
33 |
+
'ERROR_LISTID_LISTGUID_MISMATCH' => -450,
|
34 |
+
'ERROR_UNRECOGNISED_600' => -600,
|
35 |
+
'ERROR_IMPORT_PROCESS_RUNNING_FOR_DIFF_LIST' => -602,
|
36 |
+
'ERROR_CHECKING_PROCESS_STATUS' => -603,
|
37 |
+
'ERROR_STARTING_PROCESS_JOB' => -604
|
38 |
+
);*/
|
39 |
+
|
40 |
/**
|
41 |
* @var string
|
42 |
*/
|
80 |
$WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
|
81 |
$user = Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId);
|
82 |
$password = Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $this->storeId);
|
83 |
+
$headers = array(
|
84 |
+
'User' => $user,
|
85 |
+
'Password' => $password
|
86 |
+
);
|
87 |
$this->header = new SOAPHeader($this->ns, 'Authentication', $headers);
|
88 |
|
|
|
89 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
90 |
Mage::log("Connecting to {$urlConsole} as {$user}");
|
91 |
}
|
110 |
|
111 |
return $this;
|
112 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
/**
|
115 |
* Create a New Group
|
116 |
*
|
117 |
+
* @todo CHECK THE API - might have been updated??
|
118 |
+
* The API states the signature of this method is:
|
119 |
+
*
|
120 |
+
* CreateGroup(int idList, int listGUID, string newGroupName)
|
121 |
+
*
|
122 |
+
*
|
123 |
* @param type $newGroup
|
124 |
* @return boolean
|
125 |
*/
|
129 |
return false;
|
130 |
}
|
131 |
try {
|
|
|
|
|
|
|
|
|
132 |
$this->soapClient->CreateGroup($newGroup);
|
133 |
$this->printLastRequest();
|
134 |
$this->printLastResponse();
|
135 |
+
$returnCode = $this->readReturnCode('CreateGroup', 'ReturnCode');
|
136 |
+
if ($this->_config()->isLogEnabled($this->storeId)) {
|
137 |
+
$this->_config()->dbLog(sprintf(
|
138 |
+
"Mailup: Create a new Group [%s] [List:%s] [%s]",
|
139 |
+
$newGroup['newGroupName'],
|
140 |
+
$newGroup['listGUID'],
|
141 |
+
$returnCode
|
142 |
+
));
|
143 |
+
}
|
144 |
+
return $returnCode;
|
145 |
}
|
146 |
catch (SoapFault $soapFault) {
|
147 |
Mage::log('SOAP error', 0);
|
152 |
/**
|
153 |
* GetNlList
|
154 |
*
|
155 |
+
* KNOWN RESTRICTION
|
156 |
+
* Characters & and " are not escaped in returned response, so please avoid these
|
157 |
+
* characters in names of lists and groups otherwise you will experience some problems due to an invalid returned XML
|
158 |
+
*
|
159 |
+
* @todo parse the XML response correctly and return something nice.
|
160 |
+
* @return string
|
161 |
*/
|
162 |
public function GetNlList()
|
163 |
{
|
170 |
$this->printLastResponse();
|
171 |
$result = $this->soapClient->__getLastResponse();
|
172 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
173 |
+
$this->_config()->log($result, 0);
|
174 |
}
|
175 |
return $result;
|
176 |
}
|
185 |
*
|
186 |
* @see http://help.mailup.com/display/mailupapi/WSMailUpImport.NewImportProcess
|
187 |
* @param type $importProcessData
|
188 |
+
* @return int
|
189 |
*/
|
190 |
public function newImportProcess($importProcessData)
|
191 |
{
|
204 |
*/
|
205 |
$returncode = $this->readReturnCode('NewImportProcess', 'ReturnCode');
|
206 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
207 |
+
$this->_config()->dbLog("newImportProcess [ReturnCode] [{$returncode}]", 0);
|
208 |
}
|
209 |
return $returncode;
|
210 |
}
|
218 |
/**
|
219 |
* Start Process
|
220 |
*
|
221 |
+
* StartProcess(int idList, int listGUID, int idProcess)
|
222 |
+
*
|
223 |
* @see http://help.mailup.com/display/mailupapi/WSMailUpImport.StartProcess
|
224 |
* @param type $processData
|
225 |
* @return boolean
|
232 |
try {
|
233 |
$this->soapClient->StartProcess($processData);
|
234 |
$this->printLastResponse();
|
235 |
+
$returncode = $this->readReturnCode('mailupMessage', 'ReturnCode');
|
236 |
+
if ($this->_config()->isLogEnabled($this->storeId)) {
|
237 |
+
$this->_config()->log("mailup: startProcess");
|
238 |
}
|
239 |
+
|
240 |
+
return $returncode;
|
241 |
}
|
242 |
catch (SoapFault $soapFault) {
|
243 |
Mage::log('SOAP error', 0);
|
244 |
Mage::log($soapFault, 0);
|
245 |
+
return FALSE;
|
246 |
}
|
247 |
}
|
248 |
|
249 |
/**
|
250 |
* Process Detail
|
251 |
*
|
252 |
+
* GetProcessDetails(int idList, int listGUID, int idProcess)
|
253 |
+
*
|
254 |
+
* @param array $processData
|
255 |
+
* @return boolean
|
256 |
*/
|
257 |
public function getProcessDetail($processData)
|
258 |
{
|
261 |
}
|
262 |
try {
|
263 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
264 |
+
//GetProcessDetails(int idList, int listGUID, int idProcess)
|
265 |
+
$res = $this->soapClient->GetProcessDetails($processData);
|
266 |
+
$this->_config()->log($res, 0);
|
267 |
+
return $res;
|
268 |
}
|
269 |
}
|
270 |
catch (SoapFault $soapFault) {
|
271 |
Mage::log('SOAP error', 0);
|
272 |
Mage::log($soapFault, 0);
|
273 |
+
}
|
274 |
}
|
275 |
|
276 |
/**
|
278 |
*
|
279 |
* @see http://help.mailup.com/display/mailupapi/WSMailUpImport.StartImportProcesses
|
280 |
* @param type $processData
|
281 |
+
* @return int|bool
|
282 |
*/
|
283 |
public function startImportProcesses($processData)
|
284 |
{
|
288 |
try {
|
289 |
$this->soapClient->StartImportProcesses($processData);
|
290 |
$returnCode = $this->_getStartImportProcessResult();
|
291 |
+
/**
|
292 |
+
* @todo handle response better
|
293 |
+
*
|
294 |
+
* We need to check this to see if we really are done, or the process is in a queue
|
295 |
+
* or already running etc!
|
296 |
+
*/
|
297 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
298 |
+
$this->_config()->dbLog("startImportProcesses [triggered]");
|
299 |
+
$this->_config()->dbLog(sprintf("startImportProcesses [ReturnCode] [%d]", $returnCode));
|
300 |
+
//$this->_config()->log($returnCode);
|
301 |
}
|
302 |
$this->printLastRequest();
|
303 |
$this->printLastResponse();
|
304 |
+
|
305 |
+
return $returnCode;
|
306 |
}
|
307 |
catch (SoapFault $soapFault) {
|
308 |
Mage::log('SOAP error', 0);
|
350 |
*/
|
351 |
if(isset($this->domResult) && is_object($this->domResult)) {
|
352 |
$rCode = $this->domResult->getElementsByTagName($param);
|
353 |
+
return (int) $rCode->item(0)->nodeValue;
|
354 |
}
|
355 |
else {
|
356 |
+
$this->_config()->dbLog('readReturnCode [No Return Code]');
|
357 |
+
//$this->_config()->log('readReturnCode [No Return Code]');
|
358 |
return 9999;
|
359 |
}
|
360 |
|
364 |
/**
|
365 |
* Get the result form the Import Process
|
366 |
*
|
367 |
+
* An array of status code's the first one is the overall return code,
|
368 |
* but may be followed by return codes for each process started.
|
369 |
+
*
|
370 |
+
* <mailupMessage>
|
371 |
+
<mailupBody>
|
372 |
+
<ReturnCode>0</ReturnCode>
|
373 |
+
<processes>
|
374 |
+
<process>
|
375 |
+
<processID>696</processID>
|
376 |
+
<listID>4</listID>
|
377 |
+
<ReturnCode>0</ReturnCode><!-- 0 = success -->
|
378 |
+
<processID>697</processID>
|
379 |
+
<listID>4</listID>
|
380 |
+
<ReturnCode>0</ReturnCode>
|
381 |
+
</process>
|
382 |
+
</processes>
|
383 |
+
</mailupBody>
|
384 |
+
</mailupMessage>
|
385 |
*
|
386 |
* @param string
|
387 |
+
* @return int
|
388 |
*/
|
389 |
protected function _getStartImportProcessResult($param = 'ReturnCode')
|
390 |
{
|
408 |
$returnCodes[] = $node->nodeValue;
|
409 |
}
|
410 |
|
411 |
+
$processIds = array();
|
412 |
+
$nodes = $this->domResult->getElementsByTagName('processID');
|
413 |
+
foreach($nodes as $node) {
|
414 |
+
$processIds[] = $node->nodeValue;
|
415 |
+
}
|
416 |
+
|
417 |
+
$overallReturnCode = array_shift($returnCodes); // first one is the overall returnCode.
|
418 |
+
/**
|
419 |
+
* Lets get the return codes for each process
|
420 |
+
*/
|
421 |
+
if(count($returnCodes) > 0 && count($returnCodes) == count($processIds)) {
|
422 |
+
/**
|
423 |
+
* @todo Use StartImportProcesses HERE!
|
424 |
+
*
|
425 |
+
* We now have a list of Process IDs which have been added to the queue.
|
426 |
+
* We can now go through them all and try and start them!
|
427 |
+
*/
|
428 |
+
$returnCodes = array_combine($processIds, $returnCodes);
|
429 |
+
$this->_config()->log('getStartImportProcessResult [Process Return Codes]');
|
430 |
+
$this->_config()->log($returnCodes);
|
431 |
+
}
|
432 |
+
|
433 |
+
return (int) $overallReturnCode;
|
434 |
}
|
435 |
else {
|
436 |
+
$this->_config()->log('getStartImportProcessResult [No ReturnCode]');
|
437 |
return 9999;
|
438 |
}
|
439 |
|
445 |
*
|
446 |
* Get the result form New Import Process
|
447 |
*
|
|
|
|
|
|
|
448 |
* @param string
|
449 |
* @return array
|
450 |
*/
|
468 |
return $rCode->nodeValue;
|
469 |
}
|
470 |
else {
|
471 |
+
$this->_config()->log('getNewImportProcessResult [No ReturnCode]');
|
472 |
return 9999;
|
473 |
}
|
474 |
|
482 |
*/
|
483 |
private function printLastRequest()
|
484 |
{
|
485 |
+
return;
|
486 |
+
|
487 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
488 |
$this->soapClient->__getLastRequest();
|
489 |
}
|
494 |
*/
|
495 |
private function printLastResponse()
|
496 |
{
|
|
|
497 |
if ($this->_config()->isLogEnabled($this->storeId)) {
|
498 |
+
Mage::log('Mailup: printLastResponse');
|
499 |
Mage::log($this->soapClient->__getLastResponse());
|
500 |
}
|
501 |
}
|
502 |
|
503 |
/**
|
504 |
+
* Get filtered customers
|
505 |
*
|
506 |
+
* @todo refactor
|
507 |
* @param
|
508 |
+
* @param int
|
509 |
+
* @return array
|
510 |
*/
|
511 |
public function getCustomersFiltered($request, $storeId = NULL)
|
512 |
{
|
524 |
->addAttributeToSelect('group_id')
|
525 |
->addAttributeToSelect('created_at')
|
526 |
->addAttributeToSelect('store_id')
|
527 |
+
//->getSelect()->query()
|
|
|
528 |
;
|
529 |
+
/**
|
530 |
+
* @todo review if this is correct behaviour.
|
531 |
+
* If StoreID = 0 we will not bother to filter...
|
532 |
+
*/
|
533 |
+
if(isset($storeId) && ! empty($storeId)) {
|
534 |
+
$customerCollection->addAttributeToFilter('store_id', array(
|
535 |
+
'eq' => $storeId
|
536 |
+
));
|
537 |
+
}
|
538 |
+
/*else {
|
539 |
+
$customerCollection->addAttributeToFilter('store_id', array(
|
540 |
+
'eq' => Mage::app()->getDefaultStoreView()->getStoreId()
|
541 |
+
));
|
542 |
+
}*/
|
543 |
+
$customerCollection = $customerCollection->getSelect()->query();
|
544 |
|
545 |
while ($row = $customerCollection->fetch()) {
|
546 |
$customersFiltered[] = $row;
|
557 |
}
|
558 |
$customersFiltered = array_intersect($tempSubscribed, $customersFiltered);
|
559 |
}
|
560 |
+
/**
|
561 |
+
* FILTRO 1 ACQUISTATO: in base al fatto se ha effettuato o meno acquisti:
|
562 |
+
* 0 = tutti, 1 = chi ha acquistato, 2 = chi non ha mai acquistato
|
563 |
+
*/
|
564 |
$count = 0;
|
565 |
$result = array();
|
566 |
$tempPurchased = array();
|
569 |
if ($request->getRequest()->getParam('mailupCustomers') > 0) {
|
570 |
foreach ($customersFiltered as $customer) {
|
571 |
$result[] = $customer;
|
|
|
572 |
//filtro gli ordini in base al customer id
|
573 |
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $result[$count]['entity_id']);
|
|
|
574 |
//aggiungo il cliente ad un determinato array in base a se ha ordinato o meno
|
575 |
if ($orders->getData()) {
|
576 |
$tempPurchased[] = $result[$count];
|
577 |
+
}
|
578 |
+
else {
|
579 |
$tempNoPurchased[] = $result[$count];
|
580 |
}
|
|
|
581 |
//unsetto la variabile
|
582 |
unset($orders); //->unsetData();
|
|
|
583 |
$count++;
|
584 |
}
|
585 |
|
586 |
if ($request->getRequest()->getParam('mailupCustomers') == 1) {
|
587 |
$customersFiltered = array_intersect($tempPurchased, $customersFiltered);
|
588 |
+
}
|
589 |
+
elseif ($request->getRequest()->getParam('mailupCustomers') == 2) {
|
590 |
$customersFiltered = array_intersect($tempNoPurchased, $customersFiltered);
|
591 |
}
|
592 |
}
|
593 |
+
/**
|
594 |
+
* FILTRO 2 PRODOTTO ACQUISTATO: in base al fatto se ha acquistato un determinato prodotto
|
595 |
+
*/
|
596 |
$count = 0;
|
597 |
$result = array();
|
598 |
$tempProduct = array();
|
613 |
;
|
614 |
|
615 |
foreach ($orders->getData() as $order) {
|
616 |
+
if(isset($order["status"]) && ! in_array($order["status"], array("closed", "complete", "processing"))) {
|
617 |
+
continue;
|
618 |
+
}
|
619 |
$orderIncrementId = $order['increment_id'];
|
620 |
|
621 |
//carico i dati di ogni ordine
|
644 |
|
645 |
$customersFiltered = array_intersect($tempProduct, $customersFiltered);
|
646 |
}
|
647 |
+
/**
|
648 |
+
* FILTER BOUGHT IN CATEGORY 3: Depending on whether bought at least one product in a given category
|
649 |
+
*/
|
|
|
650 |
$count = 0;
|
651 |
$result = array();
|
652 |
$tempCategory = array();
|
|
|
653 |
if ($request->getRequest()->getParam('mailupCategoryId') > 0) {
|
654 |
foreach ($customersFiltered as $customer) {
|
655 |
$result[] = $customer;
|
|
|
656 |
//filtro gli ordini in base al customer id
|
657 |
$orders = Mage::getModel('sales/order')
|
658 |
->getCollection()
|
659 |
->addAttributeToFilter('customer_id', $result[$count]['entity_id'])
|
660 |
;
|
|
|
|
|
661 |
foreach ($orders->getData() as $order) {
|
662 |
+
if(isset($order["status"]) && ! in_array($order["status"], array("closed", "complete", "processing"))) {
|
663 |
+
continue;
|
664 |
+
}
|
665 |
$orderIncrementId = $order['increment_id'];
|
666 |
|
667 |
//carico i dati di ogni ordine
|
668 |
$orderData = Mage::getModel('sales/order')->loadByIncrementID($orderIncrementId);
|
669 |
$items = $orderData->getAllItems();
|
670 |
+
/**
|
671 |
+
* Category ID, and it's descendants
|
672 |
+
*/
|
673 |
+
$searchCategories = Mage::helper('mailup')->getSubCategories($request->getRequest()->getParam('mailupCategoryId'));
|
674 |
foreach ($items as $product) {
|
675 |
+
$_prod = Mage::getModel('catalog/product')->load($product->getProductId()); // ned to load full product for cats.
|
676 |
+
$productCategories = Mage::getResourceSingleton('catalog/product')->getCategoryIds($_prod);
|
677 |
+
$matchingCategories = array_intersect($productCategories, $searchCategories);
|
678 |
+
if(is_array($matchingCategories) && ! empty($matchingCategories)) {
|
679 |
+
$tempCategory[] = $result[$count];
|
680 |
break 2;
|
681 |
+
}
|
682 |
}
|
683 |
}
|
|
|
684 |
unset($orders);
|
685 |
$count++;
|
686 |
}
|
|
|
687 |
$customersFiltered = array_intersect($tempCategory, $customersFiltered);
|
688 |
}
|
689 |
+
|
690 |
+
/**
|
691 |
+
* FILTRO 4 GRUPPO DI CLIENTI
|
692 |
+
*/
|
693 |
$count = 0;
|
694 |
$result = array();
|
695 |
$tempGroup = array();
|
771 |
$filterEnd = '';
|
772 |
|
773 |
if ($request->getRequest()->getParam('mailupCustomerStartDate')) {
|
774 |
+
$date = Zend_Locale_Format::getDate(
|
775 |
+
$request->getRequest()->getParam('mailupCustomerStartDate'),
|
776 |
+
array(
|
777 |
+
'locale'=>Mage::app()->getLocale()->getLocale(),
|
778 |
+
'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
779 |
+
'fix_date'=>true
|
780 |
+
)
|
781 |
+
);
|
782 |
$date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
|
783 |
$date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
|
784 |
$filterStart = "{$date['year']}-{$date['month']}-{$date['day']} 00:00:00";
|
785 |
}
|
786 |
if ($request->getRequest()->getParam('mailupCustomerEndDate')) {
|
787 |
+
$date = Zend_Locale_Format::getDate(
|
788 |
+
$request->getRequest()->getParam('mailupCustomerEndDate'),
|
789 |
+
array(
|
790 |
+
'locale'=>Mage::app()->getLocale()->getLocale(),
|
791 |
+
'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
792 |
+
'fix_date'=>true
|
793 |
+
)
|
794 |
+
);
|
795 |
$date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
|
796 |
$date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
|
797 |
$filterEnd = "{$date['year']}-{$date['month']}-{$date['day']} 23:59:59";
|
801 |
if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
|
802 |
$tempDate[] = $customer;
|
803 |
}
|
804 |
+
}
|
805 |
+
elseif ($filterStart) {
|
806 |
// >= di start date
|
807 |
if ($createdAt >= $filterStart) {
|
808 |
$tempDate[] = $customer;
|
809 |
}
|
810 |
+
}
|
811 |
+
else {
|
812 |
// <= di end date
|
813 |
if ($createdAt <= $filterEnd) {
|
814 |
$tempDate[] = $customer;
|
839 |
$totalOrdered = 0;
|
840 |
|
841 |
foreach ($orders->getData() as $order) {
|
842 |
+
if(isset($order["status"]) && ! in_array($order["status"], array("closed", "complete", "processing"))) {
|
843 |
+
continue;
|
844 |
+
}
|
845 |
$totalOrdered += $order['subtotal'];
|
846 |
}
|
847 |
|
891 |
$orderedDate = 0;
|
892 |
|
893 |
foreach ($orders->getData() as $order) {
|
894 |
+
if(isset($order["status"]) && ! in_array($order["status"], array("closed", "complete", "processing"))) {
|
895 |
+
continue;
|
896 |
+
}
|
897 |
$createdAt = $order['created_at'];
|
898 |
$createdAt = new DateTime($createdAt, $TIMEZONE_UTC);
|
899 |
$createdAt->setTimezone($TIMEZONE_STORE);
|
902 |
$filterEnd = '';
|
903 |
|
904 |
if ($request->getRequest()->getParam('mailupOrderStartDate')) {
|
905 |
+
$date = Zend_Locale_Format::getDate(
|
906 |
+
$request->getRequest()->getParam('mailupOrderStartDate'),
|
907 |
+
array(
|
908 |
+
'locale'=>Mage::app()->getLocale()->getLocale(),
|
909 |
+
'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
910 |
+
'fix_date'=>true
|
911 |
+
)
|
912 |
+
);
|
913 |
$date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
|
914 |
$date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
|
915 |
$filterStart = "{$date['year']}-{$date['month']}-{$date['day']} 00:00:00";
|
916 |
}
|
917 |
if ($request->getRequest()->getParam('mailupOrderEndDate')) {
|
918 |
+
$date = Zend_Locale_Format::getDate(
|
919 |
+
$request->getRequest()->getParam('mailupOrderEndDate'),
|
920 |
+
array(
|
921 |
+
'locale'=>Mage::app()->getLocale()->getLocale(),
|
922 |
+
'date_format'=>Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
923 |
+
'fix_date'=>true
|
924 |
+
)
|
925 |
+
);
|
926 |
$date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
|
927 |
$date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
|
928 |
$filterEnd = "{$date['year']}-{$date['month']}-{$date['day']} 23:59:59";
|
933 |
if ($createdAt >= $filterStart and $createdAt <= $filterEnd) {
|
934 |
$orderedDate = 1;
|
935 |
}
|
936 |
+
}
|
937 |
+
elseif ($filterStart) {
|
938 |
// >= di start date
|
939 |
if ($createdAt >= $filterStart) {
|
940 |
$orderedDate = 1;
|
941 |
}
|
942 |
+
}
|
943 |
+
else {
|
944 |
// <= di end date
|
945 |
if ($createdAt <= $filterEnd) {
|
946 |
$orderedDate = 1;
|
953 |
|
954 |
if ($orderedDate == 1) {
|
955 |
$tempOrderedDateYes[] = $result[$count];
|
956 |
+
}
|
957 |
+
else {
|
958 |
$tempOrderedDateNo[] = $result[$count];
|
959 |
}
|
960 |
|
963 |
|
964 |
if ($request->getRequest()->getParam('mailupOrderYesNo') == 'yes') {
|
965 |
$customersFiltered = array_intersect($tempOrderedDateYes, $customersFiltered);
|
966 |
+
}
|
967 |
+
else {
|
968 |
$customersFiltered = array_intersect($tempOrderedDateNo, $customersFiltered);
|
969 |
}
|
970 |
}
|
971 |
//FINE FILTRO 9 DATA ACQUISTATO: testato ok
|
972 |
+
}
|
973 |
+
else {
|
974 |
//GESTISCO LE MODIFICHE MANUALI
|
975 |
$count = 0;
|
976 |
$result = array();
|
1008 |
return $customersFiltered;
|
1009 |
}
|
1010 |
|
1011 |
+
/**
|
1012 |
+
* Get Filter Hints
|
1013 |
+
*
|
1014 |
+
* @return array
|
1015 |
+
*/
|
1016 |
+
public function getFilterHints()
|
1017 |
+
{
|
1018 |
$filter_hints = array();
|
1019 |
try {
|
1020 |
// fetch write database connection that is used in Mage_Core module
|
1034 |
return $filter_hints;
|
1035 |
}
|
1036 |
|
1037 |
+
/**
|
1038 |
+
* Save Filter Hiny
|
1039 |
+
*
|
1040 |
+
* @param type $filter_name
|
1041 |
+
* @param type $post
|
1042 |
+
*/
|
1043 |
+
public function saveFilterHint($filter_name, $post)
|
1044 |
+
{
|
1045 |
try {
|
1046 |
$hints = '';
|
1047 |
foreach ($post as $k => $v) {
|
1053 |
}
|
1054 |
}
|
1055 |
//(e.g. $hints = 'mailupCustomers=2|mailupSubscribed=1';)
|
|
|
1056 |
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
|
|
1057 |
$connectionWrite->query("INSERT INTO mailup_filter_hints (filter_name, hints) VALUES ('".$filter_name."', '".$hints."')");
|
1058 |
+
}
|
1059 |
+
catch (Exception $e) {
|
1060 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
1061 |
die($e);
|
1062 |
}
|
1063 |
}
|
1064 |
|
1065 |
+
/**
|
1066 |
+
* Delete Filter Hint
|
1067 |
+
*
|
1068 |
+
* @param type $filter_name
|
1069 |
+
*/
|
1070 |
+
public function deleteFilterHint($filter_name)
|
1071 |
+
{
|
1072 |
try {
|
1073 |
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
|
|
1074 |
$connectionWrite->query("DELETE FROM mailup_filter_hints WHERE filter_name LIKE '".$filter_name."'");
|
1075 |
+
}
|
1076 |
+
catch (Exception $e) {
|
1077 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
1078 |
die($e);
|
1079 |
}
|
1091 |
$config = Mage::getModel('mailup/config');
|
1092 |
/* @var $config SevenLike_Mailup_Model_Config */
|
1093 |
return $config->getFieldsMapping($storeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1094 |
}
|
1095 |
|
1096 |
/**
|
1124 |
{
|
1125 |
return $this->_config;
|
1126 |
}
|
1127 |
+
|
1128 |
+
function __destruct()
|
1129 |
+
{
|
1130 |
+
unset($this->soapClient);
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
/**
|
1134 |
+
* Get a list of functions from the web service.
|
1135 |
+
*/
|
1136 |
+
public function getFunctions()
|
1137 |
+
{
|
1138 |
+
print_r($this->soapClient->__getFunctions());
|
1139 |
+
}
|
1140 |
}
|
app/code/local/SevenLike/MailUp/Model/Mysql14/Job.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Job.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/job", "id");
|
10 |
+
}
|
11 |
+
|
12 |
+
// /**
|
13 |
+
// * Get product identifier by sku
|
14 |
+
// *
|
15 |
+
// * @param string $sku
|
16 |
+
// * @return int|false
|
17 |
+
// */
|
18 |
+
// public function getIdBySku($sku)
|
19 |
+
// {
|
20 |
+
// $adapter = $this->_getReadAdapter();
|
21 |
+
//
|
22 |
+
// $select = $adapter->select()
|
23 |
+
// ->from('phpsolut_import')
|
24 |
+
// ->where('sku = :sku');
|
25 |
+
//
|
26 |
+
// $bind = array(':sku' => (string)$sku);
|
27 |
+
//
|
28 |
+
// return $adapter->fetchOne($select, $bind);
|
29 |
+
// }
|
30 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql14/Job/Collection.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Collection.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Job_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
6 |
+
{
|
7 |
+
public function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/job");
|
10 |
+
}
|
11 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql4/Job.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Job.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/job", "id");
|
10 |
+
}
|
11 |
+
|
12 |
+
// /**
|
13 |
+
// * Get product identifier by sku
|
14 |
+
// *
|
15 |
+
// * @param string $sku
|
16 |
+
// * @return int|false
|
17 |
+
// */
|
18 |
+
// public function getIdBySku($sku)
|
19 |
+
// {
|
20 |
+
// $adapter = $this->_getReadAdapter();
|
21 |
+
//
|
22 |
+
// $select = $adapter->select()
|
23 |
+
// ->from('phpsolut_import')
|
24 |
+
// ->where('sku = :sku');
|
25 |
+
//
|
26 |
+
// $bind = array(':sku' => (string)$sku);
|
27 |
+
//
|
28 |
+
// return $adapter->fetchOne($select, $bind);
|
29 |
+
// }
|
30 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql4/Job/Collection.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Collection.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Job_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
6 |
+
{
|
7 |
+
public function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/job");
|
10 |
+
}
|
11 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql4/Log.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Log.php
|
4 |
+
*
|
5 |
+
* @method string getType()
|
6 |
+
* @method void setType(string $type)
|
7 |
+
* @method string getStatus()
|
8 |
+
* @method void setStatus(string $type)
|
9 |
+
* @method int getStoreId()
|
10 |
+
* @method void setStoreId(int $storeId)
|
11 |
+
* @method int getJobId()
|
12 |
+
* @method void setJobId(int $jobId)
|
13 |
+
*/
|
14 |
+
class SevenLike_MailUp_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
|
15 |
+
{
|
16 |
+
const TYPE_ERROR = 'ERROR';
|
17 |
+
const TYPE_DEBUG = 'DEBUG';
|
18 |
+
const TYPE_CRON = 'CRON';
|
19 |
+
const TYPE_WARN = 'WARNING';
|
20 |
+
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init("mailup/log", "id");
|
24 |
+
}
|
25 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql4/Log/Collection.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Collection.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
6 |
+
{
|
7 |
+
public function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/log");
|
10 |
+
}
|
11 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql4/Sync.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Job.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Sync extends Mage_Core_Model_Mysql4_Abstract
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/sync", "id");
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Get the ID from the unique values
|
14 |
+
*
|
15 |
+
* @param int
|
16 |
+
* @param int
|
17 |
+
* @param int
|
18 |
+
*/
|
19 |
+
public function getIdByUniqueKey($customerId, $jobId, $storeId)
|
20 |
+
{
|
21 |
+
$adapter = $this->_getReadAdapter();
|
22 |
+
$select = $adapter->select()
|
23 |
+
->from($this->getMainTable())
|
24 |
+
->where('customer_id = :customer_id AND job_id = :job_id AND store_id = :store_id')
|
25 |
+
;
|
26 |
+
|
27 |
+
$bind = array(
|
28 |
+
':customer_id' => $customerId,
|
29 |
+
':job_id' => $jobId,
|
30 |
+
':store_id' => $storeId
|
31 |
+
);
|
32 |
+
|
33 |
+
return $adapter->fetchOne($select, $bind);
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Load by unique Key
|
39 |
+
*/
|
40 |
+
public function loadByUniqueKey()
|
41 |
+
{
|
42 |
+
//(`customer_id`,`entity`,`job_id`, `store_id`)
|
43 |
+
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
// /**
|
48 |
+
// * Get product identifier by sku
|
49 |
+
// *
|
50 |
+
// * @param string $sku
|
51 |
+
// * @return int|false
|
52 |
+
// */
|
53 |
+
// public function getIdBySku($sku)
|
54 |
+
// {
|
55 |
+
// $adapter = $this->_getReadAdapter();
|
56 |
+
//
|
57 |
+
// $select = $adapter->select()
|
58 |
+
// ->from('phpsolut_import')
|
59 |
+
// ->where('sku = :sku');
|
60 |
+
//
|
61 |
+
// $bind = array(':sku' => (string)$sku);
|
62 |
+
//
|
63 |
+
// return $adapter->fetchOne($select, $bind);
|
64 |
+
// }
|
65 |
+
|
66 |
+
//return $this->_getReadAdapter()->fetchOne(
|
67 |
+
// 'select connect_id from '.$this->getMainTable().' where sku=?',
|
68 |
+
// $sku
|
69 |
+
// );
|
70 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Mysql4/Sync/Collection.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Collection.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Model_Mysql4_Sync_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
6 |
+
{
|
7 |
+
public function _construct()
|
8 |
+
{
|
9 |
+
$this->_init("mailup/sync");
|
10 |
+
}
|
11 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Observer.php
CHANGED
@@ -6,6 +6,11 @@ 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 |
*
|
@@ -13,16 +18,14 @@ class SevenLike_MailUp_Model_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 |
|
@@ -44,7 +47,7 @@ class SevenLike_MailUp_Model_Observer
|
|
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:
|
@@ -119,9 +122,10 @@ class SevenLike_MailUp_Model_Observer
|
|
119 |
}
|
120 |
|
121 |
/**
|
|
|
122 |
*
|
123 |
-
* @see
|
124 |
-
* @param
|
125 |
* @return \SevenLike_MailUp_Model_Observer
|
126 |
*/
|
127 |
public function inviaUtente($observer)
|
@@ -149,7 +153,11 @@ class SevenLike_MailUp_Model_Observer
|
|
149 |
if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
|
150 |
Mage::log("SONO in registrazione, LEGGO PRIMA mailup!");
|
151 |
}
|
152 |
-
|
|
|
|
|
|
|
|
|
153 |
if ( ! $status) {
|
154 |
//leggo l'utente da mailup
|
155 |
$this->leggiUtente($observer);
|
@@ -246,6 +254,11 @@ class SevenLike_MailUp_Model_Observer
|
|
246 |
}
|
247 |
}
|
248 |
|
|
|
|
|
|
|
|
|
|
|
249 |
public function subscribeDuringCheckout()
|
250 |
{
|
251 |
if (@$_REQUEST["mailup_subscribe2"]) {
|
@@ -257,6 +270,11 @@ class SevenLike_MailUp_Model_Observer
|
|
257 |
}
|
258 |
}
|
259 |
|
|
|
|
|
|
|
|
|
|
|
260 |
/**
|
261 |
* Attach to sales_order_save_after event
|
262 |
*
|
@@ -271,20 +289,30 @@ class SevenLike_MailUp_Model_Observer
|
|
271 |
|
272 |
$order = $observer->getEvent()->getOrder();
|
273 |
/* @var $order Mage_Sales_Model_Order */
|
274 |
-
$
|
|
|
|
|
|
|
|
|
|
|
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($
|
281 |
-
self::setCustomerForDataSync($
|
|
|
282 |
}
|
283 |
}
|
284 |
-
|
285 |
/**
|
286 |
* Attach to customer_save_after even
|
287 |
*
|
|
|
|
|
|
|
|
|
|
|
288 |
* @see customer_save_after
|
289 |
*/
|
290 |
public function prepareCustomerForDataSync($observer)
|
@@ -294,13 +322,23 @@ class SevenLike_MailUp_Model_Observer
|
|
294 |
}
|
295 |
|
296 |
$customer = $observer->getEvent()->getCustomer();
|
297 |
-
|
|
|
|
|
|
|
|
|
298 |
$storeId = $customer->getStoreId(); // Is this always correct??
|
299 |
/**
|
300 |
* Possibly getting issues here with store id not being right...
|
|
|
|
|
|
|
|
|
|
|
301 |
*/
|
302 |
-
if($
|
303 |
-
self::setCustomerForDataSync($
|
|
|
304 |
}
|
305 |
}
|
306 |
|
@@ -311,38 +349,101 @@ class SevenLike_MailUp_Model_Observer
|
|
311 |
* @param int
|
312 |
* @return boolean
|
313 |
*/
|
314 |
-
private static function setCustomerForDataSync($
|
315 |
{
|
316 |
if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
|
317 |
-
Mage::log("TRIGGERED setCustomerForDataSync
|
318 |
}
|
319 |
|
320 |
if( ! isset($storeId)) {
|
321 |
$storeId = Mage::app()->getStore()->getId();
|
322 |
}
|
323 |
|
324 |
-
if( ! $
|
325 |
-
return
|
326 |
}
|
327 |
|
328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
try {
|
330 |
-
|
|
|
|
|
331 |
'store_id' => $storeId,
|
332 |
-
"customer_id" => $
|
333 |
"entity" => "customer",
|
334 |
-
"job_id" =>
|
335 |
-
"needs_sync" =>
|
336 |
-
"last_sync" =>
|
337 |
));
|
|
|
|
|
338 |
}
|
339 |
-
catch
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
), "customer_id=$customer_id AND entity='customer' AND job_id=0");
|
344 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
|
346 |
-
return
|
347 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
}
|
6 |
{
|
7 |
const CRON_STRING_PATH = 'crontab/jobs/sevenlike_mailup/schedule/cron_expr';
|
8 |
|
9 |
+
/**
|
10 |
+
* @var SevenLike_MailUp_Model_Config
|
11 |
+
*/
|
12 |
+
protected $_config;
|
13 |
+
|
14 |
/**
|
15 |
* Save system config event
|
16 |
*
|
18 |
*/
|
19 |
public function saveSystemConfig($observer)
|
20 |
{
|
|
|
|
|
|
|
21 |
Mage::getModel('core/config_data')
|
22 |
->load(self::CRON_STRING_PATH, 'path')
|
23 |
->setValue($this->_getSchedule())
|
24 |
->setPath(self::CRON_STRING_PATH)
|
25 |
->save();
|
26 |
+
|
27 |
Mage::app()->cleanCache();
|
28 |
+
|
29 |
$this->configCheck();
|
30 |
}
|
31 |
|
47 |
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_2_HOURS:
|
48 |
return "0 0,2,4,6,8,10,12,14,16,18,20,22 * * *";
|
49 |
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_6_HOURS:
|
50 |
+
return "0 0,6,12,18 * * *";
|
51 |
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_12_HOURS:
|
52 |
return "0 0,12 * * *";
|
53 |
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::HOURLY:
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* Observes subscription
|
126 |
*
|
127 |
+
* @see newsletter_subscriber_save_after
|
128 |
+
* @param type $observer
|
129 |
* @return \SevenLike_MailUp_Model_Observer
|
130 |
*/
|
131 |
public function inviaUtente($observer)
|
153 |
if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
|
154 |
Mage::log("SONO in registrazione, LEGGO PRIMA mailup!");
|
155 |
}
|
156 |
+
/**
|
157 |
+
* are recording, monitoring the status of magento subscribe,
|
158 |
+
* if you do not result in writing I read status from MailUp and if
|
159 |
+
* they are registered with the subject of magento before continuing
|
160 |
+
*/
|
161 |
if ( ! $status) {
|
162 |
//leggo l'utente da mailup
|
163 |
$this->leggiUtente($observer);
|
254 |
}
|
255 |
}
|
256 |
|
257 |
+
/**
|
258 |
+
* Subscribw the user, during checkout.
|
259 |
+
*
|
260 |
+
* @return void
|
261 |
+
*/
|
262 |
public function subscribeDuringCheckout()
|
263 |
{
|
264 |
if (@$_REQUEST["mailup_subscribe2"]) {
|
270 |
}
|
271 |
}
|
272 |
|
273 |
+
/**
|
274 |
+
* @var bool
|
275 |
+
*/
|
276 |
+
protected $_hasCustomerDataSynced = FALSE;
|
277 |
+
|
278 |
/**
|
279 |
* Attach to sales_order_save_after event
|
280 |
*
|
289 |
|
290 |
$order = $observer->getEvent()->getOrder();
|
291 |
/* @var $order Mage_Sales_Model_Order */
|
292 |
+
$customerId = $order->getCustomerId();
|
293 |
+
//$customer = Mage::getmodel('customer/customer')->load($customerId);
|
294 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
295 |
+
if($this->_hasCustomerDataSynced) {
|
296 |
+
return; // Don't bother if nothing has updated.
|
297 |
+
}
|
298 |
|
|
|
299 |
//$storeId = $customer->getStoreId(); // Is this always correct??
|
300 |
$storeId = $order->getStoreId();
|
301 |
|
302 |
+
if($customerId) {
|
303 |
+
self::setCustomerForDataSync($customerId, $storeId);
|
304 |
+
$this->_hasCustomerDataSynced = TRUE;
|
305 |
}
|
306 |
}
|
307 |
+
|
308 |
/**
|
309 |
* Attach to customer_save_after even
|
310 |
*
|
311 |
+
* Track if we've synced this run, only do it ocne.
|
312 |
+
* This event can be triggers 3+ times per run as the customer
|
313 |
+
* model is saved! we only want one Sync though.
|
314 |
+
*
|
315 |
+
* @todo refactor
|
316 |
* @see customer_save_after
|
317 |
*/
|
318 |
public function prepareCustomerForDataSync($observer)
|
322 |
}
|
323 |
|
324 |
$customer = $observer->getEvent()->getCustomer();
|
325 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
326 |
+
if( ! $customer->hasDataChanges() || $this->_hasCustomerDataSynced) {
|
327 |
+
return; // Don't bother if nothing has updated.
|
328 |
+
}
|
329 |
+
$customerId = $customer->getId();
|
330 |
$storeId = $customer->getStoreId(); // Is this always correct??
|
331 |
/**
|
332 |
* Possibly getting issues here with store id not being right...
|
333 |
+
*
|
334 |
+
* @todo possible issue
|
335 |
+
*
|
336 |
+
* If the customer is saved, how do we know which store to sync with?
|
337 |
+
* he could possibly have made sales on multiple websites...
|
338 |
*/
|
339 |
+
if($customerId) {
|
340 |
+
self::setCustomerForDataSync($customerId, $storeId);
|
341 |
+
$this->_hasCustomerDataSynced = TRUE;
|
342 |
}
|
343 |
}
|
344 |
|
349 |
* @param int
|
350 |
* @return boolean
|
351 |
*/
|
352 |
+
private static function setCustomerForDataSync($customerId, $storeId = NULL)
|
353 |
{
|
354 |
if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
|
355 |
+
Mage::log("TRIGGERED setCustomerForDataSync [StoreID:{$storeId}]");
|
356 |
}
|
357 |
|
358 |
if( ! isset($storeId)) {
|
359 |
$storeId = Mage::app()->getStore()->getId();
|
360 |
}
|
361 |
|
362 |
+
if( ! $customerId) {
|
363 |
+
return FALSE;
|
364 |
}
|
365 |
|
366 |
+
$helper = Mage::helper('mailup');
|
367 |
+
/* @var $helper SevenLike_Mailup_Helper_Data */
|
368 |
+
$config = Mage::getModel('mailup/config');
|
369 |
+
/* @var $config SevenLike_Mailup_Model_Config */
|
370 |
+
$lists = Mage::getModel('mailup/lists');
|
371 |
+
/* @var $lists SevenLike_MailUp_Model_Lists */
|
372 |
+
$listID = $config->getMailupListId($storeId);
|
373 |
+
$listGuid = $lists->getListGuid($listID, $storeId);
|
374 |
+
$job = Mage::getModel('mailup/job');
|
375 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Only Sync if they are a subscriber!
|
379 |
+
*/
|
380 |
+
if( ! $helper->isSubscriber($customerId, $storeId)) {
|
381 |
+
return;
|
382 |
+
}
|
383 |
+
|
384 |
+
$job->setData(array(
|
385 |
+
"mailupgroupid" => '',
|
386 |
+
"send_optin" => 0,
|
387 |
+
'as_pending' => 0,
|
388 |
+
"status" => "queued",
|
389 |
+
"queue_datetime" => gmdate("Y-m-d H:i:s"),
|
390 |
+
'store_id' => $storeId,
|
391 |
+
'list_id' => $listID,
|
392 |
+
'list_guid' => $listGuid,
|
393 |
+
));
|
394 |
+
$job->setAsAutoSync();
|
395 |
+
try {
|
396 |
+
$job->save();
|
397 |
+
$config->dbLog("Job [Insert] [Group:NO GROUP] ", $job->getId(), $storeId);
|
398 |
+
}
|
399 |
+
catch(Exception $e) {
|
400 |
+
$config->dbLog("Job [Insert] [FAILED] [NO GROUP] ", $job->getId(), $storeId);
|
401 |
+
$config->log($e);
|
402 |
+
throw $e;
|
403 |
+
}
|
404 |
+
|
405 |
try {
|
406 |
+
$jobTask = Mage::getModel('mailup/sync');
|
407 |
+
/** @var $jobTask SevenLike_MailUp_Model_Sync */
|
408 |
+
$jobTask->setData(array(
|
409 |
'store_id' => $storeId,
|
410 |
+
"customer_id" => $customerId,
|
411 |
"entity" => "customer",
|
412 |
+
"job_id" => $job->getId(),
|
413 |
+
"needs_sync" => TRUE,
|
414 |
+
"last_sync" => NULL,
|
415 |
));
|
416 |
+
$jobTask->save();
|
417 |
+
$config->dbLog("Sync [Insert] [customer] [{$customerId}]", $job->getId(), $storeId);
|
418 |
}
|
419 |
+
catch(Exception $e) {
|
420 |
+
$config->dbLog("Sync [Insert] [customer] [FAILED] [{$customerId}]", $job->getId(), $storeId);
|
421 |
+
$config->log($e);
|
422 |
+
throw $e;
|
|
|
423 |
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* @todo ADD CRON
|
427 |
+
*
|
428 |
+
* WE NEED TO ACTUALLY ADD A CRON JOB NOW!!
|
429 |
+
*
|
430 |
+
* OR we use a separate Auto Sync job!!
|
431 |
+
*/
|
432 |
|
433 |
+
return TRUE;
|
434 |
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Get the config
|
438 |
+
*
|
439 |
+
* @reutrn SevenLike_MailUp_Model_Config
|
440 |
+
*/
|
441 |
+
protected function _config()
|
442 |
+
{
|
443 |
+
if(NULL === $this->_config) {
|
444 |
+
$this->_config = Mage::getModel('mailup/config');
|
445 |
+
}
|
446 |
+
|
447 |
+
return $this->_config;
|
448 |
+
}
|
449 |
}
|
app/code/local/SevenLike/MailUp/Model/Source/Store.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Config.php
|
4 |
+
*
|
5 |
+
* Central config model
|
6 |
+
*/
|
7 |
+
class SevenLike_MailUp_Model_Source_Store
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Options getter
|
11 |
+
*
|
12 |
+
* This would be used in Admin config.
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
$return = array();
|
19 |
+
|
20 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
21 |
+
foreach ($website->getGroups() as $group) {
|
22 |
+
$stores = $group->getStores();
|
23 |
+
foreach ($stores as $store) {
|
24 |
+
/* @var $store Mage_Core_Model_Store */
|
25 |
+
$return[] = array(
|
26 |
+
'value' => $store->getId(),
|
27 |
+
'label' => $store->getName()
|
28 |
+
);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $return;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get options as we'd use in a select box.
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function getSelectOptions()
|
42 |
+
{
|
43 |
+
$return = array();
|
44 |
+
|
45 |
+
$return[0] = 'Default'; // include default site / admin
|
46 |
+
|
47 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
48 |
+
foreach ($website->getGroups() as $group) {
|
49 |
+
$stores = $group->getStores();
|
50 |
+
foreach ($stores as $store) {
|
51 |
+
/* @var $store Mage_Core_Model_Store */
|
52 |
+
$return[$store->getId()] = $store->getName();
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $return;
|
58 |
+
}
|
59 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Sync.php
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sync.php
|
4 |
+
*
|
5 |
+
* @method int getStoreId()
|
6 |
+
* @method int getCustomerId()
|
7 |
+
* @method int getJobId()
|
8 |
+
*/
|
9 |
+
class SevenLike_MailUp_Model_Sync extends Mage_Core_Model_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init("mailup/sync");
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get the ID from the unique values
|
22 |
+
*
|
23 |
+
* @param int
|
24 |
+
* @param int
|
25 |
+
* @param int
|
26 |
+
* @return int|FALSE
|
27 |
+
*/
|
28 |
+
public function getIdByUniqueKey($customerId, $jobId, $storeId)
|
29 |
+
{
|
30 |
+
return $this->_getResource()->getIdByUniqueKey(
|
31 |
+
$customerId,
|
32 |
+
$jobId,
|
33 |
+
$storeId
|
34 |
+
);
|
35 |
+
|
36 |
+
/*return $this->_getResource()->getIdByUniqueKey(
|
37 |
+
$this->getCustomerId(),
|
38 |
+
$this->getJobId(),
|
39 |
+
$this->getStoreId()
|
40 |
+
);*/
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Load by unique Key
|
45 |
+
*/
|
46 |
+
public function loadByUniqueKey()
|
47 |
+
{
|
48 |
+
//(`customer_id`,`entity`,`job_id`, `store_id`)
|
49 |
+
return $this->_getResource()->loadByUniqueKey();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Mark as Synced
|
54 |
+
*/
|
55 |
+
public function setAsSynced()
|
56 |
+
{
|
57 |
+
$this->setNeedsSync(0);
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Do we need Synced?
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function isNeedningSynced()
|
68 |
+
{
|
69 |
+
return $this->getNeedsSync() == 1;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get a collection of items which need Synced
|
74 |
+
*
|
75 |
+
* @return SevenLike_MailUp_Model_Mysql4_Sync_Collection
|
76 |
+
*/
|
77 |
+
public function getSyncItemsCollection()
|
78 |
+
{
|
79 |
+
// SELECT ms.*, ce.email FROM {$syncTableName} ms
|
80 |
+
// JOIN $customer_entity_table_name ce
|
81 |
+
// ON (ms.customer_id = ce.entity_id)
|
82 |
+
// WHERE
|
83 |
+
// ms.needs_sync=1
|
84 |
+
// AND ms.entity='customer'
|
85 |
+
// AND job_id=0"
|
86 |
+
|
87 |
+
$customerEntityTable = Mage::getSingleton('core/resource')->getTableName('customer_entity');
|
88 |
+
//$customerEntityTable = $this->getTable('customer/entity');
|
89 |
+
$collection = $this->getCollection();
|
90 |
+
/* @var $collection SevenLike_MailUp_Model_Mysql4_Sync_Collection */
|
91 |
+
|
92 |
+
$collection
|
93 |
+
->addFieldToSelect('*')
|
94 |
+
->addFieldToFilter('job_id', array('eq' => 0))
|
95 |
+
->addFieldToFilter('needs_sync', array('eq' => 1))
|
96 |
+
->getSelect()->join($customerEntityTable, "main_table.customer_id = {$customerEntityTable}.entity_id", "email")
|
97 |
+
;
|
98 |
+
|
99 |
+
return $collection;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get Sync entries for a particular job.
|
104 |
+
*
|
105 |
+
* @return SevenLike_MailUp_Model_Mysql4_Sync_Collection
|
106 |
+
*/
|
107 |
+
public function fetchByJobId($jobId)
|
108 |
+
{
|
109 |
+
//return $this->_getResource()->fetchByJobId($jobId);
|
110 |
+
return $this->getCollection()
|
111 |
+
->addFieldToSelect('*')
|
112 |
+
->addFieldToFilter('job_id', array('eq' => $jobId))
|
113 |
+
;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Get the job model.
|
118 |
+
*
|
119 |
+
* @return SevenLike_Mailup_Model_Job
|
120 |
+
*/
|
121 |
+
public function getJob()
|
122 |
+
{
|
123 |
+
return Mage::getModel('mailup/job')->load($this->getJobId());
|
124 |
+
}
|
125 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Wssend.php
CHANGED
@@ -10,7 +10,12 @@ class MailUpWsSend
|
|
10 |
* @var int
|
11 |
*/
|
12 |
protected $storeId;
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
function __construct($storeId = NULL)
|
15 |
{
|
16 |
$this->soapClient = new SoapClient(
|
@@ -70,7 +75,8 @@ class MailUpWsSend
|
|
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),
|
@@ -105,7 +111,8 @@ class MailUpWsSend
|
|
105 |
return false;
|
106 |
}
|
107 |
|
108 |
-
public function GetFields($accessKey)
|
|
|
109 |
$fields = null;
|
110 |
|
111 |
try {
|
@@ -117,10 +124,12 @@ class MailUpWsSend
|
|
117 |
}
|
118 |
|
119 |
$fields = $this->_parseGetFieldsXmlResponse($xml);
|
120 |
-
}
|
|
|
121 |
Mage::log('SOAP error', 0);
|
122 |
Mage::log($soapFault, 0);
|
123 |
-
}
|
|
|
124 |
Mage::log('Custom exception', 0);
|
125 |
Mage::log($e->getMessage(), 0);
|
126 |
}
|
@@ -128,7 +137,8 @@ class MailUpWsSend
|
|
128 |
return $fields;
|
129 |
}
|
130 |
|
131 |
-
private function _parseGetFieldsXmlResponse($xmlSimpleElement)
|
|
|
132 |
$fields = $this->_getFieldsDefaultConfiguration();
|
133 |
|
134 |
if ($xmlSimpleElement->Fields && sizeof($xmlSimpleElement->Fields->Field) > 0) {
|
@@ -142,7 +152,8 @@ class MailUpWsSend
|
|
142 |
return $fields;
|
143 |
}
|
144 |
|
145 |
-
private function _getFieldsDefaultConfiguration()
|
|
|
146 |
$fields = array();
|
147 |
|
148 |
$fields['nome'] = '1';
|
@@ -176,106 +187,132 @@ class MailUpWsSend
|
|
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 |
-
}
|
|
|
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 |
-
}
|
|
|
197 |
$this->printLastResponse();
|
198 |
}
|
199 |
-
}
|
|
|
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 |
-
}
|
|
|
212 |
$this->printLastResponse();
|
213 |
}
|
214 |
-
}
|
|
|
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 |
-
}
|
|
|
227 |
$this->printLastResponse();
|
228 |
}
|
229 |
-
}
|
|
|
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
|
242 |
-
echo '<br /><br />Errore CreateNewsletter: '. $this->readReturnCode('CreateNewsletter', 'errorCode') .' - '.
|
243 |
-
|
|
|
|
|
|
|
244 |
$this->printLastResponse();
|
245 |
}
|
246 |
-
}
|
|
|
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') .' - '.
|
259 |
-
|
|
|
|
|
|
|
260 |
$this->printLastResponse();
|
261 |
}
|
262 |
-
}
|
|
|
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') .
|
275 |
-
|
|
|
|
|
|
|
276 |
$this->printLastResponse();
|
277 |
}
|
278 |
-
}
|
|
|
279 |
Mage::log('SOAP error', 0);
|
280 |
Mage::log($soapFault, 0);
|
281 |
}
|
@@ -309,25 +346,30 @@ class MailUpWsSend
|
|
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));
|
@@ -341,9 +383,24 @@ class MailUpWsSend
|
|
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 |
}
|
10 |
* @var int
|
11 |
*/
|
12 |
protected $storeId;
|
13 |
+
/**
|
14 |
+
* @var SevenLike_MailUp_Model_Config
|
15 |
+
*/
|
16 |
+
protected $_config;
|
17 |
+
|
18 |
+
|
19 |
function __construct($storeId = NULL)
|
20 |
{
|
21 |
$this->soapClient = new SoapClient(
|
75 |
/**
|
76 |
* @return $accessKey | false
|
77 |
*/
|
78 |
+
public function loginFromId()
|
79 |
+
{
|
80 |
try {
|
81 |
//login with webservice user
|
82 |
$loginData = array ('user' => Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId),
|
111 |
return false;
|
112 |
}
|
113 |
|
114 |
+
public function GetFields($accessKey)
|
115 |
+
{
|
116 |
$fields = null;
|
117 |
|
118 |
try {
|
124 |
}
|
125 |
|
126 |
$fields = $this->_parseGetFieldsXmlResponse($xml);
|
127 |
+
}
|
128 |
+
catch (SoapFault $soapFault) {
|
129 |
Mage::log('SOAP error', 0);
|
130 |
Mage::log($soapFault, 0);
|
131 |
+
}
|
132 |
+
catch (Exception $e) {
|
133 |
Mage::log('Custom exception', 0);
|
134 |
Mage::log($e->getMessage(), 0);
|
135 |
}
|
137 |
return $fields;
|
138 |
}
|
139 |
|
140 |
+
private function _parseGetFieldsXmlResponse($xmlSimpleElement)
|
141 |
+
{
|
142 |
$fields = $this->_getFieldsDefaultConfiguration();
|
143 |
|
144 |
if ($xmlSimpleElement->Fields && sizeof($xmlSimpleElement->Fields->Field) > 0) {
|
152 |
return $fields;
|
153 |
}
|
154 |
|
155 |
+
private function _getFieldsDefaultConfiguration()
|
156 |
+
{
|
157 |
$fields = array();
|
158 |
|
159 |
$fields['nome'] = '1';
|
187 |
}
|
188 |
|
189 |
|
190 |
+
public function logout()
|
191 |
+
{
|
192 |
try {
|
193 |
$this->soapClient->Logout(array('accessKey' => $this->accessKey));
|
194 |
if ($this->readReturnCode('Logout', 'errorCode') != 0) {
|
195 |
echo '<br /><br />Errore Logout'. $this->readReturnCode('Logout', 'errorDescription');
|
196 |
}
|
197 |
+
}
|
198 |
+
catch (SoapFault $soapFault) {
|
199 |
Mage::log('SOAP error', 0);
|
200 |
Mage::log($soapFault, 0);
|
201 |
}
|
202 |
}
|
203 |
|
204 |
+
public function getLists()
|
205 |
+
{
|
206 |
try {
|
207 |
$this->soapClient->GetLists(array('accessKey' => $this->accessKey));
|
208 |
if ($this->readReturnCode('GetLists', 'errorCode') != 0) {
|
209 |
echo '<br /><br />Errore GetLists: '. $this->readReturnCode('GetLists', 'errorDescription');
|
210 |
+
}
|
211 |
+
else {
|
212 |
$this->printLastResponse();
|
213 |
}
|
214 |
+
}
|
215 |
+
catch (SoapFault $soapFault) {
|
216 |
Mage::log('SOAP error', 0);
|
217 |
Mage::log($soapFault, 0);
|
218 |
}
|
219 |
}
|
220 |
|
221 |
+
public function getGroups($params)
|
222 |
+
{
|
223 |
try {
|
224 |
$params = array_merge((array)$params, array('accessKey' => $this->accessKey));
|
225 |
$this->soapClient->GetGroups($params);
|
226 |
if ($this->readReturnCode('GetGroups', 'errorCode') != 0) {
|
227 |
echo '<br /><br />Errore GetGroups: '. $this->readReturnCode('GetGroups', 'errorDescription');
|
228 |
+
}
|
229 |
+
else {
|
230 |
$this->printLastResponse();
|
231 |
}
|
232 |
+
}
|
233 |
+
catch (SoapFault $soapFault) {
|
234 |
Mage::log('SOAP error', 0);
|
235 |
Mage::log($soapFault, 0);
|
236 |
}
|
237 |
}
|
238 |
|
239 |
+
public function getNewsletters($params)
|
240 |
+
{
|
241 |
try {
|
242 |
$params = array_merge((array)$params, array('accessKey' => $this->accessKey));
|
243 |
$this->soapClient->GetNewsletters($params);
|
244 |
if ($this->readReturnCode('GetNewsletters', 'errorCode') != 0) {
|
245 |
echo '<br /><br />Errore GetNewsletters: '. $this->readReturnCode('GetNewsletters', 'errorDescription');
|
246 |
+
}
|
247 |
+
else {
|
248 |
$this->printLastResponse();
|
249 |
}
|
250 |
+
}
|
251 |
+
catch (SoapFault $soapFault) {
|
252 |
Mage::log('SOAP error', 0);
|
253 |
Mage::log($soapFault, 0);
|
254 |
}
|
255 |
}
|
256 |
|
257 |
+
public function createNewsletter($params)
|
258 |
+
{
|
259 |
try {
|
260 |
$params = array_merge((array)$params, array('accessKey' => $this->accessKey));
|
261 |
$this->soapClient->createNewsletter($params);
|
262 |
|
263 |
$this->printLastRequest();
|
264 |
+
if($this->readReturnCode('CreateNewsletter', 'errorCode') != 0) {
|
265 |
+
echo '<br /><br />Errore CreateNewsletter: '. $this->readReturnCode('CreateNewsletter', 'errorCode') .' - '.
|
266 |
+
$this->readReturnCode('CreateNewsletter', 'errorDescription')
|
267 |
+
;
|
268 |
+
}
|
269 |
+
else {
|
270 |
$this->printLastResponse();
|
271 |
}
|
272 |
+
}
|
273 |
+
catch (SoapFault $soapFault) {
|
274 |
Mage::log('SOAP error', 0);
|
275 |
Mage::log($soapFault, 0);
|
276 |
}
|
277 |
}
|
278 |
|
279 |
+
public function sendNewsletter($params)
|
280 |
+
{
|
281 |
try {
|
282 |
$params = array_merge((array)$params, array('accessKey' => $this->accessKey));
|
283 |
$this->soapClient->SendNewsletter($params);
|
284 |
$this->printLastRequest();
|
285 |
if ($this->readReturnCode('SendNewsletter', 'errorCode') != 0) {
|
286 |
+
echo '<br /><br />Errore SendNewsletter: '. $this->readReturnCode('SendNewsletter', 'errorCode') .' - '.
|
287 |
+
$this->readReturnCode('SendNewsletter', 'errorDescription')
|
288 |
+
;
|
289 |
+
}
|
290 |
+
else {
|
291 |
$this->printLastResponse();
|
292 |
}
|
293 |
+
}
|
294 |
+
catch (SoapFault $soapFault) {
|
295 |
Mage::log('SOAP error', 0);
|
296 |
Mage::log($soapFault, 0);
|
297 |
}
|
298 |
}
|
299 |
|
300 |
+
public function sendNewsletterFast($params)
|
301 |
+
{
|
302 |
try {
|
303 |
$params = array_merge((array)$params, array('accessKey' => $this->accessKey));
|
304 |
$this->soapClient->SendNewsletterFast($params);
|
305 |
$this->printLastRequest();
|
306 |
if ($this->readReturnCode('SendNewsletterFast', 'errorCode') != 0) {
|
307 |
+
echo '<br /><br />Errore SendNewsletterFast: '. $this->readReturnCode('SendNewsletterFast', 'errorCode') .
|
308 |
+
' - '. $this->readReturnCode('SendNewsletterFast', 'errorDescription')
|
309 |
+
;
|
310 |
+
}
|
311 |
+
else {
|
312 |
$this->printLastResponse();
|
313 |
}
|
314 |
+
}
|
315 |
+
catch (SoapFault $soapFault) {
|
316 |
Mage::log('SOAP error', 0);
|
317 |
Mage::log($soapFault, 0);
|
318 |
}
|
346 |
return $rCode->item(0)->nodeValue;
|
347 |
}
|
348 |
|
349 |
+
private function printLastRequest()
|
350 |
+
{
|
351 |
echo '<br />Request :<br />'. htmlentities($this->soapClient->__getLastRequest()) .'<br />';
|
352 |
}
|
353 |
|
354 |
+
private function printLastResponse()
|
355 |
+
{
|
356 |
echo '<br />XMLResponse: '. $this->soapClient->__getLastResponse() .'<br />'; //htmlentities();
|
357 |
}
|
358 |
|
359 |
//TODO: seems unused, remove if so
|
360 |
+
public function getAccessKey()
|
361 |
+
{
|
362 |
return $this->accessKey;
|
363 |
}
|
364 |
|
365 |
+
public function option($key, $value)
|
366 |
+
{
|
367 |
return array('Key' => $key, 'Value' => $value);
|
368 |
}
|
369 |
|
370 |
//TODO: TEST stuff (this shouldn't be here)
|
371 |
+
public function loginTest()
|
372 |
+
{
|
373 |
$loginData = array('user' => 'a7410', 'pwd' => 'GA6VAN0W', 'url' => 'g4a0.s03.it');
|
374 |
|
375 |
$result = get_object_vars($this->soapClient->Login($loginData));
|
383 |
return $xml['errorCode'];
|
384 |
}
|
385 |
|
386 |
+
public function testSoap()
|
387 |
+
{
|
388 |
$client = new SoapClient('http://soapclient.com/xml/soapresponder.wsdl', array('trace' => 1, 'exceptions' => 1, 'connection_timeout' => 10));
|
389 |
//print_r($client->__getFunctions());
|
390 |
return $client->Method1('x12qaq','c56tf3');
|
391 |
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Get the config
|
395 |
+
*
|
396 |
+
* @reutrn SevenLike_MailUp_Model_Config
|
397 |
+
*/
|
398 |
+
protected function _config()
|
399 |
+
{
|
400 |
+
if(NULL === $this->_config) {
|
401 |
+
$this->_config = Mage::getModel('mailup/config');
|
402 |
+
}
|
403 |
+
|
404 |
+
return $this->_config;
|
405 |
+
}
|
406 |
}
|
app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php
CHANGED
@@ -1,23 +1,264 @@
|
|
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 |
-
|
|
|
|
|
|
|
|
|
17 |
$this->checkRunningImport();
|
18 |
$this->loadLayout()->renderLayout();
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Generate CSV
|
23 |
*
|
@@ -94,83 +335,15 @@ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Control
|
|
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 |
-
*
|
102 |
*/
|
103 |
-
public function
|
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();
|
@@ -188,7 +361,11 @@ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Control
|
|
188 |
$this->_redirect('*/*');
|
189 |
}
|
190 |
|
191 |
-
|
|
|
|
|
|
|
|
|
192 |
$this->checkRunningImport();
|
193 |
try {
|
194 |
$post = $this->getRequest()->getPost();
|
@@ -204,24 +381,6 @@ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Control
|
|
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 |
*
|
@@ -229,6 +388,7 @@ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Control
|
|
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 |
|
@@ -236,7 +396,7 @@ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Control
|
|
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
|
240 |
if( ! empty($lastTime)) {
|
241 |
$dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $lastTime);
|
242 |
$lastTimeObject = clone $dateTime;
|
@@ -250,17 +410,46 @@ class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Control
|
|
250 |
//}
|
251 |
}
|
252 |
}
|
253 |
-
|
254 |
-
$running_processes = $db->fetchOne(
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
|
|
|
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 |
}
|
1 |
<?php
|
|
|
2 |
require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
|
3 |
require_once dirname(__FILE__) . "/../../Model/Wssend.php";
|
4 |
+
/**
|
5 |
+
* FilterController.php
|
6 |
+
*/
|
7 |
class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Controller_Action
|
8 |
{
|
9 |
+
/**
|
10 |
+
* split customers into batches
|
11 |
+
*/
|
12 |
+
const BATCH_SIZE = 2000;
|
13 |
+
const STATUS_SUBSCRIBED = 'subscribed';
|
14 |
+
const STATUS_NOT_SUBSCRIBED = 'not_subscribed';
|
15 |
+
|
16 |
/**
|
17 |
* Default Action
|
18 |
*/
|
19 |
public function indexAction()
|
20 |
+
{
|
21 |
$this->checkRunningImport();
|
22 |
$this->loadLayout()->renderLayout();
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
+
* Confirm / Final Step
|
27 |
+
*/
|
28 |
+
public function confirmAction()
|
29 |
+
{
|
30 |
$this->checkRunningImport();
|
31 |
$this->loadLayout()->renderLayout();
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
* Handle Posted Data
|
36 |
+
*/
|
37 |
+
public function postAction()
|
38 |
+
{
|
39 |
+
$post = $this->getRequest()->getPost();
|
40 |
+
$storeId = isset($post['store_id']) ? (int)$post['store_id'] : NULL;
|
41 |
+
|
42 |
+
if (empty($post)) {
|
43 |
+
Mage::throwException($this->__('Invalid form data.'));
|
44 |
+
}
|
45 |
+
|
46 |
+
$config = Mage::getModel('mailup/config');
|
47 |
+
/* @var $config SevenLike_Mailup_Model_Config */
|
48 |
+
//$subscriber = Mage::getModel('newsletter/subscriber');
|
49 |
+
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
50 |
+
|
51 |
+
$sendOptinEmail = isset($post['send_optin_email_to_new_subscribers']) && ($post['send_optin_email_to_new_subscribers'] == 1);
|
52 |
+
$mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
|
53 |
+
//$totalCustomers = count($mailupCustomerIds);
|
54 |
+
$batches = $this->_getBatches($mailupCustomerIds, $storeId);
|
55 |
+
//$totalBatches = count($customerIdBatches);
|
56 |
+
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
57 |
+
/**
|
58 |
+
* Create a New Group on Mailup
|
59 |
+
*/
|
60 |
+
$post["mailupNewGroupName"] = trim($post["mailupNewGroupName"]);
|
61 |
+
if($post["mailupNewGroup"] && strlen($post["mailupNewGroupName"])) {
|
62 |
+
require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
|
63 |
+
$wsImport = new MailUpWsImport($storeId);
|
64 |
+
$post['mailupGroupId'] = $wsImport->CreaGruppo(array(
|
65 |
+
"idList" => $post['mailupIdList'],
|
66 |
+
"listGUID" => $post['mailupListGUID'],
|
67 |
+
"newGroupName" => $post["mailupNewGroupName"]
|
68 |
+
));
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Lets make batches if required. Separate the jobs into max amount of customers.
|
73 |
+
* Create a new job for each batch.
|
74 |
+
*/
|
75 |
+
foreach($batches as $batchNumber => $batch) {
|
76 |
+
try {
|
77 |
+
$customerCount = 0;
|
78 |
+
/**
|
79 |
+
* We have split into subscribers and none subscribers
|
80 |
+
*/
|
81 |
+
foreach($batch as $subscribeStatus => $customerIdArray) {
|
82 |
+
|
83 |
+
if(empty($customerIdArray)) {
|
84 |
+
continue;
|
85 |
+
}
|
86 |
+
|
87 |
+
if( ! $sendOptinEmail) {
|
88 |
+
$asPending = 0;
|
89 |
+
$sendOptin = 0;
|
90 |
+
}
|
91 |
+
else {
|
92 |
+
if($subscribeStatus == self::STATUS_SUBSCRIBED) {
|
93 |
+
$asPending = 0;
|
94 |
+
$sendOptin = 0;
|
95 |
+
}
|
96 |
+
else {
|
97 |
+
$asPending = 1;
|
98 |
+
$sendOptin = 1;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
$job = Mage::getModel('mailup/job');
|
102 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
103 |
+
$job->setData(array(
|
104 |
+
"mailupgroupid" => $post['mailupGroupId'],
|
105 |
+
"send_optin" => $sendOptin,
|
106 |
+
'as_pending' => $asPending,
|
107 |
+
"status" => "queued",
|
108 |
+
"queue_datetime" => gmdate("Y-m-d H:i:s"),
|
109 |
+
'store_id' => $storeId,
|
110 |
+
'list_id' => $post['mailupIdList'],
|
111 |
+
'list_guid' => $post['mailupListGUID'],
|
112 |
+
));
|
113 |
+
try {
|
114 |
+
$job->save();
|
115 |
+
$config->dbLog(
|
116 |
+
sprintf(
|
117 |
+
"Job [Insert] [Group:%s] [%s] [%d]",
|
118 |
+
$post['mailupGroupId'],
|
119 |
+
$subscribeStatus,
|
120 |
+
count($customerIdArray)
|
121 |
+
),
|
122 |
+
$job->getId(),
|
123 |
+
$storeId
|
124 |
+
);
|
125 |
+
}
|
126 |
+
catch(Exception $e) {
|
127 |
+
$config->dbLog("Job [Insert] [FAILED] [Group:{$post['mailupGroupId']}] ", 0, $storeId);
|
128 |
+
$config->log($e);
|
129 |
+
throw $e;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* Each Customer
|
133 |
+
*/
|
134 |
+
foreach($customerIdArray as $customerId) {
|
135 |
+
$customerCount++;
|
136 |
+
//$customer = Mage::getModel('customer/customer');
|
137 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
138 |
+
$jobTask = Mage::getModel('mailup/sync');
|
139 |
+
/* @var $jobTask SevenLike_MailUp_Model_Sync */
|
140 |
+
try {
|
141 |
+
$jobTask->setData(array(
|
142 |
+
"customer_id" => $customerId,
|
143 |
+
"entity" => "customer",
|
144 |
+
"job_id" => $job->getId(),
|
145 |
+
"needs_sync" => TRUE,
|
146 |
+
"last_sync" => null,
|
147 |
+
'store_id' => $storeId,
|
148 |
+
));
|
149 |
+
$jobTask->save();
|
150 |
+
}
|
151 |
+
catch (Exception $e) {
|
152 |
+
$config->dbLog("Job Task [Sync] [FAILED] [customer:{$customerId}] [Update]", $job->getId(), $storeId);
|
153 |
+
$config->log($e);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
$config->dbLog("Job Task [Sync] [Customer Count:{$customerCount}]", $job->getId(), $storeId);
|
158 |
+
/**
|
159 |
+
* Insert a new scheduled Task for the job.
|
160 |
+
*/
|
161 |
+
$cronDelay = (int) ($batchNumber * 15) + 2;
|
162 |
+
$db_write->insert(Mage::getSingleton('core/resource')->getTableName('cron_schedule'), array(
|
163 |
+
"job_code" => "sevenlike_mailup",
|
164 |
+
"status" => "pending",
|
165 |
+
"created_at" => gmdate("Y-m-d H:i:s"),
|
166 |
+
"scheduled_at" => gmdate("Y-m-d H:i:s", strtotime("+{$cronDelay}minutes"))
|
167 |
+
));
|
168 |
+
|
169 |
+
/*$schedule = Mage::getModel('cron/schedule');
|
170 |
+
$schedule->setJobCode($jobCode)
|
171 |
+
->setCreatedAt($timecreated)
|
172 |
+
->setScheduledAt($timescheduled)
|
173 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
174 |
+
->save();*/
|
175 |
+
|
176 |
+
//$config->dbLog("Secheduled Task: " . gmdate("Y-m-d H:i:s"), $job_id, $storeId);
|
177 |
+
$message = $this->__('Members have been sent correctly');
|
178 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
179 |
+
}
|
180 |
+
catch (Exception $e) {
|
181 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
182 |
+
$errorMessage = $this->__('Warning: no member has been selected');
|
183 |
+
Mage::getSingleton('adminhtml/session')->addError($errorMessage);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->_redirect('*/*');
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Build batches from the list of ids
|
192 |
+
*
|
193 |
+
* We will make batches of a certain size to avoid huge long running proceses.
|
194 |
+
* We also need to generate a different job for subscribers and none subscribers
|
195 |
+
*
|
196 |
+
* array(
|
197 |
+
* 0 => array(
|
198 |
+
* 'subscribed' => array(),
|
199 |
+
* 'not_subscribed' => array(),
|
200 |
+
* )
|
201 |
+
* )
|
202 |
+
*
|
203 |
+
* @param array array of ids
|
204 |
+
* @param int
|
205 |
+
* @return array
|
206 |
+
*/
|
207 |
+
protected function _getBatches($mailupCustomerIds, $storeId)
|
208 |
+
{
|
209 |
+
$helper = Mage::helper('mailup');
|
210 |
+
/* @var $helper SevenLike_Mailup_Helper_Data */
|
211 |
+
$totalCustomers = count($mailupCustomerIds);
|
212 |
+
$batches = array_chunk($mailupCustomerIds, self::BATCH_SIZE);
|
213 |
+
//$totalBatches = count($customerIdBatches);
|
214 |
+
if($totalCustomers > self::BATCH_SIZE) {
|
215 |
+
$this->_config()->dbLog("Batching Customers [{$totalCustomers}] CHUNKS [". self::BATCH_SIZE ."]", 0, $storeId);
|
216 |
+
}
|
217 |
+
$batchArray = array();
|
218 |
+
$customerCount = 0;
|
219 |
+
foreach($batches as $batch) {
|
220 |
+
$subscribed = array();
|
221 |
+
$notSubscribed = array();
|
222 |
+
foreach($batch as $customerId) {
|
223 |
+
$customerCount++;
|
224 |
+
if($helper->isSubscriber($customerId, $storeId)) {
|
225 |
+
$subscribed[] = $customerId;
|
226 |
+
}
|
227 |
+
else {
|
228 |
+
$notSubscribed[] = $customerId;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
/**
|
232 |
+
* @todo only return segmented if both not empty.
|
233 |
+
*/
|
234 |
+
$batchArray[] = array(
|
235 |
+
self::STATUS_SUBSCRIBED => $subscribed,
|
236 |
+
self::STATUS_NOT_SUBSCRIBED => $notSubscribed
|
237 |
+
);
|
238 |
+
}
|
239 |
+
|
240 |
+
return $batchArray;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @var SevenLike_MailUp_Model_Config
|
245 |
+
*/
|
246 |
+
protected $_config;
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Get the config
|
250 |
+
*
|
251 |
+
* @reutrn SevenLike_MailUp_Model_Config
|
252 |
+
*/
|
253 |
+
protected function _config()
|
254 |
+
{
|
255 |
+
if(NULL === $this->_config) {
|
256 |
+
$this->_config = Mage::getModel('mailup/config');
|
257 |
+
}
|
258 |
+
|
259 |
+
return $this->_config;
|
260 |
+
}
|
261 |
+
|
262 |
/**
|
263 |
* Generate CSV
|
264 |
*
|
335 |
//lancio il download del file
|
336 |
header("Content-type: application/csv");
|
337 |
header("Content-Disposition: attachment;Filename=filtered_customers.csv");
|
338 |
+
|
339 |
echo $file;
|
340 |
}
|
341 |
+
|
342 |
/**
|
343 |
+
* Save Filters
|
344 |
*/
|
345 |
+
public function saveFilterHintAction()
|
346 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
$this->checkRunningImport();
|
348 |
try {
|
349 |
$post = $this->getRequest()->getPost();
|
361 |
$this->_redirect('*/*');
|
362 |
}
|
363 |
|
364 |
+
/**
|
365 |
+
* Delete a Filter Hint
|
366 |
+
*/
|
367 |
+
public function deleteFilterHintAction()
|
368 |
+
{
|
369 |
$this->checkRunningImport();
|
370 |
try {
|
371 |
$post = $this->getRequest()->getPost();
|
381 |
$this->_redirect('*/*');
|
382 |
}
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
/**
|
385 |
* Check if an import is currently running
|
386 |
*
|
388 |
*/
|
389 |
public function checkRunningImport()
|
390 |
{
|
391 |
+
$syncTableName = Mage::getSingleton('core/resource')->getTableName('mailup/sync');
|
392 |
$db = Mage::getSingleton("core/resource")->getConnection("core_read");
|
393 |
$cron_schedule_table = Mage::getSingleton("core/resource")->getTableName("cron_schedule");
|
394 |
|
396 |
* @todo check if a cron has been run in the past X minites
|
397 |
* notify if cron is npt up and running
|
398 |
*/
|
399 |
+
$lastTime = $db->fetchOne("SELECT max(last_sync) FROM {$syncTableName}"); // 2013-04-18 19:23:55
|
400 |
if( ! empty($lastTime)) {
|
401 |
$dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $lastTime);
|
402 |
$lastTimeObject = clone $dateTime;
|
410 |
//}
|
411 |
}
|
412 |
}
|
413 |
+
|
414 |
+
$running_processes = $db->fetchOne(
|
415 |
+
"SELECT count(*)
|
416 |
+
FROM $cron_schedule_table
|
417 |
+
WHERE job_code='sevenlike_mailup' AND status='running'"
|
418 |
+
);
|
419 |
if ($running_processes) {
|
420 |
Mage::getSingleton("adminhtml/session")->addNotice($this->__("A MailUp import process is running."));
|
421 |
return;
|
422 |
}
|
423 |
|
424 |
+
$scheduled_processes = $db->fetchOne(
|
425 |
+
"SELECT count(*)
|
426 |
+
FROM $cron_schedule_table
|
427 |
+
WHERE job_code='sevenlike_mailup' AND status='pending'"
|
428 |
+
);
|
429 |
if ($scheduled_processes) {
|
430 |
Mage::getSingleton("adminhtml/session")->addNotice($this->__("A MailUp import process is schedules and will be executed soon."));
|
431 |
return;
|
432 |
}
|
433 |
}
|
434 |
+
|
435 |
+
public function testCronAction()
|
436 |
+
{
|
437 |
+
$cron = new SevenLike_MailUp_Model_Cron();
|
438 |
+
$cron->run();
|
439 |
+
}
|
440 |
+
|
441 |
+
public function testFieldsAction()
|
442 |
+
{
|
443 |
+
$wsSend = new MailUpWsSend();
|
444 |
+
$accessKey = $wsSend->loginFromId();
|
445 |
+
|
446 |
+
if ($accessKey !== false) {
|
447 |
+
$fields = $wsSend->GetFields($accessKey);
|
448 |
+
print_r($fields);
|
449 |
+
die('success');
|
450 |
+
}
|
451 |
+
else {
|
452 |
+
die('no access key returned');
|
453 |
+
}
|
454 |
+
}
|
455 |
}
|
app/code/local/SevenLike/MailUp/controllers/Adminhtml/LogController.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LogController.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_Adminhtml_LogController extends Mage_Adminhtml_Controller_Action
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Default Action
|
9 |
+
*/
|
10 |
+
public function indexAction()
|
11 |
+
{
|
12 |
+
$this->loadLayout();
|
13 |
+
$this->_title($this->__("Log Queue"));
|
14 |
+
$this->renderLayout();
|
15 |
+
}
|
16 |
+
}
|
app/code/local/SevenLike/MailUp/controllers/Adminhtml/MailupbackendController.php
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class SevenLike_MailUp_Adminhtml_MailupbackendController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Default Action
|
6 |
+
*/
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
$this->loadLayout();
|
10 |
+
$this->_title($this->__("MailUp Jobs"));
|
11 |
+
$this->renderLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Run The Job
|
16 |
+
*/
|
17 |
+
public function runjobAction()
|
18 |
+
{
|
19 |
+
/** @var $session Mage_Admin_Model_Session */
|
20 |
+
$session = Mage::getSingleton('adminhtml/session');
|
21 |
+
$id = $this->getRequest()->getParam('id');
|
22 |
+
|
23 |
+
if( ! $id) {
|
24 |
+
$session->addError(
|
25 |
+
Mage::helper('mailup')->__('Invalid Entity')
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
$entity = Mage::getModel('mailup/job')->load($id);
|
30 |
+
if($entity) {
|
31 |
+
Mage::helper('mailup')->runJob($entity->getId());
|
32 |
+
}
|
33 |
+
|
34 |
+
$session->addSuccess(
|
35 |
+
Mage::helper('mailup')->__("Run Job [{$entity->getId()}]")
|
36 |
+
);
|
37 |
+
|
38 |
+
$this->_redirect('*/*/index');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Delete a job
|
43 |
+
*/
|
44 |
+
public function deleteAction()
|
45 |
+
{
|
46 |
+
/** @var $session Mage_Admin_Model_Session */
|
47 |
+
$session = Mage::getSingleton('adminhtml/session');
|
48 |
+
$id = $this->getRequest()->getParam('id');
|
49 |
+
|
50 |
+
if( ! $id) {
|
51 |
+
$session->addError(
|
52 |
+
Mage::helper('mailup')->__('Invalid Entity')
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
$entity = Mage::getModel('mailup/job')->load($id);
|
57 |
+
$entity->delete();
|
58 |
+
|
59 |
+
$session->addSuccess(
|
60 |
+
Mage::helper('mailup')->__("Job [{$entity->getId()}] [Deleted]")
|
61 |
+
);
|
62 |
+
|
63 |
+
$this->_redirect('*/*/index');
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Start the process, if we've already run NewImportProcess
|
68 |
+
* and we have a process ID we can Start it.
|
69 |
+
*/
|
70 |
+
public function startProcessAction()
|
71 |
+
{
|
72 |
+
/** @var $session Mage_Admin_Model_Session */
|
73 |
+
$session = Mage::getSingleton('adminhtml/session');
|
74 |
+
$id = $this->getRequest()->getParam('id');
|
75 |
+
|
76 |
+
if( ! $id) {
|
77 |
+
$session->addError(
|
78 |
+
Mage::helper('mailup')->__('Invalid Entity')
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
$job = Mage::getModel('mailup/job')->load($id);
|
83 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
84 |
+
|
85 |
+
if( ! $job->getProcessId()) {
|
86 |
+
$session->addError(
|
87 |
+
Mage::helper('mailup')->__("Can't Run, There's no Process ID [{$job->getId()}]")
|
88 |
+
);
|
89 |
+
$this->_redirect('*/*/index');
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
|
93 |
+
require_once dirname(__FILE__) . "/../../Model/Wssend.php";
|
94 |
+
|
95 |
+
$wsSend = new MailUpWsSend($job->getStoreId());
|
96 |
+
$wsImport = new MailUpWsImport($job->getStoreId());
|
97 |
+
$accessKey = $wsSend->loginFromId();
|
98 |
+
|
99 |
+
//StartProcess(int idList, int listGUID, int idProcess)
|
100 |
+
/*$return = (string)$wsImport->startProcess(array(
|
101 |
+
'idList' => $job->getListid(),
|
102 |
+
'listGUID' => $job->getListGuid(),
|
103 |
+
'idProcess' => $job->getProcessId()
|
104 |
+
));
|
105 |
+
|
106 |
+
$session->addSuccess(
|
107 |
+
Mage::helper('mailup')->__("Job Processed [{$job->getId()}] [{$return}]")
|
108 |
+
);*/
|
109 |
+
|
110 |
+
$session->addSuccess(
|
111 |
+
Mage::helper('mailup')->__("Start Process [DISABLED]")
|
112 |
+
);
|
113 |
+
|
114 |
+
$this->_redirect('*/*/index');
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Start the process, if we've already run NewImportProcess
|
119 |
+
* and we have a process ID we can Start it.
|
120 |
+
*/
|
121 |
+
public function getProcessDetailAction()
|
122 |
+
{
|
123 |
+
/** @var $session Mage_Admin_Model_Session */
|
124 |
+
$session = Mage::getSingleton('adminhtml/session');
|
125 |
+
$id = $this->getRequest()->getParam('id');
|
126 |
+
|
127 |
+
if( ! $id) {
|
128 |
+
$session->addError(
|
129 |
+
Mage::helper('mailup')->__('Invalid Entity')
|
130 |
+
);
|
131 |
+
}
|
132 |
+
|
133 |
+
$job = Mage::getModel('mailup/job')->load($id);
|
134 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
135 |
+
|
136 |
+
if( ! $job->getProcessId()) {
|
137 |
+
$session->addError(
|
138 |
+
Mage::helper('mailup')->__("Can't Run, There's no Process ID [{$job->getId()}]")
|
139 |
+
);
|
140 |
+
$this->_redirect('*/*/index');
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
|
144 |
+
require_once dirname(__FILE__) . "/../../Model/Wssend.php";
|
145 |
+
|
146 |
+
$wsSend = new MailUpWsSend($job->getStoreId());
|
147 |
+
$wsImport = new MailUpWsImport($job->getStoreId());
|
148 |
+
$accessKey = $wsSend->loginFromId();
|
149 |
+
|
150 |
+
//StartProcess(int idList, int listGUID, int idProcess)
|
151 |
+
/*$return = $wsImport->getProcessDetail(array(
|
152 |
+
'idList' => $job->getListid(),
|
153 |
+
'listGUID' => $job->getListGuid(),
|
154 |
+
'idProcess' => $job->getProcessId()
|
155 |
+
));
|
156 |
+
|
157 |
+
$session->addSuccess(
|
158 |
+
Mage::helper('mailup')->__("Process Detail [{$job->getId()}] [{$return}]")
|
159 |
+
);*/
|
160 |
+
|
161 |
+
$session->addSuccess(
|
162 |
+
Mage::helper('mailup')->__("Process Detail [DISABLED]")
|
163 |
+
);
|
164 |
+
|
165 |
+
$this->_redirect('*/*/index');
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Get a list of processes we've added using NewImportProcess.
|
170 |
+
* We want to get a list and then go over them Starting each one, one at a time
|
171 |
+
* use
|
172 |
+
* StartProcess.
|
173 |
+
*/
|
174 |
+
public function getCurrentProcessesAction()
|
175 |
+
{
|
176 |
+
/** @var $session Mage_Admin_Model_Session */
|
177 |
+
$session = Mage::getSingleton('adminhtml/session');
|
178 |
+
$id = $this->getRequest()->getParam('id');
|
179 |
+
|
180 |
+
if( ! $id) {
|
181 |
+
$session->addError(
|
182 |
+
Mage::helper('mailup')->__('Invalid Entity')
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
$job = Mage::getModel('mailup/job')->load($id);
|
187 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
188 |
+
|
189 |
+
if( ! $job->getProcessId()) {
|
190 |
+
$session->addError(
|
191 |
+
Mage::helper('mailup')->__("Can't Run, There's no Process ID [{$job->getId()}]")
|
192 |
+
);
|
193 |
+
$this->_redirect('*/*/index');
|
194 |
+
return;
|
195 |
+
}
|
196 |
+
require_once dirname(__FILE__) . "/../../Model/MailUpWsImport.php";
|
197 |
+
require_once dirname(__FILE__) . "/../../Model/Wssend.php";
|
198 |
+
|
199 |
+
/*$wsSend = new MailUpWsSend($job->getStoreId());
|
200 |
+
$wsImport = new MailUpWsImport($job->getStoreId());
|
201 |
+
$accessKey = $wsSend->loginFromId();
|
202 |
+
|
203 |
+
//StartProcess(int idList, int listGUID, int idProcess)
|
204 |
+
$return = $wsImport->getProcessDetail(array(
|
205 |
+
'idList' => $job->getListid(),
|
206 |
+
'listGUID' => $job->getListGuid(),
|
207 |
+
'idProcess' => $job->getProcessId()
|
208 |
+
));*/
|
209 |
+
|
210 |
+
/*$session->addSuccess(
|
211 |
+
Mage::helper('mailup')->__("Process Detail [{$job->getId()}] [{$return}]")
|
212 |
+
);*/
|
213 |
+
|
214 |
+
$session->addSuccess(
|
215 |
+
Mage::helper('mailup')->__("Process Detail [DISABLED]")
|
216 |
+
);
|
217 |
+
|
218 |
+
$this->_redirect('*/*/index');
|
219 |
+
}
|
220 |
+
}
|
app/code/local/SevenLike/MailUp/controllers/Adminhtml/SyncController.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class SevenLike_MailUp_Adminhtml_SyncController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Default Action
|
6 |
+
*/
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
$this->loadLayout();
|
10 |
+
$this->_title($this->__("Sync Queue"));
|
11 |
+
$this->renderLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Sync the Entity
|
16 |
+
*/
|
17 |
+
public function syncAction()
|
18 |
+
{
|
19 |
+
/** @var $session Mage_Admin_Model_Session */
|
20 |
+
$session = Mage::getSingleton('adminhtml/session');
|
21 |
+
$id = $this->getRequest()->getParam('id');
|
22 |
+
|
23 |
+
if( ! $id) {
|
24 |
+
$session->addError(
|
25 |
+
Mage::helper('mailup')->__('Invalid Entity')
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
$entity = Mage::getModel('mailup/sync')->load($id);
|
30 |
+
|
31 |
+
$session->addSuccess(
|
32 |
+
Mage::helper('mailup')->__("Synced Entity [{$entity->getEntity()}]")
|
33 |
+
);
|
34 |
+
|
35 |
+
$this->_redirect('*/*/index');
|
36 |
+
}
|
37 |
+
}
|
app/code/local/SevenLike/MailUp/controllers/IndexController.php
CHANGED
@@ -5,40 +5,30 @@
|
|
5 |
class SevenLike_MailUp_IndexController extends Mage_Core_Controller_Front_Action
|
6 |
{
|
7 |
/**
|
8 |
-
*
|
|
|
|
|
9 |
*/
|
10 |
-
public function
|
11 |
{
|
12 |
-
return;
|
13 |
-
|
14 |
$config = Mage::getModel('mailup/config');
|
15 |
-
/* @var $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 |
-
//
|
|
|
|
|
30 |
|
31 |
-
|
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 |
/**
|
5 |
class SevenLike_MailUp_IndexController extends Mage_Core_Controller_Front_Action
|
6 |
{
|
7 |
/**
|
8 |
+
* Predispatch: should set layout area
|
9 |
+
*
|
10 |
+
* @return Mage_Core_Controller_Front_Action
|
11 |
*/
|
12 |
+
public function preDispatch()
|
13 |
{
|
|
|
|
|
14 |
$config = Mage::getModel('mailup/config');
|
15 |
+
/* @var $config SevenLike_MailUp_Model_Config */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
//if( ! $config->isTestMode()) {
|
18 |
+
// die('Access Denied.');
|
19 |
+
//}
|
20 |
|
21 |
+
parent::preDispatch();
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Default Action
|
28 |
+
*/
|
29 |
+
public function indexAction()
|
30 |
+
{
|
31 |
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
/**
|
app/code/local/SevenLike/MailUp/controllers/TestController.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TestController.php
|
4 |
+
*/
|
5 |
+
class SevenLike_MailUp_TestController extends Mage_Core_Controller_Front_Action
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Predispatch: should set layout area
|
9 |
+
*
|
10 |
+
* This is causing an issue and making 404s, something to do with the install
|
11 |
+
* being messed up and the code inside parent method doing something strange!
|
12 |
+
*
|
13 |
+
* @return Mage_Core_Controller_Front_Action
|
14 |
+
*/
|
15 |
+
public function preDispatch()
|
16 |
+
{
|
17 |
+
//$config = Mage::getModel('mailup/config');
|
18 |
+
/* @var $config SevenLike_MailUp_Model_Config */
|
19 |
+
|
20 |
+
//if( ! $config->isTestMode()) {
|
21 |
+
// die('Access Denied.');
|
22 |
+
//}
|
23 |
+
|
24 |
+
return parent::preDispatch();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Default Action
|
29 |
+
*/
|
30 |
+
public function indexAction()
|
31 |
+
{
|
32 |
+
//$this->loadLayout();
|
33 |
+
//$this->renderLayout();
|
34 |
+
//var_dump(Mage::helper('mailup')->getAllCustomerAttributes());
|
35 |
+
|
36 |
+
die('done');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function SubscriberAction()
|
40 |
+
{
|
41 |
+
$helper = Mage::helper('mailup');
|
42 |
+
|
43 |
+
var_dump($helper->isSubscriber(27, 1));
|
44 |
+
var_dump($helper->isSubscriber(29, 99));
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Start the process, if we've already run NewImportProcess
|
49 |
+
* and we have a process ID we can Start it.
|
50 |
+
*/
|
51 |
+
public function startProcessAction()
|
52 |
+
{
|
53 |
+
require_once dirname(__FILE__) . "/../Model/MailUpWsImport.php";
|
54 |
+
require_once dirname(__FILE__) . "/../Model/Wssend.php";
|
55 |
+
|
56 |
+
$wsSend = new MailUpWsSend($job->getStoreId());
|
57 |
+
$wsImport = new MailUpWsImport($job->getStoreId());
|
58 |
+
$accessKey = $wsSend->loginFromId();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* We need the ListID and ListGuid, which we will NOT
|
62 |
+
* have for sync items, as we've not saved the process id
|
63 |
+
* or anything else!!
|
64 |
+
*/
|
65 |
+
|
66 |
+
//StartProcess(int idList, int listGUID, int idProcess)
|
67 |
+
|
68 |
+
/*$return = $wsImport->startProcess(array(
|
69 |
+
'idList' => $job->getListid(),
|
70 |
+
'listGUID' => $job->getListGuid(),
|
71 |
+
'idProcess' => $job->getProcessId()
|
72 |
+
));*/
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Test the models..
|
77 |
+
*/
|
78 |
+
public function modelsAction()
|
79 |
+
{
|
80 |
+
$jobTask = Mage::getModel('mailup/sync');
|
81 |
+
/* @var $jobTask SevenLike_MailUp_Model_Sync */
|
82 |
+
|
83 |
+
$job = Mage::getModel('mailup/job');
|
84 |
+
/* @var $job SevenLike_MailUp_Model_Job */
|
85 |
+
|
86 |
+
foreach($job->fetchQueuedJobsCollection() as $job) {
|
87 |
+
echo "Job [{$job->getId()}] [{$job->getType()}] <br />";
|
88 |
+
}
|
89 |
+
|
90 |
+
echo '<br />----<br />';
|
91 |
+
|
92 |
+
foreach($job->fetchManualSyncQueuedJobsCollection() as $job) {
|
93 |
+
echo "Job [{$job->getId()}] [{$job->getType()}] <br />";
|
94 |
+
}
|
95 |
+
|
96 |
+
echo '<br />----<br />';
|
97 |
+
|
98 |
+
foreach($job->fetchAutoSyncQueuedJobsCollection() as $job) {
|
99 |
+
echo "Job [{$job->getId()}] [{$job->getType()}] <br />";
|
100 |
+
}
|
101 |
+
|
102 |
+
return;
|
103 |
+
|
104 |
+
$tasks = $jobTask->getSyncItemsCollection();
|
105 |
+
foreach($tasks as $task) {
|
106 |
+
var_dump($task->getData());
|
107 |
+
}
|
108 |
+
|
109 |
+
foreach($jobTask->fetchByJobId(0) as $task) {
|
110 |
+
var_dump($task->getData());
|
111 |
+
}
|
112 |
+
|
113 |
+
var_dump($jobTask->getJob());
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* List jobs
|
118 |
+
*/
|
119 |
+
public function cronAction()
|
120 |
+
{
|
121 |
+
echo "Server Time: " . date('H:i:s') . "<br /><br />";
|
122 |
+
|
123 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
124 |
+
$stmt = $read->query("
|
125 |
+
SELECT *
|
126 |
+
FROM cron_schedule
|
127 |
+
ORDER BY scheduled_at DESC"
|
128 |
+
);
|
129 |
+
while ($row = $stmt->fetch()) {
|
130 |
+
echo "{$row['job_code']} | {$row['status']} | {$row['scheduled_at']} | {$row['messages']}<br />";
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* List pending jobs
|
136 |
+
*/
|
137 |
+
public function cronPendingAction()
|
138 |
+
{
|
139 |
+
echo "Server Time: " . date('H:i:s') . "<br /><br />";
|
140 |
+
|
141 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
142 |
+
$stmt = $read->query("
|
143 |
+
SELECT *
|
144 |
+
FROM cron_schedule where status = 'pending'
|
145 |
+
ORDER BY scheduled_at DESC"
|
146 |
+
);
|
147 |
+
while ($row = $stmt->fetch()) {
|
148 |
+
echo "{$row['job_code']} | {$row['status']} | {$row['scheduled_at']} | {$row['messages']}<br />";
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* List jobs
|
154 |
+
*/
|
155 |
+
public function removeRunningAction()
|
156 |
+
{
|
157 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
158 |
+
$stmt = $write->query("
|
159 |
+
DELETE FROM cron_schedule WHERE job_code = 'sevenlike_mailup' AND status = 'running'"
|
160 |
+
);
|
161 |
+
die('done');
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Show Current Processes
|
166 |
+
*/
|
167 |
+
public function processesAction()
|
168 |
+
{
|
169 |
+
require_once dirname(dirname(__FILE__)) . "/Model/MailUpWsImport.php";
|
170 |
+
require_once dirname(dirname(__FILE__)) . "/Model/Wssend.php";
|
171 |
+
$wsimport = new MailUpWsImport();
|
172 |
+
|
173 |
+
var_dump($wsimport->getProcessDetail(array(
|
174 |
+
|
175 |
+
)));
|
176 |
+
}
|
177 |
+
}
|
app/code/local/SevenLike/MailUp/etc/config.xml
CHANGED
@@ -1,26 +1,44 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
|
3 |
<config>
|
4 |
<modules>
|
5 |
<SevenLike_MailUp>
|
6 |
-
<version>2.
|
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>
|
@@ -29,10 +47,22 @@
|
|
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>
|
@@ -43,6 +73,7 @@
|
|
43 |
<class>SevenLike_MailUp_Helper</class>
|
44 |
</mailup>
|
45 |
</helpers>
|
|
|
46 |
<resources>
|
47 |
<mailup_setup>
|
48 |
<setup>
|
@@ -63,6 +94,7 @@
|
|
63 |
</connection>
|
64 |
</mailup_read>
|
65 |
</resources>
|
|
|
66 |
<events>
|
67 |
<newsletter_subscriber_save_after>
|
68 |
<observers>
|
@@ -129,7 +161,7 @@
|
|
129 |
</sales_order_save_after>
|
130 |
</events>
|
131 |
</global>
|
132 |
-
|
133 |
<admin>
|
134 |
<routers>
|
135 |
<mailup>
|
@@ -141,7 +173,7 @@
|
|
141 |
</mailup>
|
142 |
</routers>
|
143 |
</admin>
|
144 |
-
|
145 |
<default>
|
146 |
<mailup_newsletter>
|
147 |
<mailup>
|
@@ -150,7 +182,7 @@
|
|
150 |
</mailup>
|
151 |
</mailup_newsletter>
|
152 |
</default>
|
153 |
-
|
154 |
<adminhtml>
|
155 |
<menu>
|
156 |
<newsletter>
|
@@ -161,13 +193,28 @@
|
|
161 |
<mailup_configuration translate="title">
|
162 |
<title><![CDATA[Settings & Field Mapping]]></title>
|
163 |
<action>mailup/adminhtml_configuration</action>
|
164 |
-
<sort_order>
|
165 |
</mailup_configuration>
|
166 |
<mailup_filters translate="title">
|
167 |
<title>Filters</title>
|
168 |
<action>mailup/adminhtml_filter</action>
|
169 |
-
<sort_order>
|
170 |
</mailup_filters>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
</children>
|
172 |
</mailup>
|
173 |
</children>
|
@@ -197,6 +244,15 @@
|
|
197 |
<mailup_viewdatatransferlog>
|
198 |
<title>View data transfer log</title>
|
199 |
</mailup_viewdatatransferlog>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
</children>
|
201 |
</mailup>
|
202 |
</children>
|
@@ -235,47 +291,35 @@
|
|
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>*/
|
277 |
<run><model>mailup/Cron::resendConnectionErrors</model></run>
|
278 |
</mailup_connectionproblemsredo>
|
279 |
</jobs>
|
280 |
</crontab>
|
281 |
-
</config>
|
1 |
<?xml version="1.0"?>
|
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SevenLike_MailUp>
|
5 |
+
<version>2.4.1</version>
|
6 |
</SevenLike_MailUp>
|
7 |
</modules>
|
8 |
+
<!-- frontend -->
|
9 |
+
<frontend>
|
10 |
+
<routers>
|
11 |
+
<mailup>
|
12 |
+
<use>standard</use>
|
13 |
+
<args>
|
14 |
+
<module>SevenLike_MailUp</module>
|
15 |
+
<frontName>mailup</frontName>
|
16 |
+
</args>
|
17 |
+
</mailup>
|
18 |
+
</routers>
|
19 |
+
<translate>
|
20 |
+
<modules>
|
21 |
+
<mailup>
|
22 |
+
<files>
|
23 |
+
<default>SevenLike_MailUp.csv</default>
|
24 |
+
</files>
|
25 |
+
</mailup>
|
26 |
+
</modules>
|
27 |
+
</translate>
|
28 |
+
<layout>
|
29 |
+
<updates>
|
30 |
+
<mailup>
|
31 |
+
<file>mailup.xml</file>
|
32 |
+
</mailup>
|
33 |
+
</updates>
|
34 |
+
</layout>
|
35 |
+
</frontend>
|
36 |
+
<!-- global -->
|
37 |
<global>
|
38 |
+
<!-- models -->
|
39 |
<models>
|
40 |
<mailup>
|
41 |
<class>SevenLike_MailUp_Model</class>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
<resourceModel>mailup_mysql4</resourceModel>
|
43 |
</mailup>
|
44 |
<mailup_mysql4>
|
47 |
<job>
|
48 |
<table>mailup_sync_jobs</table>
|
49 |
</job>
|
50 |
+
<sync>
|
51 |
+
<table>mailup_sync</table>
|
52 |
+
</sync>
|
53 |
+
<log>
|
54 |
+
<table>mailup_log</table>
|
55 |
+
</log>
|
56 |
</entities>
|
57 |
+
</mailup_mysql4>
|
58 |
+
<!-- Override Subscriber so we can disable Notifiactions -->
|
59 |
+
<newsletter>
|
60 |
+
<rewrite>
|
61 |
+
<subscriber>SevenLike_MailUp_Model_Subscriber</subscriber>
|
62 |
+
</rewrite>
|
63 |
+
</newsletter>
|
64 |
</models>
|
65 |
+
<!-- blocks -->
|
66 |
<blocks>
|
67 |
<mailup>
|
68 |
<class>SevenLike_MailUp_Block</class>
|
73 |
<class>SevenLike_MailUp_Helper</class>
|
74 |
</mailup>
|
75 |
</helpers>
|
76 |
+
<!-- resources -->
|
77 |
<resources>
|
78 |
<mailup_setup>
|
79 |
<setup>
|
94 |
</connection>
|
95 |
</mailup_read>
|
96 |
</resources>
|
97 |
+
<!-- events -->
|
98 |
<events>
|
99 |
<newsletter_subscriber_save_after>
|
100 |
<observers>
|
161 |
</sales_order_save_after>
|
162 |
</events>
|
163 |
</global>
|
164 |
+
<!-- admin -->
|
165 |
<admin>
|
166 |
<routers>
|
167 |
<mailup>
|
173 |
</mailup>
|
174 |
</routers>
|
175 |
</admin>
|
176 |
+
<!-- default -->
|
177 |
<default>
|
178 |
<mailup_newsletter>
|
179 |
<mailup>
|
182 |
</mailup>
|
183 |
</mailup_newsletter>
|
184 |
</default>
|
185 |
+
<!-- adminhtml -->
|
186 |
<adminhtml>
|
187 |
<menu>
|
188 |
<newsletter>
|
193 |
<mailup_configuration translate="title">
|
194 |
<title><![CDATA[Settings & Field Mapping]]></title>
|
195 |
<action>mailup/adminhtml_configuration</action>
|
196 |
+
<sort_order>0</sort_order>
|
197 |
</mailup_configuration>
|
198 |
<mailup_filters translate="title">
|
199 |
<title>Filters</title>
|
200 |
<action>mailup/adminhtml_filter</action>
|
201 |
+
<sort_order>10</sort_order>
|
202 |
</mailup_filters>
|
203 |
+
<mailup_jobs module="mailup">
|
204 |
+
<title>View MailUp Tasks</title>
|
205 |
+
<sort_order>20</sort_order>
|
206 |
+
<action>mailup/adminhtml_mailupbackend</action>
|
207 |
+
</mailup_jobs>
|
208 |
+
<mailup_sync module="mailup">
|
209 |
+
<title>View Task Data</title>
|
210 |
+
<sort_order>30</sort_order>
|
211 |
+
<action>mailup/adminhtml_sync</action>
|
212 |
+
</mailup_sync>
|
213 |
+
<mailup_log module="mailup">
|
214 |
+
<title>View Logs</title>
|
215 |
+
<sort_order>40</sort_order>
|
216 |
+
<action>mailup/adminhtml_log</action>
|
217 |
+
</mailup_log>
|
218 |
</children>
|
219 |
</mailup>
|
220 |
</children>
|
244 |
<mailup_viewdatatransferlog>
|
245 |
<title>View data transfer log</title>
|
246 |
</mailup_viewdatatransferlog>
|
247 |
+
<mailup_jobs translate="title">
|
248 |
+
<title>Mailup Jobs</title>
|
249 |
+
</mailup_jobs>
|
250 |
+
<mailup_sync translate="title">
|
251 |
+
<title>Mailup Job Data</title>
|
252 |
+
</mailup_sync>
|
253 |
+
<mailup_log translate="title">
|
254 |
+
<title>Mailup Logs</title>
|
255 |
+
</mailup_log>
|
256 |
</children>
|
257 |
</mailup>
|
258 |
</children>
|
291 |
</modules>
|
292 |
</translate>
|
293 |
</adminhtml>
|
294 |
+
<!-- cron -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
<crontab>
|
296 |
<jobs>
|
297 |
+
|
298 |
+
<!--
|
299 |
+
Manual Sync will be triggered ASAP.
|
300 |
+
|
301 |
+
Auto sync will be triggered by the settings in the DB / config
|
302 |
+
-->
|
303 |
+
|
304 |
+
<!--
|
305 |
+
<sevenlike_mailup_manualsync>
|
306 |
+
<run><model>mailup/Cron::run</model></run>
|
307 |
+
</sevenlike_mailup_manualsync>
|
308 |
+
-->
|
309 |
+
|
310 |
+
<sevenlike_mailup_autosync>
|
311 |
+
<run><model>mailup/Cron::autoSync</model></run>
|
312 |
+
</sevenlike_mailup_autosync>
|
313 |
+
|
314 |
<sevenlike_mailup>
|
315 |
+
<!--<schedule><cron_expr>*/15 * * * *</cron_expr></schedule>-->
|
316 |
<run><model>mailup/Cron::run</model></run>
|
317 |
</sevenlike_mailup>
|
318 |
+
<!-- not in use? never implemented.. -->
|
319 |
<mailup_connectionproblemsredo>
|
320 |
+
<schedule><cron_expr>*/30 * * * *</cron_expr></schedule>
|
321 |
<run><model>mailup/Cron::resendConnectionErrors</model></run>
|
322 |
</mailup_connectionproblemsredo>
|
323 |
</jobs>
|
324 |
</crontab>
|
325 |
+
</config>
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-2.3.0.php
CHANGED
@@ -1,27 +1,31 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
3 |
$this->startSetup();
|
4 |
|
5 |
-
$
|
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 |
-
$
|
12 |
-
CREATE TABLE IF NOT EXISTS
|
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)
|
|
|
18 |
`last_sync` datetime NULL,
|
19 |
-
PRIMARY KEY (`customer_id
|
20 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
21 |
|
22 |
-
$
|
23 |
-
DROP TABLE IF EXISTS
|
24 |
-
CREATE TABLE IF NOT EXISTS
|
25 |
`id` int(11) NOT NULL AUTO_INCREMENT,
|
26 |
`store_id` int(11) DEFAULT NULL,
|
27 |
`mailupgroupid` int(11) NOT NULL,
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Install
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
$this->startSetup();
|
7 |
|
8 |
+
$installer->run("CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
|
9 |
`filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
|
10 |
`hints` varchar(255) collate utf8_unicode_ci NOT NULL,
|
11 |
PRIMARY KEY (`filter_name`)
|
12 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
13 |
|
14 |
+
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('mailup/sync')};
|
15 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/sync')} (
|
16 |
`store_id` int(11) DEFAULT NULL,
|
17 |
`customer_id` int(11) NOT NULL,
|
18 |
`entity` varchar(100) NOT NULL,
|
19 |
`job_id` int(11) NOT NULL,
|
20 |
+
`needs_sync` tinyint(1) DEFAULT 1,
|
21 |
+
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
22 |
`last_sync` datetime NULL,
|
23 |
+
PRIMARY KEY (`customer_id`, `entity`, `job_id`)
|
24 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
25 |
|
26 |
+
$installer->run("
|
27 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/job')};
|
28 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/job')} (
|
29 |
`id` int(11) NOT NULL AUTO_INCREMENT,
|
30 |
`store_id` int(11) DEFAULT NULL,
|
31 |
`mailupgroupid` int(11) NOT NULL,
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-install-2.4.0.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Install
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
$this->startSetup();
|
7 |
+
|
8 |
+
$installer->run("
|
9 |
+
CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
|
10 |
+
`filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
|
11 |
+
`hints` varchar(255) collate utf8_unicode_ci NOT NULL,
|
12 |
+
PRIMARY KEY (`filter_name`)
|
13 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
14 |
+
/**
|
15 |
+
* Install jobs Table
|
16 |
+
*/
|
17 |
+
$installer->run("
|
18 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/job')};
|
19 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/job')} (
|
20 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
21 |
+
`store_id` int(11) DEFAULT NULL,
|
22 |
+
`mailupgroupid` int(11) DEFAULT NULL,
|
23 |
+
`list_id` int(11) DEFAULT NULL,
|
24 |
+
`list_guid` varchar(255) DEFAULT NULL,
|
25 |
+
`send_optin` tinyint(1) NOT NULL,
|
26 |
+
`as_pending` tinyint(1) DEFAULT NULL,
|
27 |
+
`status` varchar(20) NOT NULL,
|
28 |
+
`process_id` INT UNSIGNED DEFAULT NULL,
|
29 |
+
`tries` INT UNSIGNED DEFAULT 0,
|
30 |
+
`type` INT UNSIGNED DEFAULT 0,
|
31 |
+
`queue_datetime` datetime NOT NULL,
|
32 |
+
`start_datetime` datetime,
|
33 |
+
`finish_datetime` datetime,
|
34 |
+
PRIMARY KEY (`id`)
|
35 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
|
36 |
+
/**
|
37 |
+
* Install Job Sync Tasks
|
38 |
+
*/
|
39 |
+
$installer->run("
|
40 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/sync')};
|
41 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/sync')} (
|
42 |
+
`id` int (11) NOT NULL AUTO_INCREMENT,
|
43 |
+
`store_id` int(11) DEFAULT NULL,
|
44 |
+
`customer_id` int(11) NOT NULL,
|
45 |
+
`entity` varchar(100) NOT NULL,
|
46 |
+
`job_id` int(11) NOT NULL,
|
47 |
+
`needs_sync` tinyint(1) DEFAULT 1,
|
48 |
+
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
49 |
+
`last_sync` datetime NULL,
|
50 |
+
PRIMARY KEY (`id`),
|
51 |
+
UNIQUE KEY uniq_key (`customer_id`,`entity`,`job_id`, `store_id`)
|
52 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
53 |
+
/**
|
54 |
+
* Install Log Table
|
55 |
+
*/
|
56 |
+
$this->run("
|
57 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/log')};
|
58 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/log')} (
|
59 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
60 |
+
`store_id` int(11) DEFAULT NULL,
|
61 |
+
`job_id` int(11) DEFAULT NULL,
|
62 |
+
`type` varchar(20) NOT NULL,
|
63 |
+
`status` varchar(20) NOT NULL,
|
64 |
+
`data` TEXT DEFAULT NULL,
|
65 |
+
`event_time` datetime NOT NULL,
|
66 |
+
PRIMARY KEY (`id`)
|
67 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
|
68 |
+
|
69 |
+
$this->endSetup();
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.0-2.3.1.php
CHANGED
@@ -1,12 +1,13 @@
|
|
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
|
10 |
ADD `process_id` INT UNSIGNED DEFAULT NULL,
|
11 |
ADD `tries` INT UNSIGNED DEFAULT 0;
|
12 |
");
|
1 |
<?php
|
2 |
|
3 |
$this->startSetup();
|
4 |
+
$installer = $this;
|
5 |
/**
|
6 |
* We want to record the process id, and the number of attempts we've made at
|
7 |
* processing the job!
|
8 |
*/
|
9 |
$this->run("
|
10 |
+
ALTER TABLE {$installer->getTable('mailup/job')}
|
11 |
ADD `process_id` INT UNSIGNED DEFAULT NULL,
|
12 |
ADD `tries` INT UNSIGNED DEFAULT 0;
|
13 |
");
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.1-2.3.2.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Add Job Type
|
8 |
+
*/
|
9 |
+
$this->run("
|
10 |
+
ALTER TABLE {$installer->getTable('mailup/job')}
|
11 |
+
ADD `type` INT UNSIGNED DEFAULT 0;
|
12 |
+
");
|
13 |
+
/**
|
14 |
+
* Need a Simple Key to allow us to utilise the grid.
|
15 |
+
*/
|
16 |
+
$this->run("
|
17 |
+
ALTER TABLE {$installer->getTable('mailup/sync')}
|
18 |
+
ADD column id int (11) NOT NULL AUTO_INCREMENT,
|
19 |
+
DROP PRIMARY KEY,
|
20 |
+
ADD PRIMARY KEY (id),
|
21 |
+
ADD UNIQUE KEY uniq_key (`customer_id`,`entity`,`job_id`, `store_id`);
|
22 |
+
");
|
23 |
+
/**
|
24 |
+
* Install Log Table
|
25 |
+
*/
|
26 |
+
$this->run("
|
27 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/log')};
|
28 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/log')} (
|
29 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
30 |
+
`store_id` int(11) DEFAULT NULL,
|
31 |
+
`job_id` int(11) DEFAULT NULL,
|
32 |
+
`type` varchar(20) NOT NULL,
|
33 |
+
`status` varchar(20) NOT NULL,
|
34 |
+
`data` TEXT DEFAULT NULL,
|
35 |
+
`event_time` datetime NOT NULL,
|
36 |
+
PRIMARY KEY (`id`)
|
37 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
|
38 |
+
|
39 |
+
$this->endSetup();
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.3.2-2.4.0.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Install
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
$this->startSetup();
|
7 |
+
|
8 |
+
$installer->run("
|
9 |
+
CREATE TABLE IF NOT EXISTS `mailup_filter_hints` (
|
10 |
+
`filter_name` varchar(255) collate utf8_unicode_ci NOT NULL,
|
11 |
+
`hints` varchar(255) collate utf8_unicode_ci NOT NULL,
|
12 |
+
PRIMARY KEY (`filter_name`)
|
13 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
14 |
+
/**
|
15 |
+
* Install jobs Table
|
16 |
+
*/
|
17 |
+
$installer->run("
|
18 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/job')};
|
19 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/job')} (
|
20 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
21 |
+
`store_id` int(11) DEFAULT NULL,
|
22 |
+
`mailupgroupid` int(11) DEFAULT NULL,
|
23 |
+
`list_id` int(11) DEFAULT NULL,
|
24 |
+
`list_guid` varchar(255) DEFAULT NULL,
|
25 |
+
`send_optin` tinyint(1) NOT NULL,
|
26 |
+
`as_pending` tinyint(1) DEFAULT NULL,
|
27 |
+
`status` varchar(20) NOT NULL,
|
28 |
+
`process_id` INT UNSIGNED DEFAULT NULL,
|
29 |
+
`tries` INT UNSIGNED DEFAULT 0,
|
30 |
+
`type` INT UNSIGNED DEFAULT 0,
|
31 |
+
`queue_datetime` datetime NOT NULL,
|
32 |
+
`start_datetime` datetime,
|
33 |
+
`finish_datetime` datetime,
|
34 |
+
PRIMARY KEY (`id`)
|
35 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
|
36 |
+
/**
|
37 |
+
* Install Job Sync Tasks
|
38 |
+
*/
|
39 |
+
$installer->run("
|
40 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/sync')};
|
41 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/sync')} (
|
42 |
+
`id` int (11) NOT NULL AUTO_INCREMENT,
|
43 |
+
`store_id` int(11) DEFAULT NULL,
|
44 |
+
`customer_id` int(11) NOT NULL,
|
45 |
+
`entity` varchar(100) NOT NULL,
|
46 |
+
`job_id` int(11) NOT NULL,
|
47 |
+
`needs_sync` tinyint(1) DEFAULT 1,
|
48 |
+
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
49 |
+
`last_sync` datetime NULL,
|
50 |
+
PRIMARY KEY (`id`),
|
51 |
+
UNIQUE KEY uniq_key (`customer_id`,`entity`,`job_id`, `store_id`)
|
52 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
53 |
+
/**
|
54 |
+
* Install Log Table
|
55 |
+
*/
|
56 |
+
$this->run("
|
57 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/log')};
|
58 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/log')} (
|
59 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
60 |
+
`store_id` int(11) DEFAULT NULL,
|
61 |
+
`job_id` int(11) DEFAULT NULL,
|
62 |
+
`type` varchar(20) NOT NULL,
|
63 |
+
`status` varchar(20) NOT NULL,
|
64 |
+
`data` TEXT DEFAULT NULL,
|
65 |
+
`event_time` datetime NOT NULL,
|
66 |
+
PRIMARY KEY (`id`)
|
67 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
|
68 |
+
|
69 |
+
$this->endSetup();
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-2.4.0-2.4.1.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Install
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
$this->startSetup();
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Install Job Sync Tasks
|
10 |
+
*
|
11 |
+
* Change to InnoDB, and add in Foreign Key
|
12 |
+
*/
|
13 |
+
$installer->run("
|
14 |
+
DROP TABLE IF EXISTS {$installer->getTable('mailup/sync')};
|
15 |
+
CREATE TABLE IF NOT EXISTS {$installer->getTable('mailup/sync')} (
|
16 |
+
`id` int (11) NOT NULL AUTO_INCREMENT,
|
17 |
+
`store_id` int(11) DEFAULT NULL,
|
18 |
+
`customer_id` int(11) NOT NULL,
|
19 |
+
`entity` varchar(100) NOT NULL,
|
20 |
+
`job_id` int(11) NOT NULL,
|
21 |
+
`needs_sync` tinyint(1) DEFAULT 1,
|
22 |
+
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
23 |
+
`last_sync` datetime NULL,
|
24 |
+
PRIMARY KEY (`id`),
|
25 |
+
UNIQUE KEY uniq_key (`customer_id`,`entity`,`job_id`, `store_id`),
|
26 |
+
INDEX `fk_jobs_idx` (`job_id` ASC),
|
27 |
+
CONSTRAINT `fk_jobs`
|
28 |
+
FOREIGN KEY (`job_id`)
|
29 |
+
REFERENCES {$installer->getTable('mailup/job')} (`id`)
|
30 |
+
ON DELETE CASCADE
|
31 |
+
ON UPDATE NO ACTION
|
32 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
33 |
+
|
34 |
+
$this->endSetup();
|
app/design/adminhtml/default/default/layout/mailup.xml
CHANGED
@@ -1,6 +1,26 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<layout>
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
<mailup_adminhtml_filter_index>
|
5 |
<update handle="mailup_adminhtml_index"/>
|
6 |
<reference name="content">
|
1 |
<?xml version="1.0"?>
|
2 |
<layout>
|
3 |
|
4 |
+
<mailup_adminhtml_mailupbackend_index>
|
5 |
+
<reference name="content">
|
6 |
+
<!-- <block type="mailup/adminhtml_mailupbackend" name="mailupbackend" template="mailup/mailupbackend.phtml"/>-->
|
7 |
+
|
8 |
+
<block type="mailup/adminhtml_mailupbackend" name="mailupbackend" />
|
9 |
+
</reference>
|
10 |
+
</mailup_adminhtml_mailupbackend_index>
|
11 |
+
|
12 |
+
<mailup_adminhtml_sync_index>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="mailup/adminhtml_sync" name="sync" />
|
15 |
+
</reference>
|
16 |
+
</mailup_adminhtml_sync_index>
|
17 |
+
|
18 |
+
<mailup_adminhtml_log_index>
|
19 |
+
<reference name="content">
|
20 |
+
<block type="mailup/adminhtml_log" name="mailup_log" />
|
21 |
+
</reference>
|
22 |
+
</mailup_adminhtml_log_index>
|
23 |
+
|
24 |
<mailup_adminhtml_filter_index>
|
25 |
<update handle="mailup_adminhtml_index"/>
|
26 |
<reference name="content">
|
app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml
CHANGED
@@ -2,14 +2,19 @@
|
|
2 |
/**
|
3 |
* filter.phtml
|
4 |
*/
|
5 |
-
$
|
|
|
|
|
|
|
|
|
|
|
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
|
2 |
/**
|
3 |
* filter.phtml
|
4 |
*/
|
5 |
+
$storeId = $this->getRequest()->getParam('store_id');
|
6 |
+
if(empty($storeId)) {
|
7 |
+
$storeId = NULL; //Mage::app()->getDefaultStoreView()->getStoreId();
|
8 |
+
}
|
9 |
+
|
10 |
+
$wsSend = new MailUpWsSend($storeId); /** @todo add in storeID, use session.. not needed really here... **/
|
11 |
$accessKey = $wsSend->loginFromId();
|
12 |
|
13 |
if ($accessKey === false || strlen(Mage::getStoreConfig('mailup_newsletter/mailup/list')) < 1) {
|
14 |
echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
|
15 |
} else {
|
16 |
//controllo se la lista e' stata selezionata correttamente
|
17 |
+
$wsImport = new MailUpWsImport($storeId);
|
18 |
$mailupLists = $wsImport->GetNlList();
|
19 |
|
20 |
//carico i filtri salvati
|
app/design/adminhtml/default/default/template/sevenlike/mailup/filter_.phtml
CHANGED
@@ -1,526 +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')?> ⇒</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"'; } ?> /> <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"> </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"> </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);" /> <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);" /> <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);" /> <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"'; } ?> /> <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-->
|
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")?> »</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')?> »</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'); ?> »</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> </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.' »</p>';
|
464 |
-
echo '<input class="form-button" type="submit" value="'.$this->__('Set hint').'" />';
|
465 |
-
echo '</form>';
|
466 |
-
echo ' ';
|
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 } ?>
|
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')?> ⇒</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"'; } ?> /> <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"> </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"> </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);" /> <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);" /> <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);" /> <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"'; } ?> /> <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-->
|
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")?> »</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')?> »</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'); ?> »</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> </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.' »</p>';
|
464 |
+
echo '<input class="form-button" type="submit" value="'.$this->__('Set hint').'" />';
|
465 |
+
echo '</form>';
|
466 |
+
echo ' ';
|
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/frontend/base/default/layout/mailup.xml
CHANGED
@@ -5,4 +5,16 @@
|
|
5 |
<block type="mailup/checkout_subscribe" name="mailup.subscribe" template="mailup/subscribe.phtml" />
|
6 |
</reference>
|
7 |
</checkout_onepage_review>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
</layout>
|
5 |
<block type="mailup/checkout_subscribe" name="mailup.subscribe" template="mailup/subscribe.phtml" />
|
6 |
</reference>
|
7 |
</checkout_onepage_review>
|
8 |
+
|
9 |
+
<mailup_index_index>
|
10 |
+
<reference name="root">
|
11 |
+
<action method="setTemplate">
|
12 |
+
<template>page/1column.phtml</template>
|
13 |
+
</action>
|
14 |
+
</reference>
|
15 |
+
<reference name="content">
|
16 |
+
<block type="mailup/index" name="mailup_index" template="mailup/index.phtml"/>
|
17 |
+
</reference>
|
18 |
+
</mailup_index_index>
|
19 |
+
|
20 |
</layout>
|
app/design/frontend/base/default/template/mailup/index.phtml
ADDED
File without changes
|
app/design/frontend/base/default/template/mailup/subscribe.phtml
CHANGED
@@ -12,7 +12,6 @@ if (Mage::getStoreConfig("mailup_newsletter/mailup/enable_subscribe_in_checkout"
|
|
12 |
$display_checkbox = true;
|
13 |
}
|
14 |
}
|
15 |
-
|
16 |
?>
|
17 |
|
18 |
<?php if ($display_checkbox): ?>
|
12 |
$display_checkbox = true;
|
13 |
}
|
14 |
}
|
|
|
15 |
?>
|
16 |
|
17 |
<?php if ($display_checkbox): ?>
|
app/etc/modules/SevenLike_MailUp.xml
CHANGED
@@ -1,12 +1 @@
|
|
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>
|
1 |
+
<?xml version="1.0"?><config> <modules> <SevenLike_MailUp> <active>true</active> <codePool>local</codePool> <depends> <Mage_Newsletter /> </depends> </SevenLike_MailUp> </modules></config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>MailUp</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
|
7 |
<channel>community</channel>
|
@@ -53,9 +53,9 @@ Added date/time stamp of latest data sync
|
|
53 |

|
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-
|
57 |
-
<time>
|
58 |
-
<contents><target name="magelocal"><dir name="SevenLike"><dir name="MailUp"><dir name="Block"><dir name="Checkout"><file name="Subscribe.php" hash="
|
59 |
<compatible/>
|
60 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
61 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>MailUp</name>
|
4 |
+
<version>2.4.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>
|
53 |

|
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-11-21</date>
|
57 |
+
<time>22:45:31</time>
|
58 |
+
<contents><target name="magelocal"><dir name="SevenLike"><dir name="MailUp"><dir name="Block"><dir name="Adminhtml"><dir name="Log"><file name="Grid.php" hash="47caec2c8861a886019a9104e01ddcad"/></dir><file name="Log.php" hash="b81d437533b23160e0b9f85844cd45e3"/><dir name="Mailup"><file name="Grid.php" hash="a184a745b8f9f7b204804a89a8fb15e2"/></dir><file name="Mailupbackend.php" hash="142d7d788b131fc32dbf395dd51d1b7f"/><dir name="Sync"><file name="Grid.php" hash="f0534532bc00832b82356583fea050c0"/></dir><file name="Sync.php" hash="0c44aecfe6ddbd227e442fd124bd33b2"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="9cd1c87df8a23f93d8bf0995e13652f2"/></dir><file name="Filters.php" hash="f881a202a8d2e3c34b3f1b4094852b2c"/><file name="Index.php" hash="7d5c46e16c94b50f6236d8d0027066d0"/></dir><dir name="Helper"><file name="Data.php" hash="51b2c1ce6321d0a93cae6dc50c31e5b8"/></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="8f1e07f911366478c26b32cd7cef19ad"/></dir></dir></dir><file name="Config.php" hash="a5cca0bff188b18104b42f7c4033c126"/><file name="Consoleurlvalidator.php" hash="2cd27b9d21570e39ef6a5a0bbf3f97c5"/><file name="Cron.php" hash="db67d877c077536d660051535cc66060"/><file name="Job.php" hash="b7278cc246cf86dabc068bb1a4c35b36"/><file name="Lists.php" hash="b163b1e69054004148746c7138984f54"/><file name="Log.php" hash="9e15739c03264cf839a1460ac29f6def"/><file name="MailUp.php" hash="1b552b40a7bf6f4c915667adbe164140"/><file name="MailUpWsImport.php" hash="b69d7dbe7b4ac69fa52b09c55fc9db31"/><dir name="Mysql14"><dir name="Job"><file name="Collection.php" hash="9cdb99926ae73a9c6d5bafee0f2d6042"/></dir><file name="Job.php" hash="244a509b404abb9fc47755aaff8463d9"/><dir name="MailUp"><file name="Collection.php" hash="256485c1ba69eff42ae109d3218c89ff"/></dir><file name="MailUp.php" hash="d06606483ac4c35e42f9cb449a36c1c5"/></dir><dir name="Mysql4"><dir name="Job"><file name="Collection.php" hash="098c1a71a121055b3b68cac792a7880d"/></dir><file name="Job.php" hash="77fdc701679e1d72422a9eda07e74ac5"/><dir name="Log"><file name="Collection.php" hash="409d0ba61b023e7cd7c66e85e2022be1"/></dir><file name="Log.php" hash="625e8bfd86ac19b903c829ece323ca4a"/><dir name="Sync"><file name="Collection.php" hash="b453b492298d0ba7cd6a8ed6a70dc62a"/></dir><file name="Sync.php" hash="cea85b179be7f79164af2cbb99a08e0a"/></dir><file name="Observer.php" hash="1d3858cdb87b267b074d20c9343d3ed1"/><dir name="Source"><file name="Store.php" hash="de1b07b5bd94ae4292377dff5a153340"/></dir><file name="Subscriber.php" hash="877fe0e81d86e8b9b0d9c23ccd5378f2"/><file name="Sync.php" hash="7736a7e1fb38aad61c4e6a5aa89294a2"/><file name="Webserviceusernamevalidator.php" hash="9650aed034726d621968f18371d554bc"/><file name="Ws.php" hash="21ef21afcf35867d0ec8ff345babeab6"/><file name="Wssend.php" hash="759922bc344c79e9a1ab01a1a5fc42b9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigurationController.php" hash="240d526f2c944b93b78d00d85d4b6c47"/><file name="FieldsmappingController.php" hash="66f0598c537f9518433b99cb7aa9acfe"/><file name="FilterController.php" hash="e86432b78723cfed2de46ed58a7cc825"/><file name="LogController.php" hash="1300abf084a62b9ed2b00e7f2a632c29"/><file name="MailupbackendController.php" hash="963646cb267f4f4e05efd09be387b834"/><file name="SyncController.php" hash="94e0f9d8f42b609e9b08822d1766f9f8"/><file name="ViewdatatransferlogController.php" hash="eec948994f2d1491ead736578deabf92"/></dir><file name="IndexController.php" hash="d7dfe7ee526df542d7810936a496a1fc"/><file name="TestController.php" hash="9040d9536cbd305b9cac7a8f58638208"/><file name="WebhookController.php" hash="ef72fa5602b3f9fec0eae41eb34638a1"/></dir><dir name="etc"><file name="config.xml" hash="dd44666cf801b066d21ba8bc3aea8162"/><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="9532dac8b7bbc85f4e13d44816213076"/><file name="mysql4-install-2.4.0.php" hash="df3247d77cf4dff79c7dbf305e5ad9b8"/><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="d7b7aac558c7bbfcd9f5657342bb8d5d"/><file name="mysql4-upgrade-2.3.1-2.3.2.php" hash="841257c7988bd63828d2fdeaa087eaca"/><file name="mysql4-upgrade-2.3.2-2.4.0.php" hash="df3247d77cf4dff79c7dbf305e5ad9b8"/><file name="mysql4-upgrade-2.4.0-2.4.1.php" hash="812b65d636b1e15d3804c21d134de572"/></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="1e83a4178884228b5346571152dede1d"/></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="9938d917ad94034d581069b08d93c3ca"/><file name="filter_.phtml" hash="fdb7010f87813df63a1a02d0873a9ea7"/><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="34e7637555730c316157c31af746b1b9"/></dir><dir name="template"><dir name="mailup"><file name="index.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="subscribe.phtml" hash="3316f1a2e166179d2631a4a568059d66"/></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="ed52c3da61db540369d5531e8866505c"/></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="5997cafd6824942172cc23f017ad145a"/></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/mailup.css
CHANGED
@@ -1 +1 @@
|
|
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;
|
|
|
|
1 |
background: url(./images/MailUp_300_200_transparent_small.png) 10px 0 no-repeat;
|
2 |
text-indent: -9999px;
|
3 |
overflow: hidden;
|
4 |
+
h4 { font-size: 1.05em; margin-bottom: 0.6em; overflow: hidden; }#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%; }#spantitle1 a, #spantitle3 a { text-decoration: none; font-weight: bold; color: #fff; }#spansugger { display: block; padding: 7px 0 0 0; }.parscefil { float: left; width: 310px; }.spdnpg1 { height: 50px; padding: 0 25px 0 0; }td.labelpg1 { width: 170px; }.slctpg1 { width: 350px; padding: 4px; }.slctpg2 { width: 200px; padding: 4px; }.lbl1 { padding: 0 4px 0 30px; }.inptptx1 { padding: 4px; }.inptptx2 { width: 340px; padding: 4px; }.txtar1 { padding: 4px; width: 340px; }.slgrp1 { margin: 0 0 10px 0; }.slgrp2 { margin: 10px 0 20px 0; }.istrz1 { font: 12px Verdana, Geneva, sans-serif; font-style: italic; }.istrz2 { font: 12px Verdana, Geneva, sans-serif; font-style: italic; margin: 0 0 20px 0; }input, select { margin-bottom: 5px; }span.tip { font-style: italic; }li.mailup-tab-parent {}li.mailup-tab-parent dt.label { background: url(./images/MailUp_300_200_transparent_small.png) 10px 0 no-repeat; text-indent: -9999px; overflow: hidden;}a.mailup-tab {}.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;}
|