Version Notes
v2
Download this release
Release Info
Developer | Dolist |
Extension | Dolist_Net |
Version | 2.0.0.0 |
Comparing to | |
See all releases |
Version 2.0.0.0
- app/code/community/Dolist/Net/Block/Adminhtml/Customer/Edit.php +29 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Customerexport.php +54 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Customersegment/Edit.php +29 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Edit.php +21 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Edit/Form.php +18 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tab/Configuration.php +473 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tab/Export.php +100 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tab/Report.php +154 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tabs.php +36 -0
- app/code/community/Dolist/Net/Block/Adminhtml/Report.php +69 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Abstract.php +97 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Date.php +22 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistemt/Templatelist.php +120 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistemt/Templatemapping.php +105 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistemt/Testconnection.php +67 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Attributelist.php +143 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customdatefields.php +121 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customerattributelist.php +131 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customintfields.php +122 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customstrfields.php +122 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Testconnection.php +67 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Enable.php +23 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Switcher.php +58 -0
- app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Templatelist.php +121 -0
- app/code/community/Dolist/Net/Helper/Data.php +806 -0
- app/code/community/Dolist/Net/Helper/Log.php +70 -0
- app/code/community/Dolist/Net/Helper/Queue.php +103 -0
- app/code/community/Dolist/Net/Model/Adminhtml/Observer.php +196 -0
- app/code/community/Dolist/Net/Model/Adminhtml/System/Config/Backend/Serialized/Array.php +119 -0
- app/code/community/Dolist/Net/Model/Adminhtml/System/Config/Source/Timeperiods.php +39 -0
- app/code/community/Dolist/Net/Model/Customersegment.php +13 -0
- app/code/community/Dolist/Net/Model/Dolistemt/Email/Template.php +208 -0
- app/code/community/Dolist/Net/Model/Dolistemt/Message/Queued.php +23 -0
- app/code/community/Dolist/Net/Model/Dolistemt/Template.php +71 -0
- app/code/community/Dolist/Net/Model/Dolistv8/Calculatedfields.php +698 -0
- app/code/community/Dolist/Net/Model/Dolistv8/Customfields.php +110 -0
- app/code/community/Dolist/Net/Model/Dolistv8/Ftp.php +114 -0
- app/code/community/Dolist/Net/Model/Exporter/Adapter/Date.php +14 -0
- app/code/community/Dolist/Net/Model/Exporter/Adapter/Default.php +9 -0
- app/code/community/Dolist/Net/Model/Exporter/Adapter/Int.php +10 -0
- app/code/community/Dolist/Net/Model/Exporter/Csv.php +420 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Message/Queued.php +21 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Message/Queued/Collection.php +21 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Template.php +21 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Template/Collection.php +21 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Calculatedfields.php +44 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Calculatedfields/Collection.php +13 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Customfields.php +14 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Customfields/Collection.php +13 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Abstract.php +69 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Address1.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Address2.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Address3.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/City.php +31 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Company.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Country.php +62 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Default.php +30 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Firstorder.php +94 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastorder.php +95 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastquotenotordered.php +197 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Default.php +24 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Fax.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorder.php +66 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorderline.php +66 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbproductsperorder.php +49 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountexcltax.php +51 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountincltax.php +129 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountexcltax.php +46 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountincltax.php +42 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountexcltax.php +45 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountincltax.php +183 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountexcltax.php +40 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountincltax.php +43 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Nbpromotionrulesused.php +36 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountexcltax.php +50 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountincltax.php +52 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderedproducts.php +48 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorders.php +49 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Phone.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Postcode.php +29 -0
- app/code/community/Dolist/Net/Model/Mysql4/Reports.php +13 -0
- app/code/community/Dolist/Net/Model/Mysql4/Reports/Collection.php +9 -0
- app/code/community/Dolist/Net/Model/Observer.php +289 -0
- app/code/community/Dolist/Net/Model/Reports.php +85 -0
- app/code/community/Dolist/Net/Model/Service.php +1487 -0
- app/code/community/Dolist/Net/Model/Service/Dolistemt/Request/Getauthenticationtoken.php +47 -0
- app/code/community/Dolist/Net/Model/Service/Dolistemt/Request/Gettemplatelist.php +46 -0
- app/code/community/Dolist/Net/Model/Service/Dolistemt/Request/SendEmail.php +39 -0
- app/code/community/Dolist/Net/Model/Service/Dolistemt/Response/Getauthenticationtoken.php +36 -0
- app/code/community/Dolist/Net/Model/Service/Dolistemt/Response/Gettemplatelist.php +13 -0
- app/code/community/Dolist/Net/Model/Service/Dolistemt/Response/SendEmail.php +34 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Createimport.php +58 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Getauthenticationtoken.php +48 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Getcontact.php +46 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Getfieldlist.php +47 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Createimport.php +35 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Getauthenticationtoken.php +34 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Getcontact.php +35 -0
- app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Getfieldlist.php +35 -0
- app/code/community/Dolist/Net/Model/Service/Message/Abstract.php +36 -0
- app/code/community/Dolist/Net/Model/System/Config/Check.php +118 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Dolistemt/Defaulttemplate.php +34 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Dolistemt/Errors.php +34 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Dolistemt/Template.php +39 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Dolistv8/Customerattributelist.php +101 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Dolistv8/Customfield.php +31 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Email/Template.php +25 -0
- app/code/community/Dolist/Net/Model/System/Config/Source/Group.php +21 -0
- app/code/community/Dolist/Net/controllers/Adminhtml/CustomerdolistController.php +557 -0
- app/code/community/Dolist/Net/controllers/Adminhtml/System/Config/TestconnectionController.php +137 -0
- app/code/community/Dolist/Net/etc/adminhtml.xml +43 -0
- app/code/community/Dolist/Net/etc/config.xml +526 -0
- app/code/community/Dolist/Net/etc/system.xml +160 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-install-0.0.1.0.php +274 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.1.0-0.0.1.1.php +28 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.1.1-0.0.2.0.php +33 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.2.0-0.0.3.0.php +50 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.3.0-0.0.4.0.php +34 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.4.0-0.0.5.0.php +36 -0
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.5.0-0.0.6.0.php +23 -0
- app/design/adminhtml/default/default/layout/dolist.xml +24 -0
- app/design/adminhtml/default/default/template/dolist/configuration.phtml +372 -0
- app/design/adminhtml/default/default/template/dolist/customerexport.phtml +33 -0
- app/design/adminhtml/default/default/template/dolist/store/switcher.phtml +21 -0
- app/design/adminhtml/default/default/template/dolist/system/config/dolistemt/testconnection.phtml +65 -0
- app/design/adminhtml/default/default/template/dolist/system/config/dolistv8/array.phtml +146 -0
- app/design/adminhtml/default/default/template/dolist/system/config/dolistv8/testconnection.phtml +65 -0
- app/etc/modules/Dolist_Net.xml +9 -0
- app/locale/fr_FR/Dolist_Net.csv +137 -0
- package.xml +20 -0
app/code/community/Dolist/Net/Block/Adminhtml/Customer/Edit.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 rewrite block to add warning message when customer is loaded in back-office
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_Customer_Edit extends Mage_Adminhtml_Block_Customer_Edit
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Only dispatch event to grab it in adminhtml observer
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
$customerId = $this->getCustomerId();
|
21 |
+
|
22 |
+
Mage::dispatchEvent(
|
23 |
+
'dolist_status_adminhtml_customer_warning',
|
24 |
+
array(
|
25 |
+
'customer_id' => $customerId
|
26 |
+
)
|
27 |
+
);
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Customerexport.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 block to export customers from new Back Office menu
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_Customerexport extends Mage_Adminhtml_Block_Template
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve full export url to Dolist-V8
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public function getFullExportUrl()
|
18 |
+
{
|
19 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
20 |
+
return $this->getUrl('*/*/fullExport', array('store' => $storeId));
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Retrieve differential export url to Dolist-V8
|
25 |
+
*
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public function getDifferentialExportUrl()
|
29 |
+
{
|
30 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
31 |
+
return $this->getUrl('*/*/differentialExport', array('store' => $storeId));
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Retrieve update segments url to Dolist-V8
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getUpdateSegmentsUrl()
|
40 |
+
{
|
41 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
42 |
+
return $this->getUrl('*/*/updateSegments', array('store' => $storeId));
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Check if customer segment can be used, ie if this feature is available for current platform
|
47 |
+
*
|
48 |
+
* @return boolean
|
49 |
+
*/
|
50 |
+
public function showCustomerSegment()
|
51 |
+
{
|
52 |
+
return Mage::helper('dolist')->isCustomerSegmentEnabled();
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Customersegment/Edit.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 rewrite block to add export segment button
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_Customersegment_Edit extends Enterprise_CustomerSegment_Block_Adminhtml_Customersegment_Edit
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Only dispatch event to grab it in adminhtml observer
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
$segment = Mage::registry('current_customer_segment');
|
21 |
+
Mage::dispatchEvent(
|
22 |
+
'dolist_customersegment_export',
|
23 |
+
array(
|
24 |
+
'block' => $this,
|
25 |
+
'segment' => $segment
|
26 |
+
)
|
27 |
+
);
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Edit.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
$this->_blockGroup = 'dolist';
|
8 |
+
$this->_controller = 'adminhtml';
|
9 |
+
|
10 |
+
$this->_updateButton('save', 'label', Mage::helper('dolist')->__('Save'));
|
11 |
+
|
12 |
+
|
13 |
+
$this->removeButton('delete');
|
14 |
+
$this->removeButton('reset');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getHeaderText() {
|
18 |
+
return Mage::helper('dolist')->__('Dolist');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Edit/Form.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
4 |
+
|
5 |
+
protected function _prepareForm() {
|
6 |
+
$form = new Varien_Data_Form(array(
|
7 |
+
'id' => 'edit_form',
|
8 |
+
'action' => $this->getUrl('*/*/save'),
|
9 |
+
'method' => 'post',
|
10 |
+
)
|
11 |
+
);
|
12 |
+
|
13 |
+
$form->setUseContainer(true);
|
14 |
+
$this->setForm($form);
|
15 |
+
return parent::_prepareForm();
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tab/Configuration.php
ADDED
@@ -0,0 +1,473 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Edit_Tab_Configuration extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
4 |
+
{
|
5 |
+
protected $_rows;
|
6 |
+
|
7 |
+
protected $_columnsStr;
|
8 |
+
|
9 |
+
protected $_columnsInt;
|
10 |
+
|
11 |
+
protected $_columnsDate;
|
12 |
+
|
13 |
+
protected function _prepareForm()
|
14 |
+
{
|
15 |
+
$form = new Varien_Data_Form();
|
16 |
+
$this->setForm($form);
|
17 |
+
|
18 |
+
$form->setHtmlIdPrefix('dolist_conf_');
|
19 |
+
$options = array();
|
20 |
+
|
21 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
22 |
+
|
23 |
+
$fieldset = $form->addFieldset('data_dolist_form_config_v8', array(
|
24 |
+
'legend' => Mage::helper('dolist')->__('Configuration')
|
25 |
+
));
|
26 |
+
|
27 |
+
$fieldset->addField('store_id', 'hidden', array(
|
28 |
+
'name' => 'store_id',
|
29 |
+
'value' => $storeId
|
30 |
+
));
|
31 |
+
|
32 |
+
$fieldset->addField('export_customer_with_order', 'select', array_merge($options, array(
|
33 |
+
'name' => 'export_customer_with_order',
|
34 |
+
'label' => Mage::helper('dolist')->__('Export non subscribed customer with existing order'),
|
35 |
+
'class' => '',
|
36 |
+
'required' => false,
|
37 |
+
'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
|
38 |
+
)));
|
39 |
+
|
40 |
+
$fieldset->addField('calculatedfieds_mode', 'select', array_merge($options, array(
|
41 |
+
'name' => 'calculatedfieds_mode',
|
42 |
+
'label' => Mage::helper('dolist')->__('Time period for calculated fields'),
|
43 |
+
'class' => '',
|
44 |
+
'required' => false,
|
45 |
+
'values' => Mage::getModel('dolist/adminhtml_system_config_source_timeperiods')->toOptionArray(),
|
46 |
+
)));
|
47 |
+
|
48 |
+
$fieldset->addField('calculatedfieds_date', 'date', array_merge($options, array(
|
49 |
+
'name' => 'calculatedfieds_date',
|
50 |
+
'label' => Mage::helper('dolist')->__('Start date for calculated fields'),
|
51 |
+
'class' => '',
|
52 |
+
'required' => false,
|
53 |
+
'format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
54 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif')
|
55 |
+
)));
|
56 |
+
|
57 |
+
$fieldset = $form->addFieldset('data_dolist_form_config_custom_fields', array(
|
58 |
+
'legend' => Mage::helper('dolist')->__('Custom Fields')
|
59 |
+
));
|
60 |
+
|
61 |
+
$btnSync = $fieldset->addField('btnSyncCustomFields', 'button', array(
|
62 |
+
'name' => 'btnSyncCustomFields',
|
63 |
+
'value' => Mage::helper('dolist')->__('Synchronize Custom Fields'),
|
64 |
+
//'style' => 'color:white;height:50px', //just an example
|
65 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/updateCustomFields', array('store' => $storeId)) . '\')',
|
66 |
+
'type' => 'button',
|
67 |
+
));
|
68 |
+
$btnSync->setAfterElementHtml('
|
69 |
+
<script type="text/javascript">
|
70 |
+
document.getElementById("dolist_conf_btnSyncCustomFields").value = \'' . Mage::helper('dolist')->__('Synchronize Custom Fields') . '\';
|
71 |
+
</script>');
|
72 |
+
|
73 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $customFieldsCollection */
|
74 |
+
$customFieldsCollection = Mage::getModel('dolist/dolistv8_customfields')
|
75 |
+
->getCollection()
|
76 |
+
->addFieldToFilter('scope_id', $storeId)
|
77 |
+
;
|
78 |
+
|
79 |
+
foreach ($customFieldsCollection as $customField) {
|
80 |
+
|
81 |
+
if ($customField->name == 'email') {
|
82 |
+
continue;
|
83 |
+
}
|
84 |
+
|
85 |
+
if (array_key_exists($customField->name, Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
86 |
+
|
87 |
+
$fieldset->addField(sprintf('cstfield_%s', Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName[$customField->name]), 'select', array_merge($options, array(
|
88 |
+
'name' => sprintf('cstfield_%s', Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName[$customField->name]),
|
89 |
+
'label' => $customField->title,
|
90 |
+
'class' => '',
|
91 |
+
'required' => false,
|
92 |
+
'values' => Mage::getModel('adminhtml/system_config_source_enabledisable')->toOptionArray(),
|
93 |
+
)));
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->_columnsStr = array();
|
99 |
+
|
100 |
+
$this->_columnsStr['magento_customer_attribute'] = array(
|
101 |
+
'label' => Mage::helper('dolist')->__('Magento customer attribute'),
|
102 |
+
'renderer' => $this->_getMagentoCustomerAttributeStrRenderer()
|
103 |
+
);
|
104 |
+
|
105 |
+
$this->_columnsStr['dolist_custom_fields'] = array(
|
106 |
+
'label' => Mage::helper('dolist')->__('Dolist-V8 attribute name'),
|
107 |
+
'renderer' => $this->_getDolistv8AttributeStrRenderer()
|
108 |
+
);
|
109 |
+
|
110 |
+
$this->_columnsInt = array();
|
111 |
+
|
112 |
+
$this->_columnsInt['magento_customer_attribute'] = array(
|
113 |
+
'label' => Mage::helper('dolist')->__('Magento customer attribute'),
|
114 |
+
'renderer' => $this->_getMagentoCustomerAttributeIntRenderer()
|
115 |
+
);
|
116 |
+
|
117 |
+
$this->_columnsInt['dolist_custom_fields'] = array(
|
118 |
+
'label' => Mage::helper('dolist')->__('Dolist-V8 attribute name'),
|
119 |
+
'renderer' => $this->_getDolistv8AttributeIntRenderer()
|
120 |
+
);
|
121 |
+
|
122 |
+
$this->_columnsDate = array();
|
123 |
+
|
124 |
+
$this->_columnsDate['magento_customer_attribute'] = array(
|
125 |
+
'label' => Mage::helper('dolist')->__('Magento customer attribute'),
|
126 |
+
'renderer' => $this->_getMagentoCustomerAttributeDateRenderer()
|
127 |
+
);
|
128 |
+
|
129 |
+
$this->_columnsDate['dolist_custom_fields'] = array(
|
130 |
+
'label' => Mage::helper('dolist')->__('Dolist-V8 attribute name'),
|
131 |
+
'renderer' => $this->_getDolistv8AttributeDateRenderer()
|
132 |
+
);
|
133 |
+
|
134 |
+
$values = array();
|
135 |
+
|
136 |
+
foreach ($customFieldsCollection as $customField) {
|
137 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
138 |
+
|
139 |
+
if (!$customField->getData('magento_field')) {
|
140 |
+
continue;
|
141 |
+
}
|
142 |
+
|
143 |
+
if (array_key_exists($customField->getData('name'), Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
144 |
+
$values[sprintf('cstfield_%s', $customField->getData('magento_field'))] = 1;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
$values['export_customer_with_order'] = Mage::getStoreConfig('dolist/dolist_v8/export_customer_with_order');
|
149 |
+
$values['calculatedfieds_mode'] = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode');
|
150 |
+
$values['calculatedfieds_date'] = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_date');
|
151 |
+
$values['store_id'] = $storeId;
|
152 |
+
|
153 |
+
$form->setValues($values);
|
154 |
+
|
155 |
+
return parent::_prepareForm();
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Return Tab label
|
162 |
+
*
|
163 |
+
* @return string
|
164 |
+
*/
|
165 |
+
public function getTabLabel()
|
166 |
+
{
|
167 |
+
return Mage::helper('dolist')->__('Configuration');
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Return Tab title
|
172 |
+
*
|
173 |
+
* @return string
|
174 |
+
*/
|
175 |
+
public function getTabTitle()
|
176 |
+
{
|
177 |
+
return Mage::helper('dolist')->__('Configuration');
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Can show tab in tabs
|
182 |
+
*
|
183 |
+
* @return boolean
|
184 |
+
*/
|
185 |
+
public function canShowTab()
|
186 |
+
{
|
187 |
+
return true;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Tab is hidden
|
192 |
+
*
|
193 |
+
* @return boolean
|
194 |
+
*/
|
195 |
+
public function isHidden()
|
196 |
+
{
|
197 |
+
return false;
|
198 |
+
}
|
199 |
+
|
200 |
+
public function getMappingRowsString()
|
201 |
+
{
|
202 |
+
$result = array();
|
203 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
204 |
+
|
205 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
206 |
+
$collection = Mage::getModel('dolist/dolistv8_customfields')
|
207 |
+
->getCollection()
|
208 |
+
->addFieldToFilter('scope_id', $storeId)
|
209 |
+
;
|
210 |
+
|
211 |
+
foreach ($collection as $customField) {
|
212 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
213 |
+
|
214 |
+
if (!$customField->getData('magento_field')) {
|
215 |
+
continue;
|
216 |
+
}
|
217 |
+
|
218 |
+
if($customField->getData('name') == 'email') {
|
219 |
+
continue;
|
220 |
+
}
|
221 |
+
|
222 |
+
if (array_key_exists($customField->getData('name'), Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
223 |
+
continue;
|
224 |
+
}
|
225 |
+
|
226 |
+
if($customField->getData('type') != 'Varchar') {
|
227 |
+
continue;
|
228 |
+
}
|
229 |
+
|
230 |
+
$row = new Varien_Object();
|
231 |
+
$row->setData('_id', count($result));
|
232 |
+
$row->setData('option_extra_attr_' . $customField->getData('magento_field'), 'selected="selected"');
|
233 |
+
$row->setData('option_extra_attr_' . $customField->getData('name'), 'selected="selected"');
|
234 |
+
|
235 |
+
$result[] = $row;
|
236 |
+
}
|
237 |
+
|
238 |
+
return $result;
|
239 |
+
}
|
240 |
+
|
241 |
+
public function getMappingRowsInt()
|
242 |
+
{
|
243 |
+
$result = array();
|
244 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
245 |
+
|
246 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
247 |
+
$collection = Mage::getModel('dolist/dolistv8_customfields')
|
248 |
+
->getCollection()
|
249 |
+
->addFieldToFilter('scope_id', $storeId)
|
250 |
+
;
|
251 |
+
|
252 |
+
foreach ($collection as $customField) {
|
253 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
254 |
+
|
255 |
+
if (!$customField->getData('magento_field')) {
|
256 |
+
continue;
|
257 |
+
}
|
258 |
+
|
259 |
+
if (array_key_exists($customField->getData('name'), Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
260 |
+
continue;
|
261 |
+
}
|
262 |
+
|
263 |
+
if($customField->getData('type') != 'Integer') {
|
264 |
+
continue;
|
265 |
+
}
|
266 |
+
|
267 |
+
$row = new Varien_Object();
|
268 |
+
$row->setData('_id', count($result));
|
269 |
+
$row->setData('option_extra_attr_' . $customField->getData('magento_field'), 'selected="selected"');
|
270 |
+
$row->setData('option_extra_attr_' . $customField->getData('name'), 'selected="selected"');
|
271 |
+
|
272 |
+
$result[] = $row;
|
273 |
+
}
|
274 |
+
|
275 |
+
return $result;
|
276 |
+
}
|
277 |
+
|
278 |
+
public function getMappingRowsDate()
|
279 |
+
{
|
280 |
+
$result = array();
|
281 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
282 |
+
|
283 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
284 |
+
$collection = Mage::getModel('dolist/dolistv8_customfields')
|
285 |
+
->getCollection()
|
286 |
+
->addFieldToFilter('scope_id', $storeId)
|
287 |
+
;
|
288 |
+
|
289 |
+
foreach ($collection as $customField) {
|
290 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
291 |
+
|
292 |
+
if (!$customField->getData('magento_field')) {
|
293 |
+
continue;
|
294 |
+
}
|
295 |
+
|
296 |
+
if (array_key_exists($customField->getData('name'), Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
297 |
+
continue;
|
298 |
+
}
|
299 |
+
|
300 |
+
if($customField->getData('type') != 'Datetime') {
|
301 |
+
continue;
|
302 |
+
}
|
303 |
+
|
304 |
+
$row = new Varien_Object();
|
305 |
+
$row->setData('_id', count($result));
|
306 |
+
$row->setData('option_extra_attr_' . $customField->getData('magento_field'), 'selected="selected"');
|
307 |
+
$row->setData('option_extra_attr_' . $customField->getData('name'), 'selected="selected"');
|
308 |
+
|
309 |
+
$result[] = $row;
|
310 |
+
}
|
311 |
+
|
312 |
+
return $result;
|
313 |
+
}
|
314 |
+
|
315 |
+
protected function _renderCellTemplateStr($columnName)
|
316 |
+
{
|
317 |
+
if (empty($this->_columnsStr[$columnName])) {
|
318 |
+
throw new Exception('Wrong column name specified.');
|
319 |
+
}
|
320 |
+
|
321 |
+
$column = $this->_columnsStr[$columnName];
|
322 |
+
$inputName = 'cstfieldStr[#{_id}][' . $columnName . ']';
|
323 |
+
|
324 |
+
if ($column['renderer']) {
|
325 |
+
return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)->toHtml();
|
326 |
+
}
|
327 |
+
|
328 |
+
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
|
329 |
+
($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
|
330 |
+
(isset($column['class']) ? $column['class'] : 'input-text') . '"'.
|
331 |
+
(isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '/>';
|
332 |
+
}
|
333 |
+
|
334 |
+
protected function _renderCellTemplateInt($columnName)
|
335 |
+
{
|
336 |
+
if (empty($this->_columnsInt[$columnName])) {
|
337 |
+
throw new Exception('Wrong column name specified.');
|
338 |
+
}
|
339 |
+
|
340 |
+
$column = $this->_columnsInt[$columnName];
|
341 |
+
$inputName = 'cstfieldInt[#{_id}][' . $columnName . ']';
|
342 |
+
|
343 |
+
if ($column['renderer']) {
|
344 |
+
return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)->toHtml();
|
345 |
+
}
|
346 |
+
|
347 |
+
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
|
348 |
+
($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
|
349 |
+
(isset($column['class']) ? $column['class'] : 'input-text') . '"'.
|
350 |
+
(isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '/>';
|
351 |
+
}
|
352 |
+
|
353 |
+
protected function _renderCellTemplateDate($columnName)
|
354 |
+
{
|
355 |
+
if (empty($this->_columnsDate[$columnName])) {
|
356 |
+
throw new Exception('Wrong column name specified.');
|
357 |
+
}
|
358 |
+
|
359 |
+
$column = $this->_columnsDate[$columnName];
|
360 |
+
$inputName = 'cstfieldDate[#{_id}][' . $columnName . ']';
|
361 |
+
|
362 |
+
if ($column['renderer']) {
|
363 |
+
return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)->toHtml();
|
364 |
+
}
|
365 |
+
|
366 |
+
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
|
367 |
+
($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
|
368 |
+
(isset($column['class']) ? $column['class'] : 'input-text') . '"'.
|
369 |
+
(isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '/>';
|
370 |
+
}
|
371 |
+
|
372 |
+
protected function _getMagentoCustomerAttributeStrRenderer()
|
373 |
+
{
|
374 |
+
if (!$this->_magentoCustomerAttributeRendererStr) {
|
375 |
+
$this->_magentoCustomerAttributeRendererStr = $this->getLayout()->createBlock(
|
376 |
+
'dolist/adminhtml_system_config_dolistv8_customerattributelist',
|
377 |
+
'',
|
378 |
+
array(
|
379 |
+
'is_render_to_js_template' => true,
|
380 |
+
'backend_type' => array('static', 'varchar', 'text')
|
381 |
+
)
|
382 |
+
);
|
383 |
+
|
384 |
+
$this->_magentoCustomerAttributeRendererStr->setExtraParams('style="width:100%;"');
|
385 |
+
}
|
386 |
+
return $this->_magentoCustomerAttributeRendererStr;
|
387 |
+
}
|
388 |
+
|
389 |
+
protected function _getDolistv8AttributeStrRenderer()
|
390 |
+
{
|
391 |
+
if (!$this->_dolistv8AttributeRendererStr) {
|
392 |
+
$this->_dolistv8AttributeRendererStr = $this->getLayout()->createBlock(
|
393 |
+
'dolist/adminhtml_system_config_dolistv8_attributelist',
|
394 |
+
'',
|
395 |
+
array(
|
396 |
+
'is_render_to_js_template' => true,
|
397 |
+
'custom_field_type' => 'Varchar')
|
398 |
+
);
|
399 |
+
|
400 |
+
$this->_dolistv8AttributeRendererStr->setClass('dolistv8_custom_str_fields_select');
|
401 |
+
$this->_dolistv8AttributeRendererStr->setExtraParams('style="width:100%;"');
|
402 |
+
}
|
403 |
+
return $this->_dolistv8AttributeRendererStr;
|
404 |
+
}
|
405 |
+
|
406 |
+
protected function _getMagentoCustomerAttributeIntRenderer()
|
407 |
+
{
|
408 |
+
if (!$this->_magentoCustomerAttributeRendererInt) {
|
409 |
+
$this->_magentoCustomerAttributeRendererInt = $this->getLayout()->createBlock(
|
410 |
+
'dolist/adminhtml_system_config_dolistv8_customerattributelist',
|
411 |
+
'',
|
412 |
+
array(
|
413 |
+
'is_render_to_js_template' => true,
|
414 |
+
'backend_type' => array('int')
|
415 |
+
)
|
416 |
+
);
|
417 |
+
|
418 |
+
$this->_magentoCustomerAttributeRendererInt->setExtraParams('style="width:100%;"');
|
419 |
+
}
|
420 |
+
return $this->_magentoCustomerAttributeRendererInt;
|
421 |
+
}
|
422 |
+
|
423 |
+
protected function _getDolistv8AttributeIntRenderer()
|
424 |
+
{
|
425 |
+
if (!$this->_dolistv8AttributeRendererInt) {
|
426 |
+
$this->_dolistv8AttributeRendererInt = $this->getLayout()->createBlock(
|
427 |
+
'dolist/adminhtml_system_config_dolistv8_attributelist',
|
428 |
+
'',
|
429 |
+
array(
|
430 |
+
'is_render_to_js_template' => true,
|
431 |
+
'custom_field_type' => 'Integer')
|
432 |
+
);
|
433 |
+
|
434 |
+
$this->_dolistv8AttributeRendererInt->setClass('dolistv8_custom_int_fields_select');
|
435 |
+
$this->_dolistv8AttributeRendererInt->setExtraParams('style="width:100%;"');
|
436 |
+
}
|
437 |
+
return $this->_dolistv8AttributeRendererInt;
|
438 |
+
}
|
439 |
+
|
440 |
+
protected function _getMagentoCustomerAttributeDateRenderer()
|
441 |
+
{
|
442 |
+
if (!$this->_magentoCustomerAttributeRendererDate) {
|
443 |
+
$this->_magentoCustomerAttributeRendererDate = $this->getLayout()->createBlock(
|
444 |
+
'dolist/adminhtml_system_config_dolistv8_customerattributelist',
|
445 |
+
'',
|
446 |
+
array(
|
447 |
+
'is_render_to_js_template' => true,
|
448 |
+
'backend_type' => array('datetime')
|
449 |
+
)
|
450 |
+
);
|
451 |
+
|
452 |
+
$this->_magentoCustomerAttributeRendererDate->setExtraParams('style="width:100%;"');
|
453 |
+
}
|
454 |
+
return $this->_magentoCustomerAttributeRendererDate;
|
455 |
+
}
|
456 |
+
|
457 |
+
protected function _getDolistv8AttributeDateRenderer()
|
458 |
+
{
|
459 |
+
if (!$this->_dolistv8AttributeRendererDate) {
|
460 |
+
$this->_dolistv8AttributeRendererDate = $this->getLayout()->createBlock(
|
461 |
+
'dolist/adminhtml_system_config_dolistv8_attributelist',
|
462 |
+
'',
|
463 |
+
array(
|
464 |
+
'is_render_to_js_template' => true,
|
465 |
+
'custom_field_type' => 'Datetime')
|
466 |
+
);
|
467 |
+
|
468 |
+
$this->_dolistv8AttributeRendererDate->setClass('dolistv8_custom_date_fields_select');
|
469 |
+
$this->_dolistv8AttributeRendererDate->setExtraParams('style="width:100%;"');
|
470 |
+
}
|
471 |
+
return $this->_dolistv8AttributeRendererDate;
|
472 |
+
}
|
473 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tab/Export.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Edit_Tab_Export extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Return Tab label
|
7 |
+
*
|
8 |
+
* @return string
|
9 |
+
*/
|
10 |
+
public function getTabLabel()
|
11 |
+
{
|
12 |
+
return 'Export';
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Return Tab title
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getTabTitle()
|
21 |
+
{
|
22 |
+
return 'Export';
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Can show tab in tabs
|
27 |
+
*
|
28 |
+
* @return boolean
|
29 |
+
*/
|
30 |
+
public function canShowTab()
|
31 |
+
{
|
32 |
+
return true;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Tab is hidden
|
37 |
+
*
|
38 |
+
* @return boolean
|
39 |
+
*/
|
40 |
+
public function isHidden()
|
41 |
+
{
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrieve full export url to Dolist-V8
|
47 |
+
*
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getFullExportUrl()
|
51 |
+
{
|
52 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
53 |
+
return $this->getUrl('*/*/fullExport', array('store' => $storeId));
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Retrieve differential export url to Dolist-V8
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function getDifferentialExportUrl()
|
62 |
+
{
|
63 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
64 |
+
return $this->getUrl('*/*/differentialExport', array('store' => $storeId));
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Retrieve update segments url to Dolist-V8
|
69 |
+
*
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getUpdateSegmentsUrl()
|
73 |
+
{
|
74 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
75 |
+
return $this->getUrl('*/*/updateSegments', array('store' => $storeId));
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Retrieve update segments url to Dolist-V8
|
80 |
+
*
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function getUpdateCustomerFieldsUrl()
|
84 |
+
{
|
85 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
86 |
+
return $this->getUrl('*/*/updateCustomFields', array('store' => $storeId));
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check if customer segment can be used, ie if this feature is available for current platform
|
91 |
+
*
|
92 |
+
* @return boolean
|
93 |
+
*/
|
94 |
+
public function showCustomerSegment()
|
95 |
+
{
|
96 |
+
return Mage::helper('dolist')->isCustomerSegmentEnabled();
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tab/Report.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Edit_Tab_Report extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Set grid params
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('dolist_report_grid');
|
14 |
+
$this->setDefaultSort('created_at');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getMainButtonsHtml()
|
18 |
+
{
|
19 |
+
return '';
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Prepare collection
|
24 |
+
*
|
25 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
26 |
+
*/
|
27 |
+
protected function _prepareCollection()
|
28 |
+
{
|
29 |
+
/** @var Dolist_Net_Model_Mysql4_Reports_Collection $collection */
|
30 |
+
$collection = Mage::getModel('dolist/reports')->getCollection();
|
31 |
+
$collection->setOrder('id');
|
32 |
+
|
33 |
+
$this->setCollection($collection);
|
34 |
+
|
35 |
+
return parent::_prepareCollection();
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Add columns to grid
|
40 |
+
*
|
41 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
42 |
+
*/
|
43 |
+
protected function _prepareColumns()
|
44 |
+
{
|
45 |
+
$this->addColumn('started_at', array(
|
46 |
+
'header' => Mage::helper('catalog')->__('Started At'),
|
47 |
+
'index' => 'started_at',
|
48 |
+
'width' => '220',
|
49 |
+
'align' => 'center',
|
50 |
+
'filter' => false,
|
51 |
+
'frame_callback' => array($this, 'decorateDate')
|
52 |
+
));
|
53 |
+
|
54 |
+
$this->addColumn('ended_at', array(
|
55 |
+
'header' => Mage::helper('catalog')->__('Ended At'),
|
56 |
+
'index' => 'ended_at',
|
57 |
+
'width' => '220',
|
58 |
+
'align' => 'center',
|
59 |
+
'filter' => false,
|
60 |
+
'frame_callback' => array($this, 'decorateDate')
|
61 |
+
));
|
62 |
+
|
63 |
+
$this->addColumn('type', array(
|
64 |
+
'header' => $this->__('Type'),
|
65 |
+
'align' => 'center',
|
66 |
+
'index' => 'type',
|
67 |
+
'width' => '220',
|
68 |
+
'filter' => false,
|
69 |
+
'frame_callback' => array($this, 'decorateType')
|
70 |
+
));
|
71 |
+
|
72 |
+
$this->addColumn('name', array(
|
73 |
+
'header' => $this->__('Title'),
|
74 |
+
'align' => 'left',
|
75 |
+
'index' => 'name',
|
76 |
+
'filter' => false,
|
77 |
+
));
|
78 |
+
|
79 |
+
$this->addColumn('progress', array(
|
80 |
+
'header' => $this->__('Status'),
|
81 |
+
'width' => '120',
|
82 |
+
'align' => 'center',
|
83 |
+
'filter' => false,
|
84 |
+
'frame_callback' => array($this, 'decorateProgress')
|
85 |
+
));
|
86 |
+
}
|
87 |
+
|
88 |
+
public function decorateDate($value, $row, $column, $isExport)
|
89 |
+
{
|
90 |
+
/** @var Mage_Core_Helper_Data $coreHelper */
|
91 |
+
$coreHelper = Mage::helper('core');
|
92 |
+
if (!$value) {
|
93 |
+
return ' - ';
|
94 |
+
} else {
|
95 |
+
return $coreHelper->formatDate($value, 'medium', 'medium');
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
public function decorateType($value, $row, $column, $isExport)
|
100 |
+
{
|
101 |
+
switch ($value) {
|
102 |
+
case 'export':
|
103 |
+
return Mage::helper('dolist')->__('Export');
|
104 |
+
default:
|
105 |
+
return $value;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
public function decorateProgress($value, $row, $column, $isExport)
|
110 |
+
{
|
111 |
+
/** @var Dolist_Net_Model_Reports $row */
|
112 |
+
|
113 |
+
if (!$row->getData('started_at') && ! $row->getData('ended_at')) {
|
114 |
+
return '<span class="grid-severity-minor"><span>' . Mage::helper('dolist')->__('Initializing') . '</span></span>';
|
115 |
+
}
|
116 |
+
|
117 |
+
if ($row->getData('ended_at')) {
|
118 |
+
if($row->getData('result') == 'success') {
|
119 |
+
return '<span class="grid-severity-notice"><span>' . Mage::helper('dolist')->__('Completed') . '</span></span>';
|
120 |
+
}
|
121 |
+
else {
|
122 |
+
return '<span class="grid-severity-critical"><span>' . Mage::helper('dolist')->__('Completed with error') . '</span></span>';
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
$progressEnd = $row->getData('progress_end');
|
126 |
+
|
127 |
+
if (is_numeric($progressEnd)) {
|
128 |
+
$progressCurrent = $row->getData('progress_current');
|
129 |
+
|
130 |
+
if ($progressCurrent == 0) {
|
131 |
+
return '<span class="grid-severity-major"><span>' . Mage::helper('dolist')->__('Starting') . '</span></span>';
|
132 |
+
} else {
|
133 |
+
return '<span class="grid-severity-major"><span>' . Mage::helper('dolist')->__('Working') . ' ' . floor(($progressCurrent / $progressEnd) * 100) . '%</span></span>';
|
134 |
+
}
|
135 |
+
|
136 |
+
} else {
|
137 |
+
return '<span class="grid-severity-major"><span>' . Mage::helper('dolist')->__('Working') . '</span></span>';
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get row edit url
|
145 |
+
*
|
146 |
+
* @param $row
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function getRowUrl($row)
|
150 |
+
{
|
151 |
+
return $this->getUrl('*/*/report', array('id' => $row->getId()));
|
152 |
+
}
|
153 |
+
|
154 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Edit/Tabs.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('dolist_tabs');
|
8 |
+
$this->setDestElementId('edit_form');
|
9 |
+
$this->setTitle(Mage::helper('dolist')->__('Dolist'));
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _beforeToHtml() {
|
13 |
+
|
14 |
+
|
15 |
+
$this->addTab('dolist_tab_report', array(
|
16 |
+
'label' => Mage::helper('dolist')->__('Report'),
|
17 |
+
'title' => Mage::helper('dolist')->__('Report'),
|
18 |
+
'content' => $this->getLayout()->createBlock('dolist/adminhtml_edit_tab_report')->toHtml(),
|
19 |
+
));
|
20 |
+
|
21 |
+
$this->_updateActiveTab();
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _updateActiveTab()
|
26 |
+
{
|
27 |
+
$tabId = $this->getRequest()->getParam('tab');
|
28 |
+
if( $tabId ) {
|
29 |
+
$tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
|
30 |
+
if($tabId) {
|
31 |
+
$this->setActiveTab($tabId);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/Report.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_Report extends Mage_Adminhtml_Block_Widget_Container
|
4 |
+
{
|
5 |
+
private $model;
|
6 |
+
|
7 |
+
protected function _afterToHtml($html)
|
8 |
+
{
|
9 |
+
/** @var Mage_Core_Helper_Data $coreHelper */
|
10 |
+
$coreHelper = Mage::helper('core');
|
11 |
+
$progressCurrent = $this->getReport()->getData('progress_current');
|
12 |
+
$progressEnd = $this->getReport()->getData('progress_end');
|
13 |
+
|
14 |
+
return '
|
15 |
+
<div class="content-header">
|
16 |
+
<p class="form-buttons"><button title="Back" type="button" class="scalable back" onclick="setLocation(\'' . Mage::helper('adminhtml')->getUrl('*/*/') . '\')" style=""><span><span><span>Back</span></span></span></button></p>
|
17 |
+
</div>
|
18 |
+
<div class="entry-edit">
|
19 |
+
<div class="entry-edit-head"><h4 class="icon-head head-customer-view">' . Mage::helper('dolist')->__('Report Information') . '</h4></div>
|
20 |
+
<fieldset>
|
21 |
+
<table cellspacing="2" class="box-left">
|
22 |
+
<tbody>
|
23 |
+
<tr>
|
24 |
+
<td><strong>' . Mage::helper('dolist')->__('Type:') . '</strong></td>
|
25 |
+
<td>' . Mage::helper('dolist')->__($this->getReport()->getData('type')) . '</td>
|
26 |
+
</tr>
|
27 |
+
<tr>
|
28 |
+
<td><strong>' . Mage::helper('dolist')->__('Name:') . '</strong></td>
|
29 |
+
<td>' . $this->getReport()->getData('name') . '</td>
|
30 |
+
</tr>
|
31 |
+
<tr>
|
32 |
+
<td><strong>' . Mage::helper('dolist')->__('Started At:') . '</strong></td>
|
33 |
+
<td>' . ($this->getReport()->getData('started_at') ? $coreHelper->formatDate($this->getReport()->getData('started_at'), 'medium', 'medium') : ' - ') . '</td>
|
34 |
+
</tr>
|
35 |
+
<tr>
|
36 |
+
<td><strong>' . Mage::helper('dolist')->__('Ended At:') . '</strong></td>
|
37 |
+
<td>' . ($this->getReport()->getData('ended_at') ? $coreHelper->formatDate($this->getReport()->getData('ended_at'), 'medium', 'medium') : ' - ') . '</td>
|
38 |
+
</tr>
|
39 |
+
<tr>
|
40 |
+
<td><strong>' . Mage::helper('dolist')->__('Result:') . '</strong></td>
|
41 |
+
<td>' . $this->getReport()->getData('result') . ' </td>
|
42 |
+
</tr>
|
43 |
+
<tr>
|
44 |
+
<td><strong>' . Mage::helper('dolist')->__('Progression:') . '</strong></td>
|
45 |
+
<td>' . ($progressEnd != 0 ? (floor(($progressCurrent / $progressEnd) * 100)) : '-') . '% (' . ($progressCurrent ? $progressCurrent : '-') . '/' . ($progressEnd ? $progressEnd : '-') . ') </td>
|
46 |
+
</tr>
|
47 |
+
</tbody>
|
48 |
+
</table>
|
49 |
+
</fieldset>
|
50 |
+
</div>
|
51 |
+
<h4>Logs</h4>
|
52 |
+
<pre>' . $this->getReport()->getData('logs') . '</pre>';
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @return Dolist_Net_Model_Reports
|
57 |
+
*/
|
58 |
+
protected function getReport()
|
59 |
+
{
|
60 |
+
if (!$this->model) {
|
61 |
+
$this->model = Mage::getModel('dolist/reports');
|
62 |
+
if ($this->getRequest()->getParam('id')) {
|
63 |
+
$this->model = $this->model->load($this->getRequest()->getParam('id'));
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
return $this->model;
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Abstract.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist abstract block to back-office fields
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Indication whether block is prepared to render or no
|
14 |
+
*
|
15 |
+
* @var bool
|
16 |
+
*/
|
17 |
+
protected $_isPreparedToRender = false;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Check if columns are defined, set template
|
21 |
+
* Compatibility with old versions
|
22 |
+
*
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function __construct()
|
26 |
+
{
|
27 |
+
if (!$this->_addButtonLabel) {
|
28 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add');
|
29 |
+
}
|
30 |
+
if (!$this->getTemplate()) {
|
31 |
+
$this->setTemplate('system/config/form/field/array.phtml');
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Render block HTML
|
37 |
+
* Compatibility with old versions
|
38 |
+
*
|
39 |
+
* @return string Html content
|
40 |
+
* @throws Exception
|
41 |
+
*/
|
42 |
+
protected function _toHtml()
|
43 |
+
{
|
44 |
+
if (!$this->_isPreparedToRender) {
|
45 |
+
$this->_prepareToRender();
|
46 |
+
$this->_isPreparedToRender = true;
|
47 |
+
}
|
48 |
+
if (empty($this->_columns)) {
|
49 |
+
throw new Exception('At least one column must be defined.');
|
50 |
+
}
|
51 |
+
return parent::_toHtml();
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Obtain existing data from form element
|
56 |
+
* Each row will be instance of Varien_Object
|
57 |
+
* Compatibility with old versions
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function getArrayRows()
|
62 |
+
{
|
63 |
+
if (null !== $this->_arrayRowsCache) {
|
64 |
+
return $this->_arrayRowsCache;
|
65 |
+
}
|
66 |
+
$result = array();
|
67 |
+
/** @var Varien_Data_Form_Element_Abstract */
|
68 |
+
$element = $this->getElement();
|
69 |
+
if ($element->getValue() && is_array($element->getValue())) {
|
70 |
+
foreach ($element->getValue() as $rowId => $row) {
|
71 |
+
foreach ($row as $key => $value) {
|
72 |
+
$row[$key] = $this->htmlEscape($value);
|
73 |
+
}
|
74 |
+
$row['_id'] = $rowId;
|
75 |
+
$result[$rowId] = new Varien_Object($row);
|
76 |
+
$this->_prepareArrayRow($result[$rowId]);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
$this->_arrayRowsCache = $result;
|
80 |
+
return $this->_arrayRowsCache;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Calculate option hash
|
85 |
+
* Compatibility with old versions
|
86 |
+
*
|
87 |
+
* @param string $optionValue Option value
|
88 |
+
* @param Mage_Core_Block_Abstract $block Block
|
89 |
+
*
|
90 |
+
* @return string
|
91 |
+
* @see Mage_Core_Block_Html_Select
|
92 |
+
*/
|
93 |
+
public function calcOptionHash($optionValue, $block)
|
94 |
+
{
|
95 |
+
return sprintf('%u', crc32($block->getName() . $block->getId() . $optionValue));
|
96 |
+
}
|
97 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Date.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Date extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
6 |
+
{
|
7 |
+
$date = new Varien_Data_Form_Element_Date();
|
8 |
+
$format = Varien_Date::DATE_INTERNAL_FORMAT;
|
9 |
+
|
10 |
+
$data = array(
|
11 |
+
'name' => $element->getName(),
|
12 |
+
'html_id' => $element->getId(),
|
13 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
14 |
+
);
|
15 |
+
$date->setData($data);
|
16 |
+
$date->setValue($element->getValue(), $format);
|
17 |
+
$date->setFormat($format);
|
18 |
+
$date->setForm($element->getForm());
|
19 |
+
|
20 |
+
return $date->getElementHtml();
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistemt/Templatelist.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to test connection and retrieve Dolist-EMT template list
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistemt_Templatelist extends Mage_Core_Block_Html_Select
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Template list cache
|
14 |
+
*
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
private $_dolistemtTemplateList;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Retrieve template list (original and custom ones)
|
21 |
+
*
|
22 |
+
* @return array|string Template list
|
23 |
+
*/
|
24 |
+
protected function _getTemplateList()
|
25 |
+
{
|
26 |
+
if (is_null($this->_dolistemtTemplateList)) {
|
27 |
+
$this->_dolistemtTemplateList = array();
|
28 |
+
|
29 |
+
$collection = Mage::getModel('dolist/system_config_source_dolistemt_template')->toOptionArray();
|
30 |
+
foreach ($collection as $id => $item) {
|
31 |
+
$this->_dolistemtTemplateList[$id] = $item;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return $this->_dolistemtTemplateList;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Set form input name. Mandatory to submit form then store values
|
39 |
+
*
|
40 |
+
* @param string $value Form input name
|
41 |
+
*
|
42 |
+
* @return Dolist_Net_Block_Adminhtml_System_Config_Templatelist
|
43 |
+
*/
|
44 |
+
public function setInputName($value)
|
45 |
+
{
|
46 |
+
return $this->setName($value);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Render block HTML
|
51 |
+
*
|
52 |
+
* @return string HTML
|
53 |
+
*/
|
54 |
+
protected function _toHtml()
|
55 |
+
{
|
56 |
+
if (!$this->getOptions()) {
|
57 |
+
foreach ($this->_getTemplateList() as $id => $template) {
|
58 |
+
$value = $template['value'];
|
59 |
+
$label = $template['label'];
|
60 |
+
// Allow empty first line but remove 'locale default model'
|
61 |
+
if ($value != '' || $label == '') {
|
62 |
+
$this->addOption($value, addslashes($label));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
return parent::_toHtml();
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Return option HTML node
|
71 |
+
* Compatibility with old versions
|
72 |
+
*
|
73 |
+
* @param array $option Option
|
74 |
+
* @param boolean $selected Selected
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
protected function _optionToHtml($option, $selected = false)
|
79 |
+
{
|
80 |
+
$selectedHtml = $selected ? ' selected="selected"' : '';
|
81 |
+
if ($this->getIsRenderToJsTemplate() === true) {
|
82 |
+
$selectedHtml .= ' #{option_extra_attr_' . self::calcOptionHash($option['value']) . '}';
|
83 |
+
}
|
84 |
+
|
85 |
+
$params = '';
|
86 |
+
if (!empty($option['params']) && is_array($option['params'])) {
|
87 |
+
foreach ($option['params'] as $key => $value) {
|
88 |
+
if (is_array($value)) {
|
89 |
+
foreach ($value as $keyMulti => $valueMulti) {
|
90 |
+
$params .= sprintf(' %s="%s" ', $keyMulti, $valueMulti);
|
91 |
+
}
|
92 |
+
} else {
|
93 |
+
$params .= sprintf(' %s="%s" ', $key, $value);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
return sprintf(
|
99 |
+
'<option value="%s"%s %s>%s</option>',
|
100 |
+
$this->htmlEscape($option['value']),
|
101 |
+
$selectedHtml,
|
102 |
+
$params,
|
103 |
+
$this->htmlEscape($option['label'])
|
104 |
+
);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Calculate option hash
|
109 |
+
* Compatibility with old versions
|
110 |
+
*
|
111 |
+
* @param string $optionValue Option value
|
112 |
+
*
|
113 |
+
* @return string
|
114 |
+
* @see Mage_Core_Block_Html_Select
|
115 |
+
*/
|
116 |
+
public function calcOptionHash($optionValue)
|
117 |
+
{
|
118 |
+
return sprintf('%u', crc32($this->getName() . $this->getId() . $optionValue));
|
119 |
+
}
|
120 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistemt/Templatemapping.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display mapping between Magento and Dolist-EMT template list
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistemt_Templatemapping extends Dolist_Net_Block_Adminhtml_System_Config_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @var Dolist_Net_Block_Adminhtml_System_Config_Templatelist
|
14 |
+
*/
|
15 |
+
protected $_magentoTemplateRenderer;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var Dolist_Net_Block_Adminhtml_System_Config_Templatelist
|
19 |
+
*/
|
20 |
+
protected $_dolistemtTemplateRenderer;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Prepare to render
|
24 |
+
*
|
25 |
+
* @return void
|
26 |
+
*/
|
27 |
+
protected function _prepareToRender()
|
28 |
+
{
|
29 |
+
$this->addColumn(
|
30 |
+
'magento_template',
|
31 |
+
array(
|
32 |
+
'label' => Mage::helper('dolist')->__('Magento template'),
|
33 |
+
'renderer' => $this->_getMagentoTemplateRenderer(),
|
34 |
+
)
|
35 |
+
);
|
36 |
+
$this->addColumn(
|
37 |
+
'dolist_template',
|
38 |
+
array(
|
39 |
+
'label' => Mage::helper('dolist')->__('Dolist-EMT template'),
|
40 |
+
'renderer' => $this->_getDolistemtTemplateRenderer(),
|
41 |
+
)
|
42 |
+
);
|
43 |
+
$this->_addAfter = false;
|
44 |
+
$this->_addButtonLabel = Mage::helper('dolist')->__('Add Mapping');
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Renderer for magento email templates
|
49 |
+
*
|
50 |
+
* @return void
|
51 |
+
*/
|
52 |
+
protected function _getMagentoTemplateRenderer()
|
53 |
+
{
|
54 |
+
if (!$this->_magentoTemplateRenderer) {
|
55 |
+
$this->_magentoTemplateRenderer = $this->getLayout()->createBlock(
|
56 |
+
'dolist/adminhtml_system_config_templatelist',
|
57 |
+
'',
|
58 |
+
array('is_render_to_js_template' => true)
|
59 |
+
);
|
60 |
+
|
61 |
+
$this->_magentoTemplateRenderer->setClass('magento_email_template_select');
|
62 |
+
$this->_magentoTemplateRenderer->setExtraParams('style="width:120px"');
|
63 |
+
}
|
64 |
+
return $this->_magentoTemplateRenderer;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Renderer for Dolist-EMT templates
|
69 |
+
*
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
protected function _getDolistemtTemplateRenderer()
|
73 |
+
{
|
74 |
+
if (!$this->_dolistemtTemplateRenderer) {
|
75 |
+
$this->_dolistemtTemplateRenderer = $this->getLayout()->createBlock(
|
76 |
+
'dolist/adminhtml_system_config_dolistemt_templatelist',
|
77 |
+
'',
|
78 |
+
array('is_render_to_js_template' => true)
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->_dolistemtTemplateRenderer->setClass('dolistemt_email_template_select');
|
82 |
+
$this->_dolistemtTemplateRenderer->setExtraParams('style="width:120px"');
|
83 |
+
}
|
84 |
+
return $this->_dolistemtTemplateRenderer;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Prepare existing row data object
|
89 |
+
* Select stored values in select lists
|
90 |
+
*
|
91 |
+
* @param Varien_Object $row Row to select
|
92 |
+
*
|
93 |
+
* @return void
|
94 |
+
*/
|
95 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
96 |
+
{
|
97 |
+
$row->setData(
|
98 |
+
'option_extra_attr_' . $this->calcOptionHash($row->getData('magento_template'), $this->_getMagentoTemplateRenderer()),
|
99 |
+
'selected="selected"'
|
100 |
+
)->setData(
|
101 |
+
'option_extra_attr_' . $this->calcOptionHash($row->getData('dolist_template'), $this->_getDolistemtTemplateRenderer()),
|
102 |
+
'selected="selected"'
|
103 |
+
);
|
104 |
+
}
|
105 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistemt/Testconnection.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to test connection and retrieve Dolist-EMT template list
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistemt_Testconnection
|
11 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Set template to itself
|
15 |
+
*
|
16 |
+
* @return Dolist_Net_Block_Adminhtml_System_Config_Dolistemt_Testconnection
|
17 |
+
*/
|
18 |
+
protected function _prepareLayout()
|
19 |
+
{
|
20 |
+
parent::_prepareLayout();
|
21 |
+
if (!$this->getTemplate()) {
|
22 |
+
$this->setTemplate('dolist/system/config/dolistemt/testconnection.phtml');
|
23 |
+
}
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Unset some non-related element parameters
|
29 |
+
*
|
30 |
+
* @param Varien_Data_Form_Element_Abstract $element Element
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
35 |
+
{
|
36 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
37 |
+
return parent::render($element);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get the button and scripts contents
|
42 |
+
*
|
43 |
+
* @param Varien_Data_Form_Element_Abstract $element Element
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
48 |
+
{
|
49 |
+
$website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
|
50 |
+
if ($website->getId() == 0) {
|
51 |
+
$storeId = Mage::app()->getDefaultStoreView()->getId();
|
52 |
+
} else {
|
53 |
+
$storeId = $website->getDefaultStore()->getId();
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->addData(
|
57 |
+
array(
|
58 |
+
'button_label' => Mage::helper('dolist')->__('Test Dolist-EMT connection'),
|
59 |
+
'html_id' => $element->getHtmlId(),
|
60 |
+
'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/system_config_testconnection/pingdolistemt'),
|
61 |
+
'store_id' => $storeId
|
62 |
+
)
|
63 |
+
);
|
64 |
+
|
65 |
+
return $this->_toHtml();
|
66 |
+
}
|
67 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Attributelist.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display Dolist-V8 custom fields list
|
4 |
+
* Allow to choose type (String, Int or Date)
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Attributelist extends Mage_Core_Block_Html_Select
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Template list cache
|
16 |
+
*
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
private $_dolistv8AttributeList;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Retrieve options list
|
23 |
+
*
|
24 |
+
* @return array|string List
|
25 |
+
*/
|
26 |
+
protected function _getList()
|
27 |
+
{
|
28 |
+
if (is_null($this->_dolistv8AttributeList)) {
|
29 |
+
$this->_dolistv8AttributeList = array();
|
30 |
+
|
31 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
32 |
+
$collection = Mage::getModel('dolist/dolistv8_customfields')->getCollection();
|
33 |
+
$collection->addFieldToFilter('scope_id', Mage::app()->getRequest()->getParam('store', 0));
|
34 |
+
|
35 |
+
foreach($collection as $customField) {
|
36 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
37 |
+
|
38 |
+
if($customField->getData('name') == 'email') {
|
39 |
+
continue;
|
40 |
+
}
|
41 |
+
|
42 |
+
if(array_key_exists($customField->getData('name'), Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
43 |
+
continue;
|
44 |
+
}
|
45 |
+
|
46 |
+
if($customField->getData('type') != $this->getCustomFieldType()) {
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->_dolistv8AttributeList[] = array(
|
51 |
+
'value' => $customField->getData('name'),
|
52 |
+
'label' => $customField->getData('title')
|
53 |
+
);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this->_dolistv8AttributeList;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Set form input name. Mandatory to submit form then store values
|
62 |
+
*
|
63 |
+
* @param string $value Form input name
|
64 |
+
*
|
65 |
+
* @return Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Attributelist
|
66 |
+
*/
|
67 |
+
public function setInputName($value)
|
68 |
+
{
|
69 |
+
return $this->setName($value);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Render block HTML
|
74 |
+
*
|
75 |
+
* @return string HTML
|
76 |
+
*/
|
77 |
+
protected function _toHtml()
|
78 |
+
{
|
79 |
+
if (!$this->getOptions()) {
|
80 |
+
foreach ($this->_getList() as $id => $template) {
|
81 |
+
$value = $template['value'];
|
82 |
+
$label = $template['label'];
|
83 |
+
// Allow empty first line but remove 'locale default model'
|
84 |
+
if ($value != '' || $label == '') {
|
85 |
+
$this->addOption($value, addslashes($label));
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
return parent::_toHtml();
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Return option HTML node
|
94 |
+
* Compatibility with old versions
|
95 |
+
*
|
96 |
+
* @param array $option Option
|
97 |
+
* @param boolean $selected Selected
|
98 |
+
*
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
protected function _optionToHtml($option, $selected = false)
|
102 |
+
{
|
103 |
+
$selectedHtml = $selected ? ' selected="selected"' : '';
|
104 |
+
if ($this->getIsRenderToJsTemplate() === true) {
|
105 |
+
$selectedHtml .= ' #{option_extra_attr_' . $option['value'] . '}';
|
106 |
+
}
|
107 |
+
|
108 |
+
$params = '';
|
109 |
+
if (!empty($option['params']) && is_array($option['params'])) {
|
110 |
+
foreach ($option['params'] as $key => $value) {
|
111 |
+
if (is_array($value)) {
|
112 |
+
foreach ($value as $keyMulti => $valueMulti) {
|
113 |
+
$params .= sprintf(' %s="%s" ', $keyMulti, $valueMulti);
|
114 |
+
}
|
115 |
+
} else {
|
116 |
+
$params .= sprintf(' %s="%s" ', $key, $value);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
return sprintf(
|
122 |
+
'<option value="%s"%s %s>%s</option>',
|
123 |
+
$this->htmlEscape($option['value']),
|
124 |
+
$selectedHtml,
|
125 |
+
$params,
|
126 |
+
$this->htmlEscape($option['label'])
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Calculate option hash
|
132 |
+
* Compatibility with old versions
|
133 |
+
*
|
134 |
+
* @param string $optionValue Option value
|
135 |
+
*
|
136 |
+
* @return string
|
137 |
+
* @see Mage_Core_Block_Html_Select
|
138 |
+
*/
|
139 |
+
public function calcOptionHash($optionValue)
|
140 |
+
{
|
141 |
+
return sprintf('%u', crc32($this->getName() . $this->getId() . $optionValue));
|
142 |
+
}
|
143 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customdatefields.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display mapping between Magento customer attributes and Dolist-V8 attribute names
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Customdatefields extends Dolist_Net_Block_Adminhtml_System_Config_Abstract
|
11 |
+
{
|
12 |
+
protected $_magentoCustomerAttributeRenderer;
|
13 |
+
protected $_dolistv8AttributeRenderer;
|
14 |
+
protected $_limitRows = 3;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Prepare to render
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
protected function _prepareToRender()
|
22 |
+
{
|
23 |
+
$this->setTemplate('dolist/system/config/dolistv8/array.phtml');
|
24 |
+
|
25 |
+
$this->addColumn(
|
26 |
+
'magento_customer_attribute_3',
|
27 |
+
array(
|
28 |
+
'label' => Mage::helper('dolist')->__('Magento customer attribute'),
|
29 |
+
'renderer' => $this->_getMagentoCustomerAttributeRenderer(),
|
30 |
+
)
|
31 |
+
);
|
32 |
+
$this->addColumn(
|
33 |
+
'dolist_custom_date_fields',
|
34 |
+
array(
|
35 |
+
'label' => Mage::helper('dolist')->__('Dolist-V8 attribute name'),
|
36 |
+
'renderer' => $this->_getDolistv8AttributeRenderer(),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
$this->_addAfter = false;
|
40 |
+
$this->_addButtonLabel = Mage::helper('dolist')->__('Add Mapping');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Renderer for magento email templates
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
protected function _getMagentoCustomerAttributeRenderer()
|
49 |
+
{
|
50 |
+
if (!$this->_magentoCustomerAttributeRenderer) {
|
51 |
+
$this->_magentoCustomerAttributeRenderer = $this->getLayout()->createBlock(
|
52 |
+
'dolist/adminhtml_system_config_dolistv8_customerattributelist',
|
53 |
+
'',
|
54 |
+
array(
|
55 |
+
'is_render_to_js_template' => true,
|
56 |
+
'backend_type' => array('datetime')
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->_magentoCustomerAttributeRenderer->setExtraParams('style="width:120px"');
|
61 |
+
}
|
62 |
+
return $this->_magentoCustomerAttributeRenderer;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Renderer for Dolist-EMT templates
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
protected function _getDolistv8AttributeRenderer()
|
71 |
+
{
|
72 |
+
if (!$this->_dolistv8AttributeRenderer) {
|
73 |
+
$this->_dolistv8AttributeRenderer = $this->getLayout()->createBlock(
|
74 |
+
'dolist/adminhtml_system_config_dolistv8_attributelist',
|
75 |
+
'',
|
76 |
+
array(
|
77 |
+
'is_render_to_js_template' => true,
|
78 |
+
'custom_field_label' => 'CustomDate',
|
79 |
+
'custom_field_size' => 3)
|
80 |
+
);
|
81 |
+
$this->_dolistv8AttributeRenderer->setClass('dolistv8_custom_date_fields_select');
|
82 |
+
$this->_dolistv8AttributeRenderer->setExtraParams('style="width:120px"');
|
83 |
+
}
|
84 |
+
return $this->_dolistv8AttributeRenderer;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Prepare existing row data object
|
89 |
+
* Select stored values in select lists
|
90 |
+
*
|
91 |
+
* @param Varien_Object $row Row to select
|
92 |
+
*
|
93 |
+
* @return void
|
94 |
+
*/
|
95 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
96 |
+
{
|
97 |
+
$row->setData(
|
98 |
+
'option_extra_attr_' . $this->calcOptionHash(
|
99 |
+
$row->getData('magento_customer_attribute_3'),
|
100 |
+
$this->_getMagentoCustomerAttributeRenderer()
|
101 |
+
),
|
102 |
+
'selected="selected"'
|
103 |
+
)->setData(
|
104 |
+
'option_extra_attr_' . $this->calcOptionHash(
|
105 |
+
$row->getData('dolist_custom_date_fields'),
|
106 |
+
$this->_getDolistv8AttributeRenderer()
|
107 |
+
),
|
108 |
+
'selected="selected"'
|
109 |
+
);
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Return limit of rows to allow
|
114 |
+
*
|
115 |
+
* @return int
|
116 |
+
*/
|
117 |
+
public function getLimitRows()
|
118 |
+
{
|
119 |
+
return $this->_limitRows;
|
120 |
+
}
|
121 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customerattributelist.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display customer attribute list which can be exported to Dolist-V8
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Customerattributelist extends Mage_Core_Block_Html_Select
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Template list cache
|
14 |
+
*
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
private $_dolistv8AttributeList;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Retrieve options list
|
21 |
+
*
|
22 |
+
* @return array|string List
|
23 |
+
*/
|
24 |
+
protected function _getList()
|
25 |
+
{
|
26 |
+
if (is_null($this->_dolistv8AttributeList)) {
|
27 |
+
$this->_dolistv8AttributeList = array();
|
28 |
+
|
29 |
+
$collection = Mage::getModel('dolist/system_config_source_dolistv8_customerattributelist')->toOptionArray(
|
30 |
+
$this->getBackendType()
|
31 |
+
);
|
32 |
+
foreach ($collection as $id => $item) {
|
33 |
+
$this->_dolistv8AttributeList[$id] = $item;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
return $this->_dolistv8AttributeList;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Set form input name. Mandatory to submit form then store values
|
41 |
+
*
|
42 |
+
* @param string $value Form input name
|
43 |
+
*
|
44 |
+
* @return Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Customerattributelist
|
45 |
+
*/
|
46 |
+
public function setInputName($value)
|
47 |
+
{
|
48 |
+
return $this->setName($value);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Render block HTML
|
53 |
+
*
|
54 |
+
* @return string HTML
|
55 |
+
*/
|
56 |
+
protected function _toHtml()
|
57 |
+
{
|
58 |
+
if (!$this->getOptions()) {
|
59 |
+
|
60 |
+
foreach ($this->_getList() as $id => $template) {
|
61 |
+
|
62 |
+
if (!is_array($template['value'])) {
|
63 |
+
$value = $template['value'];
|
64 |
+
$label = $template['label'];
|
65 |
+
|
66 |
+
// if label empty, display value
|
67 |
+
if ($label == '') {
|
68 |
+
$label = $value;
|
69 |
+
}
|
70 |
+
|
71 |
+
$this->addOption($value, addslashes($label));
|
72 |
+
} else {
|
73 |
+
$this->addOption($template['value'], addslashes($template['label']));
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
return parent::_toHtml();
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Return option HTML node
|
82 |
+
* Compatibility with old versions
|
83 |
+
*
|
84 |
+
* @param array $option Option
|
85 |
+
* @param boolean $selected Selected
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
protected function _optionToHtml($option, $selected = false)
|
90 |
+
{
|
91 |
+
$selectedHtml = $selected ? ' selected="selected"' : '';
|
92 |
+
if ($this->getIsRenderToJsTemplate() === true) {
|
93 |
+
$selectedHtml .= ' #{option_extra_attr_' . $option['value'] . '}';
|
94 |
+
}
|
95 |
+
|
96 |
+
$params = '';
|
97 |
+
if (!empty($option['params']) && is_array($option['params'])) {
|
98 |
+
foreach ($option['params'] as $key => $value) {
|
99 |
+
if (is_array($value)) {
|
100 |
+
foreach ($value as $keyMulti => $valueMulti) {
|
101 |
+
$params .= sprintf(' %s="%s" ', $keyMulti, $valueMulti);
|
102 |
+
}
|
103 |
+
} else {
|
104 |
+
$params .= sprintf(' %s="%s" ', $key, $value);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
return sprintf(
|
110 |
+
'<option value="%s"%s %s>%s</option>',
|
111 |
+
$this->htmlEscape($option['value']),
|
112 |
+
$selectedHtml,
|
113 |
+
$params,
|
114 |
+
$this->htmlEscape($option['label'])
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Calculate option hash
|
120 |
+
* Compatibility with old versions
|
121 |
+
*
|
122 |
+
* @param string $optionValue Option value
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
* @see Mage_Core_Block_Html_Select
|
126 |
+
*/
|
127 |
+
public function calcOptionHash($optionValue)
|
128 |
+
{
|
129 |
+
return sprintf('%u', crc32($this->getName() . $this->getId() . $optionValue));
|
130 |
+
}
|
131 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customintfields.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display mapping between Magento customer attributes and Dolist-V8 attribute names
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Customintfields extends Dolist_Net_Block_Adminhtml_System_Config_Abstract
|
11 |
+
{
|
12 |
+
protected $_magentoCustomerAttributeRenderer;
|
13 |
+
protected $_dolistv8AttributeRenderer;
|
14 |
+
protected $_limitRows = 10;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Prepare to render
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
protected function _prepareToRender()
|
22 |
+
{
|
23 |
+
$this->setTemplate('dolist/system/config/dolistv8/array.phtml');
|
24 |
+
|
25 |
+
$this->addColumn(
|
26 |
+
'magento_customer_attribute_2',
|
27 |
+
array(
|
28 |
+
'label' => Mage::helper('dolist')->__('Magento customer attribute'),
|
29 |
+
'renderer' => $this->_getMagentoCustomerAttributeRenderer(),
|
30 |
+
)
|
31 |
+
);
|
32 |
+
$this->addColumn(
|
33 |
+
'dolist_custom_int_fields',
|
34 |
+
array(
|
35 |
+
'label' => Mage::helper('dolist')->__('Dolist-V8 attribute name'),
|
36 |
+
'renderer' => $this->_getDolistv8AttributeRenderer(),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
$this->_addAfter = false;
|
40 |
+
$this->_addButtonLabel = Mage::helper('dolist')->__('Add Mapping');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Renderer for magento email templates
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
protected function _getMagentoCustomerAttributeRenderer()
|
49 |
+
{
|
50 |
+
if (!$this->_magentoCustomerAttributeRenderer) {
|
51 |
+
$this->_magentoCustomerAttributeRenderer = $this->getLayout()->createBlock(
|
52 |
+
'dolist/adminhtml_system_config_dolistv8_customerattributelist',
|
53 |
+
'',
|
54 |
+
array(
|
55 |
+
'is_render_to_js_template' => true,
|
56 |
+
'backend_type' => array('int')
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->_magentoCustomerAttributeRenderer->setExtraParams('style="width:120px"');
|
61 |
+
}
|
62 |
+
return $this->_magentoCustomerAttributeRenderer;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Renderer for Dolist-EMT templates
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
protected function _getDolistv8AttributeRenderer()
|
71 |
+
{
|
72 |
+
if (!$this->_dolistv8AttributeRenderer) {
|
73 |
+
$this->_dolistv8AttributeRenderer = $this->getLayout()->createBlock(
|
74 |
+
'dolist/adminhtml_system_config_dolistv8_attributelist',
|
75 |
+
'',
|
76 |
+
array(
|
77 |
+
'is_render_to_js_template' => true,
|
78 |
+
'custom_field_label' => 'CustomInt',
|
79 |
+
'custom_field_size' => 10)
|
80 |
+
);
|
81 |
+
|
82 |
+
$this->_dolistv8AttributeRenderer->setClass('dolistv8_custom_int_fields_select');
|
83 |
+
$this->_dolistv8AttributeRenderer->setExtraParams('style="width:120px"');
|
84 |
+
}
|
85 |
+
return $this->_dolistv8AttributeRenderer;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Prepare existing row data object
|
90 |
+
* Select stored values in select lists
|
91 |
+
*
|
92 |
+
* @param Varien_Object $row Row to select
|
93 |
+
*
|
94 |
+
* @return void
|
95 |
+
*/
|
96 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
97 |
+
{
|
98 |
+
$row->setData(
|
99 |
+
'option_extra_attr_' . $this->calcOptionHash(
|
100 |
+
$row->getData('magento_customer_attribute_2'),
|
101 |
+
$this->_getMagentoCustomerAttributeRenderer()
|
102 |
+
),
|
103 |
+
'selected="selected"'
|
104 |
+
)->setData(
|
105 |
+
'option_extra_attr_' . $this->calcOptionHash(
|
106 |
+
$row->getData('dolist_custom_int_fields'),
|
107 |
+
$this->_getDolistv8AttributeRenderer()
|
108 |
+
),
|
109 |
+
'selected="selected"'
|
110 |
+
);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Return limit of rows to allow
|
115 |
+
*
|
116 |
+
* @return int
|
117 |
+
*/
|
118 |
+
public function getLimitRows()
|
119 |
+
{
|
120 |
+
return $this->_limitRows;
|
121 |
+
}
|
122 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Customstrfields.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display mapping between Magento customer attributes and Dolist-V8 attribute names
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Customstrfields extends Dolist_Net_Block_Adminhtml_System_Config_Abstract
|
11 |
+
{
|
12 |
+
protected $_magentoCustomerAttributeRenderer;
|
13 |
+
protected $_dolistv8AttributeRenderer;
|
14 |
+
protected $_limitRows = 30;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Prepare to render
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
protected function _prepareToRender()
|
22 |
+
{
|
23 |
+
$this->setTemplate('dolist/system/config/dolistv8/array.phtml');
|
24 |
+
|
25 |
+
$this->addColumn(
|
26 |
+
'magento_customer_attribute_1',
|
27 |
+
array(
|
28 |
+
'label' => Mage::helper('dolist')->__('Magento customer attribute'),
|
29 |
+
'renderer' => $this->_getMagentoCustomerAttributeRenderer(),
|
30 |
+
)
|
31 |
+
);
|
32 |
+
$this->addColumn(
|
33 |
+
'dolist_custom_str_fields',
|
34 |
+
array(
|
35 |
+
'label' => Mage::helper('dolist')->__('Dolist-V8 attribute name'),
|
36 |
+
'renderer' => $this->_getDolistv8AttributeRenderer(),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
$this->_addAfter = false;
|
40 |
+
$this->_addButtonLabel = Mage::helper('dolist')->__('Add Mapping');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Renderer for magento email templates
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
protected function _getMagentoCustomerAttributeRenderer()
|
49 |
+
{
|
50 |
+
if (!$this->_magentoCustomerAttributeRenderer) {
|
51 |
+
$this->_magentoCustomerAttributeRenderer = $this->getLayout()->createBlock(
|
52 |
+
'dolist/adminhtml_system_config_dolistv8_customerattributelist',
|
53 |
+
'',
|
54 |
+
array(
|
55 |
+
'is_render_to_js_template' => true,
|
56 |
+
'backend_type' => array('static', 'varchar', 'text')
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->_magentoCustomerAttributeRenderer->setExtraParams('style="width:120px"');
|
61 |
+
}
|
62 |
+
return $this->_magentoCustomerAttributeRenderer;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Renderer for Dolist-EMT templates
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
protected function _getDolistv8AttributeRenderer()
|
71 |
+
{
|
72 |
+
if (!$this->_dolistv8AttributeRenderer) {
|
73 |
+
$this->_dolistv8AttributeRenderer = $this->getLayout()->createBlock(
|
74 |
+
'dolist/adminhtml_system_config_dolistv8_attributelist',
|
75 |
+
'',
|
76 |
+
array(
|
77 |
+
'is_render_to_js_template' => true,
|
78 |
+
'custom_field_label' => 'CustomStr',
|
79 |
+
'custom_field_size' => 30)
|
80 |
+
);
|
81 |
+
|
82 |
+
$this->_dolistv8AttributeRenderer->setClass('dolistv8_custom_str_fields_select');
|
83 |
+
$this->_dolistv8AttributeRenderer->setExtraParams('style="width:120px"');
|
84 |
+
}
|
85 |
+
return $this->_dolistv8AttributeRenderer;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Prepare existing row data object
|
90 |
+
* Select stored values in select lists
|
91 |
+
*
|
92 |
+
* @param Varien_Object $row Row to select
|
93 |
+
*
|
94 |
+
* @return void
|
95 |
+
*/
|
96 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
97 |
+
{
|
98 |
+
$row->setData(
|
99 |
+
'option_extra_attr_' . $this->calcOptionHash(
|
100 |
+
$row->getData('magento_customer_attribute_1'),
|
101 |
+
$this->_getMagentoCustomerAttributeRenderer()
|
102 |
+
),
|
103 |
+
'selected="selected"'
|
104 |
+
)->setData(
|
105 |
+
'option_extra_attr_' . $this->calcOptionHash(
|
106 |
+
$row->getData('dolist_custom_str_fields'),
|
107 |
+
$this->_getDolistv8AttributeRenderer()
|
108 |
+
),
|
109 |
+
'selected="selected"'
|
110 |
+
);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Return limit of rows to allow
|
115 |
+
*
|
116 |
+
* @return int
|
117 |
+
*/
|
118 |
+
public function getLimitRows()
|
119 |
+
{
|
120 |
+
return $this->_limitRows;
|
121 |
+
}
|
122 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Dolistv8/Testconnection.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to test Dolist-V8 web service connection
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Testconnection
|
11 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Set template to itself
|
15 |
+
*
|
16 |
+
* @return Dolist_Net_Block_Adminhtml_System_Config_Dolistv8_Testconnection
|
17 |
+
*/
|
18 |
+
protected function _prepareLayout()
|
19 |
+
{
|
20 |
+
parent::_prepareLayout();
|
21 |
+
if (!$this->getTemplate()) {
|
22 |
+
$this->setTemplate('dolist/system/config/dolistv8/testconnection.phtml');
|
23 |
+
}
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Unset some non-related element parameters
|
29 |
+
*
|
30 |
+
* @param Varien_Data_Form_Element_Abstract $element Element
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
35 |
+
{
|
36 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
37 |
+
return parent::render($element);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get the button and scripts contents
|
42 |
+
*
|
43 |
+
* @param Varien_Data_Form_Element_Abstract $element Element
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
48 |
+
{
|
49 |
+
$website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
|
50 |
+
if ($website->getId() == 0) {
|
51 |
+
$storeId = Mage::app()->getDefaultStoreView()->getId();
|
52 |
+
} else {
|
53 |
+
$storeId = $website->getDefaultStore()->getId();
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->addData(
|
57 |
+
array(
|
58 |
+
'button_label' => Mage::helper('dolist')->__('Test Dolist-V8 connection'),
|
59 |
+
'html_id' => $element->getHtmlId(),
|
60 |
+
'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/system_config_testconnection/pingdolistv8'),
|
61 |
+
'store_id' => $storeId
|
62 |
+
)
|
63 |
+
);
|
64 |
+
|
65 |
+
return $this->_toHtml();
|
66 |
+
}
|
67 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Enable.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to display "Enable" label in Back Office but cannot modify its value
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Enable extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Return Dolist 'Enabled' label to be displayed in Back Office system configuration
|
14 |
+
*
|
15 |
+
* @param Varien_Data_Form_Element_Abstract $element Element
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
20 |
+
{
|
21 |
+
return Mage::helper('adminhtml')->__('Enabled');
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Switcher.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Dolist block to display store switcher in Back Office
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Switcher extends Mage_Adminhtml_Block_System_Config_Switcher
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Retrieve websites only
|
15 |
+
* Used id is default store view id for each website
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function getStoreSelectOptions()
|
20 |
+
{
|
21 |
+
$section = $this->getRequest()->getParam('section');
|
22 |
+
$curStore = $this->getRequest()->getParam('store');
|
23 |
+
|
24 |
+
$storeModel = Mage::getSingleton('adminhtml/system_store');
|
25 |
+
/* @var $storeModel Mage_Adminhtml_Model_System_Store */
|
26 |
+
|
27 |
+
$url = Mage::getModel('adminhtml/url');
|
28 |
+
|
29 |
+
$options = array();
|
30 |
+
$options['default'] = array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Default Config'),
|
32 |
+
'url' => $url->getUrl('*/*/*', array('section' => $section)),
|
33 |
+
'selected' => !$curStore,
|
34 |
+
'style' => 'background:#ccc; font-weight:bold;',
|
35 |
+
);
|
36 |
+
|
37 |
+
foreach ($storeModel->getWebsiteCollection() as $website) {
|
38 |
+
/** @var Mage_Core_Model_Website $website */
|
39 |
+
|
40 |
+
$websiteShow = false;
|
41 |
+
|
42 |
+
foreach ($website->getStores() as $store) {
|
43 |
+
/** @var Mage_Core_Model_Store $store */
|
44 |
+
|
45 |
+
|
46 |
+
$options['store_' . $store->getId()] = array(
|
47 |
+
'label' => $website->getName() . ' - ' . $store->getName(),
|
48 |
+
'url' => $url->getUrl('*/*/*', array('section' => $section, 'store' => $store->getId())),
|
49 |
+
'selected' => $curStore == $store->getId(),
|
50 |
+
'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
|
51 |
+
);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
return $options;
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
app/code/community/Dolist/Net/Block/Adminhtml/System/Config/Templatelist.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist block to test connection and retrieve Magento email template list
|
4 |
+
* Retrieve Magento template list (original and custom ones)
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Block_Adminhtml_System_Config_Templatelist extends Mage_Core_Block_Html_Select
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Template list cache
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
private $_templateList;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Retrieve Magento template list (original and custom ones)
|
22 |
+
*
|
23 |
+
* @return array|string Template list
|
24 |
+
*/
|
25 |
+
protected function _getTemplateList()
|
26 |
+
{
|
27 |
+
if (is_null($this->_templateList)) {
|
28 |
+
$this->_templateList = array();
|
29 |
+
|
30 |
+
$collection = Mage::getModel('dolist/system_config_source_email_template')->toOptionArray();
|
31 |
+
foreach ($collection as $id => $item) {
|
32 |
+
$this->_templateList[$id] = $item;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return $this->_templateList;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Set form input name. Mandatory to submit form then store values
|
40 |
+
*
|
41 |
+
* @param string $value Form input name
|
42 |
+
*
|
43 |
+
* @return Dolist_Net_Block_Adminhtml_System_Config_Templatelist
|
44 |
+
*/
|
45 |
+
public function setInputName($value)
|
46 |
+
{
|
47 |
+
return $this->setName($value);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Render block HTML
|
52 |
+
*
|
53 |
+
* @return string HTML
|
54 |
+
*/
|
55 |
+
protected function _toHtml()
|
56 |
+
{
|
57 |
+
if (!$this->getOptions()) {
|
58 |
+
foreach ($this->_getTemplateList() as $id => $template) {
|
59 |
+
$value = $template['value'];
|
60 |
+
$label = $template['label'];
|
61 |
+
// Allow empty first line but remove 'locale default model'
|
62 |
+
if ($value != '' || $label == '') {
|
63 |
+
$this->addOption($value, addslashes($label));
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
return parent::_toHtml();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Return option HTML node
|
72 |
+
* Compatibility with old versions
|
73 |
+
*
|
74 |
+
* @param array $option Option
|
75 |
+
* @param boolean $selected Selected
|
76 |
+
*
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
protected function _optionToHtml($option, $selected = false)
|
80 |
+
{
|
81 |
+
$selectedHtml = $selected ? ' selected="selected"' : '';
|
82 |
+
if ($this->getIsRenderToJsTemplate() === true) {
|
83 |
+
$selectedHtml .= ' #{option_extra_attr_' . self::calcOptionHash($option['value']) . '}';
|
84 |
+
}
|
85 |
+
|
86 |
+
$params = '';
|
87 |
+
if (!empty($option['params']) && is_array($option['params'])) {
|
88 |
+
foreach ($option['params'] as $key => $value) {
|
89 |
+
if (is_array($value)) {
|
90 |
+
foreach ($value as $keyMulti => $valueMulti) {
|
91 |
+
$params .= sprintf(' %s="%s" ', $keyMulti, $valueMulti);
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
$params .= sprintf(' %s="%s" ', $key, $value);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
return sprintf(
|
100 |
+
'<option value="%s"%s %s>%s</option>',
|
101 |
+
$this->htmlEscape($option['value']),
|
102 |
+
$selectedHtml,
|
103 |
+
$params,
|
104 |
+
$this->htmlEscape($option['label'])
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Calculate option hash
|
110 |
+
* Compatibility with old versions
|
111 |
+
*
|
112 |
+
* @param string $optionValue Option value
|
113 |
+
*
|
114 |
+
* @return string
|
115 |
+
* @see Mage_Core_Block_Html_Select
|
116 |
+
*/
|
117 |
+
public function calcOptionHash($optionValue)
|
118 |
+
{
|
119 |
+
return sprintf('%u', crc32($this->getName() . $this->getId() . $optionValue));
|
120 |
+
}
|
121 |
+
}
|
app/code/community/Dolist/Net/Helper/Data.php
ADDED
@@ -0,0 +1,806 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Dolist Helper
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Helper_Data extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
const XML_DOLIST_V8_ENABLED = 'dolist/dolist_v8/active';
|
14 |
+
const XML_DOLIST_EMT_ENABLED = 'dolist/dolist_emt/active';
|
15 |
+
const LOGFILE = 'dolist.log';
|
16 |
+
const FLAG_DOLIST_LAST_EXPORT = 'dolist_last_export';
|
17 |
+
const OTHER_COUNTRIES_CODE = 999;
|
18 |
+
|
19 |
+
protected $_contactExportRowAdapter = null;
|
20 |
+
protected $_optoutMapping = null;
|
21 |
+
protected $_contactHeader = array(
|
22 |
+
'Email',
|
23 |
+
'SalutationId',
|
24 |
+
'FirstName',
|
25 |
+
'LastName',
|
26 |
+
'Company',
|
27 |
+
'Address 1',
|
28 |
+
'Address 2',
|
29 |
+
'Address 3',
|
30 |
+
'ZipCode',
|
31 |
+
'City',
|
32 |
+
'CountryID',
|
33 |
+
'Phone',
|
34 |
+
'Fax',
|
35 |
+
'Mobile Phone',
|
36 |
+
'MsgFormatId',
|
37 |
+
'SaleMgt',
|
38 |
+
'Birthdate',
|
39 |
+
'CustomDate1',
|
40 |
+
'CustomDate2',
|
41 |
+
'CustomDate3',
|
42 |
+
'CustomStr1',
|
43 |
+
'CustomStr2',
|
44 |
+
'CustomStr3',
|
45 |
+
'CustomStr4',
|
46 |
+
'CustomStr5',
|
47 |
+
'CustomStr6',
|
48 |
+
'CustomStr7',
|
49 |
+
'CustomStr8',
|
50 |
+
'CustomStr9',
|
51 |
+
'CustomStr10',
|
52 |
+
'CustomStr11',
|
53 |
+
'CustomStr12',
|
54 |
+
'CustomStr13',
|
55 |
+
'CustomStr14',
|
56 |
+
'CustomStr15',
|
57 |
+
'CustomStr16',
|
58 |
+
'CustomStr17',
|
59 |
+
'CustomStr18',
|
60 |
+
'CustomStr19',
|
61 |
+
'CustomStr20',
|
62 |
+
'CustomStr21',
|
63 |
+
'CustomStr22',
|
64 |
+
'CustomStr23',
|
65 |
+
'CustomStr24',
|
66 |
+
'CustomStr25',
|
67 |
+
'CustomStr26',
|
68 |
+
'CustomStr27',
|
69 |
+
'CustomStr28',
|
70 |
+
'CustomStr29',
|
71 |
+
'CustomStr30',
|
72 |
+
'CustomInt1',
|
73 |
+
'CustomInt2',
|
74 |
+
'CustomInt3',
|
75 |
+
'CustomInt4',
|
76 |
+
'CustomInt5',
|
77 |
+
'CustomInt6',
|
78 |
+
'CustomInt7',
|
79 |
+
'CustomInt8',
|
80 |
+
'CustomInt9',
|
81 |
+
'CustomInt10'
|
82 |
+
);
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Check if Dolist-V8 is enabled
|
86 |
+
*
|
87 |
+
* @param type $store Scope
|
88 |
+
*
|
89 |
+
* @return boolean
|
90 |
+
*/
|
91 |
+
public function isDolistV8Enabled($store = null)
|
92 |
+
{
|
93 |
+
return (
|
94 |
+
Mage::getStoreConfig(self::XML_DOLIST_V8_ENABLED, $store) &&
|
95 |
+
Mage::getStoreConfig(Dolist_Net_Model_Service::XML_DOLIST_V8_ACCOUNTID, $store) != '' &&
|
96 |
+
Mage::getStoreConfig(Dolist_Net_Model_Service::XML_DOLIST_V8_AUTH_KEY, $store) != '' &&
|
97 |
+
Mage::getStoreConfig(Dolist_Net_Model_Service::XML_DOLIST_V8_LOGIN, $store) != '' &&
|
98 |
+
Mage::getStoreConfig(Dolist_Net_Model_Service::XML_DOLIST_V8_PASSWORD, $store) != ''
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Check if sales_flat_order is present
|
104 |
+
*
|
105 |
+
* @return boolean
|
106 |
+
*/
|
107 |
+
public function isFlatTableEnabled()
|
108 |
+
{
|
109 |
+
$currentVersion = Mage::getVersion();
|
110 |
+
return (version_compare($currentVersion, '1.4.1') >= 0);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Check if Dolist-EMT is enabled
|
115 |
+
*
|
116 |
+
* @param type $store Scope
|
117 |
+
*
|
118 |
+
* @return boolean
|
119 |
+
*/
|
120 |
+
public function isDolistEmtEnabled($store = null)
|
121 |
+
{
|
122 |
+
return Mage::getStoreConfig(self::XML_DOLIST_EMT_ENABLED, $store);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Check if customer segments are enabled for this instance
|
127 |
+
*
|
128 |
+
* @return boolean
|
129 |
+
*/
|
130 |
+
public function isCustomerSegmentEnabled()
|
131 |
+
{
|
132 |
+
$isEnabled = false;
|
133 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
134 |
+
$modulesArray = (array)$modules;
|
135 |
+
|
136 |
+
if (isset($modulesArray['Enterprise_CustomerSegment'])) {
|
137 |
+
$isEnabled = true;
|
138 |
+
}
|
139 |
+
return $isEnabled;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Return dolist_last_export flag (in core_flag table) if it exists, null otherwise
|
144 |
+
*
|
145 |
+
* @param int $storeId Store id Default 0 => default config
|
146 |
+
*
|
147 |
+
* @return Mage_Core_Model_Flag|null Flag
|
148 |
+
*/
|
149 |
+
public function getFlagDolistLastExport($storeId = 0)
|
150 |
+
{
|
151 |
+
// Use default store view
|
152 |
+
if ($storeId == 0) {
|
153 |
+
$storeId = Mage::app()->getDefaultStoreView();
|
154 |
+
}
|
155 |
+
|
156 |
+
// Look for last export date
|
157 |
+
$flagCode = self::FLAG_DOLIST_LAST_EXPORT . '_' . $storeId;
|
158 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))
|
159 |
+
->load($flagCode, 'flag_code');
|
160 |
+
|
161 |
+
return $flag;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Retrieve Dolist status from OptoutEmail (retrieved from Dolist-V8 webservice GetContact method)
|
166 |
+
*
|
167 |
+
* @param int $optoutEmail OptoutEmail value
|
168 |
+
*
|
169 |
+
* @return int|null
|
170 |
+
*/
|
171 |
+
public function getDolistStatus($optoutEmail)
|
172 |
+
{
|
173 |
+
$dolistStatus = null;
|
174 |
+
|
175 |
+
if (is_null($this->_optoutMapping)) {
|
176 |
+
$optoutMapping = array();
|
177 |
+
$optoutConfig = (array)Mage::getConfig()->getNode('dolistparams/optout_mapping');
|
178 |
+
|
179 |
+
foreach ($optoutConfig as $configItem) {
|
180 |
+
$configItem = (array)$configItem;
|
181 |
+
foreach (explode(',', $configItem['dolist_value']) as $value) {
|
182 |
+
$optoutMapping[$value] = $configItem['magento_value'];
|
183 |
+
}
|
184 |
+
}
|
185 |
+
$this->_optoutMapping = $optoutMapping;
|
186 |
+
}
|
187 |
+
if (array_key_exists($optoutEmail, $this->_optoutMapping)) {
|
188 |
+
$dolistStatus = $this->_optoutMapping[$optoutEmail];
|
189 |
+
}
|
190 |
+
|
191 |
+
return $dolistStatus;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Return warning message to display when customer logins or when admin edits customer in back-office
|
196 |
+
* Depends on dolist_status value in newsletter_subscriber table (got from OptoutEmail values)
|
197 |
+
* 5 - Temporary error
|
198 |
+
* 6 - Final error
|
199 |
+
* 7 - Spam
|
200 |
+
*
|
201 |
+
* @param string $dolistStatus Dolist status
|
202 |
+
* @param string $scope Scope 'front' or 'back'
|
203 |
+
*
|
204 |
+
* @return string Error message
|
205 |
+
*/
|
206 |
+
public function getDolistStatusErrorMessage($dolistStatus, $scope = 'front')
|
207 |
+
{
|
208 |
+
$errorMessage = null;
|
209 |
+
|
210 |
+
if ($dolistStatus != '') {
|
211 |
+
switch ($scope) {
|
212 |
+
case 'front':
|
213 |
+
switch ($dolistStatus) {
|
214 |
+
case '5':
|
215 |
+
$errorMessage = 'Your email address is in temporary error.';
|
216 |
+
break;
|
217 |
+
case '6':
|
218 |
+
$errorMessage = 'Your email address is in final error. Please correct it.';
|
219 |
+
break;
|
220 |
+
case '7':
|
221 |
+
$errorMessage = 'Last sent message was signaled as spam.';
|
222 |
+
break;
|
223 |
+
}
|
224 |
+
break;
|
225 |
+
|
226 |
+
case 'back':
|
227 |
+
switch ($dolistStatus) {
|
228 |
+
case '5':
|
229 |
+
$errorMessage = 'This contact email address is in temporary error.';
|
230 |
+
break;
|
231 |
+
case '6':
|
232 |
+
$errorMessage = 'This contact email address is in final error. Please correct it.';
|
233 |
+
break;
|
234 |
+
case '7':
|
235 |
+
$errorMessage = 'Last message sent from this contact was signaled as spam.';
|
236 |
+
break;
|
237 |
+
}
|
238 |
+
break;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
return $errorMessage;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Retrieve from core_flag table Dolist Exported Segment List
|
247 |
+
* If null, instantiate new object
|
248 |
+
*
|
249 |
+
* @param int $storeId Store ID scope
|
250 |
+
*
|
251 |
+
* @return Mage_Core_Model_Flag
|
252 |
+
*/
|
253 |
+
public function getDolistExportedSegmentList($storeId = 0)
|
254 |
+
{
|
255 |
+
$flagCode = 'dolist_exported_segment_list_' . $storeId;
|
256 |
+
|
257 |
+
// First, try to retrieve object
|
258 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
259 |
+
|
260 |
+
if ($flag->getId() == null) {
|
261 |
+
// Instanciate new object
|
262 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
263 |
+
$flag->save();
|
264 |
+
}
|
265 |
+
|
266 |
+
return $flag;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Retur true if this segment is already exported
|
271 |
+
*
|
272 |
+
* @param int $segmentId Segment ID
|
273 |
+
* @param int|array $stores Can be store ID or array of store ids
|
274 |
+
*
|
275 |
+
* @return boolean
|
276 |
+
*/
|
277 |
+
public function isExportedSegment($segmentId, $stores = 0)
|
278 |
+
{
|
279 |
+
$return = false;
|
280 |
+
|
281 |
+
if (is_array($stores)) {
|
282 |
+
$return = false;
|
283 |
+
foreach ($stores as $storeId) {
|
284 |
+
$resultItem = $this->isExportedSegment($segmentId, $storeId);
|
285 |
+
if ($resultItem == true) {
|
286 |
+
$return = true;
|
287 |
+
break;
|
288 |
+
}
|
289 |
+
}
|
290 |
+
} else {
|
291 |
+
$flag = $this->getDolistExportedSegmentList($stores);
|
292 |
+
$dolistExportedSegmentList = $flag->getFlagData();
|
293 |
+
|
294 |
+
if (
|
295 |
+
is_array($dolistExportedSegmentList) &&
|
296 |
+
array_search($segmentId, $dolistExportedSegmentList) !== false
|
297 |
+
) {
|
298 |
+
$return = true;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
return $return;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Add exported segment to list stored in core_flag table
|
307 |
+
*
|
308 |
+
* @param int $segmentId Segment ID
|
309 |
+
* @param int $storeId Store ID scope
|
310 |
+
*
|
311 |
+
* @return void
|
312 |
+
*/
|
313 |
+
public function addExportedSegment($segmentId, $storeId = 0)
|
314 |
+
{
|
315 |
+
$flag = $this->getDolistExportedSegmentList($storeId);
|
316 |
+
$dolistExportedSegmentList = $flag->getFlagData();
|
317 |
+
|
318 |
+
if (!is_array($dolistExportedSegmentList)) {
|
319 |
+
$dolistExportedSegmentList = array($segmentId);
|
320 |
+
} else if (array_search($segmentId, $dolistExportedSegmentList) === false) {
|
321 |
+
// Add segmentId if not found
|
322 |
+
$dolistExportedSegmentList[] = $segmentId;
|
323 |
+
}
|
324 |
+
|
325 |
+
// To avoid duplicate data
|
326 |
+
if (is_array($dolistExportedSegmentList)) {
|
327 |
+
$dolistExportedSegmentList = array_unique($dolistExportedSegmentList);
|
328 |
+
}
|
329 |
+
|
330 |
+
$flag->setFlagData($dolistExportedSegmentList)
|
331 |
+
->save();
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Remove exported segment to list stored in core_flag table
|
336 |
+
*
|
337 |
+
* @param int $segmentId Segment ID
|
338 |
+
* @param int $storeId Store ID scope
|
339 |
+
*
|
340 |
+
* @return void
|
341 |
+
*/
|
342 |
+
public function removeExportedSegment($segmentId, $storeId = 0)
|
343 |
+
{
|
344 |
+
$flag = $this->getDolistExportedSegmentList($storeId);
|
345 |
+
$dolistExportedSegmentList = $flag->getFlagData();
|
346 |
+
|
347 |
+
if (
|
348 |
+
is_array($dolistExportedSegmentList) &&
|
349 |
+
array_search($segmentId, $dolistExportedSegmentList) !== false
|
350 |
+
) {
|
351 |
+
unset($dolistExportedSegmentList[array_search($segmentId, $dolistExportedSegmentList)]);
|
352 |
+
}
|
353 |
+
|
354 |
+
// To avoid duplicate data
|
355 |
+
if (is_array($dolistExportedSegmentList)) {
|
356 |
+
$dolistExportedSegmentList = array_unique($dolistExportedSegmentList);
|
357 |
+
}
|
358 |
+
|
359 |
+
$flag->setFlagData($dolistExportedSegmentList)
|
360 |
+
->save();
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Return Dolist-V8 export contact file header fields
|
365 |
+
*
|
366 |
+
* @return array Header fields
|
367 |
+
*/
|
368 |
+
public function getDolistExportContactFileHeader()
|
369 |
+
{
|
370 |
+
return $this->_contactHeader;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Return config data for all attribute codes in config file
|
375 |
+
* Load correct row adapter, set default if nothing else specified in config
|
376 |
+
*
|
377 |
+
* @return array of Varien_Object
|
378 |
+
*/
|
379 |
+
public function getContactExportRowAdapterConfig()
|
380 |
+
{
|
381 |
+
|
382 |
+
// Avoid to reload config if already loaded
|
383 |
+
if (is_null($this->_contactExportRowAdapter)) {
|
384 |
+
|
385 |
+
// Load data from config.xml
|
386 |
+
$configAttributes = Mage::getConfig()->getNode('dolistparams/contact_export_row_adapter')->asArray();
|
387 |
+
|
388 |
+
foreach ($configAttributes as $k => $val) {
|
389 |
+
|
390 |
+
// Use a Varien_Object, more handleable than array
|
391 |
+
$config = new Varien_Object($val);
|
392 |
+
|
393 |
+
if (is_null($config->getAdapter())) {
|
394 |
+
// Default adapter
|
395 |
+
$config->setAdapter('dolist/dolistv8_export_adapter_default');
|
396 |
+
}
|
397 |
+
|
398 |
+
// Set adapter
|
399 |
+
$adapter = Mage::getResourceModel($config->getAdapter());
|
400 |
+
|
401 |
+
// Check if adapter exists
|
402 |
+
if ($adapter === false) {
|
403 |
+
Mage::throwException('Adapter ' . $config->getAdapter() . ' does not exist.');
|
404 |
+
} else {
|
405 |
+
$config->setAdapter($adapter);
|
406 |
+
}
|
407 |
+
|
408 |
+
$configAttributes[$k] = $config;
|
409 |
+
}
|
410 |
+
|
411 |
+
$this->_contactExportRowAdapter = $configAttributes;
|
412 |
+
}
|
413 |
+
|
414 |
+
return $this->_contactExportRowAdapter;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Return config data for given $attributeCode
|
419 |
+
*
|
420 |
+
* @param string $attributeCode Attribute code
|
421 |
+
*
|
422 |
+
* @return Varien_Object
|
423 |
+
*/
|
424 |
+
public function getContactExportRowAdapter($attributeCode)
|
425 |
+
{
|
426 |
+
$config = $this->_getContactExportRowAdapterConfig();
|
427 |
+
|
428 |
+
// Throw exception if attribute code is not in config file
|
429 |
+
if (!(array_key_exists($attributeCode, $config))) {
|
430 |
+
Mage::throwException('Attribute code ' . $attributeCode . ' does not exist in config file');
|
431 |
+
}
|
432 |
+
|
433 |
+
return $config[$attributeCode];
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Retrieve default contact export row adapter
|
438 |
+
*
|
439 |
+
* @return mixed
|
440 |
+
*/
|
441 |
+
public function getDefaultContactExportRowAdapter()
|
442 |
+
{
|
443 |
+
return Mage::getResourceModel('dolist/dolistv8_export_adapter_default');
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Return Dolist-V8 enabled website ids with distinct Dolist-V8 AccountID
|
448 |
+
* Avoid several sends to same account
|
449 |
+
* In return array structure, key is config website id, and value is an array containing
|
450 |
+
* website ids with same Dolist-V8 config, ie same AccountID
|
451 |
+
*
|
452 |
+
* @param array $websiteIds Dolist-V8 enabled website ids
|
453 |
+
*
|
454 |
+
* @return array
|
455 |
+
*/
|
456 |
+
public function filterDistinctEnabledWebsites($websiteIds)
|
457 |
+
{
|
458 |
+
$filteredWebsiteIds = array();
|
459 |
+
|
460 |
+
if (!is_array($websiteIds)) {
|
461 |
+
$websiteIds = array($websiteIds);
|
462 |
+
}
|
463 |
+
asort($websiteIds);
|
464 |
+
|
465 |
+
foreach ($websiteIds as $websiteId) {
|
466 |
+
|
467 |
+
$accountId = Mage::getStoreConfig(
|
468 |
+
Dolist_Net_Model_Service::XML_DOLIST_V8_ACCOUNTID,
|
469 |
+
Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId()
|
470 |
+
);
|
471 |
+
$sameIdWebsiteList = array();
|
472 |
+
|
473 |
+
// Only if Dolist-V8 is enabled on this scope
|
474 |
+
if ($this->isDolistV8Enabled(Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId())) {
|
475 |
+
|
476 |
+
// Loop again on website ids to group items with same AccountID
|
477 |
+
foreach ($websiteIds as $websiteId2) {
|
478 |
+
$accountId2 = Mage::getStoreConfig(
|
479 |
+
Dolist_Net_Model_Service::XML_DOLIST_V8_ACCOUNTID,
|
480 |
+
Mage::app()->getWebsite($websiteId2)->getDefaultStore()->getId()
|
481 |
+
);
|
482 |
+
|
483 |
+
if (
|
484 |
+
$this->isDolistV8Enabled(Mage::app()->getWebsite($websiteId2)->getDefaultStore()->getId()) &&
|
485 |
+
$accountId == $accountId2
|
486 |
+
) {
|
487 |
+
$sameIdWebsiteList[] = $websiteId2;
|
488 |
+
}
|
489 |
+
|
490 |
+
}
|
491 |
+
$filteredWebsiteIds[$websiteId] = $sameIdWebsiteList;
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
$filteredList = $this->objectUnique($filteredWebsiteIds);
|
496 |
+
return $filteredList;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Return unique values for given array
|
501 |
+
* array_unique cannot compare arrays, this function can
|
502 |
+
*
|
503 |
+
* @param array $array Array to filter
|
504 |
+
*
|
505 |
+
* @return array Filtered array
|
506 |
+
*/
|
507 |
+
public function objectUnique($array)
|
508 |
+
{
|
509 |
+
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
|
510 |
+
foreach ($result as $key => $value) {
|
511 |
+
if (is_array($value)) {
|
512 |
+
$result[$key] = $this->objectUnique($value);
|
513 |
+
}
|
514 |
+
}
|
515 |
+
return $result;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Retrieve pagination to perform Dolist-V8 full or differential export on
|
520 |
+
*
|
521 |
+
* @param string $scope Export scope. Can be full or differential
|
522 |
+
*
|
523 |
+
* @return int starting row to perform Dolist-V8 full or differential export on
|
524 |
+
*/
|
525 |
+
public function getExportPaginationStart($scope, $storeId)
|
526 |
+
{
|
527 |
+
$flagCode = 'dolist_' . $scope . '_store_' . $storeId . '_pagination_start';
|
528 |
+
$storeList = array();
|
529 |
+
|
530 |
+
// First, try to retrieve object
|
531 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
532 |
+
|
533 |
+
if ($flag->getId() != null) {
|
534 |
+
$start = $flag->getFlagData();
|
535 |
+
} else {
|
536 |
+
$this->addExportPaginationStart($scope, 1, $storeId);
|
537 |
+
$start = 1;
|
538 |
+
}
|
539 |
+
|
540 |
+
return $start;
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Change pagination starting point to export
|
545 |
+
*
|
546 |
+
* @param string $scope Export scope. Can be full or differential
|
547 |
+
* @param int $start Page id
|
548 |
+
*
|
549 |
+
*/
|
550 |
+
public function addExportPaginationStart($scope, $start, $storeId)
|
551 |
+
{
|
552 |
+
$flagCode = 'dolist_' . $scope . '_store_' . $storeId . '_pagination_start';
|
553 |
+
|
554 |
+
// First, try to retrieve object
|
555 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
556 |
+
if ($flag->getId() == null) {
|
557 |
+
// Instanciate new object
|
558 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
559 |
+
$flag->save();
|
560 |
+
}
|
561 |
+
|
562 |
+
$flag->setFlagData($start)
|
563 |
+
->save();
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* @param $total
|
568 |
+
* @param $scope
|
569 |
+
* @param $storeId
|
570 |
+
* @return mixed
|
571 |
+
*/
|
572 |
+
public function setExportTotalCount($total, $scope, $storeId)
|
573 |
+
{
|
574 |
+
$flagCode = 'dolist_' . $scope . '_store_' . $storeId . '_total_count';
|
575 |
+
|
576 |
+
// First, try to retrieve object
|
577 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
578 |
+
if ($flag->getId() == null) {
|
579 |
+
// Instanciate new object
|
580 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
581 |
+
$flag->save();
|
582 |
+
}
|
583 |
+
|
584 |
+
$flag->setFlagData($total)
|
585 |
+
->save();
|
586 |
+
return $total;
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* @param $scope
|
591 |
+
* @param $storeId
|
592 |
+
* @return mixed
|
593 |
+
*/
|
594 |
+
public function getExportTotalCount($scope, $storeId)
|
595 |
+
{
|
596 |
+
$flagCode = 'dolist_' . $scope . '_store_' . $storeId . '_total_count';
|
597 |
+
|
598 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
599 |
+
|
600 |
+
if ($flag->getId() != null) {
|
601 |
+
return $flag->getFlagData();
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
public function reScheduleDolistTask($scope, $storeId)
|
606 |
+
{
|
607 |
+
// Flag on current store id to be exported
|
608 |
+
$this->addExportStoreId($scope, $storeId);
|
609 |
+
|
610 |
+
$jobCode = 'dolist_' . $scope;
|
611 |
+
|
612 |
+
// Check if this job is not already scheduled
|
613 |
+
$scheduleCollection = Mage::getSingleton('cron/schedule')->getCollection()
|
614 |
+
->addFieldToFilter('job_code', array('eq' => $jobCode))
|
615 |
+
->addFieldToFilter('executed_at', array('null' => true))
|
616 |
+
->addFieldToFilter(
|
617 |
+
'status',
|
618 |
+
array(
|
619 |
+
'in' => array(
|
620 |
+
Mage_Cron_Model_Schedule::STATUS_PENDING
|
621 |
+
)
|
622 |
+
)
|
623 |
+
);
|
624 |
+
|
625 |
+
if ($scheduleCollection->getSize() == 0) {
|
626 |
+
|
627 |
+
// Schedule a new task only if another one is not already pending
|
628 |
+
$schedule = Mage::getModel('cron/schedule');
|
629 |
+
|
630 |
+
$schedule->setJobCode($jobCode)
|
631 |
+
->setCreatedAt(now())
|
632 |
+
->setScheduledAt(now())
|
633 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
634 |
+
->save();
|
635 |
+
}
|
636 |
+
}
|
637 |
+
|
638 |
+
/**
|
639 |
+
* Retrieve store list to perform Dolist-V8 full or differential export on
|
640 |
+
*
|
641 |
+
* @param string $scope Export scope. Can be full or differential
|
642 |
+
*
|
643 |
+
* @return array Store to perform Dolist-V8 full or differential export on
|
644 |
+
*/
|
645 |
+
public function getExportStoreIds($scope)
|
646 |
+
{
|
647 |
+
$flagCode = 'dolist_' . $scope . '_export_store_list';
|
648 |
+
$storeList = array();
|
649 |
+
|
650 |
+
// First, try to retrieve object
|
651 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
652 |
+
|
653 |
+
if ($flag->getId() != null) {
|
654 |
+
$storeList = $flag->getFlagData();
|
655 |
+
}
|
656 |
+
|
657 |
+
return $storeList;
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Add store ID to export store list
|
662 |
+
*
|
663 |
+
* @param string $scope Export scope. Can be full or differential
|
664 |
+
* @param int $storeId Store ID
|
665 |
+
*
|
666 |
+
* @return array Store to perform Dolist-V8 full or differential export on
|
667 |
+
*/
|
668 |
+
public function addExportStoreId($scope, $storeId)
|
669 |
+
{
|
670 |
+
$flagCode = 'dolist_' . $scope . '_export_store_list';
|
671 |
+
|
672 |
+
// First, try to retrieve object
|
673 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
674 |
+
if ($flag->getId() == null) {
|
675 |
+
// Instanciate new object
|
676 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
677 |
+
$flag->save();
|
678 |
+
}
|
679 |
+
|
680 |
+
$storeList = $flag->getFlagData();
|
681 |
+
|
682 |
+
if (!is_array($storeList)) {
|
683 |
+
$storeList = array($storeId);
|
684 |
+
} else if (array_search($storeId, $storeList) === false) {
|
685 |
+
// Add segmentId if not found
|
686 |
+
$storeList[] = $storeId;
|
687 |
+
}
|
688 |
+
|
689 |
+
// To avoid duplicate data
|
690 |
+
if (is_array($storeList)) {
|
691 |
+
$storeList = array_unique($storeList);
|
692 |
+
}
|
693 |
+
|
694 |
+
$flag->setFlagData($storeList)
|
695 |
+
->save();
|
696 |
+
}
|
697 |
+
|
698 |
+
/**
|
699 |
+
* Remove store ID from export store list
|
700 |
+
*
|
701 |
+
* @param string $scope Export scope. Can be full or differential
|
702 |
+
* @param int $storeId Store ID
|
703 |
+
*
|
704 |
+
* @return array Store to perform Dolist-V8 full or differential export on
|
705 |
+
*/
|
706 |
+
public function removeExportStoreId($scope, $storeId)
|
707 |
+
{
|
708 |
+
$flagCode = 'dolist_' . $scope . '_export_store_list';
|
709 |
+
|
710 |
+
// First, try to retrieve object
|
711 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
712 |
+
|
713 |
+
// Nothing to do if flag does not exist
|
714 |
+
if ($flag->getId() != null) {
|
715 |
+
$storeList = $flag->getFlagData();
|
716 |
+
|
717 |
+
if (
|
718 |
+
is_array($storeList) &&
|
719 |
+
array_search($storeId, $storeList) !== false
|
720 |
+
) {
|
721 |
+
unset($storeList[array_search($storeId, $storeList)]);
|
722 |
+
}
|
723 |
+
|
724 |
+
// To avoid duplicate data
|
725 |
+
if (is_array($storeList)) {
|
726 |
+
$storeList = array_unique($storeList);
|
727 |
+
}
|
728 |
+
|
729 |
+
$flag->setFlagData($storeList)
|
730 |
+
->save();
|
731 |
+
}
|
732 |
+
}
|
733 |
+
|
734 |
+
/**
|
735 |
+
* Log errors in custom logfile (dolist.log)
|
736 |
+
*
|
737 |
+
* @param string $message Log message
|
738 |
+
*
|
739 |
+
* @return void
|
740 |
+
*/
|
741 |
+
public function logDebug($message)
|
742 |
+
{
|
743 |
+
Mage::log($message, Zend_Log::DEBUG, self::LOGFILE);
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Log errors in custom logfile (dolist.log)
|
748 |
+
*
|
749 |
+
* @param string $message Log message
|
750 |
+
*
|
751 |
+
* @return void
|
752 |
+
*/
|
753 |
+
public function logError($message)
|
754 |
+
{
|
755 |
+
Mage::log($message, Zend_Log::ERR, self::LOGFILE);
|
756 |
+
}
|
757 |
+
|
758 |
+
|
759 |
+
/**
|
760 |
+
* @param $scope
|
761 |
+
* @param $storeId
|
762 |
+
* @return int
|
763 |
+
*/
|
764 |
+
public function createReport($scope, $storeId)
|
765 |
+
{
|
766 |
+
$flagCode = 'dolist_' . $scope . '_store_' . $storeId . '_report';
|
767 |
+
|
768 |
+
// First, try to retrieve object
|
769 |
+
/** @var Mage_Core_Model_Flag $flag */
|
770 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
771 |
+
if ($flag->getId() == null) {
|
772 |
+
// Instanciate new object
|
773 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
774 |
+
$flag->save();
|
775 |
+
}
|
776 |
+
|
777 |
+
$store = Mage::app()->getStore($storeId);
|
778 |
+
|
779 |
+
/** @var Dolist_Net_Model_Reports $report */
|
780 |
+
$report = Mage::getModel('dolist/reports');
|
781 |
+
$report->setData(array(
|
782 |
+
'type' => 'export',
|
783 |
+
'name' => Mage::helper('dolist')->__(($scope == 'full_export') ? 'Full Export' : 'Differential Export') . ' (' . $store->getWebsite()->getName() . '-' . $store->getName() . ')'
|
784 |
+
));
|
785 |
+
$report->save();
|
786 |
+
|
787 |
+
Mage::log('create flag report : ' . $report->getId());
|
788 |
+
// fix report id for the next export dolist
|
789 |
+
$flag->setFlagData((int)$report->getId())->save();
|
790 |
+
return (int)$report->getId();
|
791 |
+
}
|
792 |
+
|
793 |
+
public function getCurrentReportId($scope, $storeId)
|
794 |
+
{
|
795 |
+
if ($storeId == 0) {
|
796 |
+
$storeId = Mage::app()->getDefaultStoreView();
|
797 |
+
}
|
798 |
+
|
799 |
+
// Look for last export report
|
800 |
+
$flagCode = 'dolist_' . $scope . '_store_' . $storeId . '_report';
|
801 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))
|
802 |
+
->load($flagCode, 'flag_code');
|
803 |
+
|
804 |
+
return $flag->getFlagData();
|
805 |
+
}
|
806 |
+
}
|
app/code/community/Dolist/Net/Helper/Log.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist Helper
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Helper_Log extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
const LOGFILE = 'dolist.log';
|
13 |
+
/**
|
14 |
+
* Log web service error
|
15 |
+
*
|
16 |
+
* @param Varien_Object $request Contain request
|
17 |
+
* @param SoapFault $fault Web service exception response
|
18 |
+
* @param string $method Web service method
|
19 |
+
* @param string $additionalInfo Additional info for logs
|
20 |
+
*
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
public function logError($request, $fault, $method, $additionalInfo='')
|
24 |
+
{
|
25 |
+
Mage::log(
|
26 |
+
$method . ' call to Dolist web service failed',
|
27 |
+
Zend_Log::INFO,
|
28 |
+
self::LOGFILE
|
29 |
+
);
|
30 |
+
Mage::log(
|
31 |
+
'REQUEST',
|
32 |
+
Zend_Log::INFO,
|
33 |
+
self::LOGFILE
|
34 |
+
);
|
35 |
+
Mage::log(
|
36 |
+
(array)$request,
|
37 |
+
Zend_Log::INFO,
|
38 |
+
self::LOGFILE
|
39 |
+
);
|
40 |
+
Mage::log(
|
41 |
+
'RESPONSE',
|
42 |
+
Zend_Log::INFO,
|
43 |
+
self::LOGFILE
|
44 |
+
);
|
45 |
+
|
46 |
+
// Store fault detail in session to use it in controllers and/or in templates
|
47 |
+
$fault = (array)$fault;
|
48 |
+
if (array_key_exists('detail', $fault)) {
|
49 |
+
$detailFault = (array)$fault['detail'];
|
50 |
+
|
51 |
+
Mage::log(
|
52 |
+
$detailFault,
|
53 |
+
Zend_Log::INFO,
|
54 |
+
self::LOGFILE
|
55 |
+
);
|
56 |
+
|
57 |
+
if (array_key_exists('ServiceException', $detailFault)) {
|
58 |
+
Mage::getSingleton('core/session')->setLastDolistFaultDetail((array)$detailFault['ServiceException']);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($additionalInfo != '') {
|
63 |
+
Mage::log(
|
64 |
+
(string)$additionalInfo,
|
65 |
+
Zend_Log::INFO,
|
66 |
+
self::LOGFILE
|
67 |
+
);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Dolist/Net/Helper/Queue.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist Helper
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Helper_Queue extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
const TEMPORARY_ERRORS_XML_KEY = 'dolistparams/temporary_errors';
|
13 |
+
const LIMITREACHED_ERRORS_XML_KEY = 'dolistparams/limitreached_errors';
|
14 |
+
|
15 |
+
protected $_temporaryErrors = null;
|
16 |
+
protected $_limitReachedErrors = null;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Is the template is already queued
|
20 |
+
*
|
21 |
+
* @param int $dolistTemplateId
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
public function isTemplateQueued($dolistTemplateId)
|
25 |
+
{
|
26 |
+
$collection = Mage::getModel('dolist/dolistemt_message_queued')
|
27 |
+
->getCollection()
|
28 |
+
->addFieldToFilter('template_id', $dolistTemplateId);
|
29 |
+
return ($collection->count() > 0);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Store the message to be processed later
|
34 |
+
*
|
35 |
+
* @param int $dolistTemplateId
|
36 |
+
* @param array|string $message
|
37 |
+
* @param int $storeId
|
38 |
+
*/
|
39 |
+
public function queueMessage($dolistTemplateId, $message, $storeId = 0)
|
40 |
+
{
|
41 |
+
if (!is_string($message)) {
|
42 |
+
$message = serialize($message);
|
43 |
+
}
|
44 |
+
Mage::getModel('dolist/dolistemt_message_queued')
|
45 |
+
->load(null)
|
46 |
+
->setTemplateId($dolistTemplateId)
|
47 |
+
->setSerializedMessage($message)
|
48 |
+
->setStoreId($storeId)
|
49 |
+
->save();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* test if the SaopFault is a "template sending limit reached" one
|
54 |
+
*
|
55 |
+
* @param SoapFault $fault
|
56 |
+
* @return bool
|
57 |
+
*/
|
58 |
+
public function isLimitReachedError(SoapFault $fault)
|
59 |
+
{
|
60 |
+
$faultDetail = $fault->detail;
|
61 |
+
return in_array($faultDetail->ServiceException->ErrorCode, $this->_getLimitReachedErrors());
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* test if the SaopFault is a temporary error (API call can be redo later)
|
66 |
+
*
|
67 |
+
* @param SoapFault $fault
|
68 |
+
* @return bool
|
69 |
+
*/
|
70 |
+
public function isTemporaryError(SoapFault $fault)
|
71 |
+
{
|
72 |
+
$faultDetail = $fault->detail;
|
73 |
+
return in_array($faultDetail->ServiceException->ErrorCode, $this->_getTemporaryErrors());
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* get temporary error labels from config
|
78 |
+
*
|
79 |
+
* return array<string>
|
80 |
+
*/
|
81 |
+
protected function _getTemporaryErrors()
|
82 |
+
{
|
83 |
+
if (is_null($this->_temporaryErrors)) {
|
84 |
+
$config = (string) Mage::getConfig()->getNode(self::TEMPORARY_ERRORS_XML_KEY);
|
85 |
+
$this->_temporaryErrors = explode(',', $config);
|
86 |
+
}
|
87 |
+
return $this->_temporaryErrors;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get "limit reached" error labels from config
|
92 |
+
*
|
93 |
+
* return array<string>
|
94 |
+
*/
|
95 |
+
protected function _getLimitReachedErrors()
|
96 |
+
{
|
97 |
+
if (is_null($this->_limitReachedErrors)) {
|
98 |
+
$config = (string) Mage::getConfig()->getNode(self::LIMITREACHED_ERRORS_XML_KEY);
|
99 |
+
$this->_limitReachedErrors = explode(',', $config);
|
100 |
+
}
|
101 |
+
return $this->_limitReachedErrors;
|
102 |
+
}
|
103 |
+
}
|
app/code/community/Dolist/Net/Model/Adminhtml/Observer.php
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 admin observer
|
4 |
+
* Used to add button in Back Office without massive rewrites
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Adminhtml_Observer
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Add "export this segment" button in admin/customersegment/edit page
|
15 |
+
*
|
16 |
+
* @param Varien_Event $observer Observer
|
17 |
+
*
|
18 |
+
* @return Dolist_Net_Model_Adminhtml_Observer
|
19 |
+
*/
|
20 |
+
public function addCustomerSegmentExportButton($observer)
|
21 |
+
{
|
22 |
+
$segment = $observer->getEvent()->getSegment();
|
23 |
+
if ($segment && $segment->getId()) {
|
24 |
+
|
25 |
+
$segmentWebsiteIds = $segment->getWebsiteIds();
|
26 |
+
// Replace segment website ids with segment website default store view ids
|
27 |
+
$segmentStoreIds = array();
|
28 |
+
foreach ($segmentWebsiteIds as $segmentWebsiteId) {
|
29 |
+
$website = Mage::app()->getWebsite($segmentWebsiteId);
|
30 |
+
$segmentStoreIds[$segmentWebsiteId] = $website->getDefaultStore()->getId();
|
31 |
+
}
|
32 |
+
|
33 |
+
$enabledStoreIds = array();
|
34 |
+
foreach ($segmentStoreIds as $segmentWebsiteId => $segmentStoreId) {
|
35 |
+
if ($this->_getHelper()->isDolistV8Enabled($segmentStoreId)) {
|
36 |
+
$enabledStoreIds[$segmentWebsiteId] = $segmentStoreId;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
// If this segment is Dolist-V8 enabled for at least one store from its scope
|
41 |
+
if (!empty($enabledStoreIds)) {
|
42 |
+
$block = $observer->getEvent()->getBlock();
|
43 |
+
|
44 |
+
$url = '*/customerdolist/exportSegment';
|
45 |
+
$removeUrl = '*/customerdolist/removeSegment';
|
46 |
+
$urlParams = array(
|
47 |
+
'segment_id' => $segment->getId(),
|
48 |
+
'website_ids' => serialize(array_keys($enabledStoreIds)), // Dolist-V8 enabled websites
|
49 |
+
'store_ids' => serialize($enabledStoreIds),
|
50 |
+
);
|
51 |
+
|
52 |
+
// If this segment is not already exported
|
53 |
+
if (!$this->_getHelper()->isExportedSegment($segment->getId(), $enabledStoreIds)) {
|
54 |
+
|
55 |
+
// Newline
|
56 |
+
$block->addButton(
|
57 |
+
'dolistv8_newline',
|
58 |
+
array(
|
59 |
+
'class' => '',
|
60 |
+
'label' => '',
|
61 |
+
'onclick' => '',
|
62 |
+
'style' => 'display:block; visibility: hidden;',
|
63 |
+
),
|
64 |
+
3
|
65 |
+
);
|
66 |
+
|
67 |
+
$block->addButton(
|
68 |
+
'dolistv8_export',
|
69 |
+
array(
|
70 |
+
'class' => 'add',
|
71 |
+
'label' => Mage::helper('dolist')->__('Export this segment to Dolist-V8'),
|
72 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($url, $urlParams) . '\')',
|
73 |
+
),
|
74 |
+
4
|
75 |
+
);
|
76 |
+
} else {
|
77 |
+
|
78 |
+
// Newline
|
79 |
+
$block->addButton(
|
80 |
+
'dolistv8_newline',
|
81 |
+
array(
|
82 |
+
'class' => '',
|
83 |
+
'label' => '',
|
84 |
+
'onclick' => '',
|
85 |
+
'style' => 'display:block; visibility: hidden;',
|
86 |
+
),
|
87 |
+
3
|
88 |
+
);
|
89 |
+
|
90 |
+
// Else, propose to export it again (just one segment export)
|
91 |
+
$block->addButton(
|
92 |
+
'dolistv8_export',
|
93 |
+
array(
|
94 |
+
'class' => 'add',
|
95 |
+
'label' => Mage::helper('dolist')->__('Export again this segment to Dolist-V8'),
|
96 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($url, $urlParams) . '\')',
|
97 |
+
),
|
98 |
+
4
|
99 |
+
);
|
100 |
+
|
101 |
+
// Add new button to remove this segment from export list dolist_exported_segment_list
|
102 |
+
$block->addButton(
|
103 |
+
'dolistv8_remove_export',
|
104 |
+
array(
|
105 |
+
'class' => 'add',
|
106 |
+
'label' => Mage::helper('dolist')->__('Remove this segment from exported list'),
|
107 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($removeUrl, $urlParams) . '\')',
|
108 |
+
),
|
109 |
+
5
|
110 |
+
);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Add warning in back-office when customer edition if this customer gets invalid dolist_status
|
119 |
+
* in newsletter_subscriber table
|
120 |
+
*
|
121 |
+
* @param Varien_Event $observer Observer
|
122 |
+
*
|
123 |
+
* @return Dolist_Net_Model_Adminhtml_Observer
|
124 |
+
*/
|
125 |
+
public function warnCustomerDolistStatus($observer)
|
126 |
+
{
|
127 |
+
$customerId = $observer->getEvent()->getCustomerId();
|
128 |
+
if ($customerId) {
|
129 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->load($customerId, 'customer_id');
|
130 |
+
|
131 |
+
if ($subscriber->getId()) {
|
132 |
+
$errorMessage = $this->_getHelper()->getDolistStatusErrorMessage($subscriber->getDolistStatus(), 'back');
|
133 |
+
|
134 |
+
if (!is_null($errorMessage)) {
|
135 |
+
Mage::getSingleton('adminhtml/session')->addNotice($this->_getHelper()->__($errorMessage));
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Clean up exported segment list
|
145 |
+
* While saving customer segment, check if current segment must be removed from exported segment list
|
146 |
+
*
|
147 |
+
* @param Varien_Event $observer Observer
|
148 |
+
*
|
149 |
+
* @return Dolist_Net_Model_Adminhtml_Observer
|
150 |
+
*/
|
151 |
+
public function checkCustomerSegmentSave($observer)
|
152 |
+
{
|
153 |
+
$segment = $observer->getEvent()->getObject();
|
154 |
+
$allStoreIds = array_keys(Mage::app()->getStores());
|
155 |
+
$segmentStoreIds = array();
|
156 |
+
foreach ($segment->getWebsiteIds() as $websiteId) {
|
157 |
+
$segmentStoreIds[] = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
|
158 |
+
}
|
159 |
+
|
160 |
+
// Remove exported segment from stores where segment is not applied to
|
161 |
+
foreach (array_diff($allStoreIds, $segmentStoreIds) as $storeId) {
|
162 |
+
$this->_getHelper()->removeExportedSegment($segment->getId(), $storeId);
|
163 |
+
}
|
164 |
+
|
165 |
+
return $this;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Retrieve model helper
|
170 |
+
*
|
171 |
+
* @return Dolist_Net_Helper_Data
|
172 |
+
*/
|
173 |
+
protected function _getHelper()
|
174 |
+
{
|
175 |
+
return Mage::helper('dolist');
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* remove all dolist Flags (filenames, last exports, etc.) if the section params has changed
|
180 |
+
*
|
181 |
+
* @param Varien_Event $observer
|
182 |
+
*
|
183 |
+
* @return Dolist_Net_Model_Adminhtml_Observer
|
184 |
+
*/
|
185 |
+
public function removeDolistFlags($observer)
|
186 |
+
{
|
187 |
+
// DIRTY but the flag has no collection
|
188 |
+
$resource = Mage::getSingleton('core/resource');
|
189 |
+
$write = $resource->getConnection('core_write');
|
190 |
+
/* @var $write Varien_Db_Adapter_Pdo_Mysql */
|
191 |
+
$tablename = $resource->getTableName('core_flag');
|
192 |
+
$write->query('delete from ' . $tablename . ' where flag_code like "dolist%"');
|
193 |
+
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
}
|
app/code/community/Dolist/Net/Model/Adminhtml/System/Config/Backend/Serialized/Array.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Validate Dolist module system configuration
|
4 |
+
* Used to add button in Back Office without massive rewrites
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Adminhtml_System_Config_Backend_Serialized_Array extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Validate configuration
|
15 |
+
*
|
16 |
+
* @return Dolist_Net_Model_System_Config_Check
|
17 |
+
* @throws Mage_Core_Exception
|
18 |
+
*/
|
19 |
+
protected function _beforeSave()
|
20 |
+
{
|
21 |
+
// Retrieve data set by admin user
|
22 |
+
$configData = $this->getData();
|
23 |
+
$groupValue = null;
|
24 |
+
$customStrFieldsValues = null;
|
25 |
+
$customIntFieldsValues = null;
|
26 |
+
$customDateFieldsValues = null;
|
27 |
+
|
28 |
+
$storeConfig = Mage::getStoreConfig('dolist/dolist_v8', $configData['scope_id']);
|
29 |
+
|
30 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['group'])) {
|
31 |
+
$groupValue = $storeConfig['group'];
|
32 |
+
} else {
|
33 |
+
$groupValue = $configData['groups']['dolist_v8']['fields']['group']['value'];
|
34 |
+
}
|
35 |
+
|
36 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['custom_str_fields'])) {
|
37 |
+
$customStrFieldsValues = unserialize($storeConfig['custom_str_fields']);
|
38 |
+
} else {
|
39 |
+
$customStrFieldsValues = $configData['groups']['dolist_v8']['fields']['custom_str_fields']['value'];
|
40 |
+
}
|
41 |
+
|
42 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['custom_int_fields'])) {
|
43 |
+
$customIntFieldsValues = unserialize($storeConfig['custom_int_fields']);
|
44 |
+
} else {
|
45 |
+
$customIntFieldsValues = $configData['groups']['dolist_v8']['fields']['custom_int_fields']['value'];
|
46 |
+
}
|
47 |
+
|
48 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['custom_date_fields'])) {
|
49 |
+
$customDateFieldsValues = unserialize($storeConfig['custom_date_fields']);
|
50 |
+
} else {
|
51 |
+
$customDateFieldsValues = $configData['groups']['dolist_v8']['fields']['custom_date_fields']['value'];
|
52 |
+
}
|
53 |
+
|
54 |
+
$integrityError = false;
|
55 |
+
$setCustomStrFields = array();
|
56 |
+
$setCustomIntFields = array();
|
57 |
+
$setCustomDateFields = array();
|
58 |
+
|
59 |
+
$setCustomStrFields[] = $groupValue;
|
60 |
+
foreach ($customStrFieldsValues as $customStrFieldsValue) {
|
61 |
+
|
62 |
+
// If data already found, cannot be used twice, so throw error
|
63 |
+
if (is_array($customStrFieldsValue)) {
|
64 |
+
if (in_array($customStrFieldsValue['dolist_custom_str_fields'], $setCustomStrFields)) {
|
65 |
+
$integrityError = true;
|
66 |
+
break;
|
67 |
+
} else {
|
68 |
+
// Add data in array
|
69 |
+
$setCustomStrFields[] = $customStrFieldsValue['dolist_custom_str_fields'];
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
if (!$integrityError) {
|
75 |
+
foreach ($customIntFieldsValues as $customIntFieldsValue) {
|
76 |
+
|
77 |
+
// If data already found, cannot be used twice, so throw error
|
78 |
+
if (is_array($customIntFieldsValue)) {
|
79 |
+
if (in_array($customIntFieldsValue['dolist_custom_int_fields'], $setCustomIntFields)) {
|
80 |
+
$integrityError = true;
|
81 |
+
break;
|
82 |
+
} else {
|
83 |
+
// Add data in array
|
84 |
+
$setCustomIntFields[] = $customIntFieldsValue['dolist_custom_int_fields'];
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
if (!$integrityError) {
|
90 |
+
foreach ($customDateFieldsValues as $customDateFieldsValue) {
|
91 |
+
|
92 |
+
// If data already found, cannot be used twice, so throw error
|
93 |
+
if (is_array($customDateFieldsValue)) {
|
94 |
+
if (in_array($customDateFieldsValue['dolist_custom_date_fields'], $setCustomDateFields)) {
|
95 |
+
$integrityError = true;
|
96 |
+
break;
|
97 |
+
} else {
|
98 |
+
// Add data in array
|
99 |
+
$setCustomDateFields[] = $customDateFieldsValue['dolist_custom_date_fields'];
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
// Display error message if integrity error
|
107 |
+
if ($integrityError) {
|
108 |
+
Mage::throwException(
|
109 |
+
Mage::helper('dolist')
|
110 |
+
->__(
|
111 |
+
'Double check that group, custom str fields, custom int field and ' .
|
112 |
+
'custom date fields do not share same value.'
|
113 |
+
)
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
parent::_beforeSave();
|
118 |
+
}
|
119 |
+
}
|
app/code/community/Dolist/Net/Model/Adminhtml/System/Config/Source/Timeperiods.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Adminhtml_System_Config_Source_Timeperiods
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
array(
|
9 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::FULL,
|
10 |
+
'label' => Mage::helper('dolist')->__('All datas'),
|
11 |
+
),
|
12 |
+
array(
|
13 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::BEGIN_DATE,
|
14 |
+
'label' => Mage::helper('dolist')->__('From a specified start date'),
|
15 |
+
),
|
16 |
+
array(
|
17 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_1,
|
18 |
+
'label' => Mage::helper('dolist')->__('Data since 1 month'),
|
19 |
+
),
|
20 |
+
array(
|
21 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_3,
|
22 |
+
'label' => Mage::helper('dolist')->__('Data since 3 months'),
|
23 |
+
),
|
24 |
+
array(
|
25 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_6,
|
26 |
+
'label' => Mage::helper('dolist')->__('Data since 6 months'),
|
27 |
+
),
|
28 |
+
array(
|
29 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_12,
|
30 |
+
'label' => Mage::helper('dolist')->__('Data since 12 months'),
|
31 |
+
),
|
32 |
+
array(
|
33 |
+
'value' => \Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_24,
|
34 |
+
'label' => Mage::helper('dolist')->__('Data since 24 months'),
|
35 |
+
),
|
36 |
+
|
37 |
+
);
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Dolist/Net/Model/Customersegment.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Rewrite enterprise customer segment model only to add event prefix, then to plug observer
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Customersegment extends Enterprise_CustomerSegment_Model_Segment
|
11 |
+
{
|
12 |
+
protected $_eventPrefix = 'customersegment_segment';
|
13 |
+
}
|
app/code/community/Dolist/Net/Model/Dolistemt/Email/Template.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Rewrite Magento native email model template to send mail using Dolist-EMT webservice instead of default mail server
|
4 |
+
* Only "send" method is modified
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Dolistemt_Email_Template extends Mage_Core_Model_Email_Template
|
12 |
+
{
|
13 |
+
const XML_DOLIST_EMT_DEFAULT_TEMPLATE = 'dolist/dolist_emt/default_template';
|
14 |
+
const XML_DOLIST_EMT_TEMPLATE_MAPPING = 'dolist/dolist_emt/template_mapping';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Send mail to recipient
|
18 |
+
*
|
19 |
+
* @param array|string $email E-mail(s)
|
20 |
+
* @param array|string|null $name receiver name(s)
|
21 |
+
* @param array $variables template variables
|
22 |
+
*
|
23 |
+
* @return boolean
|
24 |
+
**/
|
25 |
+
public function send($email, $name = null, array $variables = array())
|
26 |
+
{
|
27 |
+
// To know scope of this send => use correct Dolist-EMT configuration scope
|
28 |
+
$storeId = $this->getDesignConfig()->getStore();
|
29 |
+
|
30 |
+
// Use native method if service is not enabled
|
31 |
+
if (!Mage::helper('dolist')->isDolistEmtEnabled($storeId)) {
|
32 |
+
return parent::send($email, $name, $variables);
|
33 |
+
}
|
34 |
+
|
35 |
+
if (!$this->isValidForSend()) {
|
36 |
+
Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
|
40 |
+
$emails = array_values((array)$email);
|
41 |
+
$names = is_array($name) ? $name : (array)$name;
|
42 |
+
$names = array_values($names);
|
43 |
+
foreach ($emails as $key => $email) {
|
44 |
+
if (!isset($names[$key])) {
|
45 |
+
$names[$key] = substr($email, 0, strpos($email, '@'));
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
$variables['email'] = reset($emails);
|
50 |
+
$variables['name'] = reset($names);
|
51 |
+
|
52 |
+
$setReturnPath = Mage::getStoreConfig(self::XML_PATH_SENDING_SET_RETURN_PATH);
|
53 |
+
switch ($setReturnPath) {
|
54 |
+
case 1:
|
55 |
+
$returnPathEmail = $this->getSenderEmail();
|
56 |
+
break;
|
57 |
+
case 2:
|
58 |
+
$returnPathEmail = Mage::getStoreConfig(self::XML_PATH_SENDING_RETURN_PATH_EMAIL);
|
59 |
+
break;
|
60 |
+
default:
|
61 |
+
$returnPathEmail = null;
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
|
65 |
+
$this->setUseAbsoluteLinks(true);
|
66 |
+
$text = $this->getProcessedTemplate($variables, true);
|
67 |
+
$senderEmail = $this->getSenderEmail();
|
68 |
+
$senderName = $this->getSenderName();
|
69 |
+
$magentoTemplateId = $this->getTemplateId();
|
70 |
+
$templateId = $this->_getDolistEmtTemplateId($magentoTemplateId);
|
71 |
+
|
72 |
+
if((string)$templateId == '-1') {
|
73 |
+
// EMT is disabled for this template
|
74 |
+
return parent::send($email, $name, $variables);
|
75 |
+
}
|
76 |
+
|
77 |
+
// Build message
|
78 |
+
$message = $this->_generateSendMessageRequestData(
|
79 |
+
$senderEmail,
|
80 |
+
$senderName,
|
81 |
+
$text, // Email content
|
82 |
+
$returnPathEmail,
|
83 |
+
'',
|
84 |
+
$this->getProcessedTemplateSubject($variables), // Subject
|
85 |
+
$emails, // Recipient
|
86 |
+
$templateId
|
87 |
+
);
|
88 |
+
|
89 |
+
try {
|
90 |
+
/** @var Dolist_Net_Model_Service $service */
|
91 |
+
$service = Mage::getModel('dolist/service');
|
92 |
+
// Send message using webservice
|
93 |
+
$service->dolistEmtSendmail($message, $templateId, $storeId);
|
94 |
+
} catch (Exception $e) {
|
95 |
+
Mage::logException($e);
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Generate Data field in SendMessageRequest Object used in SendMessage method
|
104 |
+
*
|
105 |
+
* @param string $fromMailLeftPart From mail left part
|
106 |
+
* @param string $fromName From name
|
107 |
+
* @param string $text Email content (same used for plain text and html)
|
108 |
+
* @param string $replyToMail Reply to mail
|
109 |
+
* @param string $replyToName Reply to name => currently not implemented by Dolist-EMT webservice
|
110 |
+
* @param string $subject Email subject
|
111 |
+
* @param array $recipients Array of recipients
|
112 |
+
* @param string $templateId Dolist-EMT template ID
|
113 |
+
*
|
114 |
+
* @return string SendMessageRequest Data
|
115 |
+
*/
|
116 |
+
protected function _generateSendMessageRequestData(
|
117 |
+
$fromMailLeftPart, $fromName, $text, $replyToMail, $replyToName, $subject, $recipients, $templateId
|
118 |
+
)
|
119 |
+
{
|
120 |
+
$message = "";
|
121 |
+
|
122 |
+
// Generate message
|
123 |
+
$domTree = new DOMDocument('1.0', 'UTF-8');
|
124 |
+
$rootNode = $domTree->createElement('emtroot');
|
125 |
+
$rootNode = $domTree->appendChild($rootNode);
|
126 |
+
|
127 |
+
$messageNode = $domTree->createElement("MESSAGE");
|
128 |
+
$messageNode = $rootNode->appendChild($messageNode);
|
129 |
+
|
130 |
+
$messageNode->appendChild($domTree->createElement('FROMMAILLEFTPART', $this->_getFromMailLeftPart($fromMailLeftPart)));
|
131 |
+
$messageNode->appendChild($domTree->createElement('FROMNAME', $fromName));
|
132 |
+
|
133 |
+
// HTMLCONTENT
|
134 |
+
$htmlContentNode = $domTree->createElement('HTMLCONTENT');
|
135 |
+
$htmlContentCdata = $domTree->createCDATASection($text);
|
136 |
+
$htmlContentNode->appendChild($htmlContentCdata);
|
137 |
+
$messageNode->appendChild($htmlContentNode);
|
138 |
+
|
139 |
+
$messageNode->appendChild($domTree->createElement('REPLYTOMAIL', $fromMailLeftPart)); // Full address
|
140 |
+
$messageNode->appendChild($domTree->createElement('REPLYTONAME', $fromName));
|
141 |
+
|
142 |
+
// SUBJECT
|
143 |
+
$subjectContentNode = $domTree->createElement('SUBJECT');
|
144 |
+
$subjectContentCdata = $domTree->createCDATASection($subject);
|
145 |
+
$subjectContentNode->appendChild($subjectContentCdata);
|
146 |
+
$messageNode->appendChild($subjectContentNode);
|
147 |
+
|
148 |
+
$message = array(
|
149 |
+
'Data' => $domTree->saveXML(),
|
150 |
+
'MessageContentType' => 'EmailMultipart',
|
151 |
+
'Recipient' => $recipients[0], // Only one recipient is allowed
|
152 |
+
'TemplateID' => $templateId
|
153 |
+
);
|
154 |
+
|
155 |
+
return $message;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Return email truncated after first occurence of '@' character
|
160 |
+
* Permit to use left part to send email from <truncatedemail>@adm.dolist.net
|
161 |
+
*
|
162 |
+
* @param string $email Email
|
163 |
+
*
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
protected function _getFromMailLeftPart($email)
|
167 |
+
{
|
168 |
+
$truncated = $email;
|
169 |
+
$pos = strpos($email, '@');
|
170 |
+
if ($pos != false) {
|
171 |
+
$truncated = substr($email, 0, $pos);
|
172 |
+
}
|
173 |
+
return $truncated;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Return Dolist-EMT template ID to use for given $magentoTemplateId
|
178 |
+
* $magentoTemplateId can be string for default email templates or int for custom email templates (in BO)
|
179 |
+
*
|
180 |
+
* @param string|int $magentoTemplateId Magento email template ID
|
181 |
+
*
|
182 |
+
* @return int Dolist-EMT template id
|
183 |
+
*/
|
184 |
+
protected function _getDolistEmtTemplateId($magentoTemplateId)
|
185 |
+
{
|
186 |
+
// To know scope of this send => use correct Dolist-EMT configuration scope
|
187 |
+
$storeId = $this->getDesignConfig()->getStore();
|
188 |
+
|
189 |
+
// Default template id
|
190 |
+
$dolistEmtTemplateId = Mage::getStoreConfig(self::XML_DOLIST_EMT_DEFAULT_TEMPLATE, $storeId);
|
191 |
+
|
192 |
+
// Build mapping array
|
193 |
+
$templateMapping = array();
|
194 |
+
|
195 |
+
foreach (unserialize(Mage::getStoreConfig(self::XML_DOLIST_EMT_TEMPLATE_MAPPING, $storeId)) as $mapping) {
|
196 |
+
if (array_key_exists('dolist_template', $mapping)) {
|
197 |
+
$templateMapping[$mapping['magento_template']] = $mapping['dolist_template'];
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
// Return specific mapping if found
|
202 |
+
if (array_key_exists($magentoTemplateId, $templateMapping)) {
|
203 |
+
$dolistEmtTemplateId = $templateMapping[$magentoTemplateId];
|
204 |
+
}
|
205 |
+
|
206 |
+
return $dolistEmtTemplateId;
|
207 |
+
}
|
208 |
+
}
|
app/code/community/Dolist/Net/Model/Dolistemt/Message/Queued.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT Message queue model
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Dolistemt_Message_Queued extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
parent::_construct();
|
20 |
+
$this->_init('dolist/dolistemt_message_queued');
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
app/code/community/Dolist/Net/Model/Dolistemt/Template.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT Email template model
|
4 |
+
* Dolist-EMT templates stored in Magento
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Dolistemt_Template extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
$this->_init('dolist/dolistemt_template');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Update stored Dolist-EMT template list if data retrieved from webservice is different
|
26 |
+
*
|
27 |
+
* @param array $templateList Template list retrieved from webservice
|
28 |
+
*
|
29 |
+
* @return bool True if stored template list has been updated
|
30 |
+
*/
|
31 |
+
public function update($templateList)
|
32 |
+
{
|
33 |
+
$templateListUpdated = false;
|
34 |
+
|
35 |
+
// Load stored template list
|
36 |
+
$storedCollection = $this->getCollection();
|
37 |
+
$storedArray = $storedCollection->toArray();
|
38 |
+
|
39 |
+
// Transform collection to match arrays
|
40 |
+
$transformedArray = array();
|
41 |
+
|
42 |
+
// Retrieve stored values if any
|
43 |
+
if ($storedArray['totalRecords'] > 0) {
|
44 |
+
foreach ($storedArray['items'] as $storedTemplate) {
|
45 |
+
$transformedArray[$storedTemplate['template_id']] = $storedTemplate['template_name'];
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
// If template list has been modified on Dolist-EMT account, empty table and insert new values
|
50 |
+
if ($transformedArray != $templateList) {
|
51 |
+
|
52 |
+
// Delete old values
|
53 |
+
foreach ($storedCollection as $storedItem) {
|
54 |
+
$storedItem->delete();
|
55 |
+
}
|
56 |
+
|
57 |
+
// Insert new values
|
58 |
+
foreach ($templateList as $id => $templatename) {
|
59 |
+
// Instanciate new object and save it
|
60 |
+
Mage::getModel('dolist/dolistemt_template')->setTemplateId($id)
|
61 |
+
->setTemplateName($templatename)
|
62 |
+
->save();
|
63 |
+
}
|
64 |
+
|
65 |
+
// Flag modifications need to be shown
|
66 |
+
$templateListUpdated = true;
|
67 |
+
}
|
68 |
+
|
69 |
+
return $templateListUpdated;
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Dolist/Net/Model/Dolistv8/Calculatedfields.php
ADDED
@@ -0,0 +1,698 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstract
|
5 |
+
{
|
6 |
+
|
7 |
+
protected $debug;
|
8 |
+
|
9 |
+
const FULL = 1;
|
10 |
+
const BEGIN_DATE = 2;
|
11 |
+
const RANGE_1 = 3;
|
12 |
+
const RANGE_3 = 4;
|
13 |
+
const RANGE_6 = 5;
|
14 |
+
const RANGE_12 = 6;
|
15 |
+
const RANGE_24 = 7;
|
16 |
+
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
parent::_construct();
|
20 |
+
$this->_init('dolist/dolistv8_calculatedfields');
|
21 |
+
$this->debug = true;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param array $attribute
|
26 |
+
* @return mixed
|
27 |
+
*/
|
28 |
+
public function getColumnValue($attribute)
|
29 |
+
{
|
30 |
+
$config = $this->getConfig();
|
31 |
+
|
32 |
+
$adapter = Mage::getModel($attribute['adapter']);
|
33 |
+
|
34 |
+
return $adapter->getExportedValue($this->getData($config[$attribute['field']]));
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
public function getConfig()
|
39 |
+
{
|
40 |
+
return array(
|
41 |
+
'first_order_amount' => 'first_order_amount',
|
42 |
+
'first_order_amount_with_vat' => 'first_order_amount_with_vat',
|
43 |
+
'last_order_amount' => 'last_order_amount',
|
44 |
+
'last_order_amount_with_vat' => 'last_order_amount_with_vat',
|
45 |
+
'total_orders_amount' => 'total_orders_amount',
|
46 |
+
'total_orders_amount_with_vat' => 'total_orders_amount_with_vat',
|
47 |
+
'average_unique_product_count' => 'average_unique_product_count',
|
48 |
+
'average_product_count_by_command_line' => 'average_product_count_by_command_line',
|
49 |
+
'total_product_count' => 'total_product_count',
|
50 |
+
'total_orders_count' => 'total_orders_count',
|
51 |
+
'last_unordered_cart_amount' => 'last_unordered_cart_amount',
|
52 |
+
'last_unordered_cart_amount_with_vat' => 'last_unordered_cart_amount_with_vat',
|
53 |
+
'discount_rule_count' => 'discount_rule_count',
|
54 |
+
'last_orders_range' => 'last_orders_range',
|
55 |
+
'first_order_date' => 'first_order_date',
|
56 |
+
'last_order_date' => 'last_order_date',
|
57 |
+
'last_unordered_cart_date' => 'last_unordered_cart_date',
|
58 |
+
'avg_order_amount_excl_tax' => 'avg_order_amount_excl_tax',
|
59 |
+
'avg_order_amount_incl_tax' => 'avg_order_amount_incl_tax',
|
60 |
+
'avg_nb_products_per_order' => 'avg_nb_products_per_order',
|
61 |
+
|
62 |
+
);
|
63 |
+
}
|
64 |
+
|
65 |
+
public function isCalculatedFieldConfig($key)
|
66 |
+
{
|
67 |
+
$config = $this->getConfig();
|
68 |
+
|
69 |
+
if (array_key_exists($key, $config)) {
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @param $customerId
|
77 |
+
* @return array
|
78 |
+
*/
|
79 |
+
protected function computeDataTtl($customerId)
|
80 |
+
{
|
81 |
+
/**
|
82 |
+
* FULL : ttl date is null
|
83 |
+
* BEGIN : ttl is from beginDate to currentDate
|
84 |
+
* RANGE_X : ttl is from currentDate - delay to currentDate
|
85 |
+
*/
|
86 |
+
$option = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode');
|
87 |
+
|
88 |
+
|
89 |
+
if (!$option) {
|
90 |
+
$option = 1;
|
91 |
+
}
|
92 |
+
|
93 |
+
$start = null;
|
94 |
+
$stop = null;
|
95 |
+
|
96 |
+
switch ($option) {
|
97 |
+
case self::FULL:
|
98 |
+
break;
|
99 |
+
case self::BEGIN_DATE:
|
100 |
+
$date = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date");
|
101 |
+
$timestamp = strtotime($date);
|
102 |
+
$start = new \DateTime();
|
103 |
+
$start->setTimestamp($timestamp);
|
104 |
+
break;
|
105 |
+
case self::RANGE_1:
|
106 |
+
$delay = 1;
|
107 |
+
$startDate = new \DateTime('-' . $delay . ' months');
|
108 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields $model */
|
109 |
+
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
110 |
+
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
111 |
+
if ($strDate) {
|
112 |
+
$startDate->setTimestamp(strtotime($strDate));
|
113 |
+
$start = $startDate;
|
114 |
+
$stop = new \DateTime();
|
115 |
+
$stop->setTimestamp(strtotime($strDate));
|
116 |
+
$stop->modify('+' . $delay . ' months');
|
117 |
+
}
|
118 |
+
break;
|
119 |
+
case self::RANGE_3:
|
120 |
+
$delay = 3;
|
121 |
+
$startDate = new \DateTime('-' . $delay . ' months');
|
122 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields $model */
|
123 |
+
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
124 |
+
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
125 |
+
if ($strDate) {
|
126 |
+
$startDate->setTimestamp(strtotime($strDate));
|
127 |
+
$start = $startDate;
|
128 |
+
$stop = new \DateTime();
|
129 |
+
$stop->setTimestamp(strtotime($strDate));
|
130 |
+
$stop->modify('+' . $delay . ' months');
|
131 |
+
}
|
132 |
+
break;
|
133 |
+
case self::RANGE_6:
|
134 |
+
$delay = 6;
|
135 |
+
$startDate = new \DateTime('-' . $delay . ' months');
|
136 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields $model */
|
137 |
+
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
138 |
+
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
139 |
+
if ($strDate) {
|
140 |
+
$startDate->setTimestamp(strtotime($strDate));
|
141 |
+
$start = $startDate;
|
142 |
+
$stop = new \DateTime();
|
143 |
+
$stop->setTimestamp(strtotime($strDate));
|
144 |
+
$stop->modify('+' . $delay . ' months');
|
145 |
+
}
|
146 |
+
break;
|
147 |
+
case self::RANGE_12:
|
148 |
+
$delay = 12;
|
149 |
+
$startDate = new \DateTime('-' . $delay . ' months');
|
150 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields $model */
|
151 |
+
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
152 |
+
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
153 |
+
if ($strDate) {
|
154 |
+
$startDate->setTimestamp(strtotime($strDate));
|
155 |
+
$start = $startDate;
|
156 |
+
$stop = new \DateTime();
|
157 |
+
$stop->setTimestamp(strtotime($strDate));
|
158 |
+
$stop->modify('+' . $delay . ' months');
|
159 |
+
}
|
160 |
+
break;
|
161 |
+
case self::RANGE_24:
|
162 |
+
$delay = 24;
|
163 |
+
$startDate = new \DateTime('-' . $delay . ' months');
|
164 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields $model */
|
165 |
+
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
166 |
+
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
167 |
+
if ($strDate) {
|
168 |
+
$startDate->setTimestamp(strtotime($strDate));
|
169 |
+
$start = $startDate;
|
170 |
+
$stop = new \DateTime();
|
171 |
+
$stop->setTimestamp(strtotime($strDate));
|
172 |
+
$stop->modify('+' . $delay . ' months');
|
173 |
+
}
|
174 |
+
break;
|
175 |
+
}
|
176 |
+
|
177 |
+
return array(
|
178 |
+
'start' => $start,
|
179 |
+
'stop' => $stop
|
180 |
+
);
|
181 |
+
}
|
182 |
+
|
183 |
+
public function recompute($customerId)
|
184 |
+
{
|
185 |
+
|
186 |
+
$dates = $this->computeDataTtl($customerId);
|
187 |
+
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode");
|
188 |
+
|
189 |
+
$data = array(
|
190 |
+
'customer_id' => $this->getData('customer_id'),
|
191 |
+
'first_order_amount' => $this->computeFirstOrderAmount($customerId),
|
192 |
+
'first_order_amount_with_vat' => $this->computeFirstOrderAmount($customerId, true),
|
193 |
+
'last_order_amount' => $this->computeLastOrderAmount($customerId),
|
194 |
+
'last_order_amount_with_vat' => $this->computeLastOrderAmount($customerId, true),
|
195 |
+
'total_orders_amount' => $this->computeTotalOrdersAmount($customerId, $dates),
|
196 |
+
'total_orders_amount_with_vat' => $this->computeTotalOrdersAmount($customerId, $dates, true),
|
197 |
+
'average_unique_product_count' => $this->computeAverageUniqueProductCount($customerId, $dates),
|
198 |
+
'average_product_count_by_command_line' => $this->computeAverageProductCountByCommandLine($customerId, $dates),
|
199 |
+
'total_product_count' => $this->computeTotalProductCount($customerId, $dates),
|
200 |
+
'total_orders_count' => $this->computeTotalOrdersCount($customerId, $dates),
|
201 |
+
'last_unordered_cart_amount' => $this->computeLastUnorderedCartAmount($customerId, $dates),
|
202 |
+
'last_unordered_cart_amount_with_vat' => $this->computeLastUnorderedCartAmount($customerId, $dates, true),
|
203 |
+
'discount_rule_count' => $this->computeDiscountRuleCount($customerId, $dates),
|
204 |
+
'first_order_date' => $this->getFirstOrderDate($customerId),
|
205 |
+
'last_order_date' => $this->getLastOrderDate($customerId),
|
206 |
+
'last_unordered_cart_date' => $this->getLastUnorderedCartDate($customerId),
|
207 |
+
'last_orders_range' => $this->getLastTwoOrdersRange($customerId),
|
208 |
+
'config' => $config,
|
209 |
+
'start_date' => ($config == $this::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date") : null,
|
210 |
+
);
|
211 |
+
|
212 |
+
$this->addData($data);
|
213 |
+
|
214 |
+
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
215 |
+
$this->setData('orders_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
216 |
+
}
|
217 |
+
|
218 |
+
$now = new \DateTime();
|
219 |
+
$this->setData('updated_at', $now->format('Y-m-d H:i:s'));
|
220 |
+
|
221 |
+
try {
|
222 |
+
$this->save();
|
223 |
+
} catch (Exception $e) {
|
224 |
+
Mage::logException($e);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
public function compute($customerId)
|
229 |
+
{
|
230 |
+
$dates = $this->computeDataTtl($customerId);
|
231 |
+
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode");
|
232 |
+
$lastOrderDate = $this->getLastOrderDate($customerId, true);
|
233 |
+
// load model
|
234 |
+
$this->load($customerId);
|
235 |
+
|
236 |
+
$now = new \DateTime();
|
237 |
+
$this->addData(array(
|
238 |
+
'customer_id' => $customerId,
|
239 |
+
'first_order_amount' => $this->computeFirstOrderAmount($customerId),
|
240 |
+
'first_order_amount_with_vat' => $this->computeFirstOrderAmount($customerId, true),
|
241 |
+
'last_order_amount' => $this->computeLastOrderAmount($customerId),
|
242 |
+
'last_order_amount_with_vat' => $this->computeLastOrderAmount($customerId, true),
|
243 |
+
'total_orders_amount' => $this->computeTotalOrdersAmount($customerId, $dates),
|
244 |
+
'total_orders_amount_with_vat' => $this->computeTotalOrdersAmount($customerId, $dates, true),
|
245 |
+
'average_unique_product_count' => $this->computeAverageUniqueProductCount($customerId, $dates),
|
246 |
+
'average_product_count_by_command_line' => $this->computeAverageProductCountByCommandLine($customerId, $dates),
|
247 |
+
'total_product_count' => $this->computeTotalProductCount($customerId, $dates),
|
248 |
+
'total_orders_count' => $this->computeTotalOrdersCount($customerId, $dates),
|
249 |
+
'last_unordered_cart_amount' => $this->computeLastUnorderedCartAmount($customerId, $dates),
|
250 |
+
'last_unordered_cart_amount_with_vat' => $this->computeLastUnorderedCartAmount($customerId, $dates, true),
|
251 |
+
'discount_rule_count' => $this->computeDiscountRuleCount($customerId, $dates),
|
252 |
+
'last_orders_range' => $this->getLastTwoOrdersRange($customerId),
|
253 |
+
'first_order_date' => $this->getFirstOrderDate($customerId),
|
254 |
+
'last_order_date' => $this->getLastOrderDate($customerId),
|
255 |
+
'last_unordered_cart_date' => $this->getLastUnorderedCartDate($customerId),
|
256 |
+
'config' => $config,
|
257 |
+
'start_date' => ($config == $this::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date") : null,
|
258 |
+
));
|
259 |
+
|
260 |
+
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
261 |
+
$this->setData('orders_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
262 |
+
$this->setData('cart_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
263 |
+
}
|
264 |
+
|
265 |
+
$this->setData('updated_at', $now->format('Y-m-d H:i:s'));
|
266 |
+
|
267 |
+
try {
|
268 |
+
$this->save();
|
269 |
+
} catch (Exception $e) {
|
270 |
+
Mage::logException($e);
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
public function onNewOrder(Varien_Event_Observer $event)
|
275 |
+
{
|
276 |
+
$currentOrder = null;
|
277 |
+
/** @var Mage_Sales_Model_Order $currentOrder */
|
278 |
+
if ($event) {
|
279 |
+
$currentOrder = $event->getData('order');
|
280 |
+
}
|
281 |
+
|
282 |
+
if ($currentOrder) {
|
283 |
+
$customerId = $currentOrder->getData('customer_id');
|
284 |
+
|
285 |
+
if (!$customerId) {
|
286 |
+
return;
|
287 |
+
}
|
288 |
+
|
289 |
+
$dates = $this->computeDataTtl($customerId);
|
290 |
+
|
291 |
+
// load model
|
292 |
+
$this->load($customerId);
|
293 |
+
|
294 |
+
$now = new \DateTime();
|
295 |
+
// full update
|
296 |
+
if ($this->getData('customer_id') == null && $customerId != null) {
|
297 |
+
$this->compute($customerId);
|
298 |
+
} else {
|
299 |
+
if ((in_array(Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode'), array(self::RANGE_1, self::RANGE_3, self::RANGE_6, self::RANGE_12, self::RANGE_24)) && $this->getData('orders_expire') == null) || ($this->getData('orders_expire') != null && strtotime($this->getData('orders_expire')) < $now->getTimestamp())) {
|
300 |
+
$this->recompute($customerId);
|
301 |
+
} else {
|
302 |
+
$this->addData(array(
|
303 |
+
"total_orders_amount" => $this->getData('total_orders_amount') + ($currentOrder->getData('grand_total') - $currentOrder->getData('tax_amount')),
|
304 |
+
"total_orders_amount_with_vat" => $this->getData('total_orders_amount') + $currentOrder->getData('grand_total'),
|
305 |
+
"average_unique_product_count" => $this->computeAverageUniqueProductCount($customerId, $dates),
|
306 |
+
"average_product_count_by_command_line" => $this->computeAverageProductCountByCommandLine($customerId, $dates),
|
307 |
+
"total_product_count" => $this->getData('total_product_count') + $currentOrder->getData('total_item_count'),
|
308 |
+
"total_orders_count" => $this->getData('total_orders_count') + 1,
|
309 |
+
"discount_rule_count" => $this->computeDiscountRuleCount($customerId, $dates),
|
310 |
+
));
|
311 |
+
}
|
312 |
+
|
313 |
+
if (!$this->getData('first_order_amount') || $this->getData('first_order_amount') == 0) {
|
314 |
+
$this->setData('first_order_amount', $this->computeFirstOrderAmount($customerId));
|
315 |
+
}
|
316 |
+
if (!$this->getData('first_order_date')) {
|
317 |
+
$this->setData('first_order_date', $this->getFirstOrderDate($customerId));
|
318 |
+
}
|
319 |
+
|
320 |
+
if (!$this->getData('first_order_amount_with_vat')) {
|
321 |
+
$this->setData('first_order_amount_with_vat', $this->computeFirstOrderAmount($customerId, true));
|
322 |
+
}
|
323 |
+
|
324 |
+
if ($currentOrder) {
|
325 |
+
$this->setData('last_order_amount', $this->computeLastOrderAmount($customerId));
|
326 |
+
$this->setData('last_order_amount_with_vat', $this->computeLastOrderAmount($customerId, true));
|
327 |
+
$this->setData('last_order_date', $this->getLastOrderDate($customerId, true));
|
328 |
+
$this->setData('last_orders_range', (strtotime($currentOrder->getData('created_at')) - strtotime($this->getData('last_order_date'))) / 60 / 60 / 24);
|
329 |
+
}
|
330 |
+
$this->setData('updated_at', $now->format('Y-m-d H:i:s'));
|
331 |
+
$this->setData('customer_id', $customerId);
|
332 |
+
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
333 |
+
$this->setData('orders_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
334 |
+
}
|
335 |
+
try {
|
336 |
+
$this->save();
|
337 |
+
} catch (Exception $e) {
|
338 |
+
Mage::logException($e);
|
339 |
+
}
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
public function onNewCart(Varien_Event_Observer $observer)
|
345 |
+
{
|
346 |
+
$customerId = null;
|
347 |
+
if ($observer->hasData('quote_item')) {
|
348 |
+
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
|
349 |
+
$quoteItem = $observer->getQuoteItem();
|
350 |
+
|
351 |
+
if ($quoteItem->getQuote()->getCustomer()) {
|
352 |
+
$customerId = $quoteItem->getQuote()->getCustomer()->getId();
|
353 |
+
}
|
354 |
+
} elseif ($observer->hasData('cart')) {
|
355 |
+
/** @var Mage_Checkout_Model_Cart $cart */
|
356 |
+
$cart = $observer->getData('cart');
|
357 |
+
|
358 |
+
if ($cart->getQuote()->getCustomer()) {
|
359 |
+
$customerId = $cart->getQuote()->getCustomer()->getId();
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
if (!$customerId) {
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
|
367 |
+
|
368 |
+
/** @var Mage_Core_Model_Abstract $model */
|
369 |
+
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
370 |
+
|
371 |
+
// load model
|
372 |
+
$model->load($customerId);
|
373 |
+
|
374 |
+
$now = new \DateTime();
|
375 |
+
|
376 |
+
$dates = $this->computeDataTtl($customerId);
|
377 |
+
|
378 |
+
if ($this->getData('customer_id') == null && $customerId != null) {
|
379 |
+
$this->compute($customerId);
|
380 |
+
} else {
|
381 |
+
$model->addData(array(
|
382 |
+
'last_unordered_cart_amount' => $this->computeLastUnorderedCartAmount($customerId),
|
383 |
+
'last_unordered_cart_amount_with_vat' => $this->computeLastUnorderedCartAmount($customerId, true),
|
384 |
+
'last_unordered_cart_date' => $this->getLastUnorderedCartDate($customerId),
|
385 |
+
'updated_at' => $now->format('Y-m-d H:i:s')
|
386 |
+
));
|
387 |
+
|
388 |
+
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
389 |
+
$model->setData("cart_expire", $dates['stop']->format('Y-m-d H:i:s'));
|
390 |
+
}
|
391 |
+
|
392 |
+
try {
|
393 |
+
$model->save();
|
394 |
+
} catch (Exception $e) {
|
395 |
+
Mage::logException($e);
|
396 |
+
}
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* @param $customerId
|
402 |
+
* @param bool $withVat
|
403 |
+
*
|
404 |
+
* @return float
|
405 |
+
*/
|
406 |
+
protected function computeFirstOrderAmount($customerId, $withVat = false)
|
407 |
+
{
|
408 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountInclTax $model */
|
409 |
+
$model = null;
|
410 |
+
if ($withVat)
|
411 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_firstorderamountincltax');
|
412 |
+
else {
|
413 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_firstorderamountexcltax');
|
414 |
+
}
|
415 |
+
|
416 |
+
return $model->calculatedAttributeRequest($customerId);
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* @param $customerId
|
421 |
+
* @param bool $withVat
|
422 |
+
*
|
423 |
+
* @return float
|
424 |
+
*/
|
425 |
+
protected function computeLastOrderAmount($customerId, $withVat = false)
|
426 |
+
{
|
427 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountInclTax $model */
|
428 |
+
$model = null;
|
429 |
+
if ($withVat)
|
430 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastorderamountincltax');
|
431 |
+
else {
|
432 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastorderamountexcltax');
|
433 |
+
}
|
434 |
+
return $model->calculatedAttributeRequest($customerId);
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* @param $customerId
|
439 |
+
* @param array $dates
|
440 |
+
* @param bool $withVat
|
441 |
+
*
|
442 |
+
* @return float
|
443 |
+
*/
|
444 |
+
protected function computeTotalOrdersAmount($customerId, $dates = array(), $withVat = false)
|
445 |
+
{
|
446 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTax $model */
|
447 |
+
$model = null;
|
448 |
+
if ($withVat)
|
449 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderamountincltax');
|
450 |
+
else {
|
451 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderamountexcltax');
|
452 |
+
}
|
453 |
+
|
454 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
455 |
+
}
|
456 |
+
|
457 |
+
|
458 |
+
/**
|
459 |
+
* @param $customerId
|
460 |
+
* @param array $dates
|
461 |
+
* @param bool $withVat
|
462 |
+
*
|
463 |
+
* @return float
|
464 |
+
*/
|
465 |
+
protected function computeAverageOrdersAmount($customerId, $dates = array(), $withVat = false)
|
466 |
+
{
|
467 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax $model */
|
468 |
+
$model = null;
|
469 |
+
if ($withVat)
|
470 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgorderamountincltax');
|
471 |
+
else {
|
472 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgorderamountexcltax');
|
473 |
+
}
|
474 |
+
|
475 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
476 |
+
}
|
477 |
+
|
478 |
+
public function getAvgOrdersAmount($withVat = false)
|
479 |
+
{
|
480 |
+
$count = $this->getData('total_orders_count');
|
481 |
+
$amount = $this->getData(!$withVat ? 'total_orders_amount' : 'total_orders_amount_with_vat');
|
482 |
+
|
483 |
+
if ($count != 0) {
|
484 |
+
return $amount / $count;
|
485 |
+
} else {
|
486 |
+
return 0;
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* @param $customerId
|
492 |
+
* @param array $dates
|
493 |
+
*
|
494 |
+
* @return float
|
495 |
+
*/
|
496 |
+
protected function computeAverageProductCount($customerId, $dates = array())
|
497 |
+
{
|
498 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbProductsPerOrder $model */
|
499 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbproductsperorder');
|
500 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
501 |
+
}
|
502 |
+
|
503 |
+
public function getAvgProductCount()
|
504 |
+
{
|
505 |
+
$orderCount = $this->getData('total_orders_count');
|
506 |
+
$productCount = $this->getData('total_product_count');
|
507 |
+
|
508 |
+
if($orderCount != 0) {
|
509 |
+
return $productCount / $orderCount;
|
510 |
+
}
|
511 |
+
else {
|
512 |
+
return 0;
|
513 |
+
}
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* @param $customerId
|
518 |
+
*
|
519 |
+
* @param array $dates
|
520 |
+
* @return float
|
521 |
+
*/
|
522 |
+
protected function computeAverageUniqueProductCount($customerId, $dates = array())
|
523 |
+
{
|
524 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrder $model */
|
525 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbdifferentproductsperorder');
|
526 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* @param $customerId
|
531 |
+
*
|
532 |
+
* @param array $dates
|
533 |
+
* @return float
|
534 |
+
*/
|
535 |
+
protected function computeAverageProductCountByCommandLine($customerId, $dates = array())
|
536 |
+
{
|
537 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrderLine $model */
|
538 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbdifferentproductsperorderline');
|
539 |
+
|
540 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* @param $customerId
|
545 |
+
*
|
546 |
+
* @param array $dates
|
547 |
+
* @return float
|
548 |
+
*/
|
549 |
+
protected function computeTotalProductCount($customerId, $dates = array())
|
550 |
+
{
|
551 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts $model */
|
552 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderedproducts');
|
553 |
+
|
554 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* @param $customerId
|
559 |
+
*
|
560 |
+
* @param array $dates
|
561 |
+
* @return float
|
562 |
+
*/
|
563 |
+
protected function computeTotalOrdersCount($customerId, $dates = array())
|
564 |
+
{
|
565 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders $model */
|
566 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorders');
|
567 |
+
|
568 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* @param $customerId
|
573 |
+
* @param array $dates
|
574 |
+
* @param bool $withVat
|
575 |
+
*
|
576 |
+
* @return float
|
577 |
+
*/
|
578 |
+
protected function computeLastUnorderedCartAmount($customerId, $dates = array(), $withVat = false)
|
579 |
+
{
|
580 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountInclTax $model */
|
581 |
+
$model = null;
|
582 |
+
if ($withVat)
|
583 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastnotorderedcartamountincltax');
|
584 |
+
else {
|
585 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastnotorderedcartamountexcltax');
|
586 |
+
}
|
587 |
+
|
588 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* @param $customerId
|
593 |
+
*
|
594 |
+
* @param array $dates
|
595 |
+
* @return float
|
596 |
+
*/
|
597 |
+
protected function computeDiscountRuleCount($customerId, $dates = array())
|
598 |
+
{
|
599 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_NbPromotionRulesUsed $model */
|
600 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_nbpromotionrulesused');
|
601 |
+
|
602 |
+
return $model->calculatedAttributeRequest($customerId, $dates);
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* @param $customerId
|
607 |
+
*
|
608 |
+
* @return DateTime
|
609 |
+
*/
|
610 |
+
protected function getFirstOrderDate($customerId)
|
611 |
+
{
|
612 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder $model */
|
613 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_firstorder');
|
614 |
+
|
615 |
+
return $model->calculatedAttributeRequest($customerId);
|
616 |
+
}
|
617 |
+
|
618 |
+
/**
|
619 |
+
* @param $customerId
|
620 |
+
*
|
621 |
+
* @return DateTime
|
622 |
+
*/
|
623 |
+
protected function getLastOrderDate($customerId)
|
624 |
+
{
|
625 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder $model */
|
626 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_lastorder');
|
627 |
+
|
628 |
+
return $model->calculatedAttributeRequest($customerId);
|
629 |
+
}
|
630 |
+
|
631 |
+
public function getLastTwoOrdersRange($customerId)
|
632 |
+
{
|
633 |
+
$readAdapter = $this->_getReadAdapter();
|
634 |
+
|
635 |
+
$tableName = null;
|
636 |
+
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
637 |
+
$tableName = 'sales_flat_order';
|
638 |
+
}else{
|
639 |
+
$tableName = 'sales_order';
|
640 |
+
}
|
641 |
+
|
642 |
+
/** @var Varien_Db_Select $select */
|
643 |
+
$select = $readAdapter->select();
|
644 |
+
$select->from(array('o' => $this->getTable($tableName)), array('o.created_at'))
|
645 |
+
->order('o.created_at DESC')
|
646 |
+
->where('o.customer_id = ?', $customerId)
|
647 |
+
->limit(2)
|
648 |
+
;
|
649 |
+
|
650 |
+
|
651 |
+
$data = $readAdapter->fetchAll($select);
|
652 |
+
|
653 |
+
if(count($data) < 2) {
|
654 |
+
return 0;
|
655 |
+
}
|
656 |
+
|
657 |
+
$diff = date_create_from_format('Y-m-d H:i:s', $data[1]['created_at'])->diff(date_create_from_format('Y-m-d H:i:s', $data[0]['created_at']));
|
658 |
+
|
659 |
+
|
660 |
+
return $diff->days;
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* @param $customerId
|
665 |
+
*
|
666 |
+
* @return DateTime
|
667 |
+
*/
|
668 |
+
protected function getLastUnorderedCartDate($customerId)
|
669 |
+
{
|
670 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered $model */
|
671 |
+
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_lastquotenotordered');
|
672 |
+
|
673 |
+
return $model->calculatedAttributeRequest($customerId);
|
674 |
+
}
|
675 |
+
|
676 |
+
/**
|
677 |
+
* Retrieve connection for read data
|
678 |
+
*
|
679 |
+
* @return mixed
|
680 |
+
*/
|
681 |
+
protected function _getReadAdapter()
|
682 |
+
{
|
683 |
+
return Mage::getModel('core/resource')->getConnection('read');
|
684 |
+
}
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Return table name including prefix
|
688 |
+
*
|
689 |
+
* @param string $tableName Table name
|
690 |
+
*
|
691 |
+
* @return string Table name
|
692 |
+
*/
|
693 |
+
public function getTable($tableName)
|
694 |
+
{
|
695 |
+
$tablePrefix = (string)Mage::getConfig()->getTablePrefix();
|
696 |
+
return $tablePrefix . $tableName;
|
697 |
+
}
|
698 |
+
}
|
app/code/community/Dolist/Net/Model/Dolistv8/Customfields.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Dolist_Net_Model_Dolistv8_Customfields extends Mage_Core_Model_Abstract
|
5 |
+
{
|
6 |
+
public static $coreFieldName = array(
|
7 |
+
'firstname' => 'firstname',
|
8 |
+
'lastname' => 'lastname',
|
9 |
+
'birthdate' => 'dob',
|
10 |
+
'company' => 'company',
|
11 |
+
'address1' => 'address1',
|
12 |
+
'address2' => 'address2',
|
13 |
+
'address3' => 'address3',
|
14 |
+
'zipcode' => 'zipcode',
|
15 |
+
'city' => 'city',
|
16 |
+
'countryid' => 'countryid',
|
17 |
+
'phone' => 'phone',
|
18 |
+
'fax' => 'fax',
|
19 |
+
);
|
20 |
+
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->_init('dolist/dolistv8_customfields');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getMapping($storeId = 0)
|
28 |
+
{
|
29 |
+
$mapping = array(
|
30 |
+
'email' => array(
|
31 |
+
'field' => 'email',
|
32 |
+
'adapter' => 'dolist/exporter_adapter_default'
|
33 |
+
)
|
34 |
+
);
|
35 |
+
|
36 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
37 |
+
$collection = $this->getCollection();
|
38 |
+
$collection->addFieldToFilter('scope_id', array('eq' => $storeId));
|
39 |
+
|
40 |
+
if($collection->count() == 0) {
|
41 |
+
$collection = $this->getCollection();
|
42 |
+
$collection->addFieldToFilter('scope_id', array('eq' => 0));
|
43 |
+
}
|
44 |
+
|
45 |
+
foreach ($collection as $customField) {
|
46 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
47 |
+
|
48 |
+
$magentoField = $customField->getData('magento_field');
|
49 |
+
if (!$magentoField) {
|
50 |
+
// field not mapped
|
51 |
+
continue;
|
52 |
+
}
|
53 |
+
|
54 |
+
$mapping[$customField->getData('name')] = array(
|
55 |
+
'field' => $magentoField,
|
56 |
+
'adapter' => $customField->getFieldAdapater()
|
57 |
+
);
|
58 |
+
}
|
59 |
+
return $mapping;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function loadByNameAndScope($name, $scopeId)
|
63 |
+
{
|
64 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
65 |
+
$collection = $this->getCollection()
|
66 |
+
->addFieldToFilter('name', $name)
|
67 |
+
->addFieldToFilter('scope_id', $scopeId);
|
68 |
+
|
69 |
+
|
70 |
+
return $collection->getFirstItem();
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
public function toOptionArray($type, $storeId)
|
75 |
+
{
|
76 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
77 |
+
$collection = $this->getCollection();
|
78 |
+
$collection->addFieldToFilter('type', array('like' => $type));
|
79 |
+
$collection->addFieldToFilter('scope_id', $storeId);
|
80 |
+
|
81 |
+
$optionArray = array(
|
82 |
+
array('value' => '', 'label' => Mage::helper('adminhtml')->__('Disable'))
|
83 |
+
|
84 |
+
);
|
85 |
+
|
86 |
+
foreach ($collection as $customField) {
|
87 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
88 |
+
|
89 |
+
$optionArray[] = array(
|
90 |
+
'value' => $customField->getData('name'),
|
91 |
+
'label' => $customField->getData('title')
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
return $optionArray;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getFieldAdapater()
|
99 |
+
{
|
100 |
+
switch (strtolower($this->getData('type'))) {
|
101 |
+
case 'integer':
|
102 |
+
return 'dolist/exporter_adapter_int';
|
103 |
+
case 'datetime':
|
104 |
+
return 'dolist/exporter_adapter_date';
|
105 |
+
case 'varchar':
|
106 |
+
default:
|
107 |
+
return 'dolist/exporter_adapter_default';
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
app/code/community/Dolist/Net/Model/Dolistv8/Ftp.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist FTP client
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Dolistv8_Ftp extends Varien_Io_Ftp
|
11 |
+
{
|
12 |
+
const XML_DOLIST_V8_LOGIN = 'dolist/dolist_v8/login';
|
13 |
+
const XML_DOLIST_V8_PASSWORD = 'dolist/dolist_v8/password';
|
14 |
+
|
15 |
+
protected $_args = null;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Intialize arguments
|
19 |
+
*
|
20 |
+
* @param array $params Init params
|
21 |
+
*
|
22 |
+
* @return Dolist_Net_Model_Dolistv8_Ftp Ftp connection
|
23 |
+
*/
|
24 |
+
public function __construct($params=null)
|
25 |
+
{
|
26 |
+
// Init params
|
27 |
+
$storeId = 0;
|
28 |
+
if (array_key_exists('store_id', $params)) {
|
29 |
+
$storeId = $params['store_id'];
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
$this->_args = array(
|
34 |
+
'host' => (string) Mage::getConfig()->getNode('dolistparams/ftp/host'),
|
35 |
+
'user' => Mage::getStoreConfig(self::XML_DOLIST_V8_LOGIN, $storeId),
|
36 |
+
'password' => Mage::getStoreConfig(self::XML_DOLIST_V8_PASSWORD, $storeId),
|
37 |
+
'passive' => true // Enable passive mode, mandatory when target is behind firewall
|
38 |
+
);
|
39 |
+
|
40 |
+
Mage::log('FTP CONNECTION for store ' . $storeId);
|
41 |
+
Mage::log($this->_args);
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Fix login and password
|
47 |
+
*
|
48 |
+
* @param string $login Optional login (used to test connection in back office)
|
49 |
+
* @param string $password Optional password (used to test connection in back office)
|
50 |
+
*
|
51 |
+
* @return Dolist_Net_Model_Dolistv8_Ftp Ftp connection
|
52 |
+
*/
|
53 |
+
public function fixArgs($login=null, $password = null)
|
54 |
+
{
|
55 |
+
$this->_args = array(
|
56 |
+
'host' => (string) Mage::getConfig()->getNode('dolistparams/ftp/host'),
|
57 |
+
'user' => $login,
|
58 |
+
'password' => $password,
|
59 |
+
'passive' => true // Enable passive mode, mandatory when target is behind firewall
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Init FTP connection to Dolist-V8 FTP server
|
65 |
+
*
|
66 |
+
* @return boolean Connection OK or NOK
|
67 |
+
*/
|
68 |
+
protected function _openConnection()
|
69 |
+
{
|
70 |
+
$connectionStatus = false;
|
71 |
+
|
72 |
+
try {
|
73 |
+
$connectionStatus = $this->open($this->_args);
|
74 |
+
} catch (Varien_Io_Exception $e) {
|
75 |
+
$message = 'Dolist-V8 FTP Connection: ' . $e->getMessage();
|
76 |
+
// Store error message in session to display it in Back Office
|
77 |
+
Mage::getSingleton('core/session')->setLastDolistFaultDetail($message);
|
78 |
+
$this->_getHelper()->logError($message);
|
79 |
+
}
|
80 |
+
return $connectionStatus;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Init FTP connection to Dolist-V8 FTP server
|
85 |
+
*
|
86 |
+
* @return Dolist_Net_Model_Dolistv8_Ftp FTP connection
|
87 |
+
*/
|
88 |
+
public function getConnection()
|
89 |
+
{
|
90 |
+
$this->_openConnection();
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Init FTP connection to Dolist-V8 FTP server
|
96 |
+
*
|
97 |
+
* @return boolean Connection OK or NOK
|
98 |
+
*/
|
99 |
+
public function getStatus()
|
100 |
+
{
|
101 |
+
$connectionStatus = $this->_openConnection();
|
102 |
+
return $connectionStatus;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Retrieve model helper
|
107 |
+
*
|
108 |
+
* @return Dolist_Net_Helper_Data
|
109 |
+
*/
|
110 |
+
protected function _getHelper()
|
111 |
+
{
|
112 |
+
return Mage::helper('dolist');
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Dolist/Net/Model/Exporter/Adapter/Date.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Exporter_Adapter_Date extends Dolist_Net_Model_Exporter_Adapter_Default
|
4 |
+
{
|
5 |
+
public function getExportedValue($value)
|
6 |
+
{
|
7 |
+
if ($value != '') {
|
8 |
+
$date = new Zend_Date($value);
|
9 |
+
$return = $date->toString('dd/MM/YYYY');
|
10 |
+
return $return;
|
11 |
+
}
|
12 |
+
return null;
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Dolist/Net/Model/Exporter/Adapter/Default.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Exporter_Adapter_Default
|
4 |
+
{
|
5 |
+
public function getExportedValue($value)
|
6 |
+
{
|
7 |
+
return $value;
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Dolist/Net/Model/Exporter/Adapter/Int.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Exporter_Adapter_Int extends Dolist_Net_Model_Exporter_Adapter_Default
|
4 |
+
{
|
5 |
+
public function getExportedValue($value)
|
6 |
+
{
|
7 |
+
$v = explode('.', $value);
|
8 |
+
return $v[0];
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Dolist/Net/Model/Exporter/Csv.php
ADDED
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Exports a set of Varien Objects to a CSV file
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
12 |
+
{
|
13 |
+
private $_toExport;
|
14 |
+
private $_dolistToExport;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->_toExport = array();
|
25 |
+
$this->setDelimiter(',');
|
26 |
+
$this->setEnclosure('"');
|
27 |
+
$this->setNoLineBreak(true);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Adds an object to export
|
32 |
+
*
|
33 |
+
* format:
|
34 |
+
* array(
|
35 |
+
* 'prefix' => '<string>' /// prefix to put before all data fields (in header row)
|
36 |
+
* 'object' => <Varien_Object>,
|
37 |
+
* 'fields' => array('field1','field2'), /// if ommited all fields are exported
|
38 |
+
* 'exclude' => array('field1','field2'), /// usefull if all fields but these must be exported
|
39 |
+
* )
|
40 |
+
*
|
41 |
+
* @param array $objectArray Object to export
|
42 |
+
*
|
43 |
+
* @return Dolist_Net_Model_Exporter_Csv
|
44 |
+
*/
|
45 |
+
public function addObjectToExport($objectArray)
|
46 |
+
{
|
47 |
+
$this->_toExport[] = $objectArray;
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add subscriber to export queue
|
53 |
+
*
|
54 |
+
* @param Mage_Newsletter_Model_Subscriber $subscriber Newsletter subscriber
|
55 |
+
* @param mixed $dolistv8SystemConfig Config
|
56 |
+
*
|
57 |
+
* @return Dolist_Net_Model_Exporter_Csv
|
58 |
+
*/
|
59 |
+
public function setContactToExport($subscriber, $dolistv8SystemConfig)
|
60 |
+
{
|
61 |
+
$this->_dolistToExport = array(
|
62 |
+
'contact' => $subscriber,
|
63 |
+
'config' => $dolistv8SystemConfig
|
64 |
+
);
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* render all objects previously added to a CSV file
|
70 |
+
*
|
71 |
+
* @param string $filename Filename
|
72 |
+
* @param mixed $addHeader auto => see $append, false => do not add, true => allways add
|
73 |
+
* @param boolean $append if set to true and the file already exists the content is added at the end of the file
|
74 |
+
* and the headers are not added (they are allready at the beginning of the file)
|
75 |
+
* @param bool|string $specificHeader Specific header key
|
76 |
+
* @param string $exportType Can be 'auto', or 'dolist'
|
77 |
+
*
|
78 |
+
* @param int $storeId
|
79 |
+
* @throws Mage_Core_Exception
|
80 |
+
* @return Smile_Interfaces_Model_Exporter_Csv
|
81 |
+
*/
|
82 |
+
public function export($filename, $addHeader = 'auto', $append = true, $specificHeader = false, $exportType = 'auto', $storeId = 0)
|
83 |
+
{
|
84 |
+
$varienCsv = new Varien_File_Csv();
|
85 |
+
|
86 |
+
$row = array();
|
87 |
+
if ($exportType == 'auto') {
|
88 |
+
$row = $this->_autoExportGetRow();
|
89 |
+
} elseif ($exportType == 'dolist') {
|
90 |
+
$row = $this->_dolistExportGetRow($storeId);
|
91 |
+
}
|
92 |
+
|
93 |
+
//open the file
|
94 |
+
$mode = 'a';
|
95 |
+
if (!$append) {
|
96 |
+
$mode = 'w';
|
97 |
+
}
|
98 |
+
if ($addHeader == 'auto') {
|
99 |
+
if (is_file($filename)) {
|
100 |
+
$addHeader = false;
|
101 |
+
} else {
|
102 |
+
$addHeader = true;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
try {
|
108 |
+
if (!is_dir(dirname($filename))) {
|
109 |
+
mkdir(dirname($filename), 0755, true);
|
110 |
+
}
|
111 |
+
|
112 |
+
$file = fopen($filename, $mode);
|
113 |
+
|
114 |
+
// Prepare header every time (needed to prepare cells even if empty)
|
115 |
+
$header = null;
|
116 |
+
if ($specificHeader == false) {
|
117 |
+
$header = array_keys($row);
|
118 |
+
} else if ($specificHeader == 'contact_header') {
|
119 |
+
$header = array_keys($this->getMapping(Mage::app()->getRequest()->getParam('store', $storeId)));
|
120 |
+
}
|
121 |
+
|
122 |
+
// but add the header only if needed
|
123 |
+
if ($addHeader) {
|
124 |
+
$varienCsv->fputcsv($file, $header, $this->getDelimiter(), $this->getEnclosure());
|
125 |
+
}
|
126 |
+
|
127 |
+
// export file must contain as many columns as header
|
128 |
+
$filledRow = array_fill(0, count($header), '');
|
129 |
+
// fill the row with empty values for empty fields
|
130 |
+
foreach (array_values($row) as $rowKey => $rowValue) {
|
131 |
+
$filledRow[$rowKey] = $rowValue;
|
132 |
+
}
|
133 |
+
|
134 |
+
//add data
|
135 |
+
$varienCsv->fputcsv($file, $filledRow, $this->getDelimiter(), $this->getEnclosure());
|
136 |
+
|
137 |
+
} catch (Exception $e) {
|
138 |
+
$this->_getHelper()->logDebug($e->__toString());
|
139 |
+
Mage::throwException($e->getMessage());
|
140 |
+
}
|
141 |
+
try {
|
142 |
+
|
143 |
+
fclose($file);
|
144 |
+
|
145 |
+
} catch (Exception $e) {
|
146 |
+
$this->_getHelper()->logDebug($e->__toString());
|
147 |
+
Mage::throwException($e->getMessage());
|
148 |
+
}
|
149 |
+
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Return row to export - automatic method
|
155 |
+
*
|
156 |
+
* @return array
|
157 |
+
*/
|
158 |
+
protected function _autoExportGetRow()
|
159 |
+
{
|
160 |
+
$row = array();
|
161 |
+
//fill the row
|
162 |
+
$this->_getHelper(print_r($this->_toExport));
|
163 |
+
foreach ($this->_toExport as $exportObj) {
|
164 |
+
$this->_getHelper(print_r($exportObj));
|
165 |
+
//transform this array in local variables to have a more readable code
|
166 |
+
$obj = $exportObj['object'];
|
167 |
+
$prefix = "";
|
168 |
+
if (isset($exportObj['prefix'])) {
|
169 |
+
$prefix = $exportObj['prefix'];
|
170 |
+
}
|
171 |
+
$fields = false;
|
172 |
+
if (isset($exportObj['fields'])) {
|
173 |
+
$fields = $exportObj['fields'];
|
174 |
+
}
|
175 |
+
$exclude = false;
|
176 |
+
if (!$fields && isset($exportObj['exclude'])) {
|
177 |
+
$exclude = $exportObj['exclude'];
|
178 |
+
}
|
179 |
+
|
180 |
+
//check all fields
|
181 |
+
if ($fields !== false) {
|
182 |
+
// only some fields must be added
|
183 |
+
|
184 |
+
foreach ($fields as $k) {
|
185 |
+
$v = "-"; //avoid empty columns causing problems with the header
|
186 |
+
if ($obj->hasData($k) && $obj->getData($k) != '') {
|
187 |
+
$v = $obj->getData($k);
|
188 |
+
}
|
189 |
+
$row[$prefix . $k] = $this->_checkValueBeforeInsert($v);
|
190 |
+
}
|
191 |
+
|
192 |
+
} else {
|
193 |
+
foreach ($obj->getData() as $k => $v) {
|
194 |
+
$add = true;
|
195 |
+
|
196 |
+
if ($exclude !== false) {
|
197 |
+
//some fields musn't be exported
|
198 |
+
$add = !array_key_exists($k, $exclude);
|
199 |
+
}
|
200 |
+
|
201 |
+
if ($add) {
|
202 |
+
//add this field to the current row!
|
203 |
+
$row[$prefix . $k] = $this->_checkValueBeforeInsert($v);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
return $row;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* @param $storeId
|
213 |
+
* @return array
|
214 |
+
*/
|
215 |
+
protected function getMapping($storeId)
|
216 |
+
{
|
217 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $model */
|
218 |
+
$model = Mage::getModel('dolist/dolistv8_customfields');
|
219 |
+
return $model->getMapping($storeId);
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Return row to export - dolist method
|
224 |
+
*
|
225 |
+
* @param $storeId
|
226 |
+
* @return array
|
227 |
+
*/
|
228 |
+
protected function _dolistExportGetRow($storeId)
|
229 |
+
{
|
230 |
+
$row = array();
|
231 |
+
|
232 |
+
$mappingConfig = $this->getMapping($storeId);
|
233 |
+
|
234 |
+
$contact = $this->_dolistToExport['contact'];
|
235 |
+
|
236 |
+
// If customer exists, load it
|
237 |
+
/** @var Mage_Customer_Model_Customer $customer */
|
238 |
+
$customer = null;
|
239 |
+
$forceAbonneNewsletter = false;
|
240 |
+
|
241 |
+
if (is_array($contact) && array_key_exists('customer_id', $contact) && filter_var($contact['customer_id'], FILTER_VALIDATE_INT) !== false) {
|
242 |
+
$customer = Mage::getModel('customer/customer')->load($contact['customer_id']);
|
243 |
+
} else {
|
244 |
+
// If no customer exists, create a fictive customer (but DO NOT save it) with email, only in order to be exported
|
245 |
+
$this->_getHelper()->logDebug('CustomerId : ' . $contact['customer_id']);
|
246 |
+
$customer = Mage::getModel('customer/customer');
|
247 |
+
$customer->setData('email', $contact['customer_id']);
|
248 |
+
|
249 |
+
//
|
250 |
+
$forceAbonneNewsletter = true;
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
/** @var Dolist_Net_Model_Dolistv8_Calculatedfields $dolistCalculatedFieldsModel */
|
255 |
+
$dolistCalculatedFieldsModel = Mage::getModel('dolist/dolistv8_calculatedfields');
|
256 |
+
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode", $storeId);
|
257 |
+
$configStartDate = ($config == Dolist_Net_Model_Dolistv8_Calculatedfields::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date", $storeId) : null;
|
258 |
+
|
259 |
+
foreach ($mappingConfig as $dolistHeader => $magentoAttributeCode) {
|
260 |
+
$v = '';
|
261 |
+
if ($dolistCalculatedFieldsModel->isCalculatedFieldConfig($magentoAttributeCode['field']) || $magentoAttributeCode['field'] == 'is_subscriber') {
|
262 |
+
if (!$dolistCalculatedFieldsModel->getId()) {
|
263 |
+
$dolistCalculatedFieldsModel->load($customer->getId());
|
264 |
+
|
265 |
+
if (is_numeric($customer->getId())) {
|
266 |
+
if (!$dolistCalculatedFieldsModel->getData('customer_id')) {
|
267 |
+
$dolistCalculatedFieldsModel->compute($customer->getId());
|
268 |
+
} elseif ($dolistCalculatedFieldsModel->getData('order_expire') && ($dolistCalculatedFieldsModel->getData('orders_expire')) <= time()) {
|
269 |
+
$dolistCalculatedFieldsModel->recompute($customer->getId());
|
270 |
+
} elseif ((!$dolistCalculatedFieldsModel->getData('first_order_amount') || $dolistCalculatedFieldsModel->getData('first_order_amount') == 0 || !$dolistCalculatedFieldsModel->getData('last_order_amount') || strlen($dolistCalculatedFieldsModel->getData('first_order_date')) > 0)) {
|
271 |
+
$dolistCalculatedFieldsModel->recompute($customer->getId());
|
272 |
+
} elseif ($dolistCalculatedFieldsModel->getData('config') != $config || $dolistCalculatedFieldsModel->getData('start_date') != $configStartDate) {
|
273 |
+
// Calculated fields config has changed
|
274 |
+
$dolistCalculatedFieldsModel->recompute($customer->getId());
|
275 |
+
} elseif (strpos($magentoAttributeCode['field'], 'last_unordered_cart_') === 0) {
|
276 |
+
// Always
|
277 |
+
$dolistCalculatedFieldsModel->recompute($customer->getId());
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
if ($magentoAttributeCode['field'] == 'avg_order_amount_excl_tax') {
|
283 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
284 |
+
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgOrdersAmount());
|
285 |
+
} elseif ($magentoAttributeCode['field'] == 'avg_order_amount_incl_tax') {
|
286 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
287 |
+
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgOrdersAmount(true));
|
288 |
+
} elseif ($magentoAttributeCode['field'] == 'avg_nb_products_per_order') {
|
289 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
290 |
+
|
291 |
+
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgProductCount());
|
292 |
+
|
293 |
+
} elseif ($magentoAttributeCode['field'] == 'is_subscriber') {
|
294 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
295 |
+
$subscriber = null;
|
296 |
+
if (!$forceAbonneNewsletter) {
|
297 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
|
298 |
+
}
|
299 |
+
|
300 |
+
$v = $adapter->getExportedValue($forceAbonneNewsletter || $subscriber->getData('subscriber_status') == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED ? $this->_getHelper()->__('newsletter subscriber') : $this->_getHelper()->__('not subscribed newsletter'));
|
301 |
+
} else {
|
302 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
303 |
+
// Calculated fields
|
304 |
+
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getData($magentoAttributeCode['field']));
|
305 |
+
}
|
306 |
+
|
307 |
+
} elseif (in_array($magentoAttributeCode['field'], array('company', 'address1', 'address2', 'address3', 'city', 'countryid', 'zipcode', 'postcode', 'fax', 'phone'))) {
|
308 |
+
$address = $customer->getDefaultBillingAddress();
|
309 |
+
/** @var Dolist_Net_Model_Exporter_Adapter_Default $adapter */
|
310 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
311 |
+
|
312 |
+
if (!empty($address)) {
|
313 |
+
|
314 |
+
switch ($magentoAttributeCode['field']) {
|
315 |
+
case 'countryid':
|
316 |
+
$customerCountry = $address->getCountry();
|
317 |
+
if ($customerCountry != '') {
|
318 |
+
$countries = $this->_getCountries();
|
319 |
+
if (array_key_exists($customerCountry, $countries)) {
|
320 |
+
/** @var Mage_Directory_Model_Country $country */
|
321 |
+
$country = $countries[$customerCountry];
|
322 |
+
$v = $adapter->getExportedValue($country->getDolistCode());
|
323 |
+
} else {
|
324 |
+
$v = $adapter->getExportedValue(Dolist_Net_Helper_Data::OTHER_COUNTRIES_CODE);
|
325 |
+
}
|
326 |
+
} else {
|
327 |
+
$v = $adapter->getExportedValue('');
|
328 |
+
}
|
329 |
+
break;
|
330 |
+
case 'address1':
|
331 |
+
$v = $adapter->getExportedValue($address->getStreet(1));
|
332 |
+
break;
|
333 |
+
case 'address2':
|
334 |
+
$v = $adapter->getExportedValue($address->getStreet(2));
|
335 |
+
break;
|
336 |
+
case 'address3':
|
337 |
+
$v = $adapter->getExportedValue($address->getStreet(3));
|
338 |
+
break;
|
339 |
+
case 'phone':
|
340 |
+
$v = $adapter->getExportedValue($address->getData('telephone'));
|
341 |
+
break;
|
342 |
+
case 'zipcode':
|
343 |
+
$v = $adapter->getExportedValue($address->getData('zipcode'));
|
344 |
+
if (!$v || strlen($v)) {
|
345 |
+
$v = $adapter->getExportedValue($address->getData('postcode'));
|
346 |
+
}
|
347 |
+
break;
|
348 |
+
case 'postcode':
|
349 |
+
$v = $adapter->getExportedValue($address->getData('zipcode'));
|
350 |
+
if (!$v || strlen($v)) {
|
351 |
+
$v = $adapter->getExportedValue($address->getData('postcode'));
|
352 |
+
}
|
353 |
+
break;
|
354 |
+
default:
|
355 |
+
$v = $adapter->getExportedValue($address->getData($magentoAttributeCode['field']));
|
356 |
+
break;
|
357 |
+
}
|
358 |
+
} else {
|
359 |
+
$v = $adapter->getExportedValue('');
|
360 |
+
}
|
361 |
+
|
362 |
+
} else {
|
363 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
364 |
+
$v = $adapter->getExportedValue($customer->getData($magentoAttributeCode['field']));
|
365 |
+
}
|
366 |
+
|
367 |
+
//$adapter->getExportedValue($customer, $magentoAttributeCode);
|
368 |
+
$row[$dolistHeader] = $this->_checkValueBeforeInsert($v);
|
369 |
+
}
|
370 |
+
|
371 |
+
return $row;
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Check a value before inserting it into a CSV file
|
376 |
+
*
|
377 |
+
* checks:
|
378 |
+
* Removes line breaks if $this->getNoLineBreak() is true
|
379 |
+
*
|
380 |
+
* @param string $value Value
|
381 |
+
*
|
382 |
+
* @return string
|
383 |
+
*/
|
384 |
+
protected function _checkValueBeforeInsert($value)
|
385 |
+
{
|
386 |
+
if ($this->getNoLineBreak()) {
|
387 |
+
$value = str_replace('\r', '', $value);
|
388 |
+
$value = str_replace('\n', ' ', $value);
|
389 |
+
}
|
390 |
+
return $value;
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Retrieve model helper
|
395 |
+
*
|
396 |
+
* @return Dolist_Net_Helper_Data
|
397 |
+
*/
|
398 |
+
protected function _getHelper()
|
399 |
+
{
|
400 |
+
return Mage::helper('dolist');
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Load countries
|
405 |
+
*
|
406 |
+
* @return array Countries
|
407 |
+
*/
|
408 |
+
protected function _getCountries()
|
409 |
+
{
|
410 |
+
if (is_null($this->_countries)) {
|
411 |
+
$countries = Mage::getModel('directory/country')
|
412 |
+
->getCollection()
|
413 |
+
->getItems();
|
414 |
+
|
415 |
+
$this->_countries = $countries;
|
416 |
+
}
|
417 |
+
|
418 |
+
return $this->_countries;
|
419 |
+
}
|
420 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Message/Queued.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT Message Queue resource model
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistemt_Message_Queued extends Mage_Core_Model_Mysql4_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$this->_init('dolist/dolistemt_message_queued', 'id');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Message/Queued/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT Message queue collection resource model
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistemt_Message_Queued_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$this->_init('dolist/dolistemt_message_queued');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Template.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT Email template resource model
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistemt_Template extends Mage_Core_Model_Mysql4_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$this->_init('dolist/dolistemt_template', 'id');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistemt/Template/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT Email template collection resource model
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistemt_Template_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$this->_init('dolist/dolistemt_template');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Calculatedfields.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Model initialization
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _construct()
|
10 |
+
{
|
11 |
+
$this->_isPkAutoIncrement=false;
|
12 |
+
$this->_init('dolist/dolistv8_calculatedfields', 'customer_id');
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @param $customerId
|
17 |
+
* @param $startDate
|
18 |
+
* @return mixed
|
19 |
+
*/
|
20 |
+
public function getFirstOrderDate($customerId, $startDate){
|
21 |
+
$readAdapter = $this->_getReadAdapter();
|
22 |
+
$orderTableName = null;
|
23 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
24 |
+
$orderTableName = 'sales_flat_order';
|
25 |
+
|
26 |
+
} else {
|
27 |
+
$orderTableName = 'sales_order';
|
28 |
+
}
|
29 |
+
$select = $readAdapter
|
30 |
+
->select()
|
31 |
+
->from(
|
32 |
+
array('o' => $this->getTable($orderTableName)),
|
33 |
+
array(
|
34 |
+
'date' => 'o.created_at'
|
35 |
+
)
|
36 |
+
)
|
37 |
+
->where('o.customer_id = ?', $customerId)
|
38 |
+
->where('o.created_at >= ?', $startDate->format('Y-m-d h:g:s'))
|
39 |
+
->order('o.created_at ASC');
|
40 |
+
|
41 |
+
$row = $readAdapter->fetchOne($select);
|
42 |
+
return $row;
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Calculatedfields/Collection.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
5 |
+
/**
|
6 |
+
* Initialize resource
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _construct()
|
10 |
+
{
|
11 |
+
$this->_init('dolist/dolistv8_calculatedfields');
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Customfields.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Customfields extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Model initialization
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _construct()
|
10 |
+
{
|
11 |
+
$this->_isPkAutoIncrement=false;
|
12 |
+
$this->_init('dolist/dolistv8_customfields', 'id');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Customfields/Collection.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
5 |
+
/**
|
6 |
+
* Initialize resource
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _construct()
|
10 |
+
{
|
11 |
+
$this->_init('dolist/dolistv8_customfields');
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Abstract.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Abstract attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
abstract class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve connection for read data
|
14 |
+
*
|
15 |
+
* @return mixed
|
16 |
+
*/
|
17 |
+
protected function _getReadAdapter()
|
18 |
+
{
|
19 |
+
return Mage::getModel('core/resource')->getConnection('read');
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Return table name including prefix
|
24 |
+
*
|
25 |
+
* @param string $tableName Table name
|
26 |
+
*
|
27 |
+
* @return string Table name
|
28 |
+
*/
|
29 |
+
public function getTable($tableName)
|
30 |
+
{
|
31 |
+
$tablePrefix = (string)Mage::getConfig()->getTablePrefix();
|
32 |
+
return $tablePrefix . $tableName;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Transform date to Dolist format
|
37 |
+
*
|
38 |
+
* @param string $inputDate Input date
|
39 |
+
*
|
40 |
+
* @return string Dolist formatted date
|
41 |
+
*/
|
42 |
+
public function formatDate($inputDate)
|
43 |
+
{
|
44 |
+
$outputDate = new Zend_Date($inputDate, 'Y-m-d H:i:s');
|
45 |
+
return $outputDate->toString('dd/m/Y');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Round string to integer, Dolist format
|
50 |
+
*
|
51 |
+
* @param string $inputInt Input string
|
52 |
+
*
|
53 |
+
* @return int Dolist formatted rounded integer
|
54 |
+
*/
|
55 |
+
public function formatInt($inputInt)
|
56 |
+
{
|
57 |
+
return round($inputInt);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Retrieve default helper
|
62 |
+
*
|
63 |
+
* @return Dolist_Net_Helper_Data
|
64 |
+
*/
|
65 |
+
protected function _getHelper()
|
66 |
+
{
|
67 |
+
return Mage::helper('dolist');
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Address1.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Address1 extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getStreet(1);
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Address2.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Address2 extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getStreet(2);
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Address3.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Address3 extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string|void
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getStreet(3);
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/City.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_City extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string|void
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
|
24 |
+
/** @var Mage_Customer_Model_Address $address */
|
25 |
+
$address = $customer->getDefaultBillingAddress();
|
26 |
+
if (!empty($address)) {
|
27 |
+
$return = $address->getCity();
|
28 |
+
}
|
29 |
+
return $return;
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Company.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Company extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getCompany();
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Country.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Country extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
protected $_countries = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Synchronize data in real tables in production database from temporary tables
|
16 |
+
*
|
17 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
18 |
+
* @param Varien_Object $config Config for this attribute
|
19 |
+
*
|
20 |
+
* @return
|
21 |
+
*/
|
22 |
+
public function getExportedValue($customer, $config)
|
23 |
+
{
|
24 |
+
$return = '';
|
25 |
+
$customerCountry = '';
|
26 |
+
|
27 |
+
$address = $customer->getDefaultBillingAddress();
|
28 |
+
if (!empty($address)) {
|
29 |
+
$customerCountry = $address->getCountry();
|
30 |
+
}
|
31 |
+
|
32 |
+
if ($customerCountry != '') {
|
33 |
+
$countries = $this->_getCountries();
|
34 |
+
if (array_key_exists($customerCountry, $countries)) {
|
35 |
+
$country = $countries[$customerCountry];
|
36 |
+
$return = $country->getDolistCode();
|
37 |
+
} else {
|
38 |
+
$return = Dolist_Net_Helper_Data::OTHER_COUNTRIES_CODE;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
return $return;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Load countries
|
47 |
+
*
|
48 |
+
* @return array Countries
|
49 |
+
*/
|
50 |
+
protected function _getCountries()
|
51 |
+
{
|
52 |
+
if (is_null($this->_countries)) {
|
53 |
+
$countries = Mage::getModel('directory/country')
|
54 |
+
->getCollection()
|
55 |
+
->getItems();
|
56 |
+
|
57 |
+
$this->_countries = $countries;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->_countries;
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Default.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Default date attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Mysql4_Dolistv8_Export_Adapter_Date_Default extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$origDate = $customer->getData($config);
|
24 |
+
if ($origDate != '') {
|
25 |
+
$date = new Zend_Date($customer->getData($config));
|
26 |
+
$return = $date->toString('dd/MM/YYYY');
|
27 |
+
}
|
28 |
+
return $return;
|
29 |
+
}
|
30 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Firstorder.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Calculated attribute adapter
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return value to display in export file for current field
|
15 |
+
*
|
16 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
17 |
+
* @param Varien_Object $config Config for this attribute
|
18 |
+
*
|
19 |
+
* @return string Exported value
|
20 |
+
*/
|
21 |
+
public function getExportedValue($customer, $config)
|
22 |
+
{
|
23 |
+
// Load array from cache
|
24 |
+
$serializedData = Mage::app()->loadCache(get_class($this));
|
25 |
+
$cacheArray = unserialize($serializedData);
|
26 |
+
$value = '';
|
27 |
+
|
28 |
+
// Return value if in array
|
29 |
+
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
30 |
+
$value = $cacheArray[$customer->getEmail()]['created_at'];
|
31 |
+
$value = $this->formatDate($value);
|
32 |
+
}
|
33 |
+
|
34 |
+
return $value;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Perform SQl request for calculated attribute and save result in cache
|
39 |
+
* Call to this method is performed before exporting, to be done only once.
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function performCalculatedAttributeRequest()
|
44 |
+
{
|
45 |
+
$readAdapter = $this->_getReadAdapter();
|
46 |
+
|
47 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
48 |
+
$tableName = 'sales_flat_order';
|
49 |
+
$select = $readAdapter->select()
|
50 |
+
->from($this->getTable($tableName), array('customer_email', 'MIN(created_at) AS created_at'))
|
51 |
+
->group('customer_email');
|
52 |
+
} else {
|
53 |
+
$tableName = 'sales_order';
|
54 |
+
$customerTableName = 'customer_entity';
|
55 |
+
$select = $readAdapter->select()
|
56 |
+
->from(array('sa' => $this->getTable($tableName)), array('ce.email AS customer_email', 'MIN(sa.created_at) AS created_at'))
|
57 |
+
->join(
|
58 |
+
array('ce' => $this->getTable($customerTableName)),
|
59 |
+
"ce.entity_id=sa.customer_id",
|
60 |
+
array()
|
61 |
+
)
|
62 |
+
->group('customer_email');
|
63 |
+
//SELECT ce.email as customer_email, min(o.created_at) as created_at FROM sales_order AS o INNER JOIN customer_entity ce ON ce.entity_id = o.customer_id GROUP BY o.customer_id;
|
64 |
+
}
|
65 |
+
|
66 |
+
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
67 |
+
$serializedData = serialize($rows);
|
68 |
+
|
69 |
+
// Save array to cache: use class_name as cache key
|
70 |
+
Mage::app()->saveCache($serializedData, get_class($this));
|
71 |
+
}
|
72 |
+
|
73 |
+
public function calculatedAttributeRequest($customerId)
|
74 |
+
{
|
75 |
+
$readAdapter = $this->_getReadAdapter();
|
76 |
+
|
77 |
+
$tableName = null;
|
78 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
79 |
+
$tableName = 'sales_flat_order';
|
80 |
+
} else {
|
81 |
+
$tableName = 'sales_order';
|
82 |
+
}
|
83 |
+
|
84 |
+
$select = $readAdapter->select()
|
85 |
+
->from(array('o' => $this->getTable($tableName)),
|
86 |
+
array(
|
87 |
+
'date' => 'MIN(created_at)'
|
88 |
+
))
|
89 |
+
->where('o.customer_id = ?', $customerId);
|
90 |
+
|
91 |
+
$row = $readAdapter->fetchOne($select);
|
92 |
+
return $row;
|
93 |
+
}
|
94 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastorder.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Return value to display in export file for current field
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
// Load array from cache
|
23 |
+
$serializedData = Mage::app()->loadCache(get_class($this));
|
24 |
+
$cacheArray = unserialize($serializedData);
|
25 |
+
$value = '';
|
26 |
+
|
27 |
+
// Return value if in array
|
28 |
+
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
29 |
+
$value = $cacheArray[$customer->getEmail()]['created_at'];
|
30 |
+
$value = $this->formatDate($value);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $value;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Perform SQl request for calculated attribute and save result in cache
|
38 |
+
* Call to this method is performed before exporting, to be done only once.
|
39 |
+
*
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function performCalculatedAttributeRequest()
|
43 |
+
{
|
44 |
+
$readAdapter = $this->_getReadAdapter();
|
45 |
+
|
46 |
+
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
47 |
+
$tableName = 'sales_flat_order';
|
48 |
+
$select = $readAdapter->select()
|
49 |
+
->from($this->getTable($tableName), array('customer_email', 'MAX(created_at) AS created_at'))
|
50 |
+
->group('customer_email');
|
51 |
+
}else{
|
52 |
+
$tableName = 'sales_order';
|
53 |
+
$customerTableName = 'customer_entity';
|
54 |
+
$select = $readAdapter->select()
|
55 |
+
->from(array('sa' => $this->getTable($tableName)), array('ce.email AS customer_email', 'MAX(sa.created_at) AS created_at'))
|
56 |
+
->join(
|
57 |
+
array('ce' => $this->getTable($customerTableName)),
|
58 |
+
"ce.entity_id=sa.customer_id",
|
59 |
+
array()
|
60 |
+
)
|
61 |
+
->group('customer_email');
|
62 |
+
//SELECT ce.email as customer_email, max(o.created_at) as created_at FROM sales_order AS o INNER JOIN customer_entity ce ON ce.entity_id = o.customer_id GROUP BY o.customer_id;
|
63 |
+
}
|
64 |
+
|
65 |
+
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
66 |
+
$serializedData = serialize($rows);
|
67 |
+
|
68 |
+
// Save array to cache: use class_name as cache key
|
69 |
+
Mage::app()->saveCache($serializedData, get_class($this));
|
70 |
+
}
|
71 |
+
|
72 |
+
public function calculatedAttributeRequest($customerId)
|
73 |
+
{
|
74 |
+
$readAdapter = $this->_getReadAdapter();
|
75 |
+
|
76 |
+
$tableName = null;
|
77 |
+
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
78 |
+
$tableName = 'sales_flat_order';
|
79 |
+
}else{
|
80 |
+
$tableName = 'sales_order';
|
81 |
+
}
|
82 |
+
|
83 |
+
$select = $readAdapter->select()
|
84 |
+
->from(array('o' => $this->getTable($tableName)),
|
85 |
+
array(
|
86 |
+
'date'=>'MAX(created_at)'
|
87 |
+
))
|
88 |
+
->where('o.customer_id = ?', $customerId)
|
89 |
+
;
|
90 |
+
|
91 |
+
|
92 |
+
$row = $readAdapter->fetchOne($select);
|
93 |
+
return $row;
|
94 |
+
}
|
95 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastquotenotordered.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered
|
11 |
+
extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return value to display in export file for current field
|
15 |
+
*
|
16 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
17 |
+
* @param Varien_Object $config Config for this attribute
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
public function getExportedValue($customer, $config)
|
22 |
+
{
|
23 |
+
// Load array from cache
|
24 |
+
$serializedData = Mage::app()->loadCache(get_class($this));
|
25 |
+
$cacheArray = unserialize($serializedData);
|
26 |
+
$value = '';
|
27 |
+
|
28 |
+
// Return value if in array
|
29 |
+
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
30 |
+
$value = $cacheArray[$customer->getEmail()]['created_at'];
|
31 |
+
$value = $this->formatDate($value);
|
32 |
+
}
|
33 |
+
|
34 |
+
return $value;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Perform SQl request for calculated attribute and save result in cache
|
39 |
+
* Call to this method is performed before exporting, to be done only once.
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function performCalculatedAttributeRequest()
|
44 |
+
{
|
45 |
+
$readAdapter = $this->_getReadAdapter();
|
46 |
+
|
47 |
+
$quoteTableName = 'sales_flat_quote';
|
48 |
+
$orderTableName = 'sales_flat_order';
|
49 |
+
$customerTableName = 'customer_entity';
|
50 |
+
|
51 |
+
|
52 |
+
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
53 |
+
// Nested request
|
54 |
+
$nestedRequest = $readAdapter->select()
|
55 |
+
->from(
|
56 |
+
array('q' => $this->getTable($quoteTableName)),
|
57 |
+
array(
|
58 |
+
'q.entity_id AS quote_id',
|
59 |
+
'q.customer_id',
|
60 |
+
'q.created_at'
|
61 |
+
)
|
62 |
+
)
|
63 |
+
->joinLeft(
|
64 |
+
array('o' => $this->getTable($orderTableName)),
|
65 |
+
"q.entity_id=o.quote_id",
|
66 |
+
array()
|
67 |
+
)
|
68 |
+
->where('o.entity_id IS NULL')
|
69 |
+
->order('q.created_at DESC');
|
70 |
+
|
71 |
+
$select = $readAdapter->select()
|
72 |
+
->from(
|
73 |
+
array('l' => $nestedRequest),
|
74 |
+
array(
|
75 |
+
'c.email AS customer_email',
|
76 |
+
'l.created_at'
|
77 |
+
)
|
78 |
+
)
|
79 |
+
->join(
|
80 |
+
array('c' => $this->getTable($customerTableName)),
|
81 |
+
"c.entity_id=l.customer_id",
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('l.customer_id');
|
85 |
+
|
86 |
+
/*
|
87 |
+
* MySQL request
|
88 |
+
SELECT customer_entity.email, last_not_ordered_carts.created_at
|
89 |
+
FROM
|
90 |
+
(
|
91 |
+
SELECT sales_flat_quote.entity_id AS quote_id, sales_flat_quote.customer_id, sales_flat_quote.created_at
|
92 |
+
FROM sales_flat_quote
|
93 |
+
LEFT JOIN sales_flat_order ON sales_flat_quote.entity_id = sales_flat_order.quote_id
|
94 |
+
WHERE sales_flat_order.entity_id IS NULL
|
95 |
+
ORDER BY sales_flat_quote.created_at DESC
|
96 |
+
)
|
97 |
+
AS last_not_ordered_carts
|
98 |
+
INNER JOIN customer_entity ON customer_entity.entity_id = last_not_ordered_carts.customer_id
|
99 |
+
GROUP BY last_not_ordered_carts.customer_id
|
100 |
+
*/
|
101 |
+
}else{
|
102 |
+
$quoteTableName = 'sales_flat_quote';
|
103 |
+
$customerTableName = 'customer_entity';
|
104 |
+
$orderTableName = 'sales_order';
|
105 |
+
$attributeTableName = 'sales_order_int';
|
106 |
+
$eavTableName = 'eav_attribute';
|
107 |
+
$nestedRequest = $readAdapter->select()
|
108 |
+
->from(
|
109 |
+
array('q' => $this->getTable($quoteTableName)),
|
110 |
+
array(
|
111 |
+
'q.entity_id AS quote_id',
|
112 |
+
'q.customer_id',
|
113 |
+
'q.created_at'
|
114 |
+
)
|
115 |
+
)
|
116 |
+
->joinLeft(
|
117 |
+
array('e' => $this->getTable($eavTableName)),
|
118 |
+
"e.attribute_code='quote_id'",
|
119 |
+
array()
|
120 |
+
)
|
121 |
+
->joinLeft(
|
122 |
+
array('a' => $this->getTable($attributeTableName)),
|
123 |
+
"a.value=q.entity_id AND a.attribute_id = e.attribute_id",
|
124 |
+
array()
|
125 |
+
)
|
126 |
+
->joinLeft(
|
127 |
+
array('o' => $this->getTable($orderTableName)),
|
128 |
+
"a.entity_id=o.entity_id",
|
129 |
+
array()
|
130 |
+
)
|
131 |
+
->where('o.entity_id IS NULL')
|
132 |
+
->order('q.created_at DESC');
|
133 |
+
|
134 |
+
$select = $readAdapter->select()
|
135 |
+
->from(
|
136 |
+
array('l' => $nestedRequest),
|
137 |
+
array(
|
138 |
+
'c.email AS customer_email',
|
139 |
+
'l.created_at'
|
140 |
+
)
|
141 |
+
)
|
142 |
+
->join(
|
143 |
+
array('c' => $this->getTable($customerTableName)),
|
144 |
+
"c.entity_id=l.customer_id",
|
145 |
+
array()
|
146 |
+
)
|
147 |
+
->group('l.customer_id');
|
148 |
+
|
149 |
+
/*
|
150 |
+
* MySQL request
|
151 |
+
SELECT customer_entity.email, last_not_ordered_carts.created_at
|
152 |
+
FROM
|
153 |
+
(
|
154 |
+
SELECT sales_flat_quote.entity_id AS quote_id, sales_flat_quote.customer_id, sales_flat_quote.created_at
|
155 |
+
FROM sales_flat_quote
|
156 |
+
LEFT JOIN sales_flat_order ON sales_flat_quote.entity_id = sales_flat_order.quote_id
|
157 |
+
WHERE sales_flat_order.entity_id IS NULL
|
158 |
+
ORDER BY sales_flat_quote.created_at DESC
|
159 |
+
)
|
160 |
+
AS last_not_ordered_carts
|
161 |
+
INNER JOIN customer_entity ON customer_entity.entity_id = last_not_ordered_carts.customer_id
|
162 |
+
GROUP BY last_not_ordered_carts.customer_id
|
163 |
+
*/
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
168 |
+
$serializedData = serialize($rows);
|
169 |
+
|
170 |
+
// Save array to cache: use class_name as cache key
|
171 |
+
Mage::app()->saveCache($serializedData, get_class($this));
|
172 |
+
}
|
173 |
+
|
174 |
+
public function calculatedAttributeRequest($customerId){
|
175 |
+
$readAdapter = $this->_getReadAdapter();
|
176 |
+
$quoteTableName = null;
|
177 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
178 |
+
$quoteTableName = 'sales_flat_quote';
|
179 |
+
} else {
|
180 |
+
$quoteTableName = 'sales_flat_quote';
|
181 |
+
}
|
182 |
+
|
183 |
+
$request = $readAdapter->select()
|
184 |
+
->from(
|
185 |
+
array('q' => $this->getTable($quoteTableName)),
|
186 |
+
array(
|
187 |
+
'q.created_at'
|
188 |
+
)
|
189 |
+
)
|
190 |
+
->where('q.customer_id = ?', $customerId)
|
191 |
+
->where('q.reserved_order_id IS NULL')
|
192 |
+
->order('q.created_at DESC');
|
193 |
+
|
194 |
+
$row = $readAdapter->fetchOne($request);
|
195 |
+
return $row;
|
196 |
+
}
|
197 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Default.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Default attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Default extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return mixed
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
return $customer->getData($config);
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Fax.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Fax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getFax();
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorder.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param $customerId
|
17 |
+
* @return mixed
|
18 |
+
*/
|
19 |
+
public function calculatedAttributeRequest($customerId, $dates = array())
|
20 |
+
{
|
21 |
+
$readAdapter = $this->_getReadAdapter();
|
22 |
+
|
23 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
24 |
+
$orderTableName = 'sales_flat_order';
|
25 |
+
|
26 |
+
// Nested request
|
27 |
+
$select = $readAdapter->select()
|
28 |
+
->from(
|
29 |
+
array('o' => $this->getTable($orderTableName)),
|
30 |
+
array(
|
31 |
+
'AVG(o.total_item_count) AS avg_total_item_count'
|
32 |
+
)
|
33 |
+
)
|
34 |
+
->where('o.customer_id = ?', $customerId);
|
35 |
+
} else {
|
36 |
+
$orderTableName = 'sales_order';
|
37 |
+
$orderItemTableName = 'sales_flat_order_item';
|
38 |
+
|
39 |
+
// Nested request
|
40 |
+
$select = $readAdapter->select()
|
41 |
+
->from(
|
42 |
+
array('o' => $this->getTable($orderTableName)),
|
43 |
+
array(
|
44 |
+
'count(sf.item_id)/count(DISTINCT o.entity_id) as avg_total_item_count'
|
45 |
+
)
|
46 |
+
)->joinLeft(
|
47 |
+
array('sf' => $this->getTable($orderItemTableName)),
|
48 |
+
"sf.order_id = o.entity_id",
|
49 |
+
array()
|
50 |
+
)
|
51 |
+
->where('o.customer_id = ?', $customerId);
|
52 |
+
}
|
53 |
+
|
54 |
+
if (!empty($dates)) {
|
55 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
56 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
57 |
+
}
|
58 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
59 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$row = $readAdapter->fetchOne($select);
|
64 |
+
return $row;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorderline.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrderLine extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param $customerId
|
17 |
+
* @return mixed
|
18 |
+
*/
|
19 |
+
public function calculatedAttributeRequest($customerId, $dates=array())
|
20 |
+
{
|
21 |
+
$readAdapter = $this->_getReadAdapter();
|
22 |
+
|
23 |
+
$select = null;
|
24 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
25 |
+
$orderTableName = 'sales_flat_order';
|
26 |
+
|
27 |
+
// Nested request
|
28 |
+
$select = $readAdapter->select()
|
29 |
+
->from(
|
30 |
+
array('o' => $this->getTable($orderTableName)),
|
31 |
+
array(
|
32 |
+
'AVG(total_qty_ordered / total_item_count) AS avg_products_per_line'
|
33 |
+
)
|
34 |
+
)
|
35 |
+
->where('o.customer_id = ?', $customerId);
|
36 |
+
} else {
|
37 |
+
$orderTableName = 'sales_order';
|
38 |
+
$orderItemTableName = 'sales_flat_order_item';
|
39 |
+
|
40 |
+
$select = $readAdapter->select()
|
41 |
+
->from(
|
42 |
+
array('o' => $this->getTable($orderTableName)),
|
43 |
+
array(
|
44 |
+
'SUM(o.total_qty_ordered)/count(sf.item_id) as avg_products_per_line'
|
45 |
+
)
|
46 |
+
)->joinLeft(
|
47 |
+
array('sf' => $this->getTable($orderItemTableName)),
|
48 |
+
"sf.order_id = o.entity_id",
|
49 |
+
array()
|
50 |
+
)
|
51 |
+
->where('o.customer_id = ?', $customerId);
|
52 |
+
}
|
53 |
+
|
54 |
+
if (!empty($dates)) {
|
55 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
56 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
57 |
+
}
|
58 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
59 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$row = $readAdapter->fetchOne($select);
|
64 |
+
return $row;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbproductsperorder.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbProductsPerOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Perform SQl request for calculated attribute and save result in cache
|
15 |
+
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $dates = array())
|
18 |
+
{
|
19 |
+
$readAdapter = $this->_getReadAdapter();
|
20 |
+
$orderTableName = null;
|
21 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
22 |
+
$orderTableName = 'sales_flat_order';
|
23 |
+
|
24 |
+
} else {
|
25 |
+
$orderTableName = 'sales_order';
|
26 |
+
}
|
27 |
+
$select = $readAdapter
|
28 |
+
->select()
|
29 |
+
->from(
|
30 |
+
array('o' => $this->getTable($orderTableName)),
|
31 |
+
array(
|
32 |
+
'total' => 'AVG(o.total_qty_ordered)'
|
33 |
+
)
|
34 |
+
)
|
35 |
+
->where('o.customer_id = ?', $customerId)
|
36 |
+
->order('o.created_at ASC');
|
37 |
+
|
38 |
+
if (!empty($dates)) {
|
39 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
40 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
41 |
+
}
|
42 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
43 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
44 |
+
}
|
45 |
+
}
|
46 |
+
$row = $readAdapter->fetchOne($select);
|
47 |
+
return $row;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountexcltax.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @author mague <mague@smile.fr>
|
8 |
+
* @copyright 2012 Smile
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountExclTax
|
12 |
+
extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Perform SQl request for calculated attribute and save result in cache
|
16 |
+
* Call to this method is performed before exporting, to be done only once.
|
17 |
+
*/
|
18 |
+
public function calculatedAttributeRequest($customerId, $dates = array())
|
19 |
+
{
|
20 |
+
$readAdapter = $this->_getReadAdapter();
|
21 |
+
$orderTableName = null;
|
22 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
23 |
+
$orderTableName = 'sales_flat_order';
|
24 |
+
|
25 |
+
} else {
|
26 |
+
$orderTableName = 'sales_order';
|
27 |
+
}
|
28 |
+
$select = $readAdapter
|
29 |
+
->select()
|
30 |
+
->from(
|
31 |
+
array('o' => $this->getTable($orderTableName)),
|
32 |
+
array(
|
33 |
+
'total' => 'AVG(o.grand_total - o.tax_amount)'
|
34 |
+
)
|
35 |
+
)
|
36 |
+
->where('o.customer_id = ?', $customerId)
|
37 |
+
->order('o.created_at ASC');
|
38 |
+
|
39 |
+
if (!empty($dates)) {
|
40 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
41 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
42 |
+
}
|
43 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
44 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$row = $readAdapter->fetchOne($select);
|
49 |
+
return $row;
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountincltax.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Return value to display in export file for current field
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
// Load array from cache
|
23 |
+
$serializedData = Mage::app()->loadCache(get_class($this));
|
24 |
+
$cacheArray = unserialize($serializedData);
|
25 |
+
$value = '';
|
26 |
+
|
27 |
+
// Return value if in array
|
28 |
+
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
29 |
+
$value = $cacheArray[$customer->getEmail()]['avg_grand_total'];
|
30 |
+
$value = $this->formatInt($value);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $value;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Perform SQl request for calculated attribute and save result in cache
|
38 |
+
* Call to this method is performed before exporting, to be done only once.
|
39 |
+
*
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function performCalculatedAttributeRequest()
|
43 |
+
{
|
44 |
+
$readAdapter = $this->_getReadAdapter();
|
45 |
+
|
46 |
+
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
47 |
+
$orderTableName = 'sales_flat_order';
|
48 |
+
|
49 |
+
// Nested request
|
50 |
+
$select = $readAdapter->select()
|
51 |
+
->from(
|
52 |
+
array('o' => $this->getTable($orderTableName)),
|
53 |
+
array(
|
54 |
+
'o.customer_email AS customer_email',
|
55 |
+
'o.customer_id',
|
56 |
+
'AVG(o.grand_total) AS avg_grand_total'
|
57 |
+
)
|
58 |
+
)
|
59 |
+
->group('o.customer_id');
|
60 |
+
|
61 |
+
/*
|
62 |
+
* MySQL request
|
63 |
+
SELECT o.customer_id, o.customer_email, AVG(o.subtotal), AVG(o.grand_total)
|
64 |
+
FROM sales_flat_order AS o
|
65 |
+
GROUP BY o.customer_id
|
66 |
+
*/
|
67 |
+
}else{
|
68 |
+
$orderTableName = 'sales_order';
|
69 |
+
$customerTableName = 'customer_entity';
|
70 |
+
|
71 |
+
// Nested request
|
72 |
+
$select = $readAdapter->select()
|
73 |
+
->from(
|
74 |
+
array('o' => $this->getTable($orderTableName)),
|
75 |
+
array(
|
76 |
+
'ce.email AS customer_email',
|
77 |
+
'o.customer_id',
|
78 |
+
'AVG(o.grand_total) AS avg_grand_total'
|
79 |
+
)
|
80 |
+
)->join(
|
81 |
+
array('ce' => $this->getTable($customerTableName)),
|
82 |
+
"ce.entity_id=o.customer_id",
|
83 |
+
array()
|
84 |
+
)
|
85 |
+
->group('o.customer_id');
|
86 |
+
//SELECT o.customer_id, ce.email as customer_email, AVG(o.grand_total) as avg_grand_total FROM sales_order AS o INNER JOIN customer_entity ce ON ce.entity_id = o.customer_id GROUP BY o.customer_id
|
87 |
+
}
|
88 |
+
|
89 |
+
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
90 |
+
$serializedData = serialize($rows);
|
91 |
+
|
92 |
+
// Save array to cache: use class_name as cache key
|
93 |
+
Mage::app()->saveCache($serializedData, get_class($this));
|
94 |
+
}
|
95 |
+
|
96 |
+
public function calculatedAttributeRequest($customerId, $dates=array())
|
97 |
+
{
|
98 |
+
$readAdapter = $this->_getReadAdapter();
|
99 |
+
$orderTableName = null;
|
100 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
101 |
+
$orderTableName = 'sales_flat_order';
|
102 |
+
|
103 |
+
} else {
|
104 |
+
$orderTableName = 'sales_order';
|
105 |
+
}
|
106 |
+
$select = $readAdapter
|
107 |
+
->select()
|
108 |
+
->from(
|
109 |
+
array('o' => $this->getTable($orderTableName)),
|
110 |
+
array(
|
111 |
+
'total' => 'AVG(o.grand_total)'
|
112 |
+
)
|
113 |
+
)
|
114 |
+
->where('o.customer_id = ?', $customerId)
|
115 |
+
->order('o.created_at ASC');
|
116 |
+
|
117 |
+
if (!empty($dates)) {
|
118 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
119 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
120 |
+
}
|
121 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
122 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
$row = $readAdapter->fetchOne($select);
|
127 |
+
return $row;
|
128 |
+
}
|
129 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountexcltax.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Calculated attribute adapter
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Perform SQl request for calculated attribute and save result in cache
|
17 |
+
* Call to this method is performed before exporting, to be done only once.
|
18 |
+
*
|
19 |
+
* @param $customerId
|
20 |
+
* @return mixed
|
21 |
+
*/
|
22 |
+
public function calculatedAttributeRequest($customerId)
|
23 |
+
{
|
24 |
+
$readAdapter = $this->_getReadAdapter();
|
25 |
+
$orderTableName = null;
|
26 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
27 |
+
$orderTableName = 'sales_flat_order';
|
28 |
+
|
29 |
+
} else {
|
30 |
+
$orderTableName = 'sales_order';
|
31 |
+
}
|
32 |
+
$select = $readAdapter
|
33 |
+
->select()
|
34 |
+
->from(
|
35 |
+
array('o' => $this->getTable($orderTableName)),
|
36 |
+
array(
|
37 |
+
'total' => '(o.grand_total - o.tax_amount)'
|
38 |
+
)
|
39 |
+
)
|
40 |
+
->where('o.customer_id = ?', $customerId)
|
41 |
+
->order('o.created_at ASC');
|
42 |
+
|
43 |
+
$row = $readAdapter->fetchOne($select);
|
44 |
+
return $row;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountincltax.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Calculated attribute adapter
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Perform SQl request for calculated attribute and save result in cache
|
16 |
+
* Call to this method is performed before exporting, to be done only once.
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function calculatedAttributeRequest($customerId)
|
20 |
+
{
|
21 |
+
$readAdapter = $this->_getReadAdapter();
|
22 |
+
$orderTableName = null;
|
23 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
24 |
+
$orderTableName = 'sales_flat_order';
|
25 |
+
} else {
|
26 |
+
$orderTableName = 'sales_order';
|
27 |
+
}
|
28 |
+
$select = $readAdapter
|
29 |
+
->select()
|
30 |
+
->from(
|
31 |
+
array('o' => $this->getTable($orderTableName)),
|
32 |
+
array(
|
33 |
+
'total' => 'o.grand_total'
|
34 |
+
)
|
35 |
+
)
|
36 |
+
->where('o.customer_id = ?', $customerId)
|
37 |
+
->order('o.created_at ASC');
|
38 |
+
|
39 |
+
$row = $readAdapter->fetchOne($select);
|
40 |
+
return $row;
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountexcltax.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountExclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param $customerId
|
17 |
+
* @return mixed
|
18 |
+
*/
|
19 |
+
public function calculatedAttributeRequest($customerId)
|
20 |
+
{
|
21 |
+
$readAdapter = $this->_getReadAdapter();
|
22 |
+
|
23 |
+
$quoteTableName = null;
|
24 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
25 |
+
$quoteTableName = 'sales_flat_quote';
|
26 |
+
} else {
|
27 |
+
$quoteTableName = 'sales_flat_quote';
|
28 |
+
}
|
29 |
+
|
30 |
+
$request = $readAdapter->select()
|
31 |
+
->from(
|
32 |
+
array('q' => $this->getTable($quoteTableName)),
|
33 |
+
array(
|
34 |
+
'q.subtotal'
|
35 |
+
)
|
36 |
+
)
|
37 |
+
->where('q.customer_id = ?', $customerId)
|
38 |
+
->where('q.reserved_order_id IS NULL')
|
39 |
+
->order('q.created_at DESC');
|
40 |
+
|
41 |
+
$row = $readAdapter->fetchOne($request);
|
42 |
+
|
43 |
+
return $row;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountincltax.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Return value to display in export file for current field
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
// Load array from cache
|
23 |
+
$serializedData = Mage::app()->loadCache(get_class($this));
|
24 |
+
$cacheArray = unserialize($serializedData);
|
25 |
+
$value = '';
|
26 |
+
|
27 |
+
// Return value if in array
|
28 |
+
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
29 |
+
$value = $cacheArray[$customer->getEmail()]['grand_total'];
|
30 |
+
$value = $this->formatInt($value);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $value;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Perform SQl request for calculated attribute and save result in cache
|
38 |
+
* Call to this method is performed before exporting, to be done only once.
|
39 |
+
*
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function performCalculatedAttributeRequest()
|
43 |
+
{
|
44 |
+
$readAdapter = $this->_getReadAdapter();
|
45 |
+
|
46 |
+
|
47 |
+
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
48 |
+
$quoteTableName = 'sales_flat_quote';
|
49 |
+
$orderTableName = 'sales_flat_order';
|
50 |
+
$customerTableName = 'customer_entity';
|
51 |
+
// Nested request
|
52 |
+
$nestedRequest = $readAdapter->select()
|
53 |
+
->from(
|
54 |
+
array('q' => $this->getTable($quoteTableName)),
|
55 |
+
array(
|
56 |
+
'q.entity_id AS quote_id',
|
57 |
+
'q.customer_id',
|
58 |
+
'q.grand_total'
|
59 |
+
)
|
60 |
+
)
|
61 |
+
->joinLeft(
|
62 |
+
array('o' => $this->getTable($orderTableName)),
|
63 |
+
"q.entity_id=o.quote_id",
|
64 |
+
array()
|
65 |
+
)
|
66 |
+
->where('o.entity_id IS NULL')
|
67 |
+
->order('q.created_at DESC');
|
68 |
+
|
69 |
+
$select = $readAdapter->select()
|
70 |
+
->from(
|
71 |
+
array('l' => $nestedRequest),
|
72 |
+
array(
|
73 |
+
'c.email AS customer_email',
|
74 |
+
'l.grand_total'
|
75 |
+
)
|
76 |
+
)
|
77 |
+
->join(
|
78 |
+
array('c' => $this->getTable($customerTableName)),
|
79 |
+
"c.entity_id=l.customer_id",
|
80 |
+
array()
|
81 |
+
)
|
82 |
+
->group('l.customer_id');
|
83 |
+
|
84 |
+
/*
|
85 |
+
* MySQL request
|
86 |
+
SELECT customer_entity.email, last_not_ordered_carts.grand_total, last_not_ordered_carts.subtotal
|
87 |
+
FROM
|
88 |
+
(
|
89 |
+
SELECT q.grand_total, q.subtotal, q.customer_id
|
90 |
+
FROM sales_flat_quote AS q
|
91 |
+
LEFT JOIN sales_flat_order ON q.entity_id = sales_flat_order.quote_id
|
92 |
+
WHERE sales_flat_order.entity_id IS NULL
|
93 |
+
ORDER BY q.created_at DESC
|
94 |
+
)
|
95 |
+
AS last_not_ordered_carts
|
96 |
+
INNER JOIN customer_entity ON customer_entity.entity_id = last_not_ordered_carts.customer_id
|
97 |
+
*/
|
98 |
+
}else{
|
99 |
+
$quoteTableName = 'sales_flat_quote';
|
100 |
+
$customerTableName = 'customer_entity';
|
101 |
+
$orderTableName = 'sales_order';
|
102 |
+
$attributeTableName = 'sales_order_int';
|
103 |
+
$eavTableName = 'eav_attribute';
|
104 |
+
// Nested request
|
105 |
+
$nestedRequest = $readAdapter->select()
|
106 |
+
->from(
|
107 |
+
array('q' => $this->getTable($quoteTableName)),
|
108 |
+
array(
|
109 |
+
'q.entity_id AS quote_id',
|
110 |
+
'q.customer_id',
|
111 |
+
'q.grand_total'
|
112 |
+
)
|
113 |
+
)
|
114 |
+
->joinLeft(
|
115 |
+
array('e' => $this->getTable($eavTableName)),
|
116 |
+
"e.attribute_code='quote_id'",
|
117 |
+
array()
|
118 |
+
)
|
119 |
+
->joinLeft(
|
120 |
+
array('a' => $this->getTable($attributeTableName)),
|
121 |
+
"a.value=q.entity_id AND a.attribute_id = e.attribute_id",
|
122 |
+
array()
|
123 |
+
)
|
124 |
+
->joinLeft(
|
125 |
+
array('o' => $this->getTable($orderTableName)),
|
126 |
+
"a.entity_id=o.entity_id",
|
127 |
+
array()
|
128 |
+
)
|
129 |
+
->where('o.entity_id IS NULL')
|
130 |
+
->order('q.created_at DESC');
|
131 |
+
|
132 |
+
$select = $readAdapter->select()
|
133 |
+
->from(
|
134 |
+
array('l' => $nestedRequest),
|
135 |
+
array(
|
136 |
+
'c.email AS customer_email',
|
137 |
+
'l.grand_total'
|
138 |
+
)
|
139 |
+
)
|
140 |
+
->join(
|
141 |
+
array('c' => $this->getTable($customerTableName)),
|
142 |
+
"c.entity_id=l.customer_id",
|
143 |
+
array()
|
144 |
+
)
|
145 |
+
->group('l.customer_id');
|
146 |
+
}
|
147 |
+
|
148 |
+
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
149 |
+
$serializedData = serialize($rows);
|
150 |
+
|
151 |
+
// Save array to cache: use class_name as cache key
|
152 |
+
Mage::app()->saveCache($serializedData, get_class($this));
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param $customerId
|
157 |
+
* @return mixed
|
158 |
+
*/
|
159 |
+
public function calculatedAttributeRequest($customerId)
|
160 |
+
{
|
161 |
+
$readAdapter = $this->_getReadAdapter();
|
162 |
+
$quoteTableName = null;
|
163 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
164 |
+
$quoteTableName = 'sales_flat_quote';
|
165 |
+
} else {
|
166 |
+
$quoteTableName = 'sales_flat_quote';
|
167 |
+
}
|
168 |
+
|
169 |
+
$request = $readAdapter->select()
|
170 |
+
->from(
|
171 |
+
array('q' => $this->getTable($quoteTableName)),
|
172 |
+
array(
|
173 |
+
'q.grand_total'
|
174 |
+
)
|
175 |
+
)
|
176 |
+
->where('q.customer_id = ?', $customerId)
|
177 |
+
->where('q.reserved_order_id IS NULL')
|
178 |
+
->order('q.created_at DESC');
|
179 |
+
|
180 |
+
$row = $readAdapter->fetchOne($request);
|
181 |
+
return $row;
|
182 |
+
}
|
183 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountexcltax.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountExclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*/
|
16 |
+
public function calculatedAttributeRequest($customerId)
|
17 |
+
{
|
18 |
+
$readAdapter = $this->_getReadAdapter();
|
19 |
+
$orderTableName = null;
|
20 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
21 |
+
$orderTableName = 'sales_flat_order';
|
22 |
+
|
23 |
+
} else {
|
24 |
+
$orderTableName = 'sales_order';
|
25 |
+
}
|
26 |
+
$select = $readAdapter
|
27 |
+
->select()
|
28 |
+
->from(
|
29 |
+
array('o' => $this->getTable($orderTableName)),
|
30 |
+
array(
|
31 |
+
'total' => '(o.grand_total - o.tax_amount)'
|
32 |
+
)
|
33 |
+
)
|
34 |
+
->where('o.customer_id = ?', $customerId)
|
35 |
+
->order('o.created_at DESC');
|
36 |
+
|
37 |
+
$row = $readAdapter->fetchOne($select);
|
38 |
+
return $row;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountincltax.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param $customerId
|
17 |
+
* @return mixed
|
18 |
+
*/
|
19 |
+
public function calculatedAttributeRequest($customerId)
|
20 |
+
{
|
21 |
+
$readAdapter = $this->_getReadAdapter();
|
22 |
+
$orderTableName = null;
|
23 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
24 |
+
$orderTableName = 'sales_flat_order';
|
25 |
+
} else {
|
26 |
+
$orderTableName = 'sales_order';
|
27 |
+
}
|
28 |
+
$select = $readAdapter
|
29 |
+
->select()
|
30 |
+
->from(
|
31 |
+
array('o' => $this->getTable($orderTableName)),
|
32 |
+
array(
|
33 |
+
'total' => 'o.grand_total'
|
34 |
+
)
|
35 |
+
)
|
36 |
+
->where('o.customer_id = ?', $customerId)
|
37 |
+
->order('o.created_at DESC');
|
38 |
+
|
39 |
+
|
40 |
+
$row = $readAdapter->fetchOne($select);
|
41 |
+
return $row;
|
42 |
+
}
|
43 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Nbpromotionrulesused.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_NbPromotionRulesUsed extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*/
|
16 |
+
public function calculatedAttributeRequest($customerId)
|
17 |
+
{
|
18 |
+
$readAdapter = $this->_getReadAdapter();
|
19 |
+
|
20 |
+
$salesruleTableName = 'salesrule_customer';
|
21 |
+
|
22 |
+
// Nested request
|
23 |
+
$select = $readAdapter->select()
|
24 |
+
->from(
|
25 |
+
array('s' => $this->getTable($salesruleTableName)),
|
26 |
+
array(
|
27 |
+
'nb_rules'=>'SUM(s.times_used)'
|
28 |
+
)
|
29 |
+
)
|
30 |
+
->where('s.customer_id = ?', $customerId);
|
31 |
+
|
32 |
+
|
33 |
+
$row = $readAdapter->fetchOne($select);
|
34 |
+
return $row;
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountexcltax.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountExclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Perform SQl request for calculated attribute and save result in cache
|
15 |
+
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $dates=array())
|
18 |
+
{
|
19 |
+
$readAdapter = $this->_getReadAdapter();
|
20 |
+
$orderTableName = null;
|
21 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
22 |
+
$orderTableName = 'sales_flat_order';
|
23 |
+
} else {
|
24 |
+
$orderTableName = 'sales_order';
|
25 |
+
}
|
26 |
+
|
27 |
+
$select = $readAdapter
|
28 |
+
->select()
|
29 |
+
->from(
|
30 |
+
array('o' => $this->getTable($orderTableName)),
|
31 |
+
array(
|
32 |
+
'total' => 'SUM(o.grand_total - o.tax_amount)'
|
33 |
+
)
|
34 |
+
)
|
35 |
+
->where('o.customer_id = ?', $customerId)
|
36 |
+
->order('o.created_at ASC');
|
37 |
+
|
38 |
+
if (!empty($dates)) {
|
39 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
40 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
41 |
+
}
|
42 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
43 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
$row = $readAdapter->fetchOne($select);
|
48 |
+
return $row;
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountincltax.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Calculated attribute adapter
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Perform SQl request for calculated attribute and save result in cache
|
15 |
+
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $dates = array())
|
18 |
+
{
|
19 |
+
$readAdapter = $this->_getReadAdapter();
|
20 |
+
$orderTableName = null;
|
21 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
22 |
+
$orderTableName = 'sales_flat_order';
|
23 |
+
} else {
|
24 |
+
$orderTableName = 'sales_order';
|
25 |
+
}
|
26 |
+
|
27 |
+
$select = $readAdapter
|
28 |
+
->select()
|
29 |
+
->from(
|
30 |
+
array('o' => $this->getTable($orderTableName)),
|
31 |
+
array(
|
32 |
+
'total' => 'SUM(o.grand_total)'
|
33 |
+
)
|
34 |
+
)
|
35 |
+
->where('o.customer_id = ?', $customerId);
|
36 |
+
|
37 |
+
|
38 |
+
if (!empty($dates)) {
|
39 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
40 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
41 |
+
}
|
42 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
43 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
$select->order('o.created_at ASC');
|
48 |
+
|
49 |
+
$row = $readAdapter->fetchOne($select);
|
50 |
+
return $row;
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderedproducts.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Calculated attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Perform SQl request for calculated attribute and save result in cache
|
14 |
+
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*/
|
16 |
+
public function calculatedAttributeRequest($customerId, $dates = array())
|
17 |
+
{
|
18 |
+
$readAdapter = $this->_getReadAdapter();
|
19 |
+
$orderTableName = null;
|
20 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
21 |
+
$orderTableName = 'sales_flat_order';
|
22 |
+
|
23 |
+
} else {
|
24 |
+
$orderTableName = 'sales_order';
|
25 |
+
}
|
26 |
+
$select = $readAdapter
|
27 |
+
->select()
|
28 |
+
->from(
|
29 |
+
array('o' => $this->getTable($orderTableName)),
|
30 |
+
array(
|
31 |
+
'total' => 'SUM(o.total_qty_ordered)'
|
32 |
+
)
|
33 |
+
)
|
34 |
+
->where('o.customer_id = ?', $customerId)
|
35 |
+
->order('o.created_at ASC');
|
36 |
+
|
37 |
+
if (!empty($dates)) {
|
38 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
39 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
40 |
+
}
|
41 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
42 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
43 |
+
}
|
44 |
+
}
|
45 |
+
$row = $readAdapter->fetchOne($select);
|
46 |
+
return $row;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorders.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Calculated attribute adapter
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Perform SQl request for calculated attribute and save result in cache
|
15 |
+
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $dates = array())
|
18 |
+
{
|
19 |
+
$readAdapter = $this->_getReadAdapter();
|
20 |
+
$orderTableName = null;
|
21 |
+
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
22 |
+
$orderTableName = 'sales_flat_order';
|
23 |
+
|
24 |
+
} else {
|
25 |
+
$orderTableName = 'sales_order';
|
26 |
+
}
|
27 |
+
$select = $readAdapter
|
28 |
+
->select()
|
29 |
+
->from(
|
30 |
+
array('o' => $this->getTable($orderTableName)),
|
31 |
+
array(
|
32 |
+
'total' => 'COUNT(entity_id)'
|
33 |
+
)
|
34 |
+
)
|
35 |
+
->where('o.customer_id = ?', $customerId)
|
36 |
+
->order('o.created_at ASC');
|
37 |
+
|
38 |
+
if (!empty($dates)) {
|
39 |
+
if (array_key_exists('start', $dates) && $dates["start"] != null && $dates["start"] instanceof \DateTime) {
|
40 |
+
$select->where('o.created_at > ?', $dates['start']->format('Y-m-d H:i:s'));
|
41 |
+
}
|
42 |
+
if (array_key_exists('stop', $dates) && $dates["stop"] != null && $dates["stop"] instanceof \DateTime) {
|
43 |
+
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
44 |
+
}
|
45 |
+
}
|
46 |
+
$row = $readAdapter->fetchOne($select);
|
47 |
+
return $row;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Phone.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Phone extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getTelephone();
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Postcode.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute adapter
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Postcode extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Synchronize data in real tables in production database from temporary tables
|
14 |
+
*
|
15 |
+
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
+
* @param Varien_Object $config Config for this attribute
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getExportedValue($customer, $config)
|
21 |
+
{
|
22 |
+
$return = '';
|
23 |
+
$address = $customer->getDefaultBillingAddress();
|
24 |
+
if (!empty($address)) {
|
25 |
+
$return = $address->getPostcode();
|
26 |
+
}
|
27 |
+
return $return;
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Reports.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Mysql4_Reports extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Model initialization
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _construct()
|
10 |
+
{
|
11 |
+
$this->_init('dolist/reports', 'id');
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Reports/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Mysql4_Reports_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('dolist/reports');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Dolist/Net/Model/Observer.php
ADDED
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist Observer
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Observer extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
const SEND_MESSAGE_PROCESS_ID = 'dolist_send_message';
|
13 |
+
|
14 |
+
protected $_processes = array();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* List all queued messages and send its
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
public function sendQueuedMessages()
|
22 |
+
{
|
23 |
+
// get lock
|
24 |
+
if ($this->_getLock(self::SEND_MESSAGE_PROCESS_ID)) {
|
25 |
+
//load queued message list
|
26 |
+
$queuedMessages = Mage::getModel('dolist/dolistemt_message_queued')
|
27 |
+
->getCollection()
|
28 |
+
->setOrder('id', 'ASC');
|
29 |
+
//prepare collection by template
|
30 |
+
$messagesByTemplates = array();
|
31 |
+
foreach ($queuedMessages as $message) {
|
32 |
+
$messagesByTemplates[$message->getTemplateId()][] = $message;
|
33 |
+
}
|
34 |
+
|
35 |
+
foreach ($messagesByTemplates as $templateId => $templateMessages) {
|
36 |
+
foreach($templateMessages as $message) {
|
37 |
+
try {
|
38 |
+
//prepare message
|
39 |
+
$messageContent = unserialize($message->getSerializedMessage());
|
40 |
+
// try to send message
|
41 |
+
Mage::getSingleton('dolist/service')->callDolistEmtSendmail($messageContent, $templateId, $message->getStoreId());
|
42 |
+
//remove from queue
|
43 |
+
$message->delete();
|
44 |
+
|
45 |
+
} catch (SoapFault $fault) {
|
46 |
+
$queue = Mage::helper('dolist/queue');
|
47 |
+
/// All temporary errors (including "limit reached") should be requeued
|
48 |
+
if ($queue->isTemporaryError($fault)) {
|
49 |
+
Mage::log($fault);
|
50 |
+
$newQueuedMessage = clone $message;
|
51 |
+
//remove from queue and re-queue it
|
52 |
+
$message->delete();
|
53 |
+
$newQueuedMessage->setId(null)->save();
|
54 |
+
//else log & remove
|
55 |
+
} else {
|
56 |
+
$message->delete();
|
57 |
+
Mage::helper('dolist/log')->logError($message, $fault, 'SendMessage');
|
58 |
+
}
|
59 |
+
//if the error is a "limit reached" break to the next template
|
60 |
+
if ($queue->isLimitReachedError($fault)) {
|
61 |
+
break;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
//release the lock
|
68 |
+
$this->_releaseLock(self::SEND_MESSAGE_PROCESS_ID);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* put a lock to avoid duplicate processing
|
74 |
+
*
|
75 |
+
* @param string $processId
|
76 |
+
* @return bool true if the scrip has been locked, false if it was already locked by another process
|
77 |
+
*/
|
78 |
+
protected function _getLock($processId)
|
79 |
+
{
|
80 |
+
if (isset($this->_processes[$processId]) && $this->_processes[$processId]->isLocked()) {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
$this->_processes[$processId] = Mage::getModel('index/process')->setId($processId);
|
84 |
+
$this->_processes[$processId]->lock();
|
85 |
+
return true;
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* realease a lock
|
89 |
+
*
|
90 |
+
* @param string $processId
|
91 |
+
*/
|
92 |
+
protected function _releaseLock($processId)
|
93 |
+
{
|
94 |
+
$this->_processes[$processId]->unlock();
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Import contacts from Dolist-V8 to Magento
|
99 |
+
* Use dolist_status field from newsletter_subscriber table
|
100 |
+
*
|
101 |
+
* @return void
|
102 |
+
*/
|
103 |
+
public function contactImport()
|
104 |
+
{
|
105 |
+
// Loop on every website
|
106 |
+
$websites = Mage::app()->getWebsites();
|
107 |
+
$needToLoop = false;
|
108 |
+
foreach ($websites as $website) {
|
109 |
+
// Get website default store id
|
110 |
+
$storeId = $website->getDefaultStore()->getId();
|
111 |
+
|
112 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
113 |
+
// Enforce translations loading
|
114 |
+
Mage::getSingleton('core/translate')->init('frontend');
|
115 |
+
|
116 |
+
/** @var Dolist_Net_Model_Service $service */
|
117 |
+
$service = Mage::getSingleton('dolist/service');
|
118 |
+
$result = $service->dolistV8ContactImport($storeId);
|
119 |
+
if(!$result) {
|
120 |
+
$needToLoop = true;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
if($needToLoop) {
|
126 |
+
// Schedule new execution
|
127 |
+
/** @var Mage_Cron_Model_Schedule $schedule */
|
128 |
+
$schedule = Mage::getModel('cron/schedule');
|
129 |
+
|
130 |
+
$schedule->setJobCode('dolist_contact_import')
|
131 |
+
->setCreatedAt(now())
|
132 |
+
->setScheduledAt(now())
|
133 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
134 |
+
->save();
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Perform full export
|
140 |
+
*
|
141 |
+
* @return void
|
142 |
+
*/
|
143 |
+
public function fullExport()
|
144 |
+
{
|
145 |
+
$this->_getHelper()->logError('Starting full customer export');
|
146 |
+
$process = new Mage_Index_Model_Process();
|
147 |
+
$process->setId("full_export");
|
148 |
+
if($process->isLocked()){
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
$process->lockAndBlock();
|
152 |
+
// Retrieve store list to full export
|
153 |
+
$fullExportStoreIds = $this->_getHelper()->getExportStoreIds('full');
|
154 |
+
foreach ($fullExportStoreIds as $storeId) {
|
155 |
+
$startPagination = $this->_getHelper()->getExportPaginationStart('full_export', $storeId);
|
156 |
+
if($startPagination == 0){
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
160 |
+
/** @var Dolist_Net_Model_Service $service */
|
161 |
+
$service = Mage::getSingleton('dolist/service');
|
162 |
+
$service->dolistV8FullExport($storeId, $startPagination);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
$process->unlock();
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Differential export contacts from Magento to Dolist-V8
|
170 |
+
*
|
171 |
+
* @return void
|
172 |
+
*/
|
173 |
+
public function differentialExport()
|
174 |
+
{
|
175 |
+
$this->_getHelper()->logDebug('Starting differential customer export');
|
176 |
+
|
177 |
+
$process = new Mage_Index_Model_Process();
|
178 |
+
$process->setId("differential_export");
|
179 |
+
if($process->isLocked()){
|
180 |
+
return;
|
181 |
+
}
|
182 |
+
Mage::log('Export observer before lock');
|
183 |
+
|
184 |
+
$process->lockAndBlock();
|
185 |
+
// Retrieve store list to full export
|
186 |
+
$differentialExportStoreIds = $this->_getHelper()->getExportStoreIds('differential');
|
187 |
+
foreach ($differentialExportStoreIds as $storeId) {
|
188 |
+
$startPagination = $this->_getHelper()->getExportPaginationStart('differential_export', $storeId);
|
189 |
+
if($startPagination == 0){
|
190 |
+
continue;
|
191 |
+
}
|
192 |
+
|
193 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId) && $this->_isAllowedDifferentialExport($storeId)) {
|
194 |
+
Mage::log('Export observer go service');
|
195 |
+
|
196 |
+
/** @var Dolist_Net_Model_Service $service */
|
197 |
+
$service = Mage::getSingleton('dolist/service');
|
198 |
+
$service->dolistV8DifferentialExport($storeId, $startPagination);
|
199 |
+
}
|
200 |
+
}
|
201 |
+
$process->unlock();
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Add all Dolist-V8 enabled stores to dolist_differential_export list (before dolist_differential_export)
|
206 |
+
* Must be scheduled before dolist_differential_export
|
207 |
+
*
|
208 |
+
* @return void
|
209 |
+
*/
|
210 |
+
public function prepareNightlyDifferentialExport()
|
211 |
+
{
|
212 |
+
foreach (array_keys(Mage::app()->getStores()) as $storeId) {
|
213 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
214 |
+
$this->_getHelper()->addExportStoreId('differential', $storeId);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Return True if differential export can be performed,
|
221 |
+
* ie if at least one full export has already been performed
|
222 |
+
*
|
223 |
+
* @param int $storeId Store ID scope
|
224 |
+
*
|
225 |
+
* @return boolean True if differential export can be performed
|
226 |
+
*/
|
227 |
+
protected function _isAllowedDifferentialExport($storeId)
|
228 |
+
{
|
229 |
+
return !is_null($this->_getHelper()->getFlagDolistLastExport($storeId));
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Update updated_at field in newsletter_subscriber table
|
234 |
+
* This field permits a differential export
|
235 |
+
*
|
236 |
+
* @param Varien_Event_Observer $observer Observer
|
237 |
+
*
|
238 |
+
* @return Dolist_Net_Model_Observer
|
239 |
+
*/
|
240 |
+
public function updateSubscriber($observer)
|
241 |
+
{
|
242 |
+
$subscriber = $observer->getEvent()->getSubscriber();
|
243 |
+
$origSubscriber = Mage::getModel('newsletter/subscriber')->load($subscriber->getId());
|
244 |
+
|
245 |
+
if ($subscriber->getData('subscriber_status') != $origSubscriber->getData('subscriber_status')) {
|
246 |
+
$subscriber->setUpdatedAt(time());
|
247 |
+
}
|
248 |
+
|
249 |
+
return $this;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Warn customer after login if dolist_status gets an error
|
254 |
+
*
|
255 |
+
* @param Varien_Event_Observer $observer Observer
|
256 |
+
*
|
257 |
+
* @return Dolist_Net_Model_Observer
|
258 |
+
*/
|
259 |
+
public function warnCustomerDolistStatus($observer)
|
260 |
+
{
|
261 |
+
$customer = $observer->getEvent()->getCustomer();
|
262 |
+
$customerId = $customer->getId();
|
263 |
+
if ($customerId) {
|
264 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->load($customerId, 'customer_id');
|
265 |
+
|
266 |
+
if ($subscriber->getId()) {
|
267 |
+
$errorMessage = $this->_getHelper()->getDolistStatusErrorMessage($subscriber->getDolistStatus(), 'front');
|
268 |
+
|
269 |
+
if (!is_null($errorMessage)) {
|
270 |
+
|
271 |
+
Mage::getSingleton('customer/session')->addNotice($this->_getHelper()->__($errorMessage));
|
272 |
+
}
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
return $this;
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Retrieve model helper
|
282 |
+
*
|
283 |
+
* @return Dolist_Net_Helper_Data
|
284 |
+
*/
|
285 |
+
protected function _getHelper()
|
286 |
+
{
|
287 |
+
return Mage::helper('dolist');
|
288 |
+
}
|
289 |
+
}
|
app/code/community/Dolist/Net/Model/Reports.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dolist_Net_Model_Reports extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('dolist/reports');
|
9 |
+
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param $max
|
14 |
+
*/
|
15 |
+
public function start($max)
|
16 |
+
{
|
17 |
+
$now = new DateTime();
|
18 |
+
$this->setData('started_at', $now->format(DateTime::W3C));
|
19 |
+
$this->setData('progress_end', $max);
|
20 |
+
try {
|
21 |
+
$this->save();
|
22 |
+
} catch (Exception $ex) {
|
23 |
+
Mage::logException($ex);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
public function end($result = 'success')
|
31 |
+
{
|
32 |
+
$now = new DateTime();
|
33 |
+
$this->setData('progress_current', $this->getData('progress_end'));
|
34 |
+
$this->setData('result', $result);
|
35 |
+
$this->setData('ended_at', $now->format(DateTime::W3C));
|
36 |
+
|
37 |
+
try {
|
38 |
+
$this->save();
|
39 |
+
} catch (Exception $ex) {
|
40 |
+
Mage::logException($ex);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
*
|
46 |
+
*/
|
47 |
+
public function progress($progress)
|
48 |
+
{
|
49 |
+
$this->setData('progress_current', $progress);
|
50 |
+
|
51 |
+
try {
|
52 |
+
$this->save();
|
53 |
+
} catch (Exception $ex) {
|
54 |
+
Mage::log($ex->getMessage());
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @param $message
|
60 |
+
*/
|
61 |
+
public function log($message)
|
62 |
+
{
|
63 |
+
$this->setData('last_logs', $message);
|
64 |
+
$this->setData('logs', $this->getData('logs') . PHP_EOL . $message);
|
65 |
+
|
66 |
+
Mage::helper('dolist')->logDebug($message);
|
67 |
+
|
68 |
+
try {
|
69 |
+
$this->save();
|
70 |
+
} catch (Exception $ex) {
|
71 |
+
Mage::helper('dolist')->logDebug($ex->__toString());
|
72 |
+
Mage::logException($ex->__toString());
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
protected function _beforeSave()
|
78 |
+
{
|
79 |
+
if ($this->hasDataChanges()) {
|
80 |
+
$this->setData('updated_at', (date_create('now')->format('Y-m-d H:i:s')));
|
81 |
+
}
|
82 |
+
|
83 |
+
return parent::_beforeSave();
|
84 |
+
}
|
85 |
+
}
|
app/code/community/Dolist/Net/Model/Service.php
ADDED
@@ -0,0 +1,1487 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Dolist SOAP adapter
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Service extends Varien_Object
|
12 |
+
{
|
13 |
+
const CODE = 'dolist';
|
14 |
+
const SOAP_VERSION = SOAP_1_1;
|
15 |
+
|
16 |
+
const XML_DOLIST_V8_ACCOUNTID = 'dolist/dolist_v8/accountid';
|
17 |
+
const XML_DOLIST_V8_AUTH_KEY = 'dolist/dolist_v8/authentication_key';
|
18 |
+
const XML_DOLIST_V8_LOGIN = 'dolist/dolist_v8/login';
|
19 |
+
const XML_DOLIST_V8_PASSWORD = 'dolist/dolist_v8/password';
|
20 |
+
|
21 |
+
const XML_DOLIST_EMT_ACCOUNTID = 'dolist/dolist_emt/accountid';
|
22 |
+
const XML_DOLIST_EMT_AUTH_KEY = 'dolist/dolist_emt/authentication_key';
|
23 |
+
|
24 |
+
const MAGENTO_FULL_EXPORT_LABEL = 'MAGENTO - Chargement complet';
|
25 |
+
const MAGENTO_DIFF_EXPORT_LABEL = 'MAGENTO - Chargement différentiel';
|
26 |
+
|
27 |
+
private $_tables;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Send transactional email using Dolist-EMT webservice instead of native Magento method
|
31 |
+
*
|
32 |
+
* @param array $message Message parameters
|
33 |
+
* @param $dolistTemplateId
|
34 |
+
* @param array|int $storeId Store ID
|
35 |
+
*
|
36 |
+
* @return void
|
37 |
+
*/
|
38 |
+
public function dolistEmtSendmail($message, $dolistTemplateId, $storeId = 0)
|
39 |
+
{
|
40 |
+
/** @var Dolist_Net_Helper_Queue $queue */
|
41 |
+
$queue = Mage::helper('dolist/queue');
|
42 |
+
|
43 |
+
if (Mage::getStoreConfig('dolist/dolist_emt/asynchronous') == 1) {
|
44 |
+
$queue->queueMessage($dolistTemplateId, $message, $storeId);
|
45 |
+
} else {
|
46 |
+
try {
|
47 |
+
$this->callDolistEmtSendmail($message, $dolistTemplateId, $storeId);
|
48 |
+
} catch (SoapFault $fault) {
|
49 |
+
$queue->queueMessage($dolistTemplateId, $message, $storeId);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Send transactional email using Dolist-EMT webservice instead of native Magento method
|
56 |
+
*
|
57 |
+
* @param array $message Message parameters
|
58 |
+
* @param $dolistTemplateId
|
59 |
+
* @param array|int $storeId Store ID
|
60 |
+
*
|
61 |
+
* @throws Exception
|
62 |
+
* @throws SoapFault
|
63 |
+
* @return void
|
64 |
+
*/
|
65 |
+
public function callDolistEmtSendmail($message, $dolistTemplateId, $storeId = 0)
|
66 |
+
{
|
67 |
+
try {
|
68 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/send_message/proxywsdl');
|
69 |
+
|
70 |
+
$client = new SoapClient(
|
71 |
+
$proxywsdl,
|
72 |
+
array(
|
73 |
+
'soap_version' => self::SOAP_VERSION,
|
74 |
+
'trace' => 0,
|
75 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/send_message/location')
|
76 |
+
)
|
77 |
+
);
|
78 |
+
|
79 |
+
// get auth key from SOAP
|
80 |
+
$token = $this->_dolistEmtGetKey($storeId);
|
81 |
+
|
82 |
+
$wsParmas = array(
|
83 |
+
'store_id' => $storeId,
|
84 |
+
'key' => $token['Key'],
|
85 |
+
'message' => $message,
|
86 |
+
);
|
87 |
+
// Construct request
|
88 |
+
$request = Mage::getModel('dolist/service_dolistemt_request_sendEmail', $wsParmas);
|
89 |
+
|
90 |
+
// To use magic methods on response object
|
91 |
+
$response = Mage::getModel('dolist/service_dolistemt_response_sendEmail');
|
92 |
+
// Call web service
|
93 |
+
$response = $response->addData((array)$client->SendMessage($request->toArray()));
|
94 |
+
|
95 |
+
} catch (SoapFault $fault) {
|
96 |
+
throw $fault;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Retrieve template list created with Dolist-EMT
|
102 |
+
* This method is also used to test connection in Back-Office
|
103 |
+
*
|
104 |
+
* @param array|int $storeId Store ID
|
105 |
+
*
|
106 |
+
* @param string $accountId Optional account (used to test connection in back office)
|
107 |
+
* @param null $authenticationKey
|
108 |
+
* @internal param string $AuthKey Optional auth,ntification key (used to test connection in back office)
|
109 |
+
* @return array Array of Dolist-EMT templates. Name indexed by Dolist-EMT ids
|
110 |
+
*/
|
111 |
+
public function dolistEmtGetTemplateList($storeId = 0, $accountId = null, $authenticationKey = null)
|
112 |
+
{
|
113 |
+
$request = null;
|
114 |
+
$response = null;
|
115 |
+
|
116 |
+
try {
|
117 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/get_template_list/proxywsdl');
|
118 |
+
$client = new SoapClient(
|
119 |
+
$proxywsdl,
|
120 |
+
array(
|
121 |
+
'soap_version' => self::SOAP_VERSION,
|
122 |
+
'trace' => 1,
|
123 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/get_template_list/location')
|
124 |
+
)
|
125 |
+
);
|
126 |
+
|
127 |
+
// get auth key from SOAP
|
128 |
+
$token = $this->_dolistEmtGetKey($storeId, $accountId, $authenticationKey);
|
129 |
+
|
130 |
+
// Construct request
|
131 |
+
$request = Mage::getModel('dolist/service_dolistemt_request_gettemplatelist', array('store_id' => $storeId, 'key' => $token['Key'], 'account_id' => $accountId));
|
132 |
+
|
133 |
+
// To use magic methods on response object
|
134 |
+
$response = Mage::getModel('dolist/service_dolistemt_response_gettemplatelist');
|
135 |
+
// Call web service
|
136 |
+
$response = $response->addData((array)$client->GetTemplateList($request->toArray()));
|
137 |
+
|
138 |
+
} catch (SoapFault $fault) {
|
139 |
+
$this->_logError($request, $fault, 'GetTemplateList');
|
140 |
+
}
|
141 |
+
|
142 |
+
return $response;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Dolist-V8 authentication before every call to web services
|
147 |
+
* Init web service connection
|
148 |
+
*
|
149 |
+
* @param int $storeId Store ID
|
150 |
+
* @param string $accountId Optional account ID (used to test connection in back office)
|
151 |
+
* @param string $authenticationKey Optional authentication Key (used to test connection in back office)
|
152 |
+
*
|
153 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Response_Getauthenticationtoken Webservice response object
|
154 |
+
*/
|
155 |
+
public function dolistV8GetAuthenticationToken($storeId = 0, $accountId = null, $authenticationKey = null)
|
156 |
+
{
|
157 |
+
$request = null;
|
158 |
+
$response = null;
|
159 |
+
|
160 |
+
try {
|
161 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/get_authentication_v8_token/proxywsdl');
|
162 |
+
$client = new SoapClient(
|
163 |
+
$proxywsdl,
|
164 |
+
array(
|
165 |
+
'soap_version' => self::SOAP_VERSION,
|
166 |
+
'trace' => 1,
|
167 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/get_authentication_v8_token/location')
|
168 |
+
)
|
169 |
+
);
|
170 |
+
|
171 |
+
// Construct request
|
172 |
+
$request = Mage::getModel(
|
173 |
+
'dolist/service_dolistv8_request_getauthenticationtoken',
|
174 |
+
array(
|
175 |
+
'store_id' => $storeId,
|
176 |
+
'account_id' => $accountId,
|
177 |
+
'auth_key' => $authenticationKey
|
178 |
+
)
|
179 |
+
);
|
180 |
+
|
181 |
+
// To use magic methods on response object
|
182 |
+
$response = Mage::getModel('dolist/service_dolistv8_response_getauthenticationtoken');
|
183 |
+
|
184 |
+
// Call web service
|
185 |
+
$response = $response->addData((array)$client->GetAuthenticationToken($request->toArray()));
|
186 |
+
|
187 |
+
} catch (SoapFault $fault) {
|
188 |
+
$this->_logError($request, $fault, 'GetAuthenticationToken');
|
189 |
+
}
|
190 |
+
|
191 |
+
return $response;
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Dolist-Emt authentication before every call to web services
|
197 |
+
* Init web service connection
|
198 |
+
*
|
199 |
+
* @param int $storeId Store ID
|
200 |
+
* @param string $accountId Optional account ID (used to test connection in back office)
|
201 |
+
* @param string $authenticationKey Optional authentication Key (used to test connection in back office)
|
202 |
+
*
|
203 |
+
* @return Dolist_Net_Model_Service_Dolistemt_Response_Getauthenticationtoken Webservice response object
|
204 |
+
*/
|
205 |
+
public function dolistEmtGetAuthenticationToken($storeId = 0, $accountId = null, $authenticationKey = null)
|
206 |
+
{
|
207 |
+
$request = null;
|
208 |
+
$response = null;
|
209 |
+
|
210 |
+
try {
|
211 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/get_authentication_emt_token/proxywsdl');
|
212 |
+
$client = new SoapClient(
|
213 |
+
$proxywsdl,
|
214 |
+
array(
|
215 |
+
'soap_version' => self::SOAP_VERSION,
|
216 |
+
'trace' => 1,
|
217 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/get_authentication_emt_token/location')
|
218 |
+
)
|
219 |
+
);
|
220 |
+
|
221 |
+
// Construct request
|
222 |
+
$request = Mage::getModel(
|
223 |
+
'dolist/service_dolistemt_request_getauthenticationtoken',
|
224 |
+
array(
|
225 |
+
'store_id' => $storeId,
|
226 |
+
'account_id' => $accountId,
|
227 |
+
'auth_key' => $authenticationKey
|
228 |
+
)
|
229 |
+
);
|
230 |
+
// To use magic methods on response object
|
231 |
+
$response = Mage::getModel('dolist/service_dolistemt_response_getauthenticationtoken');
|
232 |
+
|
233 |
+
// Call web service
|
234 |
+
$response = $response->addData((array)$client->GetAuthenticationToken($request->toArray()));
|
235 |
+
|
236 |
+
} catch (SoapFault $fault) {
|
237 |
+
$this->_logError($request, $fault, 'GetAuthenticationToken');
|
238 |
+
}
|
239 |
+
|
240 |
+
return $response;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Call dolistV8GetAuthenticationToken method to retrieve authentication token
|
245 |
+
* and to use it in other Dolist-V8 webservice methods
|
246 |
+
*
|
247 |
+
* @param int $storeId Store ID
|
248 |
+
*
|
249 |
+
* @return string Authentication token key
|
250 |
+
*/
|
251 |
+
protected function _dolistV8GetKey($storeId = 0)
|
252 |
+
{
|
253 |
+
$key = "";
|
254 |
+
|
255 |
+
$token = $this->dolistV8GetAuthenticationToken($storeId);
|
256 |
+
if ($token) {
|
257 |
+
$tokenData = $token->getData();
|
258 |
+
if (is_array($tokenData) && array_key_exists('Key', $tokenData)) {
|
259 |
+
$key = $tokenData['Key'];
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
// Key could not be retrieved or is null
|
264 |
+
if ($key == "") {
|
265 |
+
Mage::helper('dolist')->logError('Authentication token key could not be retrieved or is null');
|
266 |
+
}
|
267 |
+
|
268 |
+
return $key;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Call dolistEmtGetAuthenticationToken method to retrieve authentication token
|
273 |
+
* and to use it in other Dolist-Emt webservice methods
|
274 |
+
*
|
275 |
+
* @param int $storeId Store ID
|
276 |
+
*
|
277 |
+
* @param null $accountId
|
278 |
+
* @param null $authenticationKey
|
279 |
+
* @return string Authentication token key
|
280 |
+
*/
|
281 |
+
protected function _dolistEmtGetKey($storeId = 0, $accountId = null, $authenticationKey = null)
|
282 |
+
{
|
283 |
+
$key = "";
|
284 |
+
$result = array('Key' => null);
|
285 |
+
$token = $this->dolistEmtGetAuthenticationToken($storeId, $accountId, $authenticationKey);
|
286 |
+
if ($token) {
|
287 |
+
$tokenData = $token->getData();
|
288 |
+
if (is_array($tokenData) && array_key_exists('Key', $tokenData)) {
|
289 |
+
$result = array(
|
290 |
+
'Key' => $tokenData['Key'],
|
291 |
+
'DeprecatedDate' => $tokenData['DeprecatedDate'],
|
292 |
+
);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
// Key could not be retrieved or is null
|
297 |
+
if ($result['Key'] == "") {
|
298 |
+
Mage::helper('dolist')->logError('Authentication token key could not be retrieved or is null');
|
299 |
+
}
|
300 |
+
|
301 |
+
return $result;
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Call CreateImport Dolist-V8 webservice method
|
306 |
+
*
|
307 |
+
* @param string $importName Import Name
|
308 |
+
* @param bool $createSegment Does this import create segment or not. Default: false
|
309 |
+
* @param int $storeId Store ID
|
310 |
+
*
|
311 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Response_Createimport Webservice response object
|
312 |
+
*/
|
313 |
+
public function dolistV8CreateImport($importName, $createSegment = false, $storeId = 0)
|
314 |
+
{
|
315 |
+
$request = null;
|
316 |
+
$response = null;
|
317 |
+
|
318 |
+
try {
|
319 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/create_import/proxywsdl');
|
320 |
+
$client = new SoapClient(
|
321 |
+
$proxywsdl,
|
322 |
+
array(
|
323 |
+
'soap_version' => self::SOAP_VERSION,
|
324 |
+
'trace' => 1,
|
325 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/create_import/location')
|
326 |
+
)
|
327 |
+
);
|
328 |
+
|
329 |
+
// Construct request
|
330 |
+
$key = $this->_dolistV8GetKey($storeId);
|
331 |
+
$request = Mage::getModel(
|
332 |
+
'dolist/service_dolistv8_request_createimport',
|
333 |
+
array(
|
334 |
+
'store_id' => $storeId,
|
335 |
+
'key' => $key,
|
336 |
+
'import_name' => $importName,
|
337 |
+
'create_segment' => $createSegment
|
338 |
+
)
|
339 |
+
);
|
340 |
+
|
341 |
+
// To use magic methods on response object
|
342 |
+
$response = Mage::getModel('dolist/service_dolistv8_response_createimport');
|
343 |
+
|
344 |
+
// Call web service
|
345 |
+
$response = $response->addData((array)$client->CreateImport($request->toArray()));
|
346 |
+
|
347 |
+
} catch (SoapFault $fault) {
|
348 |
+
$this->_logError($request, $fault, 'CreateImport');
|
349 |
+
return false;
|
350 |
+
}
|
351 |
+
|
352 |
+
return $response;
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* @param int $storeId
|
357 |
+
* @return false|Mage_Core_Model_Abstract|null|Varien_Object
|
358 |
+
*/
|
359 |
+
public function dolistV8GetFieldList($storeId = 0)
|
360 |
+
{
|
361 |
+
$request = null;
|
362 |
+
$response = null;
|
363 |
+
|
364 |
+
try {
|
365 |
+
$key = $this->_dolistV8GetKey($storeId);
|
366 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/get_field_list/proxywsdl');
|
367 |
+
|
368 |
+
$client = new SoapClient(
|
369 |
+
$proxywsdl,
|
370 |
+
array(
|
371 |
+
'soap_version' => self::SOAP_VERSION,
|
372 |
+
'trace' => 1,
|
373 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/get_field_list/location')
|
374 |
+
)
|
375 |
+
);
|
376 |
+
|
377 |
+
// Construct request
|
378 |
+
$request = Mage::getModel(
|
379 |
+
'dolist/service_dolistv8_request_getfieldlist',
|
380 |
+
array(
|
381 |
+
'store_id' => $storeId,
|
382 |
+
'key' => $key
|
383 |
+
)
|
384 |
+
);
|
385 |
+
|
386 |
+
// To use magic methods on response object
|
387 |
+
$response = Mage::getModel('dolist/service_dolistv8_response_getfieldlist');
|
388 |
+
|
389 |
+
// Call web service
|
390 |
+
$response = $response->addData((array)$client->GetFieldList($request->toArray()));
|
391 |
+
|
392 |
+
} catch (SoapFault $fault) {
|
393 |
+
$this->_logError($request, $fault, 'GetFieldList');
|
394 |
+
}
|
395 |
+
|
396 |
+
return $response;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Call GetContact Dolist-V8 webservice method
|
401 |
+
*
|
402 |
+
* @param string $key Token authentication key
|
403 |
+
* @param array|int $storeId Store ID
|
404 |
+
*
|
405 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Response_Createimport Webservice response object
|
406 |
+
*/
|
407 |
+
public function dolistV8GetContact($key, $storeId = 0)
|
408 |
+
{
|
409 |
+
$request = null;
|
410 |
+
$response = null;
|
411 |
+
|
412 |
+
try {
|
413 |
+
$proxywsdl = (string)Mage::getConfig()->getNode('dolistparams/get_contact/proxywsdl');
|
414 |
+
$client = new SoapClient(
|
415 |
+
$proxywsdl,
|
416 |
+
array(
|
417 |
+
'soap_version' => self::SOAP_VERSION,
|
418 |
+
'trace' => 1,
|
419 |
+
'location' => (string)Mage::getConfig()->getNode('dolistparams/get_contact/location')
|
420 |
+
)
|
421 |
+
);
|
422 |
+
|
423 |
+
// Construct request
|
424 |
+
$request = Mage::getModel(
|
425 |
+
'dolist/service_dolistv8_request_getcontact',
|
426 |
+
array(
|
427 |
+
'store_id' => $storeId,
|
428 |
+
'key' => $key
|
429 |
+
)
|
430 |
+
);
|
431 |
+
|
432 |
+
// To use magic methods on response object
|
433 |
+
$response = Mage::getModel('dolist/service_dolistv8_response_getcontact');
|
434 |
+
|
435 |
+
// Call web service
|
436 |
+
$response = $response->addData((array)$client->GetContact($request->toArray()));
|
437 |
+
|
438 |
+
} catch (SoapFault $fault) {
|
439 |
+
$this->_logError($request, $fault, 'GetContact');
|
440 |
+
}
|
441 |
+
|
442 |
+
return $response;
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Perfom contact import from Dolist-V8
|
447 |
+
*
|
448 |
+
* @param int $storeId Store ID
|
449 |
+
*
|
450 |
+
* @return void
|
451 |
+
*/
|
452 |
+
public function dolistV8ContactImport($storeId = 0)
|
453 |
+
{
|
454 |
+
$key = $this->_dolistV8GetKey($storeId);
|
455 |
+
$handled = 0;
|
456 |
+
$maxHandled = Mage::getStoreConfig('dolist/dolist_v8/export_page_size');
|
457 |
+
|
458 |
+
$response = $this->dolistV8GetContact($key, $storeId);
|
459 |
+
$contactList = $response->getData('ContactList');
|
460 |
+
$returnContactsCount = $response->getData('ReturnContactsCount');
|
461 |
+
|
462 |
+
while ($returnContactsCount > 0 && $handled < $maxHandled) {
|
463 |
+
$handled += $returnContactsCount;
|
464 |
+
Mage::log('Handled : ' . $handled);
|
465 |
+
|
466 |
+
$contactList = (array)$contactList;
|
467 |
+
$contactList = $contactList['ContactData'];
|
468 |
+
|
469 |
+
foreach ($contactList as $contact) {
|
470 |
+
$contact = (array)$contact;
|
471 |
+
|
472 |
+
$email = $contact['Email'];
|
473 |
+
$optoutEmail = $contact['OptoutEmail'];
|
474 |
+
|
475 |
+
// Look for contact in newsletter_subscriber table
|
476 |
+
/** @var Mage_Newsletter_Model_Subscriber $subscriber */
|
477 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->load($email, 'subscriber_email');
|
478 |
+
if ($subscriber->getId()) {
|
479 |
+
// If contact found, update its dolist_status value
|
480 |
+
$dolistStatus = $this->_getHelper()->getDolistStatus($optoutEmail);
|
481 |
+
|
482 |
+
// if dolistStatus found and different from store value
|
483 |
+
if (!is_null($dolistStatus) && $dolistStatus != $subscriber->getDolistStatus()) {
|
484 |
+
// Value to save in dolist_status field from newsletter_subscriber table
|
485 |
+
$subscriber->setDolistStatus($dolistStatus);
|
486 |
+
|
487 |
+
// Update subscriber status if maps to Magento status
|
488 |
+
if (
|
489 |
+
$dolistStatus >= Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED
|
490 |
+
&& $dolistStatus <= Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED
|
491 |
+
) {
|
492 |
+
$subscriber->setSubscriberStatus($dolistStatus);
|
493 |
+
}
|
494 |
+
|
495 |
+
$subscriber->save();
|
496 |
+
}
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
$response = $this->dolistV8GetContact($key, $storeId);
|
501 |
+
$contactList = $response->getData('ContactList');
|
502 |
+
$returnContactsCount = $response->getData('ReturnContactsCount');
|
503 |
+
}
|
504 |
+
|
505 |
+
return $returnContactsCount <= 0;
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Perform full export: all Magento contacts to Dolist-V8
|
510 |
+
* This operation can be long, depending on your contact base size (customer and newsletter subscribers)
|
511 |
+
*
|
512 |
+
* @param int $storeId Store ID
|
513 |
+
*
|
514 |
+
* @param $startPagination
|
515 |
+
* @throws Exception
|
516 |
+
* @return void
|
517 |
+
*/
|
518 |
+
public function dolistV8FullExport($storeId = 0, $startPagination)
|
519 |
+
{
|
520 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
521 |
+
$report = null;
|
522 |
+
|
523 |
+
try {
|
524 |
+
$report = null;
|
525 |
+
$reportId = $this->_getHelper()->getCurrentReportId('full_export', $storeId);
|
526 |
+
|
527 |
+
if ($reportId) {
|
528 |
+
/** @var Dolist_Net_Model_Reports $report */
|
529 |
+
$report = Mage::getModel('dolist/reports')->load($reportId);
|
530 |
+
}
|
531 |
+
|
532 |
+
if ($report) {
|
533 |
+
$report->log(sprintf($this->_getHelper()->__('Starting full customer export Store id : %s'), $storeId));
|
534 |
+
}
|
535 |
+
|
536 |
+
if ($startPagination == 1) {
|
537 |
+
$query = $this->getCustomerIdCollection($startPagination, $storeId, true);
|
538 |
+
|
539 |
+
if (Mage::getStoreConfig('dev/log/active') && $report) {
|
540 |
+
$report->log($query->assemble());
|
541 |
+
}
|
542 |
+
|
543 |
+
$result = $query->query()->fetchAll();
|
544 |
+
$this->_getHelper()->setExportTotalCount($result[0]['total'], 'full_export', $storeId);
|
545 |
+
|
546 |
+
if ($result[0]['total'] == 0) {
|
547 |
+
// 4. Save dolist_last_export flag
|
548 |
+
// First, try to retrieve stored value
|
549 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
550 |
+
|
551 |
+
// Instanciate new flag object only first time
|
552 |
+
if ($flag->getId() == null) {
|
553 |
+
$flag = Mage::getModel(
|
554 |
+
'core/flag',
|
555 |
+
array(
|
556 |
+
'flag_code' => Dolist_Net_Helper_Data::FLAG_DOLIST_LAST_EXPORT . '_' . $storeId
|
557 |
+
)
|
558 |
+
);
|
559 |
+
}
|
560 |
+
|
561 |
+
$flag->setFlagData(time())->save();
|
562 |
+
|
563 |
+
// Remove flag on current store id to be exported
|
564 |
+
$this->_getHelper()->removeExportStoreId('full', $storeId);
|
565 |
+
|
566 |
+
$report->log($this->_getHelper()->__('Nothing to export')) .
|
567 |
+
$report->end();
|
568 |
+
return;
|
569 |
+
}
|
570 |
+
|
571 |
+
if ($report) {
|
572 |
+
$report->start($result[0]['total']);
|
573 |
+
}
|
574 |
+
}
|
575 |
+
|
576 |
+
|
577 |
+
// 4 steps:
|
578 |
+
// 1. Retrieve full export file name (either in configuration table, either from webservice)
|
579 |
+
try {
|
580 |
+
$exportFileName = $this->retrieveFileName('full_export', $storeId);
|
581 |
+
} catch (\Exception $ex) {
|
582 |
+
if ($report) {
|
583 |
+
$report->log($ex->__toString());
|
584 |
+
$report->end('error');
|
585 |
+
}
|
586 |
+
|
587 |
+
// Remove flag on current store id to be exported
|
588 |
+
$this->_getHelper()->removeExportStoreId('full', $storeId);
|
589 |
+
|
590 |
+
return;
|
591 |
+
}
|
592 |
+
|
593 |
+
// 2. Generate full export file
|
594 |
+
$localFilename = $this->generateExportFile('full_export', $exportFileName, $storeId, $startPagination);
|
595 |
+
|
596 |
+
if (!is_null($localFilename)) {
|
597 |
+
|
598 |
+
// 3. Push full export file on Dolist FTP server
|
599 |
+
$this->pushExportFile($exportFileName, $localFilename, $storeId, $report);
|
600 |
+
|
601 |
+
// 4. Save dolist_last_export flag
|
602 |
+
// First, try to retrieve stored value
|
603 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
604 |
+
|
605 |
+
// Instanciate new flag object only first time
|
606 |
+
if ($flag->getId() == null) {
|
607 |
+
$flag = Mage::getModel(
|
608 |
+
'core/flag',
|
609 |
+
array(
|
610 |
+
'flag_code' => Dolist_Net_Helper_Data::FLAG_DOLIST_LAST_EXPORT . '_' . $storeId
|
611 |
+
)
|
612 |
+
);
|
613 |
+
}
|
614 |
+
|
615 |
+
$flag->setFlagData(time())->save();
|
616 |
+
|
617 |
+
// Remove flag on current store id to be exported
|
618 |
+
$this->_getHelper()->removeExportStoreId('full', $storeId);
|
619 |
+
|
620 |
+
if ($report) {
|
621 |
+
$report->end();
|
622 |
+
}
|
623 |
+
}
|
624 |
+
} catch (Exception $ex) {
|
625 |
+
if ($report) {
|
626 |
+
$report->log($ex->getMessage());
|
627 |
+
$report->end('failed');
|
628 |
+
}
|
629 |
+
|
630 |
+
throw $ex;
|
631 |
+
}
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Perform differential export: Magento contacts updated from last export (last export could be full or differential) to Dolist-V8
|
637 |
+
* First export must be full export, to save dolistv8_last_export_date parameter
|
638 |
+
*
|
639 |
+
* @param int $storeId Store ID
|
640 |
+
*
|
641 |
+
* @param $startPagination
|
642 |
+
* @return void
|
643 |
+
*/
|
644 |
+
public function dolistV8DifferentialExport($storeId = 0, $startPagination)
|
645 |
+
{
|
646 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
647 |
+
|
648 |
+
$report = null;
|
649 |
+
$reportId = $this->_getHelper()->getCurrentReportId('differential_export', $storeId);
|
650 |
+
|
651 |
+
if (!$reportId) {
|
652 |
+
$reportId = $this->_getHelper()->createReport('differential_export', $storeId);
|
653 |
+
}
|
654 |
+
|
655 |
+
/** @var Dolist_Net_Model_Reports $report */
|
656 |
+
$report = Mage::getModel('dolist/reports')->load($reportId);
|
657 |
+
|
658 |
+
if ($report) {
|
659 |
+
$report->log(sprintf($this->_getHelper()->__('Starting differential customer export Store id : %s'), $storeId));
|
660 |
+
}
|
661 |
+
|
662 |
+
if ($startPagination == 1) {
|
663 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
664 |
+
|
665 |
+
// Log error if flag has never been set
|
666 |
+
if ($flag->getId() == null) {
|
667 |
+
$this->_getHelper()->logError($this->_getHelper()->__('At least one full export should have been perfomed before generating differential export file.'));
|
668 |
+
if ($report) {
|
669 |
+
$report->log($this->_getHelper()->__('At least one full export should have been perfomed before generating differential export file.'));
|
670 |
+
$report->end('error');
|
671 |
+
}
|
672 |
+
$this->_getHelper()->removeExportStoreId('differential', $storeId);
|
673 |
+
|
674 |
+
// Stop processing if export never performed
|
675 |
+
return;
|
676 |
+
|
677 |
+
}
|
678 |
+
|
679 |
+
$lastExportTimestamp = $flag->getFlagData(); // timestamp format
|
680 |
+
$query = $this->getCustomerIdCollection($startPagination, $storeId, true, $lastExportTimestamp);
|
681 |
+
|
682 |
+
if (Mage::getStoreConfig('dev/log/active') && $report) {
|
683 |
+
$report->log($query->assemble());
|
684 |
+
}
|
685 |
+
|
686 |
+
$result = $query->query()->fetchAll();
|
687 |
+
|
688 |
+
if ($result[0]['total'] == 0) {
|
689 |
+
if ($report) {
|
690 |
+
$report->log($this->_getHelper()->__('Nothing to export')) .
|
691 |
+
$report->end();
|
692 |
+
}
|
693 |
+
$this->_getHelper()->removeExportStoreId('differential', $storeId);
|
694 |
+
}
|
695 |
+
|
696 |
+
$this->_getHelper()->setExportTotalCount($result[0]['total'], 'differential_export', $storeId);
|
697 |
+
|
698 |
+
if ($report) {
|
699 |
+
$report->start($result[0]['total']);
|
700 |
+
}
|
701 |
+
}
|
702 |
+
|
703 |
+
// 6 steps:
|
704 |
+
// Store date at the beginning of process, because it can be long
|
705 |
+
$now = time();
|
706 |
+
// Export for differential subscribers
|
707 |
+
$exportDiffPerformed = false;
|
708 |
+
// Export for differential unsubscribers
|
709 |
+
$exportUnsubsPerformed = false;
|
710 |
+
|
711 |
+
// 1. Retrieve differential export file name (either in configuration table, either from webservice)
|
712 |
+
$exportFileName = $this->retrieveFileName('differential_export', $storeId);
|
713 |
+
|
714 |
+
// 2. Generate differential export file
|
715 |
+
$localFilename = $this->generateExportFile('differential_export', $exportFileName, $storeId, $startPagination);
|
716 |
+
|
717 |
+
if (!is_null($localFilename)) {
|
718 |
+
|
719 |
+
// 3. Push differential export file on Dolist FTP server
|
720 |
+
$exportDiffPerformed = $this->pushExportFile($exportFileName, $localFilename, $storeId, $report);
|
721 |
+
}
|
722 |
+
|
723 |
+
// 4. Generate newsletter unsubscribed contacts file
|
724 |
+
$localUnsubscribeFilename = $this->generateUnsubscribeFile($storeId);
|
725 |
+
|
726 |
+
// 5. Push newsletter unsubscribed contacts file on Dolist FTP server
|
727 |
+
if (!is_null($localUnsubscribeFilename)) {
|
728 |
+
$exportUnsubsPerformed = $this->pushUnsubscribeFile($localUnsubscribeFilename, $storeId);
|
729 |
+
}
|
730 |
+
|
731 |
+
// 6. Save dolist_last_export flag; only if export has been performed
|
732 |
+
if ($exportDiffPerformed || $exportUnsubsPerformed) {
|
733 |
+
|
734 |
+
// First, try to retrieve stored object
|
735 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
736 |
+
|
737 |
+
if ($flag->getId() != null) {
|
738 |
+
$flag->setFlagData($now)
|
739 |
+
->save();
|
740 |
+
} else {
|
741 |
+
$this->_getHelper()->logError(
|
742 |
+
Mage::helper('dolist')->__(
|
743 |
+
'dolist_last_export flag should be set.'
|
744 |
+
)
|
745 |
+
);
|
746 |
+
}
|
747 |
+
|
748 |
+
// Remove flag on current store id to be exported
|
749 |
+
$this->_getHelper()->removeExportStoreId('differential', $storeId);
|
750 |
+
if ($report) {
|
751 |
+
$report->end();
|
752 |
+
}
|
753 |
+
}
|
754 |
+
|
755 |
+
}
|
756 |
+
}
|
757 |
+
|
758 |
+
public function getCustomerIdCollection($startPagination, $storeId, $count = false, $differential = false)
|
759 |
+
{
|
760 |
+
$exportPageSize = Mage::getStoreConfig('dolist/dolist_v8/export_page_size');
|
761 |
+
$exportWithCustomer = Mage::getStoreConfig('dolist/dolist_v8/export_customer_with_order');
|
762 |
+
|
763 |
+
$query = null;
|
764 |
+
if ($exportWithCustomer) {
|
765 |
+
/** @var Varien_Db_Select $select1 */
|
766 |
+
$select1 = Mage::getModel('sales/order')
|
767 |
+
->getCollection()
|
768 |
+
->addAttributeToSelect('customer_id')
|
769 |
+
->addFieldToFilter('store_id', $storeId)
|
770 |
+
->getSelect();
|
771 |
+
$select2 = Mage::getModel('newsletter/subscriber')
|
772 |
+
->getCollection()
|
773 |
+
->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
774 |
+
->addFieldToFilter('store_id', $storeId)
|
775 |
+
->getSelect();
|
776 |
+
$select2->reset(Zend_Db_Select::COLUMNS);
|
777 |
+
$select2->columns('IF(customer_id=0, subscriber_email, customer_id)');
|
778 |
+
|
779 |
+
/** @var Varien_Db_Select $query */
|
780 |
+
$innerQuery = new Varien_Db_Select($select1->getAdapter());
|
781 |
+
$innerQuery->union(array($select1, $select2), Zend_Db_Select::SQL_UNION_ALL);
|
782 |
+
|
783 |
+
$query = new Varien_Db_Select($select1->getAdapter());
|
784 |
+
$query->from(array('subscriber_extract' => $innerQuery));
|
785 |
+
$query->joinLeft($this->getTable('customer_entity'), 'subscriber_extract.customer_id = ' . $this->getTable('customer_entity') . '.entity_id');
|
786 |
+
$query->joinLeft($this->getTable('customer_address_entity'), 'subscriber_extract.customer_id = ' . $this->getTable('customer_address_entity') . '.parent_id');
|
787 |
+
$query->joinLeft($this->getTable('dolist_dolistv8_calculatedfields'), 'subscriber_extract.customer_id = ' . $this->getTable('dolist_dolistv8_calculatedfields') . '.customer_id');
|
788 |
+
$query->joinLeft($this->getTable('newsletter_subscriber'), 'subscriber_extract.customer_id = ' . $this->getTable('newsletter_subscriber') . '.customer_id AND ' . $this->getTable('newsletter_subscriber') . '.customer_id != 0');
|
789 |
+
$query->joinLeft(array($this->getTable('newsletter_subscriber') . '_guest' => $this->getTable('newsletter_subscriber')), 'subscriber_extract.customer_id = ' . $this->getTable('newsletter_subscriber') . '_guest' . '.subscriber_email AND ' . $this->getTable('newsletter_subscriber') . '_guest.customer_id = 0');
|
790 |
+
|
791 |
+
$query->reset(Zend_Db_Select::COLUMNS);
|
792 |
+
if ($count) {
|
793 |
+
$query->columns('COUNT(DISTINCT subscriber_extract.customer_id) as total');
|
794 |
+
} else {
|
795 |
+
$query->columns('subscriber_extract.customer_id as customer_id')->distinct();
|
796 |
+
}
|
797 |
+
} else {
|
798 |
+
/** @var Varien_Db_Select $query */
|
799 |
+
$query = Mage::getModel('newsletter/subscriber')
|
800 |
+
->getCollection()
|
801 |
+
->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
802 |
+
->addFieldToFilter('store_id', $storeId)
|
803 |
+
->getSelect();
|
804 |
+
|
805 |
+
$query
|
806 |
+
->reset(Zend_Db_Select::COLUMNS)
|
807 |
+
->reset(Zend_Db_Select::FROM)
|
808 |
+
->reset(Zend_Db_Select::WHERE)
|
809 |
+
->from($this->getTable('newsletter_subscriber'), '')
|
810 |
+
->where($this->getTable('newsletter_subscriber') . '.subscriber_status = ?', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
811 |
+
->where($this->getTable('newsletter_subscriber') . '.store_id = ?', $storeId);
|
812 |
+
|
813 |
+
if ($count) {
|
814 |
+
$query->columns('COUNT(DISTINCT customer_id) as total');
|
815 |
+
} else {
|
816 |
+
$query->columns('IF(customer_id=0, subscriber_email, customer_id) AS customer_id');
|
817 |
+
}
|
818 |
+
}
|
819 |
+
|
820 |
+
if ($differential !== false) {
|
821 |
+
$query->where($this->getTable('newsletter_subscriber') . '.updated_at >= ?', $differential);
|
822 |
+
if ($exportWithCustomer) {
|
823 |
+
$date = new DateTime();
|
824 |
+
$date->setTimestamp($differential);
|
825 |
+
$query->orwhere($this->getTable('customer_entity') . '.updated_at >= ?', $date->format('Y-m-d\TH:i:sP'));
|
826 |
+
$query->orWhere($this->getTable('customer_address_entity') . '.updated_at >= ?', $date->format('Y-m-d\TH:i:sP'));
|
827 |
+
$query->orWhere($this->getTable('dolist_dolistv8_calculatedfields') . '.updated_at >= ?', $date->format('Y-m-d\TH:i:sP'));
|
828 |
+
$query->orWhere($this->getTable('newsletter_subscriber') . '_guest.updated_at >= ?', $differential);
|
829 |
+
}
|
830 |
+
}
|
831 |
+
|
832 |
+
$query->limitPage($startPagination, $exportPageSize);
|
833 |
+
|
834 |
+
return $query;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Retrieve export file name, either stored value or generated by webservice
|
839 |
+
*
|
840 |
+
* @param string $exportType Export type. Can be 'full_export'|'differential_export'
|
841 |
+
* @param int $storeId Store ID
|
842 |
+
*
|
843 |
+
* @return string Export filename
|
844 |
+
*/
|
845 |
+
public function retrieveFileName($exportType, $storeId)
|
846 |
+
{
|
847 |
+
$flagCode = 'dolist_' . $exportType . '_filename_' . $storeId;
|
848 |
+
|
849 |
+
// First, try to retrieve stored value
|
850 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
851 |
+
|
852 |
+
// Export file name already set => just return value
|
853 |
+
if ($flag->getId() != null) {
|
854 |
+
$exportFileName = $flag->getFlagData();
|
855 |
+
} else {
|
856 |
+
// If there is no stored value, retrieve it from webservice call
|
857 |
+
$storeName = Mage::getModel('core/website')->load($storeId)->getName();
|
858 |
+
|
859 |
+
switch ($exportType) {
|
860 |
+
case 'full_export':
|
861 |
+
$fileName = self::MAGENTO_FULL_EXPORT_LABEL . '(' . $storeName . ')';
|
862 |
+
break;
|
863 |
+
|
864 |
+
case 'differential_export':
|
865 |
+
$fileName = self::MAGENTO_DIFF_EXPORT_LABEL . '(' . $storeName . ')';
|
866 |
+
break;
|
867 |
+
}
|
868 |
+
$response = $this->dolistV8CreateImport($fileName, false, $storeId);
|
869 |
+
$exportFileName = $response->getData('FileName');
|
870 |
+
|
871 |
+
// Then store it for next time
|
872 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
873 |
+
$flag->setFlagData($exportFileName)
|
874 |
+
->save();
|
875 |
+
}
|
876 |
+
|
877 |
+
return $exportFileName;
|
878 |
+
}
|
879 |
+
|
880 |
+
/**
|
881 |
+
* Generate export file
|
882 |
+
* Can be full or differential export
|
883 |
+
*
|
884 |
+
* @param string $exportType Export type. Can be 'full_export'|'differential_export'
|
885 |
+
* @param string $exportFileName Export filename
|
886 |
+
* @param int $storeId Sto re ID
|
887 |
+
*
|
888 |
+
* @param int $startPagination
|
889 |
+
* @return string Tmp local file name
|
890 |
+
*/
|
891 |
+
public function generateExportFile($exportType, $exportFileName, $storeId, $startPagination = 1)
|
892 |
+
{
|
893 |
+
$localFilename = null;
|
894 |
+
$error = false;
|
895 |
+
$exportPageSize = Mage::getStoreConfig('dolist/dolist_v8/export_page_size');
|
896 |
+
|
897 |
+
if (!$exportPageSize || intval($exportPageSize) < 1) {
|
898 |
+
$exportPageSize = 5000;
|
899 |
+
}
|
900 |
+
|
901 |
+
$query = $this->getCustomerIdCollection($startPagination, $storeId, false);
|
902 |
+
|
903 |
+
$report = null;
|
904 |
+
$reportId = $this->_getHelper()->getCurrentReportId($exportType, $storeId);
|
905 |
+
|
906 |
+
$this->_getHelper()->logDebug('Report : ' . $reportId);
|
907 |
+
if ($reportId) {
|
908 |
+
/** @var Dolist_Net_Model_Reports $report */
|
909 |
+
$report = Mage::getModel('dolist/reports')->load($reportId);
|
910 |
+
}
|
911 |
+
|
912 |
+
$this->_getHelper()->logDebug('ExportType : ' . $exportType);
|
913 |
+
// If differential export, filter subscribers modified from last export
|
914 |
+
if ($exportType == 'differential_export') {
|
915 |
+
|
916 |
+
// Look for last export date
|
917 |
+
// First, try to retrieve stored value
|
918 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
919 |
+
|
920 |
+
// Log error if flag has never been set
|
921 |
+
if ($flag->getId() == null) {
|
922 |
+
$this->_getHelper()->logError($this->_getHelper()->__('At least one full export should have been perfomed before generating differential export file.'));
|
923 |
+
$report->log($this->_getHelper()->__('At least one full export should have been perfomed before generating differential export file.'));
|
924 |
+
$report->end('error');
|
925 |
+
|
926 |
+
// Stop processing if export never performed
|
927 |
+
$error = true;
|
928 |
+
|
929 |
+
} else {
|
930 |
+
|
931 |
+
$lastExportTimestamp = $flag->getFlagData(); // timestamp format
|
932 |
+
$query = $this->getCustomerIdCollection($startPagination, $storeId, false, $lastExportTimestamp);
|
933 |
+
}
|
934 |
+
}
|
935 |
+
|
936 |
+
if (Mage::getStoreConfig('dev/log/active') && $report) {
|
937 |
+
$report->log($query->assemble());
|
938 |
+
}
|
939 |
+
|
940 |
+
$collection = $query->query()->fetchAll();
|
941 |
+
|
942 |
+
// Perform only if collection is not empty and no error found
|
943 |
+
if (count($collection) > 0 && !$error) {
|
944 |
+
$startPagination++;
|
945 |
+
$this->_getHelper()->addExportPaginationStart($exportType, $startPagination, $storeId);
|
946 |
+
|
947 |
+
/** @var Dolist_Net_Model_Exporter_Csv $exporter */
|
948 |
+
$exporter = Mage::getModel('dolist/exporter_csv');
|
949 |
+
$exporter->setEnclosure(); // Dolist does not use enclosures
|
950 |
+
$exporter->setDelimiter(chr(9));
|
951 |
+
|
952 |
+
// Retrieve export config. Fields to export and mapping attributes
|
953 |
+
$dolistv8SystemConfig = $this->_getDolistV8SystemConfig($storeId);
|
954 |
+
|
955 |
+
$i = 0;
|
956 |
+
// Write one line for each subscriber to export
|
957 |
+
foreach ($collection as $object) {
|
958 |
+
$i++;
|
959 |
+
|
960 |
+
if ($i % 100 == 0) {
|
961 |
+
if ($report) {
|
962 |
+
$report->progress(($startPagination - 2) * $exportPageSize + $i);
|
963 |
+
}
|
964 |
+
}
|
965 |
+
|
966 |
+
$exporter->setContactToExport($object, $dolistv8SystemConfig);
|
967 |
+
$localFilename = sys_get_temp_dir() . '/' . $exportFileName; // Temporary filename
|
968 |
+
|
969 |
+
// Write in tmp CSV file
|
970 |
+
$exporter->export($localFilename, 'auto', true, 'contact_header', 'dolist', $storeId);
|
971 |
+
|
972 |
+
//We reset until all content is exported
|
973 |
+
$localFilename = null;
|
974 |
+
}
|
975 |
+
|
976 |
+
Mage::log('Exporting ' . count($collection) . ' items to ' . sys_get_temp_dir() . '/' . $exportFileName);
|
977 |
+
$this->_getHelper()->logError('Exporting ' . count($collection) . ' items to ' . sys_get_temp_dir() . '/' . $exportFileName);
|
978 |
+
} else {
|
979 |
+
$this->_getHelper()->addExportPaginationStart($exportType, 0, $storeId);
|
980 |
+
}
|
981 |
+
|
982 |
+
/* get total count */
|
983 |
+
$count = $this->_getHelper()->getExportTotalCount($exportType, $storeId);
|
984 |
+
$lastPageNumber = ceil($count / $exportPageSize);
|
985 |
+
$collectionSize = count($collection);
|
986 |
+
if ($startPagination > $lastPageNumber && $collectionSize > 0) {
|
987 |
+
//ready to export
|
988 |
+
$localFilename = sys_get_temp_dir() . '/' . $exportFileName; // Temporary filename
|
989 |
+
$this->_getHelper()->addExportPaginationStart($exportType, 0, $storeId);
|
990 |
+
} elseif ($startPagination <= $lastPageNumber && $collectionSize > 0) {
|
991 |
+
//Need another iteration
|
992 |
+
$this->_getHelper()->reScheduleDolistTask($exportType, $storeId);
|
993 |
+
}
|
994 |
+
if ($startPagination > $lastPageNumber) {
|
995 |
+
$this->_getHelper()->addExportPaginationStart($exportType, 0, $storeId);
|
996 |
+
}
|
997 |
+
|
998 |
+
return $localFilename;
|
999 |
+
}
|
1000 |
+
|
1001 |
+
/**
|
1002 |
+
* Retrieve Dolist-V8 system config from back-office
|
1003 |
+
* and return Mapping between Export file header fields and Magento attributes to export
|
1004 |
+
*
|
1005 |
+
* @param int $storeId Store ID
|
1006 |
+
*
|
1007 |
+
* @return array Mapping between Export file header fields and Magento attributes to export
|
1008 |
+
*/
|
1009 |
+
protected function _getDolistV8SystemConfig($storeId)
|
1010 |
+
{
|
1011 |
+
// System configuration (set in back office)
|
1012 |
+
$systemConfig = Mage::getStoreConfig('dolist/dolist_v8', $storeId);
|
1013 |
+
|
1014 |
+
// Mapping configuration (set in config.xml)
|
1015 |
+
$mappingConfig = $this->_getHelper()->getContactExportRowAdapterConfig();
|
1016 |
+
|
1017 |
+
$exportContactFileMapping = array_flip($this->_getHelper()->getDolistExportContactFileHeader());
|
1018 |
+
// Empty values
|
1019 |
+
$this->_eraseVal($exportContactFileMapping);
|
1020 |
+
|
1021 |
+
// Keys are Magento system config attribute names
|
1022 |
+
$mandatoryFields = array('email');
|
1023 |
+
foreach ($mandatoryFields as $mandatoryField) {
|
1024 |
+
$object = $mappingConfig[$mandatoryField];
|
1025 |
+
$exportContactFileMapping[$object->getHeader()] = $mandatoryField;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
// Specific case: group
|
1029 |
+
if (array_key_exists('group', $systemConfig)) {
|
1030 |
+
$exportContactFileMapping[$systemConfig['group']] = 'group_id';
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
// Usual fields can only be enabled and disabled. Their name in export file is defined in config.xml
|
1034 |
+
$usualFields = array();
|
1035 |
+
|
1036 |
+
// Filter enabled fields
|
1037 |
+
$enabledUsualFields = array();
|
1038 |
+
foreach ($usualFields as $usualField) {
|
1039 |
+
if ($systemConfig[$usualField] == 1) {
|
1040 |
+
$enabledUsualFields[] = $usualField;
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
// Add enabled field to export file mapping
|
1045 |
+
foreach ($enabledUsualFields as $usualField) {
|
1046 |
+
$object = $mappingConfig[$usualField];
|
1047 |
+
$exportContactFileMapping[$object->getHeader()] = $usualField;
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
// Retrieve Custom fields (str, int and date)
|
1051 |
+
if (array_key_exists('custom_str_fields', $systemConfig)) {
|
1052 |
+
$customStrFields = unserialize($systemConfig['custom_str_fields']);
|
1053 |
+
foreach ($customStrFields as $customStrField) {
|
1054 |
+
$exportContactFileMapping[$customStrField['dolist_custom_str_fields']] = $customStrField['magento_customer_attribute_1'];
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
if (array_key_exists('custom_int_fields', $systemConfig)) {
|
1058 |
+
$customIntFields = unserialize($systemConfig['custom_int_fields']);
|
1059 |
+
foreach ($customIntFields as $customIntField) {
|
1060 |
+
$exportContactFileMapping[$customIntField['dolist_custom_int_fields']] = $customIntField['magento_customer_attribute_2'];
|
1061 |
+
}
|
1062 |
+
}
|
1063 |
+
if (array_key_exists('custom_date_fields', $systemConfig)) {
|
1064 |
+
$customDateFields = unserialize($systemConfig['custom_date_fields']);
|
1065 |
+
foreach ($customDateFields as $customDateField) {
|
1066 |
+
$exportContactFileMapping[$customDateField['dolist_custom_date_fields']] = $customDateField['magento_customer_attribute_3'];
|
1067 |
+
}
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
return $exportContactFileMapping;
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
/**
|
1074 |
+
* Empty array values per reference
|
1075 |
+
*
|
1076 |
+
* @param array &$myarr Input array
|
1077 |
+
*
|
1078 |
+
* @return array
|
1079 |
+
*/
|
1080 |
+
protected function _eraseVal(&$myarr)
|
1081 |
+
{
|
1082 |
+
$myarr = array_map(create_function('$n', 'return null;'), $myarr);
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
/**
|
1086 |
+
* Generate unsubscribe file
|
1087 |
+
* Contain contacts unsubscribed from last export
|
1088 |
+
* File format:
|
1089 |
+
* - file at UTF-8 format
|
1090 |
+
* - separator: carriage return
|
1091 |
+
* - no header line
|
1092 |
+
* - only email address per line
|
1093 |
+
* - filename unsubscribe_<YYYYMMDD_hhmmss>.txt
|
1094 |
+
*
|
1095 |
+
* @param int $storeId Store ID
|
1096 |
+
*
|
1097 |
+
* @return string Tmp unsubscribe file name
|
1098 |
+
*/
|
1099 |
+
public function generateUnsubscribeFile($storeId)
|
1100 |
+
{
|
1101 |
+
$shortFileName = null;
|
1102 |
+
$unsubscribeFilename = null;
|
1103 |
+
$error = false;
|
1104 |
+
|
1105 |
+
// Look for last export date
|
1106 |
+
// First, try to retrieve stored value
|
1107 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
1108 |
+
|
1109 |
+
// Log error if flag has never been set
|
1110 |
+
if ($flag->getId() == null) {
|
1111 |
+
$this->_getHelper()->logError(
|
1112 |
+
$this->_getHelper()->__(
|
1113 |
+
'At least one full export should have been perfomed before generating unsubscribe file.'
|
1114 |
+
)
|
1115 |
+
);
|
1116 |
+
|
1117 |
+
// Stop processing if export never performed
|
1118 |
+
$error = true;
|
1119 |
+
|
1120 |
+
} else {
|
1121 |
+
$lastExportTimestamp = $flag->getFlagData(); // timestamp format
|
1122 |
+
$collection = Mage::getModel('newsletter/subscriber')
|
1123 |
+
->getCollection()
|
1124 |
+
->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
|
1125 |
+
->addFieldToFilter('updated_at', array('from' => $lastExportTimestamp))
|
1126 |
+
->addFieldToFilter('store_id', $storeId);
|
1127 |
+
|
1128 |
+
// Perform only if collection is not empty and no error found
|
1129 |
+
if ($collection->getSize() > 0 && !$error) {
|
1130 |
+
$exporter = Mage::getModel('dolist/exporter_csv');
|
1131 |
+
$exporter->setEnclosure(); // Dolist does not use enclosures
|
1132 |
+
$exporter->setDelimiter(chr(9));
|
1133 |
+
|
1134 |
+
// Write one line for each subscriber to export
|
1135 |
+
foreach ($collection as $subscriber) {
|
1136 |
+
|
1137 |
+
$exporter->addObjectToExport(
|
1138 |
+
array(
|
1139 |
+
'prefix' => '',
|
1140 |
+
'object' => $subscriber,
|
1141 |
+
'fields' => array(
|
1142 |
+
'subscriber_email'
|
1143 |
+
)
|
1144 |
+
)
|
1145 |
+
);
|
1146 |
+
|
1147 |
+
$now = new Zend_Date();
|
1148 |
+
$shortFileName = 'unsubscribe_' . $now->toString('YYYYMMdd_HHmmss') . '.txt';
|
1149 |
+
$unsubscribeFilename = sys_get_temp_dir() . '/' . $shortFileName; // Temporary filename
|
1150 |
+
// Write in tmp CSV file, no header
|
1151 |
+
$exporter->export($unsubscribeFilename, false);
|
1152 |
+
}
|
1153 |
+
}
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
return $shortFileName;
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
/**
|
1160 |
+
* Generate segment file
|
1161 |
+
* File format:
|
1162 |
+
* - file at UTF-8 format
|
1163 |
+
* - separator: carriage return
|
1164 |
+
* - Header line: Email
|
1165 |
+
* - only email address per line
|
1166 |
+
*
|
1167 |
+
* @param mixed $collection Collection of customers (Mage_Customer_Model_Customer) to export
|
1168 |
+
* @param string $exportFileName Export filename
|
1169 |
+
*
|
1170 |
+
* @return string Tmp segment file name
|
1171 |
+
*/
|
1172 |
+
public function generateSegmentFile($collection, $exportFileName)
|
1173 |
+
{
|
1174 |
+
$localFilename = null;
|
1175 |
+
|
1176 |
+
// Perform only if collection is not empty
|
1177 |
+
if ($collection->getSize() > 0) {
|
1178 |
+
$exporter = Mage::getModel('dolist/exporter_csv');
|
1179 |
+
$exporter->setEnclosure(); // Dolist does not use enclosures
|
1180 |
+
$exporter->setDelimiter(chr(9));
|
1181 |
+
|
1182 |
+
// Write one line for each customer to export
|
1183 |
+
foreach ($collection as $customer) {
|
1184 |
+
|
1185 |
+
// Only email field is filled in
|
1186 |
+
$exporter->addObjectToExport(
|
1187 |
+
array(
|
1188 |
+
'prefix' => '',
|
1189 |
+
'object' => $customer,
|
1190 |
+
'fields' => array(
|
1191 |
+
'email'
|
1192 |
+
)
|
1193 |
+
)
|
1194 |
+
);
|
1195 |
+
|
1196 |
+
$localFilename = sys_get_temp_dir() . '/' . $exportFileName; // Temporary filename
|
1197 |
+
// Write in tmp CSV file
|
1198 |
+
$exporter->export($localFilename, 'auto', true, 'contact_header');
|
1199 |
+
}
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
return $localFilename;
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
/**
|
1206 |
+
* Push export file to FTP server
|
1207 |
+
*
|
1208 |
+
* @param string $exportFileName Export filename
|
1209 |
+
* @param string $localFilename Local export filename (usually in /tmp directory)
|
1210 |
+
* @param int $storeId Store ID
|
1211 |
+
*
|
1212 |
+
* @param null $report
|
1213 |
+
* @return boolean
|
1214 |
+
*/
|
1215 |
+
public function pushExportFile($exportFileName, $localFilename, $storeId, $report = null)
|
1216 |
+
{
|
1217 |
+
$this->_getHelper()->logDebug('Start push file to dolist');
|
1218 |
+
|
1219 |
+
/** @var Dolist_Net_Model_Reports $report */
|
1220 |
+
if ($report instanceof Dolist_Net_Model_Reports) {
|
1221 |
+
$report->log(sprintf('EXPORT for store %s', $storeId));
|
1222 |
+
$report->log(sprintf('local filename %s', $localFilename));
|
1223 |
+
$report->log(sprintf('FTP filename %s', $exportFileName));
|
1224 |
+
}
|
1225 |
+
|
1226 |
+
//reencode file in UTF16 with BOM
|
1227 |
+
$this->_reencodeFileToExport($localFilename);
|
1228 |
+
|
1229 |
+
// Zip file
|
1230 |
+
$zipFilename = str_replace('.txt', '.zip', $localFilename);
|
1231 |
+
if ($report instanceof Dolist_Net_Model_Reports) {
|
1232 |
+
$report->log(sprintf('zip filename %s', $zipFilename));
|
1233 |
+
}
|
1234 |
+
$zip = new ZipArchive();
|
1235 |
+
$zip->open($zipFilename, ZipArchive::CREATE);
|
1236 |
+
$zip->addFile($localFilename, basename($localFilename));
|
1237 |
+
$zip->close();
|
1238 |
+
|
1239 |
+
/** @var Dolist_Net_Model_Dolistv8_Ftp $ftpConnection */
|
1240 |
+
$ftpConnection = Mage::getModel('dolist/dolistv8_ftp', array('store_id' => $storeId));
|
1241 |
+
$connection = $ftpConnection->getConnection();
|
1242 |
+
$result = false;
|
1243 |
+
|
1244 |
+
try {
|
1245 |
+
// Generate remote filename from export filename
|
1246 |
+
$remoteFolder = (string)Mage::getConfig()->getNode('dolistparams/ftp/upload_contact_directory');
|
1247 |
+
// To be sure to get only one slash
|
1248 |
+
$remoteFolder = rtrim($remoteFolder, '/') . '/';
|
1249 |
+
$remoteFilename = $remoteFolder . basename($zipFilename);
|
1250 |
+
|
1251 |
+
if ($report instanceof Dolist_Net_Model_Reports) {
|
1252 |
+
$report->log(sprintf('Remote filename %s', $remoteFilename));
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
// Push on FTP server
|
1256 |
+
$result = $connection->write($remoteFilename, $zipFilename);
|
1257 |
+
|
1258 |
+
// Close FTP connection
|
1259 |
+
$connection->close();
|
1260 |
+
|
1261 |
+
// Delete tmp file
|
1262 |
+
unlink($localFilename);
|
1263 |
+
unlink($zipFilename);
|
1264 |
+
|
1265 |
+
} catch (Exception $e) {
|
1266 |
+
// Delete tmp file
|
1267 |
+
unlink($localFilename);
|
1268 |
+
unlink($zipFilename);
|
1269 |
+
|
1270 |
+
$report->log($e->getMessage());
|
1271 |
+
$this->_getHelper()->logError($e->getMessage());
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
return $result;
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
/**
|
1278 |
+
* Push unsubscribe file to FTP server
|
1279 |
+
*
|
1280 |
+
* @param string $shortFilename Local unsubscribe filename (usually in /tmp directory)
|
1281 |
+
* @param int $storeId Store ID
|
1282 |
+
*
|
1283 |
+
* @return void
|
1284 |
+
*/
|
1285 |
+
public function pushUnsubscribeFile($shortFilename, $storeId)
|
1286 |
+
{
|
1287 |
+
$ftpConnection = Mage::getSingleton('dolist/dolistv8_ftp', array('store_id' => $storeId));
|
1288 |
+
$connection = $ftpConnection->getConnection();
|
1289 |
+
$result = false;
|
1290 |
+
|
1291 |
+
$unsubscribeFilename = sys_get_temp_dir() . '/' . $shortFilename; // Temporary filename
|
1292 |
+
|
1293 |
+
try {
|
1294 |
+
// Generate remote filename from export filename
|
1295 |
+
$remoteFolder = (string)Mage::getConfig()->getNode('dolistparams/ftp/unsubscribe_contact_directory');
|
1296 |
+
// To be sure to get only one slash
|
1297 |
+
$remoteFolder = rtrim($remoteFolder, '/') . '/';
|
1298 |
+
$remoteFilename = $remoteFolder . $shortFilename;
|
1299 |
+
|
1300 |
+
//reencode file in UTF16 with BOM
|
1301 |
+
$this->_reencodeFileToExport($localFilename);
|
1302 |
+
|
1303 |
+
// Push on FTP server
|
1304 |
+
$result = $connection->write($remoteFilename, $unsubscribeFilename);
|
1305 |
+
|
1306 |
+
// Close FTP connection
|
1307 |
+
$connection->close();
|
1308 |
+
|
1309 |
+
// Delete tmp file
|
1310 |
+
unlink($unsubscribeFilename);
|
1311 |
+
|
1312 |
+
} catch (Exception $e) {
|
1313 |
+
// Delete tmp file
|
1314 |
+
unlink($unsubscribeFilename);
|
1315 |
+
$this->_getHelper()->logError($e->getMessage());
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
return $result;
|
1319 |
+
}
|
1320 |
+
|
1321 |
+
/**
|
1322 |
+
* Perfom segment export for given $segmentId to Dolist-V8
|
1323 |
+
* Perform one export for each website.
|
1324 |
+
* Websites have been filtered before to avoid several sends with same Dolist-V8 configuration
|
1325 |
+
*
|
1326 |
+
* @param int $segmentId Customer segment Id
|
1327 |
+
* @param array $websiteIds Websites where Dolist-V8 is enabled
|
1328 |
+
* @param array $storeIds Websites default store where Dolist-V8 is enabled. Array is indexed by website id
|
1329 |
+
*
|
1330 |
+
* @return bool Return true if export is successful, false otherwise
|
1331 |
+
*/
|
1332 |
+
public function exportSegment($segmentId, $websiteIds, $storeIds)
|
1333 |
+
{
|
1334 |
+
$return = true;
|
1335 |
+
|
1336 |
+
$customerSegment = Mage::getModel('enterprise_customersegment/segment')->load($segmentId);
|
1337 |
+
$exportPerformed = false;
|
1338 |
+
|
1339 |
+
// One export performed for each website
|
1340 |
+
foreach ($websiteIds as $configWebsiteId => $websiteListToFilter) {
|
1341 |
+
|
1342 |
+
$storeId = $storeIds[$configWebsiteId];
|
1343 |
+
|
1344 |
+
if ($customerSegment->getId()) {
|
1345 |
+
|
1346 |
+
// Retrieve segment customers to export
|
1347 |
+
$collection = Mage::getResourceModel('enterprise_customersegment/report_customer_collection');
|
1348 |
+
$collection->addNameToSelect()
|
1349 |
+
->setViewMode($customerSegment->getViewMode())
|
1350 |
+
->addSegmentFilter($customerSegment)
|
1351 |
+
->addWebsiteFilter($websiteListToFilter);
|
1352 |
+
|
1353 |
+
if ($collection->count() > 0) {
|
1354 |
+
|
1355 |
+
// Create new import.
|
1356 |
+
// ImportName : 'MAGENTO - <segment.name> - <YYYYMMDD_HHmmss>
|
1357 |
+
$now = new Zend_Date();
|
1358 |
+
$importName = 'MAGENTO - ' . $customerSegment->getName() . ' - ' . $now->toString('YYYYMMdd_HHmmss');
|
1359 |
+
$response = $this->dolistV8CreateImport($importName, true, $storeId);
|
1360 |
+
$exportFileName = $response->getData('FileName');
|
1361 |
+
|
1362 |
+
// Create segment file
|
1363 |
+
if (!is_null($exportFileName)) {
|
1364 |
+
$localFilename = $this->generateSegmentFile($collection, $exportFileName);
|
1365 |
+
|
1366 |
+
if (!is_null($localFilename)) {
|
1367 |
+
// Push file on FTP server
|
1368 |
+
$exportPerformed = $this->pushExportFile($exportFileName, $localFilename, $storeId);
|
1369 |
+
}
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
if ($exportPerformed) {
|
1373 |
+
// If success, check if this segment has already been exported
|
1374 |
+
// If never exported, add it to exported segment list (dolist_exported_segment_list)
|
1375 |
+
$this->_getHelper()->addExportedSegment($customerSegment->getId(), $storeId);
|
1376 |
+
|
1377 |
+
Mage::getSingleton('adminhtml/session')
|
1378 |
+
->addSuccess($this->_getHelper()->__("Exporting segment id %s to Dolist-V8 succeeded", $segmentId));
|
1379 |
+
|
1380 |
+
} else {
|
1381 |
+
|
1382 |
+
Mage::getSingleton('adminhtml/session')
|
1383 |
+
->addError($this->_getHelper()->__("Exporting segment id %s to Dolist-V8 failed", $segmentId));
|
1384 |
+
$return = false;
|
1385 |
+
}
|
1386 |
+
|
1387 |
+
} else {
|
1388 |
+
Mage::getSingleton('adminhtml/session')
|
1389 |
+
->addError($this->_getHelper()->__("Segment id %s has not been exported because it is empty", $segmentId));
|
1390 |
+
$return = false;
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
} else {
|
1394 |
+
Mage::getSingleton('adminhtml/session')
|
1395 |
+
->addNotice($this->_getHelper()->__("Segment id %s couldn't be loaded", $segmentId));
|
1396 |
+
|
1397 |
+
|
1398 |
+
// Remove this segment from dolist exported segment list
|
1399 |
+
$this->_getHelper()->removeExportedSegment($segmentId);
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
return $return;
|
1404 |
+
}
|
1405 |
+
|
1406 |
+
/**
|
1407 |
+
* Log web service error
|
1408 |
+
*
|
1409 |
+
* @param Varien_Object $request Contain request
|
1410 |
+
* @param SoapFault $fault Web service exception response
|
1411 |
+
* @param string $method Web service method
|
1412 |
+
* @param string $additionalInfo Additional info for logs
|
1413 |
+
*
|
1414 |
+
* @return void
|
1415 |
+
*/
|
1416 |
+
protected function _logError($request, $fault, $method, $additionalInfo = '')
|
1417 |
+
{
|
1418 |
+
Mage::helper('dolist/log')->logError($request, $fault, $method, $additionalInfo);
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
/**
|
1422 |
+
* Retrieve model helper
|
1423 |
+
*
|
1424 |
+
* @return Dolist_Net_Helper_Data
|
1425 |
+
*/
|
1426 |
+
protected function _getHelper()
|
1427 |
+
{
|
1428 |
+
return Mage::helper('dolist');
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
/**
|
1432 |
+
* Reencode a file in UTF16 with BOM
|
1433 |
+
*
|
1434 |
+
* @param string $filename
|
1435 |
+
* @return string
|
1436 |
+
*/
|
1437 |
+
protected function _reencodeFileToExport($filename)
|
1438 |
+
{
|
1439 |
+
$origContent = file_get_contents($filename);
|
1440 |
+
|
1441 |
+
$encoding = mb_detect_encoding($origContent, "auto");
|
1442 |
+
// escape all of the question marks so we can remove artifacts from
|
1443 |
+
// the unicode conversion process
|
1444 |
+
$encodedContent = str_replace("?", "[question_mark]", $origContent);
|
1445 |
+
$encodedContent = mb_convert_encoding($encodedContent, "UTF-16LE", $encoding);
|
1446 |
+
$encodedContent = str_replace("?", "", $encodedContent);
|
1447 |
+
// replace the token string "[question_mark]" with the symbol "?"
|
1448 |
+
$encodedContent = str_replace("[question_mark]", "?", $encodedContent);
|
1449 |
+
// add BOM
|
1450 |
+
$encodedContent = "\xFF\xFE" . $encodedContent;
|
1451 |
+
|
1452 |
+
file_put_contents($filename, $encodedContent);
|
1453 |
+
return $filename;
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
/**
|
1457 |
+
* Get table name (validated by db adapter) by table placeholder
|
1458 |
+
*
|
1459 |
+
* @param string|array $tableName
|
1460 |
+
* @return string
|
1461 |
+
*/
|
1462 |
+
public function getTable($tableName)
|
1463 |
+
{
|
1464 |
+
$cacheKey = $this->_getTableCacheName($tableName);
|
1465 |
+
if (!isset($this->_tables[$cacheKey])) {
|
1466 |
+
/** @var Mage_Core_Model_Resource $coreResource */
|
1467 |
+
$coreResource = Mage::getSingleton('core/resource');
|
1468 |
+
$this->_tables[$cacheKey] = $coreResource->getTableName($tableName);
|
1469 |
+
}
|
1470 |
+
return $this->_tables[$cacheKey];
|
1471 |
+
}
|
1472 |
+
|
1473 |
+
/**
|
1474 |
+
* Retrieve table name for cache
|
1475 |
+
*
|
1476 |
+
* @param string|array $tableName
|
1477 |
+
* @return string
|
1478 |
+
*/
|
1479 |
+
protected function _getTableCacheName($tableName)
|
1480 |
+
{
|
1481 |
+
if (is_array($tableName)) {
|
1482 |
+
return join('_', $tableName);
|
1483 |
+
|
1484 |
+
}
|
1485 |
+
return $tableName;
|
1486 |
+
}
|
1487 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistemt/Request/Getauthenticationtoken.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT SOAP request for GetAuthenticationToken method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistemt_Request_Getauthenticationtoken extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize default values
|
14 |
+
*
|
15 |
+
* @param array $params Init params
|
16 |
+
*
|
17 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Request_Getauthenticationtoken Request
|
18 |
+
*/
|
19 |
+
public function __construct($params=null)
|
20 |
+
{
|
21 |
+
$storeId = 0;
|
22 |
+
if (!is_null($params) && array_key_exists('store_id', $params)) {
|
23 |
+
$storeId = $params['store_id'];
|
24 |
+
}
|
25 |
+
|
26 |
+
if (is_null($params['account_id'])) {
|
27 |
+
$accountId = Mage::getStoreConfig(self::XML_DOLIST_EMT_ACCOUNTID, $storeId);
|
28 |
+
} else {
|
29 |
+
$accountId = $params['account_id'];
|
30 |
+
}
|
31 |
+
|
32 |
+
if (is_null($params['auth_key'])) {
|
33 |
+
$authKey = Mage::getStoreConfig(self::XML_DOLIST_EMT_AUTHENTICATION_KEY, $storeId);
|
34 |
+
} else {
|
35 |
+
$authKey = $params['auth_key'];
|
36 |
+
}
|
37 |
+
|
38 |
+
// Init default values
|
39 |
+
$this->setAuthenticationRequest(
|
40 |
+
array(
|
41 |
+
'AccountID' => $accountId,
|
42 |
+
'AuthenticationKey' => $authKey
|
43 |
+
)
|
44 |
+
);
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistemt/Request/Gettemplatelist.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT SOAP request for GetTemplateList method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistemt_Request_Gettemplatelist extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize default values
|
14 |
+
*
|
15 |
+
* @param array $params Init parameters
|
16 |
+
*
|
17 |
+
* @return Dolist_Net_Model_Service_Dolistemt_Request_Gettemplatelist
|
18 |
+
*/
|
19 |
+
public function __construct($params=null)
|
20 |
+
{
|
21 |
+
// Init params
|
22 |
+
$storeId = 0;
|
23 |
+
if (array_key_exists('store_id', $params)) {
|
24 |
+
$storeId = $params['store_id'];
|
25 |
+
}
|
26 |
+
|
27 |
+
if (is_null($params['account_id'])) {
|
28 |
+
$accountId = Mage::getStoreConfig(self::XML_DOLIST_EMT_ACCOUNTID, $storeId);
|
29 |
+
} else {
|
30 |
+
$accountId = $params['account_id'];
|
31 |
+
}
|
32 |
+
|
33 |
+
$key = $params['key'];
|
34 |
+
|
35 |
+
// Init default values
|
36 |
+
$this->setToken(
|
37 |
+
array(
|
38 |
+
'AccountID' => $accountId,
|
39 |
+
'Key' => $key
|
40 |
+
)
|
41 |
+
);
|
42 |
+
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistemt/Request/SendEmail.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT SOAP request for SendEmail method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistemt_Request_SendEmail extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize default values
|
14 |
+
*
|
15 |
+
* @param array $params Init parameters
|
16 |
+
*
|
17 |
+
* @return Dolist_Net_Model_Service_Dolistemt_Request_Gettemplatelist
|
18 |
+
*/
|
19 |
+
public function __construct($params=null)
|
20 |
+
{
|
21 |
+
// Init params
|
22 |
+
$storeId = 0;
|
23 |
+
if (array_key_exists('store_id', $params)) {
|
24 |
+
$storeId = $params['store_id'];
|
25 |
+
}
|
26 |
+
$key = $params['key'];
|
27 |
+
$message = $params['message'];
|
28 |
+
// Init default values
|
29 |
+
$this->setToken(
|
30 |
+
array(
|
31 |
+
'AccountID' => Mage::getStoreConfig(self::XML_DOLIST_EMT_ACCOUNTID, $storeId),
|
32 |
+
'Key' => $key
|
33 |
+
)
|
34 |
+
)->setMessage($message);
|
35 |
+
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistemt/Response/Getauthenticationtoken.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-Emt SOAP response for GetAuthenticationToken request
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistemt_Response_Getauthenticationtoken extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Check web service response and return array result
|
16 |
+
*
|
17 |
+
* @param array $arr Data to add to response
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function addData(array $arr)
|
22 |
+
{
|
23 |
+
parent::addData($arr);
|
24 |
+
|
25 |
+
// Check if there is result
|
26 |
+
$response = null;
|
27 |
+
$tokenResult = $this->getData('GetAuthenticationTokenResult');
|
28 |
+
if ($tokenResult != null) {
|
29 |
+
$response = Mage::getModel('dolist/service_message_abstract');
|
30 |
+
$response->addData((array)$tokenResult);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $response;
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistemt/Response/Gettemplatelist.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT SOAP response for GetTemplateList method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistemt_Response_Gettemplatelist extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistemt/Response/SendEmail.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-EMT SOAP response for SendMail method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistemt_Response_SendEmail extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check web service response and return array result
|
14 |
+
*
|
15 |
+
* @param array $arr Data to add to response
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function addData(array $arr)
|
20 |
+
{
|
21 |
+
parent::addData($arr);
|
22 |
+
|
23 |
+
// Check if there is result
|
24 |
+
$response = "";
|
25 |
+
$listResult = $this->getData('SendEmailResult');
|
26 |
+
if ($listResult != null) {
|
27 |
+
$listResult = (array)$listResult;
|
28 |
+
$response = $listResult['GetTemplateResponse'];
|
29 |
+
}
|
30 |
+
|
31 |
+
return $response;
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Createimport.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP request for CreateImport method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Request_Createimport extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize request
|
14 |
+
* Key and ImportName need to be set
|
15 |
+
* param string $key Authentication token key
|
16 |
+
* param string $importName Import name: "MAGENTO - Chargement complet" or "MAGENTO - Chargement différentiel"
|
17 |
+
* param bool $createSegment Does this import create segment or not. Default: false
|
18 |
+
*
|
19 |
+
* @param array $params Init parameters
|
20 |
+
*
|
21 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Request_Createimport Request
|
22 |
+
*/
|
23 |
+
public function __construct($params=null)
|
24 |
+
{
|
25 |
+
// Init params
|
26 |
+
$storeId = 0;
|
27 |
+
if (array_key_exists('store_id', $params)) {
|
28 |
+
$storeId = $params['store_id'];
|
29 |
+
}
|
30 |
+
$key = $params['key'];
|
31 |
+
$importName = $params['import_name'];
|
32 |
+
$createSegment = false;
|
33 |
+
if (array_key_exists('create_segment', $params)) {
|
34 |
+
$createSegment = $params['create_segment'];
|
35 |
+
}
|
36 |
+
|
37 |
+
// Init default values
|
38 |
+
$this->setToken(
|
39 |
+
array(
|
40 |
+
'AccountID' => Mage::getStoreConfig(self::XML_DOLIST_V8_ACCOUNTID, $storeId),
|
41 |
+
'Key' => $key
|
42 |
+
)
|
43 |
+
)->setImportFile(
|
44 |
+
array(
|
45 |
+
'CreateSegment' => $createSegment,
|
46 |
+
'ImportName' => $importName,
|
47 |
+
'InterestCenter' => '',
|
48 |
+
'IsRent' => false,
|
49 |
+
'ProviderFileName' => '',
|
50 |
+
'RentCredit' => 0,
|
51 |
+
'ReportAddresses' => array(Mage::getStoreConfig('trans_email/ident_general/email', $storeId)),
|
52 |
+
'UpdateContacts' => true
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Getauthenticationtoken.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP request for GetAuthenticationToken method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Request_Getauthenticationtoken extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize default values
|
14 |
+
*
|
15 |
+
* @param array $params Init params
|
16 |
+
*
|
17 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Request_Getauthenticationtoken Request
|
18 |
+
*/
|
19 |
+
public function __construct($params=null)
|
20 |
+
{
|
21 |
+
$storeId = 0;
|
22 |
+
if (!is_null($params) && array_key_exists('store_id', $params)) {
|
23 |
+
$storeId = $params['store_id'];
|
24 |
+
}
|
25 |
+
|
26 |
+
if (is_null($params['account_id'])) {
|
27 |
+
$accountId = Mage::getStoreConfig(self::XML_DOLIST_V8_ACCOUNTID, $storeId);
|
28 |
+
} else {
|
29 |
+
$accountId = $params['account_id'];
|
30 |
+
}
|
31 |
+
|
32 |
+
if (is_null($params['auth_key'])) {
|
33 |
+
$authKey = Mage::getStoreConfig(self::XML_DOLIST_V8_AUTHENTICATION_KEY, $storeId);
|
34 |
+
} else {
|
35 |
+
$authKey = $params['auth_key'];
|
36 |
+
}
|
37 |
+
|
38 |
+
// Init default values
|
39 |
+
$this->setAuthenticationRequest(
|
40 |
+
array(
|
41 |
+
'AccountID' => $accountId,
|
42 |
+
'AuthenticationKey' => $authKey
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Getcontact.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP request for GetContact method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Request_Getcontact extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize request
|
14 |
+
* Key need to be set
|
15 |
+
*
|
16 |
+
* @param array $params Init params
|
17 |
+
*
|
18 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Request_Getcontact Request
|
19 |
+
*/
|
20 |
+
public function __construct($params=null)
|
21 |
+
{
|
22 |
+
// Init params
|
23 |
+
$storeId = 0;
|
24 |
+
if (!is_null($params) && array_key_exists('store_id', $params)) {
|
25 |
+
$storeId = $params['store_id'];
|
26 |
+
}
|
27 |
+
$key = $params['key'];
|
28 |
+
|
29 |
+
// Init default values
|
30 |
+
$this->setToken(
|
31 |
+
array(
|
32 |
+
'AccountID' => Mage::getStoreConfig(self::XML_DOLIST_V8_ACCOUNTID, $storeId),
|
33 |
+
'Key' => $key
|
34 |
+
)
|
35 |
+
)->setRequest(
|
36 |
+
array(
|
37 |
+
'AllFields' => false,
|
38 |
+
'Interest' => false,
|
39 |
+
'LastModifiedOnly' => true,
|
40 |
+
'ReturnFields' => array('Email', 'OptoutEmail')
|
41 |
+
)
|
42 |
+
);
|
43 |
+
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Request/Getfieldlist.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP request for GetFieldList method
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2011 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Request_Getfieldlist extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Intialize request
|
14 |
+
* Key need to be set
|
15 |
+
*
|
16 |
+
* @param array $params Init params
|
17 |
+
*
|
18 |
+
* @return Dolist_Net_Model_Service_Dolistv8_Request_Getfieldlist Request
|
19 |
+
*/
|
20 |
+
public function __construct($params=null)
|
21 |
+
{
|
22 |
+
// Init params
|
23 |
+
$storeId = 0;
|
24 |
+
if (!is_null($params) && array_key_exists('store_id', $params)) {
|
25 |
+
$storeId = $params['store_id'];
|
26 |
+
}
|
27 |
+
$key = $params['key'];
|
28 |
+
|
29 |
+
// Init default values
|
30 |
+
$this->setToken(
|
31 |
+
array(
|
32 |
+
'AccountID' => Mage::getStoreConfig(self::XML_DOLIST_V8_ACCOUNTID, $storeId),
|
33 |
+
'Key' => $key
|
34 |
+
)
|
35 |
+
)->setRequest(
|
36 |
+
array(
|
37 |
+
//'Culture' => 'fr-FR',
|
38 |
+
//'UserEmail' => false,
|
39 |
+
//'ProfileID' => 1,
|
40 |
+
//'Offset' => array('Email', 'OptoutEmail'),
|
41 |
+
//'Limit'
|
42 |
+
)
|
43 |
+
);
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Createimport.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP response for CreateImport request
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Response_Createimport extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check web service response and return array result
|
14 |
+
*
|
15 |
+
* @param array $arr Data to add to response
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function addData(array $arr)
|
20 |
+
{
|
21 |
+
parent::addData($arr);
|
22 |
+
|
23 |
+
// Check if there is result
|
24 |
+
$response = null;
|
25 |
+
$importReport = $this->getData('CreateImportResult');
|
26 |
+
|
27 |
+
if ($importReport != null) {
|
28 |
+
$response = Mage::getModel('dolist/service_message_abstract');
|
29 |
+
$response->addData((array)$importReport);
|
30 |
+
}
|
31 |
+
|
32 |
+
return $response;
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Getauthenticationtoken.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP response for GetAuthenticationToken request
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Response_Getauthenticationtoken extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check web service response and return array result
|
14 |
+
*
|
15 |
+
* @param array $arr Data to add to response
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function addData(array $arr)
|
20 |
+
{
|
21 |
+
parent::addData($arr);
|
22 |
+
|
23 |
+
// Check if there is result
|
24 |
+
$response = null;
|
25 |
+
$tokenResult = $this->getData('GetAuthenticationTokenResult');
|
26 |
+
if ($tokenResult != null) {
|
27 |
+
$response = Mage::getModel('dolist/service_message_abstract');
|
28 |
+
$response->addData((array)$tokenResult);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $response;
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Getcontact.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP response for GetContact request
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Response_Getcontact extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check web service response and return array result
|
14 |
+
*
|
15 |
+
* @param array $arr Data to add to response
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function addData(array $arr)
|
20 |
+
{
|
21 |
+
parent::addData($arr);
|
22 |
+
|
23 |
+
// Check if there is result
|
24 |
+
$response = null;
|
25 |
+
$contactResponse = $this->getData('GetContactResult');
|
26 |
+
|
27 |
+
if ($contactResponse != null) {
|
28 |
+
$response = Mage::getModel('dolist/service_message_abstract');
|
29 |
+
$response->addData((array)$contactResponse);
|
30 |
+
}
|
31 |
+
|
32 |
+
return $response;
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Dolistv8/Response/Getfieldlist.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist-V8 SOAP response for GetFieldList request
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_Service_Dolistv8_Response_Getfieldlist extends Dolist_Net_Model_Service_Message_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check web service response and return array result
|
14 |
+
*
|
15 |
+
* @param array $arr Data to add to response
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function addData(array $arr)
|
20 |
+
{
|
21 |
+
parent::addData($arr);
|
22 |
+
|
23 |
+
// Check if there is result
|
24 |
+
$response = null;
|
25 |
+
$fieldListResponse = $this->getData('GetFieldListResult');
|
26 |
+
|
27 |
+
if ($fieldListResponse != null) {
|
28 |
+
$response = Mage::getModel('dolist/service_message_abstract');
|
29 |
+
$response->addData((array)$fieldListResponse);
|
30 |
+
}
|
31 |
+
|
32 |
+
return $response;
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Dolist/Net/Model/Service/Message/Abstract.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist SOAP abstract message
|
4 |
+
* Convert stdClass Object to Varien Object
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_Service_Message_Abstract extends Varien_Object
|
12 |
+
{
|
13 |
+
const XML_DOLIST_EMT_ACCOUNTID = 'dolist/dolist_emt/accountid';
|
14 |
+
const XML_DOLIST_EMT_AUTHENTICATION_KEY = 'dolist/dolist_emt/authentication_key';
|
15 |
+
|
16 |
+
const XML_DOLIST_V8_ACCOUNTID = 'dolist/dolist_v8/accountid';
|
17 |
+
const XML_DOLIST_V8_AUTHENTICATION_KEY = 'dolist/dolist_v8/authentication_key';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Use web service convention for attribute names
|
21 |
+
* Converts field names for setters and getters
|
22 |
+
* $this->setMyField($value) === $this->setData('myField', $value)
|
23 |
+
*
|
24 |
+
* Do not use cache to avoid side effects with Varien_Object one
|
25 |
+
*
|
26 |
+
* @param string $name Attribute name
|
27 |
+
*
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
protected function _underscore($name)
|
31 |
+
{
|
32 |
+
// lcfist is only available since 5.3, the line below is equivalent to "$name = lcfirst($name);"
|
33 |
+
$name[0] = strtolower($name[0]);
|
34 |
+
return $name;
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Check.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist configuration integrity check
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_System_Config_Check extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check for Dolist-V8 custom fields duplicates before saving configuration parameters
|
14 |
+
*
|
15 |
+
* @return Dolist_Net_Model_System_Config_Check
|
16 |
+
* @throws Mage_Core_Exception
|
17 |
+
*/
|
18 |
+
protected function _beforeSave()
|
19 |
+
{
|
20 |
+
// Retrieve data set by admin user
|
21 |
+
$configData = $this->getData();
|
22 |
+
$groupValue = null;
|
23 |
+
$customStrFieldsValues = null;
|
24 |
+
$customIntFieldsValues = null;
|
25 |
+
$customDateFieldsValues = null;
|
26 |
+
|
27 |
+
$storeConfig = Mage::getStoreConfig('dolist/dolist_v8', $configData['scope_id']);
|
28 |
+
|
29 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['group'])) {
|
30 |
+
$groupValue = unserialize($storeConfig['group']);
|
31 |
+
} else {
|
32 |
+
$groupValue = $configData['groups']['dolist_v8']['fields']['group']['value'];
|
33 |
+
}
|
34 |
+
|
35 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['custom_str_fields'])) {
|
36 |
+
$customStrFieldsValues = unserialize($storeConfig['custom_str_fields']);
|
37 |
+
} else {
|
38 |
+
$customStrFieldsValues = $configData['groups']['dolist_v8']['fields']['custom_str_fields']['value'];
|
39 |
+
}
|
40 |
+
|
41 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['custom_int_fields'])) {
|
42 |
+
$customIntFieldsValues = unserialize($storeConfig['custom_int_fields']);
|
43 |
+
} else {
|
44 |
+
$customIntFieldsValues = $configData['groups']['dolist_v8']['fields']['custom_int_fields']['value'];
|
45 |
+
}
|
46 |
+
|
47 |
+
if (array_key_exists('inherit', $configData['groups']['dolist_v8']['fields']['custom_date_fields'])) {
|
48 |
+
$customDateFieldsValues = unserialize($storeConfig['custom_date_fields']);
|
49 |
+
} else {
|
50 |
+
$customDateFieldsValues = $configData['groups']['dolist_v8']['fields']['custom_date_fields']['value'];
|
51 |
+
}
|
52 |
+
|
53 |
+
$integrityError = false;
|
54 |
+
$setCustomStrFields = array();
|
55 |
+
$setCustomIntFields = array();
|
56 |
+
$setCustomDateFields = array();
|
57 |
+
|
58 |
+
$setCustomStrFields[] = $groupValue;
|
59 |
+
foreach ($customStrFieldsValues as $customStrFieldsValue) {
|
60 |
+
|
61 |
+
// If data already found, cannot be used twice, so throw error
|
62 |
+
if (is_array($customStrFieldsValue)) {
|
63 |
+
if (in_array($customStrFieldsValue['dolist_custom_str_fields'], $setCustomStrFields)) {
|
64 |
+
$integrityError = true;
|
65 |
+
break;
|
66 |
+
} else {
|
67 |
+
// Add data in array
|
68 |
+
$setCustomStrFields[] = $customStrFieldsValue['dolist_custom_str_fields'];
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
if (!$integrityError) {
|
74 |
+
foreach ($customIntFieldsValues as $customIntFieldsValue) {
|
75 |
+
|
76 |
+
// If data already found, cannot be used twice, so throw error
|
77 |
+
if (is_array($customIntFieldsValue)) {
|
78 |
+
if (in_array($customIntFieldsValue['dolist_custom_int_fields'], $setCustomIntFields)) {
|
79 |
+
$integrityError = true;
|
80 |
+
break;
|
81 |
+
} else {
|
82 |
+
// Add data in array
|
83 |
+
$setCustomIntFields[] = $customIntFieldsValue['dolist_custom_int_fields'];
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
if (!$integrityError) {
|
89 |
+
foreach ($customDateFieldsValues as $customDateFieldsValue) {
|
90 |
+
|
91 |
+
// If data already found, cannot be used twice, so throw error
|
92 |
+
if (is_array($customDateFieldsValue)) {
|
93 |
+
if (in_array($customDateFieldsValue['dolist_custom_date_fields'], $setCustomDateFields)) {
|
94 |
+
$integrityError = true;
|
95 |
+
break;
|
96 |
+
} else {
|
97 |
+
// Add data in array
|
98 |
+
$setCustomDateFields[] = $customDateFieldsValue['dolist_custom_date_fields'];
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
// Display error message if integrity error
|
106 |
+
if ($integrityError) {
|
107 |
+
Mage::throwException(
|
108 |
+
Mage::helper('dolist')
|
109 |
+
->__(
|
110 |
+
'Double check that group, custom str fields, custom int field and ' .
|
111 |
+
'custom date fields do not share same value.'
|
112 |
+
)
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Dolistemt/Defaulttemplate.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select Dolist-EMT templates
|
4 |
+
* Retrieve stored values
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_System_Config_Source_Dolistemt_Defaulttemplate
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return list of Dolist-EMT templates stored in Magento when "Test Dolist-EMT connection" button is clicked on
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function toOptionArray()
|
19 |
+
{
|
20 |
+
$storedArray = Mage::getModel('dolist/dolistemt_template')->getCollection()->toArray();
|
21 |
+
$options = array();
|
22 |
+
|
23 |
+
if ($storedArray['totalRecords'] > 0) {
|
24 |
+
foreach ($storedArray['items'] as $storedTemplate) {
|
25 |
+
$options[] = array(
|
26 |
+
'value' => $storedTemplate['template_id'],
|
27 |
+
'label' => $storedTemplate['template_name']
|
28 |
+
);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
return $options;
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Dolistemt/Errors.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select Dolist-EMT API errors
|
4 |
+
* Retrieve stored values
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_System_Config_Source_Dolistemt_Errors
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return list of Dolist-EMT templates stored in Magento when "Test Dolist-EMT connection" button is clicked on
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function toOptionArray()
|
19 |
+
{
|
20 |
+
$storedArray = Mage::getModel('dolist/dolistemt_template')->getCollection()->toArray();
|
21 |
+
$options = array();
|
22 |
+
|
23 |
+
if ($storedArray['totalRecords'] > 0) {
|
24 |
+
foreach ($storedArray['items'] as $storedTemplate) {
|
25 |
+
$options[] = array(
|
26 |
+
'value' => $storedTemplate['template_id'],
|
27 |
+
'label' => $storedTemplate['template_name']
|
28 |
+
);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
return $options;
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Dolistemt/Template.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select Dolist-EMT templates
|
4 |
+
* Retrieve stored values
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_System_Config_Source_Dolistemt_Template
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return list of Dolist-EMT templates stored in Magento when "Test Dolist-EMT connection" button is clicked on
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function toOptionArray()
|
19 |
+
{
|
20 |
+
$storedArray = Mage::getModel('dolist/dolistemt_template')->getCollection()->toArray();
|
21 |
+
$options = array();
|
22 |
+
|
23 |
+
if ($storedArray['totalRecords'] > 0) {
|
24 |
+
foreach ($storedArray['items'] as $storedTemplate) {
|
25 |
+
$options[] = array(
|
26 |
+
'value' => $storedTemplate['template_id'],
|
27 |
+
'label' => $storedTemplate['template_name']
|
28 |
+
);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
$options[] = array(
|
33 |
+
'value' => -1,
|
34 |
+
'label' => Mage::helper('dolist')->__('Use magento native email system')
|
35 |
+
);
|
36 |
+
|
37 |
+
return $options;
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Dolistv8/Customerattributelist.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select customer attribute list which can be exported to Doslit-V8
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_System_Config_Source_Dolistv8_Customerattributelist
|
11 |
+
{
|
12 |
+
protected $_staticAttrByBackend = array(
|
13 |
+
'datetime' => array('created_at', 'updated_at'),
|
14 |
+
'int' => array('entity_id', 'entity_type_id', 'attribute_set_id', 'increment_id')
|
15 |
+
);
|
16 |
+
|
17 |
+
protected $_staticAttrToExcludeByBackend = array(
|
18 |
+
'static' => array('created_at', 'updated_at'),
|
19 |
+
'varchar' => array('entity_id', 'entity_type_id', 'attribute_set_id', 'increment_id')
|
20 |
+
);
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Return Dolist-V8 customer attribute list
|
24 |
+
* Contain automatic Magento attributes, and also custom attributes dynamically generated (specific sql requests)
|
25 |
+
* defined in config.xml file
|
26 |
+
*
|
27 |
+
* @param array|string $backendType Backend type to display. Can be static|int|varchar|datetime
|
28 |
+
*
|
29 |
+
* @return array Options with labels and values. Values are models for calculated attributes
|
30 |
+
*/
|
31 |
+
public function toOptionArray($backendType)
|
32 |
+
{
|
33 |
+
if (!is_array($backendType)) {
|
34 |
+
$backendType = array($backendType);
|
35 |
+
}
|
36 |
+
//prepare static attr to add
|
37 |
+
$staticAttrToAdd = array();
|
38 |
+
foreach ($backendType as $type) {
|
39 |
+
if(isset($this->_staticAttrByBackend[$type])) {
|
40 |
+
$staticAttrToAdd = array_merge($staticAttrToAdd, $this->_staticAttrByBackend[$type]);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
$staticAttrToExclude = array();
|
45 |
+
foreach ($backendType as $type) {
|
46 |
+
if(isset($this->_staticAttrToExcludeByBackend[$type])) {
|
47 |
+
$staticAttrToExclude = array_merge($staticAttrToExclude, $this->_staticAttrToExcludeByBackend[$type]);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$customerModel = Mage::getModel('customer/customer');
|
52 |
+
$attributes = $customerModel->getAttributes();
|
53 |
+
|
54 |
+
// Customer attributes
|
55 |
+
$options = array();
|
56 |
+
if (!empty($attributes)) {
|
57 |
+
$options[] = array('value' => array(), 'label' => Mage::helper('dolist')->__("Customer attributes"));
|
58 |
+
}
|
59 |
+
foreach ($attributes as $att) {
|
60 |
+
/** @var Mage_Customer_Model_Attribute $att */
|
61 |
+
if(in_array($att->getAttributeCode(), array('default_shipping', 'default_billing', 'email', 'is_confirmed'))) {
|
62 |
+
continue;
|
63 |
+
}
|
64 |
+
|
65 |
+
if(in_array($att->getAttributeCode(), Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
66 |
+
continue;
|
67 |
+
}
|
68 |
+
|
69 |
+
// Filter following backend type
|
70 |
+
if ((in_array($att->getBackendType(), $backendType) && !in_array($att->getAttributeCode(), $staticAttrToExclude)) || in_array($att->getAttributeCode(), $staticAttrToAdd)) {
|
71 |
+
$options[] = array('value' => $att->getAttributeCode(), 'label' => Mage::helper('customer')->__($att->getFrontendLabel()));
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
// Calculated attributes
|
77 |
+
$calculatedAttributes = Mage::getConfig()->getNode('dolistparams/contact_export_row_adapter/calculated_attributes')->asArray();
|
78 |
+
foreach ($calculatedAttributes as $key => $calculatedAttributeList) {
|
79 |
+
// Display these attributes
|
80 |
+
if (in_array($key, $backendType)) {
|
81 |
+
$options[] = array('value' => array(), 'label' => Mage::helper('dolist')->__("Calculated attributes"));
|
82 |
+
foreach ($calculatedAttributeList as $id => $calculatedAttributeItem) {
|
83 |
+
|
84 |
+
if ($calculatedAttributeItem['adapter'] == "separator") {
|
85 |
+
$options[] = array(
|
86 |
+
'value' => array(),
|
87 |
+
'label' => Mage::helper('dolist')->__($calculatedAttributeItem['label'])
|
88 |
+
);
|
89 |
+
} else {
|
90 |
+
$options[] = array(
|
91 |
+
'value' => $id,
|
92 |
+
'label' => Mage::helper('dolist')->__($calculatedAttributeItem['label'])
|
93 |
+
);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
return $options;
|
100 |
+
}
|
101 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Dolistv8/Customfield.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select custom field
|
4 |
+
* Factorized class for String, Int and Date
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Model_System_Config_Source_Dolistv8_Customfield
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return Dolist-V8 CustomStr, CustomInt or CustomDate fields
|
15 |
+
*
|
16 |
+
* @param string $label Label, can be 'CustomStr', 'CustomInt', 'CustomDate'
|
17 |
+
* @param int $size Size for this label
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function toOptionArray($label, $size)
|
22 |
+
{
|
23 |
+
$options = array();
|
24 |
+
for ($i = 1; $i <= $size; $i++) {
|
25 |
+
$fieldname = $label . $i;
|
26 |
+
$options[] = array('value' => $fieldname, 'label' => $fieldname);
|
27 |
+
}
|
28 |
+
|
29 |
+
return $options;
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Email/Template.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select all email templates
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_System_Config_Source_Email_Template
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Return merged array containing original Magento email templates and custom ones (defined in back office)
|
14 |
+
*
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
public function toOptionArray()
|
18 |
+
{
|
19 |
+
$originalTemplates = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
|
20 |
+
$customTemplates = Mage::getSingleton('adminhtml/system_config_source_email_template')->toOptionArray();
|
21 |
+
|
22 |
+
$options = array_merge($originalTemplates, $customTemplates);
|
23 |
+
return $options;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Dolist/Net/Model/System/Config/Source/Group.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Dolist source chooser to select custom str field for group
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Model_System_Config_Source_Group
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Return Dolist-V8 fields able to contain Magento customer group
|
14 |
+
*
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
public function toOptionArray()
|
18 |
+
{
|
19 |
+
return Mage::getModel('dolist/system_config_source_dolistv8_customfield')->toOptionArray('CustomStr', 30);
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Dolist/Net/controllers/Adminhtml/CustomerdolistController.php
ADDED
@@ -0,0 +1,557 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Admin Dolist customer dolist controller (new screen in Back Office)
|
5 |
+
*
|
6 |
+
* @category Dolist
|
7 |
+
* @package Dolist_Net
|
8 |
+
* @copyright 2012 Dolist
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* index action
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
public function indexAction()
|
20 |
+
{
|
21 |
+
$this->loadLayout();
|
22 |
+
|
23 |
+
$this->_setActiveMenu('customer/customerdolist');
|
24 |
+
$this->_addBreadcrumb(
|
25 |
+
$this->_getHelper()->__('Dolist'), $this->_getHelper()->__('ERP Dolist'));
|
26 |
+
|
27 |
+
$this->renderLayout();
|
28 |
+
}
|
29 |
+
|
30 |
+
public function reportAction()
|
31 |
+
{
|
32 |
+
$this->loadLayout();
|
33 |
+
|
34 |
+
$this->_setActiveMenu('customer/customerdolist');
|
35 |
+
$this->_addBreadcrumb(
|
36 |
+
$this->_getHelper()->__('Dolist'), $this->_getHelper()->__('ERP Dolist'));
|
37 |
+
$this->_addContent($this->getLayout()->createBlock('dolist/adminhtml_report'));
|
38 |
+
|
39 |
+
$this->renderLayout();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
public function saveAction()
|
46 |
+
{
|
47 |
+
|
48 |
+
if ($data = $this->getRequest()->getPost()) {
|
49 |
+
$storeId = $data['store_id'];
|
50 |
+
|
51 |
+
try {
|
52 |
+
$isMappingChanged = false;
|
53 |
+
|
54 |
+
if ((string)$data['calculatedfieds_mode'] == '2') {
|
55 |
+
$dt = DateTime::createFromFormat("Y-m-d", $data['calculatedfieds_date']);
|
56 |
+
if ($dt === false || array_sum($dt->getLastErrors()) > 0) {
|
57 |
+
throw new \Exception($this->_getHelper()->__('When you choose “From a specified start date“ for the time period of calculated fields, you must provide a start date.'));
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$config = Mage::getConfig();
|
62 |
+
$config->saveConfig('dolist/dolist_v8/export_customer_with_order', $data['export_customer_with_order'], $storeId == 0 ? 'default' : 'store', $storeId);
|
63 |
+
|
64 |
+
$oldCalculatedfiedsMode = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode', $storeId);
|
65 |
+
$oldCalculatedfiedsDate = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_date', $storeId);
|
66 |
+
|
67 |
+
if($oldCalculatedfiedsMode != $data['calculatedfieds_mode'] || $oldCalculatedfiedsDate != $data['calculatedfieds_date']) {
|
68 |
+
$config->saveConfig('dolist/dolist_v8/calculatedfieds_mode', $data['calculatedfieds_mode'], $storeId == 0 ? 'default' : 'store', $storeId);
|
69 |
+
$config->saveConfig('dolist/dolist_v8/calculatedfieds_date', $data['calculatedfieds_date'], $storeId == 0 ? 'default' : 'store', $storeId);
|
70 |
+
$isMappingChanged = true;
|
71 |
+
}
|
72 |
+
|
73 |
+
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Customfields_Collection $collection */
|
74 |
+
$collection = Mage::getModel('dolist/dolistv8_customfields')->getCollection();
|
75 |
+
$collection->addFieldToFilter('scope_id', $storeId);
|
76 |
+
|
77 |
+
$transform = array();
|
78 |
+
|
79 |
+
foreach ($data['cstfieldStr'] as $item) {
|
80 |
+
$transform['cstfield_' . $item['magento_customer_attribute']] = $item['dolist_custom_fields'];
|
81 |
+
}
|
82 |
+
|
83 |
+
foreach ($data['cstfieldInt'] as $item) {
|
84 |
+
$transform['cstfield_' . $item['magento_customer_attribute']] = $item['dolist_custom_fields'];
|
85 |
+
}
|
86 |
+
|
87 |
+
foreach ($data['cstfieldDate'] as $item) {
|
88 |
+
$transform['cstfield_' . $item['magento_customer_attribute']] = $item['dolist_custom_fields'];
|
89 |
+
}
|
90 |
+
|
91 |
+
foreach ($collection as $customField) {
|
92 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $customField */
|
93 |
+
$dolistName = $customField->getData('name');
|
94 |
+
|
95 |
+
if (array_key_exists($dolistName, Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName)) {
|
96 |
+
$magentoName = Dolist_Net_Model_Dolistv8_Customfields::$coreFieldName[$dolistName];
|
97 |
+
if (array_key_exists(sprintf('cstfield_%s', $magentoName), $data) && $data[sprintf('cstfield_%s', $magentoName)] == '1') {
|
98 |
+
if ($customField->getData('magento_field') != $magentoName) {
|
99 |
+
$isMappingChanged = true;
|
100 |
+
$customField->setData('magento_field', $magentoName);
|
101 |
+
}
|
102 |
+
} else {
|
103 |
+
if ($customField->getData('magento_field') != null) {
|
104 |
+
$isMappingChanged = true;
|
105 |
+
$customField->setData('magento_field', null);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
} else {
|
110 |
+
if (!in_array($dolistName, $transform)) {
|
111 |
+
if ($customField->getData('magento_field') != null) {
|
112 |
+
$isMappingChanged = true;
|
113 |
+
$customField->setData('magento_field', null);
|
114 |
+
}
|
115 |
+
} else {
|
116 |
+
$key = array_search($dolistName, $transform);
|
117 |
+
$magentoField = substr($key, strlen('cstfield_'));
|
118 |
+
if ($customField->getData('magento_field') != $magentoField) {
|
119 |
+
$isMappingChanged = true;
|
120 |
+
$customField->setData('magento_field', $magentoField);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
$customField->save();
|
125 |
+
}
|
126 |
+
|
127 |
+
if ($isMappingChanged) {
|
128 |
+
if ($storeId == 0) {
|
129 |
+
$stores = $this->_getStoreList($storeId);
|
130 |
+
foreach ($stores as $_storeId) {
|
131 |
+
// Full Export
|
132 |
+
$flagCode = 'dolist_differential_export_filename_' . $_storeId;
|
133 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
134 |
+
$flag->delete();
|
135 |
+
|
136 |
+
// Differential Export
|
137 |
+
$flagCode = 'dolist_full_export_filename_' . $_storeId;
|
138 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
139 |
+
$flag->delete();
|
140 |
+
|
141 |
+
// Remove flag for full export to block differential
|
142 |
+
$flagCode = Dolist_Net_Helper_Data::FLAG_DOLIST_LAST_EXPORT . '_' . $_storeId;
|
143 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
144 |
+
$flag->delete();
|
145 |
+
}
|
146 |
+
|
147 |
+
} else {
|
148 |
+
// Full Export
|
149 |
+
$flagCode = 'dolist_differential_export_filename_' . $storeId;
|
150 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
151 |
+
$flag->delete();
|
152 |
+
|
153 |
+
// Differential Export
|
154 |
+
$flagCode = 'dolist_full_export_filename_' . $storeId;
|
155 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
156 |
+
$flag->delete();
|
157 |
+
|
158 |
+
// Remove flag for full export to block differential
|
159 |
+
$flagCode = Dolist_Net_Helper_Data::FLAG_DOLIST_LAST_EXPORT . '_' . $storeId;
|
160 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
161 |
+
$flag->delete();
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
$this->_getSession()->addSuccess($this->_getHelper()->__('Saved.'));
|
166 |
+
} catch (Exception $e) {
|
167 |
+
$this->_getSession()->addError($e->getMessage());
|
168 |
+
$this->_redirect('*/*/', array('store' => $storeId));
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
$this->_redirect('*/*/', array('store' => $storeId));
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
*
|
178 |
+
*/
|
179 |
+
public function updateCustomFieldsAction()
|
180 |
+
{
|
181 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
182 |
+
$initStoreId = $storeId;
|
183 |
+
|
184 |
+
/** @var Dolist_Net_Model_Service $dolistService */
|
185 |
+
$dolistService = Mage::getModel('dolist/service');
|
186 |
+
|
187 |
+
$result = $dolistService->dolistV8GetFieldList();
|
188 |
+
|
189 |
+
if(!is_object($result)) {
|
190 |
+
$successMessage = $this->_getHelper()->__('Unable to contact Dolist API.');
|
191 |
+
$this->_getSession()->addSuccess($successMessage);
|
192 |
+
|
193 |
+
$this->_redirect('*/*/', array('store' => $initStoreId));
|
194 |
+
return;
|
195 |
+
}
|
196 |
+
|
197 |
+
foreach ($result->getData('FieldList')->Field as $field) {
|
198 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $model */
|
199 |
+
$model = Mage::getModel('dolist/dolistv8_customfields');
|
200 |
+
$model = $model->loadByNameAndScope($field->Name, $storeId);
|
201 |
+
|
202 |
+
if (!$field->Access->CanDisplay) {
|
203 |
+
$model->delete();
|
204 |
+
continue;
|
205 |
+
}
|
206 |
+
|
207 |
+
$model->addData(array(
|
208 |
+
'type' => $field->Type,
|
209 |
+
'name' => $field->Name,
|
210 |
+
'title' => $field->Title,
|
211 |
+
'display' => $field->Display,
|
212 |
+
'displayRank' => $field->DisplayRank,
|
213 |
+
'translationKey' => $field->TranslationKey,
|
214 |
+
'isCustom' => $field->IsCustom ? 1 : 0,
|
215 |
+
'scope' => 'store',
|
216 |
+
'scope_id' => $storeId
|
217 |
+
));
|
218 |
+
|
219 |
+
$model->save();
|
220 |
+
}
|
221 |
+
|
222 |
+
$successMessage = $this->_getHelper()->__('Dolist custom field has been successfully updated.');
|
223 |
+
$this->_getSession()->addSuccess($successMessage);
|
224 |
+
|
225 |
+
$this->_redirect('*/*/', array('store' => $initStoreId));
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Schedule full export to Dolist-V8
|
230 |
+
*
|
231 |
+
* @return void
|
232 |
+
* @throws Exception
|
233 |
+
*/
|
234 |
+
public function fullExportAction()
|
235 |
+
{
|
236 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
237 |
+
$initStoreId = $storeId;
|
238 |
+
$stores = $this->_getStoreList($storeId);
|
239 |
+
|
240 |
+
// Loop on every store
|
241 |
+
foreach ($stores as $storeId) {
|
242 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
243 |
+
$this->_getHelper()->createReport('full_export', $storeId);
|
244 |
+
|
245 |
+
try {
|
246 |
+
|
247 |
+
$this->scheduleDolistTask('full', $storeId);
|
248 |
+
|
249 |
+
$this->_getHelper()->addExportPaginationStart("full_export", 1, $storeId);
|
250 |
+
$successMessage = $this->_getHelper()->__('Full export has been scheduled and will be performed next Cron crossing.')
|
251 |
+
. " (default store view id: " . $storeId . ")";
|
252 |
+
|
253 |
+
$this->_getSession()
|
254 |
+
->addSuccess($successMessage);
|
255 |
+
|
256 |
+
} catch (Exception $e) {
|
257 |
+
$errorMessage = $this->_getHelper()->__('Full export could not be scheduled.')
|
258 |
+
. " (default store view id: " . $storeId . ")";
|
259 |
+
|
260 |
+
$this->_getSession()
|
261 |
+
->addError($errorMessage);
|
262 |
+
}
|
263 |
+
|
264 |
+
} else {
|
265 |
+
$errorMessage = $this->_getHelper()->__("Dolist-V8 is not enabled for selected website.")
|
266 |
+
. " (default store view id: " . $storeId . ")";
|
267 |
+
|
268 |
+
$this->_getSession()
|
269 |
+
->addError($errorMessage);
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
$this->_redirect('*/*/', array('store' => $initStoreId));
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Schedule differential export to Dolist-V8
|
279 |
+
*
|
280 |
+
* @return void
|
281 |
+
* @throws Exception
|
282 |
+
*/
|
283 |
+
public function differentialExportAction()
|
284 |
+
{
|
285 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
286 |
+
$initStoreId = $storeId;
|
287 |
+
$stores = $this->_getStoreList($storeId);
|
288 |
+
|
289 |
+
// Loop on every store
|
290 |
+
foreach ($stores as $storeId) {
|
291 |
+
|
292 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
293 |
+
try {
|
294 |
+
|
295 |
+
// Look for last export date
|
296 |
+
// First, try to retrieve stored value
|
297 |
+
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
298 |
+
|
299 |
+
// Throw exception if flag has never been set
|
300 |
+
if ($flag->getId() == null) {
|
301 |
+
throw new Exception(
|
302 |
+
$this->_getHelper()->__(
|
303 |
+
'At least one full export should have been perfomed before scheduling a differential export.'
|
304 |
+
) . " (default store view id: " . $storeId . ")"
|
305 |
+
);
|
306 |
+
}
|
307 |
+
|
308 |
+
$this->_getHelper()->createReport('differential_export', $storeId);
|
309 |
+
|
310 |
+
$this->scheduleDolistTask('differential', $storeId);
|
311 |
+
|
312 |
+
$this->_getHelper()->addExportPaginationStart("differential_export", 1, $storeId);
|
313 |
+
$successMessage = $this->_getHelper()->__(
|
314 |
+
'Differential export has been scheduled and will be performed next time Cron runs.'
|
315 |
+
) . " (default store view id: " . $storeId . ")";
|
316 |
+
|
317 |
+
$this->_getSession()->addSuccess($successMessage);
|
318 |
+
|
319 |
+
} catch (Exception $e) {
|
320 |
+
$errorMessage = $e->getMessage();
|
321 |
+
|
322 |
+
$this->_getSession()->addError($errorMessage);
|
323 |
+
|
324 |
+
$this->_getHelper()->logError($errorMessage);
|
325 |
+
}
|
326 |
+
} else {
|
327 |
+
$errorMessage = $this->_getHelper()->__("Dolist-V8 is not enabled for selected website.")
|
328 |
+
. " (default store view id: " . $storeId . ")";
|
329 |
+
|
330 |
+
$this->_getSession()->addError($errorMessage);
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
$this->_redirect('*/*/', array('store' => $initStoreId));
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Create new segment export for all already exported segments to Dolist-V8
|
339 |
+
*
|
340 |
+
* @return void
|
341 |
+
*/
|
342 |
+
public function updateSegmentsAction()
|
343 |
+
{
|
344 |
+
$storeId = $this->getRequest()->getParam('store', 0);
|
345 |
+
$initStoreId = $storeId;
|
346 |
+
$stores = $this->_getStoreList($storeId);
|
347 |
+
$error = false;
|
348 |
+
|
349 |
+
// Loop on every store
|
350 |
+
foreach ($stores as $storeId) {
|
351 |
+
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
352 |
+
|
353 |
+
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
|
354 |
+
|
355 |
+
// Retrieve already exported segments
|
356 |
+
$flag = $this->_getHelper()->getDolistExportedSegmentList($storeId);
|
357 |
+
$dolistExportedSegmentList = $flag->getFlagData();
|
358 |
+
|
359 |
+
if (!is_array($dolistExportedSegmentList) || empty($dolistExportedSegmentList)) {
|
360 |
+
|
361 |
+
// If nothing, cannot update
|
362 |
+
$this->_getSession()
|
363 |
+
->addError(
|
364 |
+
$this->_getHelper()->__('Cannot update customer segments because no segment has been exported')
|
365 |
+
. " (default store view id: " . $storeId . ")"
|
366 |
+
);
|
367 |
+
|
368 |
+
} else {
|
369 |
+
|
370 |
+
// Else perform new export for each one
|
371 |
+
/** @var Dolist_Net_Model_Service $service */
|
372 |
+
$service = Mage::getSingleton('dolist/service');
|
373 |
+
foreach ($dolistExportedSegmentList as $segmentId) {
|
374 |
+
$exportReturn = $service->exportSegment($segmentId, array($websiteId), array($storeId));
|
375 |
+
|
376 |
+
if (!$exportReturn) {
|
377 |
+
$error = true;
|
378 |
+
}
|
379 |
+
}
|
380 |
+
}
|
381 |
+
} else {
|
382 |
+
$errorMessage = $this->_getHelper()->__("Dolist-V8 is not enabled for selected website.")
|
383 |
+
. " (default store view id: " . $storeId . ")";
|
384 |
+
|
385 |
+
$this->_getSession()
|
386 |
+
->addError($errorMessage);
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
if ($error) {
|
391 |
+
$this->_getSession()
|
392 |
+
->addError(
|
393 |
+
$this->_getHelper()
|
394 |
+
->__('At least one error occured while segment updating. Please watch logs to get more details.')
|
395 |
+
);
|
396 |
+
}
|
397 |
+
|
398 |
+
$this->_redirect('*/*/', array('store' => $initStoreId));
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Schedule task for given $jobcode. Task will be performed at next cron running
|
403 |
+
* Write in cron_schedule table
|
404 |
+
*
|
405 |
+
* @param string $scope Export scope. Can be full or differential
|
406 |
+
* @param int $storeId Store id
|
407 |
+
*
|
408 |
+
* @return void
|
409 |
+
* @throws Exception if export already running
|
410 |
+
*/
|
411 |
+
public function scheduleDolistTask($scope, $storeId)
|
412 |
+
{
|
413 |
+
// Flag on current store id to be exported
|
414 |
+
$this->_getHelper()->addExportStoreId($scope, $storeId);
|
415 |
+
|
416 |
+
$jobCode = 'dolist_' . $scope . '_export';
|
417 |
+
/** @var Mage_Cron_Model_Mysql4_Schedule_Collection $runningJobCollection */
|
418 |
+
$runningJobCollection = Mage::getSingleton('cron/schedule')->getCollection()
|
419 |
+
->addFieldToFilter('job_code', array('eq' => $jobCode))
|
420 |
+
->addFieldToFilter(
|
421 |
+
'status',
|
422 |
+
array(
|
423 |
+
'in' => array(
|
424 |
+
Mage_Cron_Model_Schedule::STATUS_RUNNING
|
425 |
+
)
|
426 |
+
)
|
427 |
+
);
|
428 |
+
|
429 |
+
if ($runningJobCollection->getSize() > 0) {
|
430 |
+
$errorMessage = $this->_getHelper()->__("Another export is already running. Please try again later.");
|
431 |
+
$this->_getSession()
|
432 |
+
->addError($errorMessage);
|
433 |
+
throw new Exception($errorMessage);
|
434 |
+
}
|
435 |
+
|
436 |
+
// Check if this job is not already scheduled
|
437 |
+
/** @var Mage_Cron_Model_Mysql4_Schedule_Collection $scheduleCollection */
|
438 |
+
$scheduleCollection = Mage::getSingleton('cron/schedule')->getCollection()
|
439 |
+
->addFieldToFilter('job_code', array('eq' => $jobCode))
|
440 |
+
->addFieldToFilter(
|
441 |
+
'status',
|
442 |
+
array(
|
443 |
+
'in' => array(
|
444 |
+
Mage_Cron_Model_Schedule::STATUS_PENDING
|
445 |
+
)
|
446 |
+
)
|
447 |
+
);
|
448 |
+
|
449 |
+
if ($scheduleCollection->getSize() == 0) {
|
450 |
+
|
451 |
+
// Schedule a new task only if another one is not already pending
|
452 |
+
/** @var Mage_Cron_Model_Schedule $schedule */
|
453 |
+
$schedule = Mage::getModel('cron/schedule');
|
454 |
+
$schedule->setJobCode($jobCode)
|
455 |
+
->setCreatedAt(now())
|
456 |
+
->setScheduledAt(now())
|
457 |
+
->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)
|
458 |
+
->save();
|
459 |
+
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Perform specific customer segment export to Dolist-V8
|
465 |
+
* Export is performed in live, this operation is not scheduled for later
|
466 |
+
*
|
467 |
+
* @return void
|
468 |
+
*/
|
469 |
+
public function exportSegmentAction()
|
470 |
+
{
|
471 |
+
// Load segment
|
472 |
+
$segmentId = $this->getRequest()->getParam('segment_id');
|
473 |
+
$websiteIds = unserialize(urldecode($this->getRequest()->getParam('website_ids')));
|
474 |
+
// Array of enabled stored indexed by website id
|
475 |
+
$storeIds = unserialize(urldecode($this->getRequest()->getParam('store_ids')));
|
476 |
+
// Website ids grouped by same Dolist-V8 config
|
477 |
+
$filteredWebsiteIds = $this->_getHelper()->filterDistinctEnabledWebsites($websiteIds);
|
478 |
+
|
479 |
+
/** @var Dolist_Net_Model_Service $service */
|
480 |
+
$service = Mage::getSingleton('dolist/service');
|
481 |
+
$service->exportSegment($segmentId, $filteredWebsiteIds, $storeIds);
|
482 |
+
|
483 |
+
// Redirect to segment index page
|
484 |
+
$this->_redirect('*/customersegment/index');
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Remove segment from exported list
|
489 |
+
*
|
490 |
+
* @return void
|
491 |
+
*/
|
492 |
+
public function removeSegmentAction()
|
493 |
+
{
|
494 |
+
// Load segment
|
495 |
+
$segmentId = $this->getRequest()->getParam('segment_id');
|
496 |
+
$storeIds = array_keys(Mage::app()->getStores());
|
497 |
+
|
498 |
+
// Remove exported segments from all stores
|
499 |
+
foreach ($storeIds as $storeId) {
|
500 |
+
$this->_getHelper()->removeExportedSegment($segmentId, $storeId);
|
501 |
+
}
|
502 |
+
|
503 |
+
// Redirect to segment index page
|
504 |
+
$this->_redirect('*/customersegment/index');
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Return array with default store view ids for each website
|
509 |
+
*
|
510 |
+
* @param int $storeId Store id
|
511 |
+
*
|
512 |
+
* @return array Store list
|
513 |
+
*/
|
514 |
+
protected function _getStoreList($storeId = 0)
|
515 |
+
{
|
516 |
+
$stores = array();
|
517 |
+
|
518 |
+
// If default config, retrieve all website default store ids
|
519 |
+
if ($storeId == 0) {
|
520 |
+
|
521 |
+
// Loop on every website
|
522 |
+
$websites = Mage::app()->getWebsites();
|
523 |
+
foreach ($websites as $website) {
|
524 |
+
// Get website default store id
|
525 |
+
/** @var Mage_Core_Model_Website $website */
|
526 |
+
foreach($website->getStoreIds() as $_storeId) {
|
527 |
+
$stores[] = $_storeId;
|
528 |
+
}
|
529 |
+
}
|
530 |
+
} else {
|
531 |
+
// If store id not default, return it as array
|
532 |
+
$stores = array($storeId);
|
533 |
+
}
|
534 |
+
|
535 |
+
return $stores;
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Retrieve model helper
|
540 |
+
*
|
541 |
+
* @return Dolist_Net_Helper_Data
|
542 |
+
*/
|
543 |
+
protected function _getHelper()
|
544 |
+
{
|
545 |
+
return Mage::helper('dolist');
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Retrieve model helper
|
550 |
+
*
|
551 |
+
* @return Mage_Adminhtml_Model_Session
|
552 |
+
*/
|
553 |
+
protected function _getSession()
|
554 |
+
{
|
555 |
+
return Mage::getSingleton('adminhtml/session');
|
556 |
+
}
|
557 |
+
}
|
app/code/community/Dolist/Net/controllers/Adminhtml/System/Config/TestconnectionController.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Dolist test connection controller
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Dolist_Net_Adminhtml_System_Config_TestconnectionController extends Mage_Adminhtml_Controller_Action
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check connection to Dolist-V8 webservice,
|
14 |
+
* then check connection to Dolist-V8 FTP server
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
public function pingdolistv8Action()
|
19 |
+
{
|
20 |
+
// Response is json
|
21 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
22 |
+
|
23 |
+
$accountid = $_REQUEST['accountid'];
|
24 |
+
$authenticationKey = $_REQUEST['authentication_key'];
|
25 |
+
$login = $_REQUEST['login'];
|
26 |
+
$password = $_REQUEST['password'];
|
27 |
+
$storeId = $_REQUEST['storeId'];
|
28 |
+
|
29 |
+
$error = false;
|
30 |
+
/** @var Dolist_Net_Model_Service $service */
|
31 |
+
$service = Mage::getModel('dolist/service');
|
32 |
+
// First check connection to Dolist V-8 webservice
|
33 |
+
$response = $service->dolistV8GetAuthenticationToken($storeId, $accountid, $authenticationKey);
|
34 |
+
$key = $response->getData('Key');
|
35 |
+
|
36 |
+
// OK if key is found and not empty
|
37 |
+
if ($key != null && $key != "") {
|
38 |
+
|
39 |
+
// Then check connection to FTP server
|
40 |
+
$ftpConnection = Mage::getSingleton('dolist/dolistv8_ftp');
|
41 |
+
// Arguments to check in live, just typed in back office
|
42 |
+
$ftpConnection->fixArgs($login, $password);
|
43 |
+
$connectionStatus = $ftpConnection->getStatus();
|
44 |
+
if ($connectionStatus) {
|
45 |
+
|
46 |
+
// result is true if authentication key is retrieved and FTP connection is OK
|
47 |
+
$result['connectionStatus'] = 1;
|
48 |
+
|
49 |
+
} else {
|
50 |
+
$error = true;
|
51 |
+
}
|
52 |
+
|
53 |
+
} else {
|
54 |
+
$error = true;
|
55 |
+
}
|
56 |
+
|
57 |
+
if ($error) {
|
58 |
+
$errorDetail = Mage::getSingleton('core/session')->getLastDolistFaultDetail();
|
59 |
+
|
60 |
+
// result is false if there is exception
|
61 |
+
$result['connectionStatus'] = 0;
|
62 |
+
$result['error'] = $errorDetail;
|
63 |
+
}
|
64 |
+
|
65 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Check if connection to Dolist-EMT webservice
|
70 |
+
* and return template list to preload them
|
71 |
+
*
|
72 |
+
* @return void
|
73 |
+
*/
|
74 |
+
public function pingdolistemtAction()
|
75 |
+
{
|
76 |
+
// Response is json
|
77 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
78 |
+
|
79 |
+
$accountid = $_REQUEST['accountid'];
|
80 |
+
$authenticationKey = $_REQUEST['authentication_key'];
|
81 |
+
$storeId = $_REQUEST['storeId'];
|
82 |
+
|
83 |
+
$error = false;
|
84 |
+
$service = Mage::getModel('dolist/service');
|
85 |
+
// First check connection to Dolist EMT webservice
|
86 |
+
$response = $service->dolistEmtGetAuthenticationToken($storeId, $accountid, $authenticationKey);
|
87 |
+
$key = $response->getData('Key');
|
88 |
+
// OK if key is found and not empty
|
89 |
+
if ($key != null && $key != "") {
|
90 |
+
$response = $service->dolistEmtGetTemplateList($storeId, $accountid, $authenticationKey);
|
91 |
+
// result is true if authentication key is retrieved
|
92 |
+
$result['connectionStatus'] = 1;
|
93 |
+
|
94 |
+
// extract template response array
|
95 |
+
$templateResponse = null;
|
96 |
+
if ($response->getData('GetTemplateListResult')) {
|
97 |
+
$templateResponse = $response->getData('GetTemplateListResult')->GetTemplateResponse;
|
98 |
+
}
|
99 |
+
|
100 |
+
// refresh templatelist
|
101 |
+
if (is_array($templateResponse) && !is_null($templateResponse)) {
|
102 |
+
|
103 |
+
// Convert webservice response to Varien Object, more handable
|
104 |
+
$templateList = array();
|
105 |
+
foreach ($templateResponse as $templateData) {
|
106 |
+
$template = (array)$templateData;
|
107 |
+
$templateList[$template['ID']] = $template['ID'] . ' - ' . $template['Name'];
|
108 |
+
}
|
109 |
+
// Compare template list retrieved by webservice with stored one, and update it if necesary
|
110 |
+
$templateListUpdated = Mage::getModel('dolist/dolistemt_template')->update($templateList);
|
111 |
+
|
112 |
+
// result is true if template list is loaded
|
113 |
+
$result['connectionStatus'] = 1;
|
114 |
+
// inform if template list need to be updated
|
115 |
+
$result['templateListUpdated'] = $templateListUpdated;
|
116 |
+
// provide template list
|
117 |
+
$result['templateList'] = $templateList;
|
118 |
+
|
119 |
+
} else {
|
120 |
+
// result is false if there is exception
|
121 |
+
$error = true;
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
$error = true;
|
125 |
+
}
|
126 |
+
|
127 |
+
if ($error) {
|
128 |
+
$errorDetail = Mage::getSingleton('core/session')->getLastDolistFaultDetail();
|
129 |
+
|
130 |
+
// result is false if there is exception
|
131 |
+
$result['connectionStatus'] = 0;
|
132 |
+
$result['error'] = $errorDetail;
|
133 |
+
}
|
134 |
+
|
135 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
136 |
+
}
|
137 |
+
}
|
app/code/community/Dolist/Net/etc/adminhtml.xml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
|
5 |
+
<menu>
|
6 |
+
<customer>
|
7 |
+
<children>
|
8 |
+
<customerdolist translate="title" module="dolist">
|
9 |
+
<title>Dolist</title>
|
10 |
+
<action>adminhtml/customerdolist</action>
|
11 |
+
<sort_order>150</sort_order>
|
12 |
+
</customerdolist>
|
13 |
+
</children>
|
14 |
+
</customer>
|
15 |
+
</menu>
|
16 |
+
|
17 |
+
<acl>
|
18 |
+
<resources>
|
19 |
+
<admin>
|
20 |
+
<children>
|
21 |
+
<customer>
|
22 |
+
<children>
|
23 |
+
<customerdolist translate="title" module="dolist">
|
24 |
+
<title>Dolist</title>
|
25 |
+
<sort_order>150</sort_order>
|
26 |
+
</customerdolist>
|
27 |
+
</children>
|
28 |
+
</customer>
|
29 |
+
<system>
|
30 |
+
<children>
|
31 |
+
<config>
|
32 |
+
<children>
|
33 |
+
<dolist />
|
34 |
+
</children>
|
35 |
+
</config>
|
36 |
+
</children>
|
37 |
+
</system>
|
38 |
+
</children>
|
39 |
+
</admin>
|
40 |
+
</resources>
|
41 |
+
</acl>
|
42 |
+
|
43 |
+
</config>
|
app/code/community/Dolist/Net/etc/config.xml
ADDED
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
|
5 |
+
<modules>
|
6 |
+
<Dolist_Net>
|
7 |
+
<version>2.0.0.0</version>
|
8 |
+
</Dolist_Net>
|
9 |
+
</modules>
|
10 |
+
|
11 |
+
<default>
|
12 |
+
<dolist>
|
13 |
+
<dolist_v8>
|
14 |
+
<active>0</active>
|
15 |
+
<group>CustomStr30</group>
|
16 |
+
<calculatedfieds_date_mode>0</calculatedfieds_date_mode>
|
17 |
+
<export_page_size>5000</export_page_size>
|
18 |
+
</dolist_v8>
|
19 |
+
<dolist_emt>
|
20 |
+
<active>0</active>
|
21 |
+
<asynchronous>0</asynchronous>
|
22 |
+
<default_template>2</default_template>
|
23 |
+
</dolist_emt>
|
24 |
+
</dolist>
|
25 |
+
</default>
|
26 |
+
|
27 |
+
<dolistparams>
|
28 |
+
<send_message>
|
29 |
+
<proxywsdl>http://api.emt.dolist.net/V3/MessageService.svc?wsdl</proxywsdl>
|
30 |
+
<location>http://api.emt.dolist.net/V3/MessageService.svc/soap1.1</location>
|
31 |
+
</send_message>
|
32 |
+
<get_template_list>
|
33 |
+
<proxywsdl>http://api.emt.dolist.net/V3/TemplateService.svc?wsdl</proxywsdl>
|
34 |
+
<location>http://api.emt.dolist.net/V3/TemplateService.svc/soap1.1</location>
|
35 |
+
</get_template_list>
|
36 |
+
<get_authentication_v8_token>
|
37 |
+
<proxywsdl>http://api.dolist.net/V2/AuthenticationService.svc?wsdl</proxywsdl>
|
38 |
+
<location>http://api.dolist.net/V2/AuthenticationService.svc/soap1.1</location>
|
39 |
+
</get_authentication_v8_token>
|
40 |
+
<get_authentication_emt_token>
|
41 |
+
<proxywsdl>http://api.emt.dolist.net/V3/AuthenticationService.svc?wsdl</proxywsdl>
|
42 |
+
<location>http://api.emt.dolist.net/V3/AuthenticationService.svc/soap1.1</location>
|
43 |
+
</get_authentication_emt_token>
|
44 |
+
<create_import>
|
45 |
+
<proxywsdl>http://api.dolist.net/V2/ImportService.svc?wsdl</proxywsdl>
|
46 |
+
<location>http://api.dolist.net/V2/ImportService.svc/soap1.1</location>
|
47 |
+
</create_import>
|
48 |
+
<get_contact>
|
49 |
+
<proxywsdl>http://api.dolist.net/v2/ContactManagementService.svc?wsdl</proxywsdl>
|
50 |
+
<location>http://api.dolist.net/V2/ContactManagementService.svc/soap1.1</location>
|
51 |
+
</get_contact>
|
52 |
+
<get_field_list>
|
53 |
+
<proxywsdl>http://api.dolist.net/CustomFieldManagementService.svc?wsdl</proxywsdl>
|
54 |
+
<location>http://api.dolist.net/CustomFieldManagementService.svc/soap1.1</location>
|
55 |
+
</get_field_list>
|
56 |
+
<ftp>
|
57 |
+
<host>ftp.dolist.net</host>
|
58 |
+
<upload_contact_directory>/upload/contact</upload_contact_directory>
|
59 |
+
<unsubscribe_contact_directory>/upload/contact/unsubscribe</unsubscribe_contact_directory>
|
60 |
+
</ftp>
|
61 |
+
<optout_mapping>
|
62 |
+
<subscribed>
|
63 |
+
<dolist_value>0</dolist_value>
|
64 |
+
<magento_value>1</magento_value>
|
65 |
+
</subscribed>
|
66 |
+
<not_active>
|
67 |
+
<dolist_value>33</dolist_value>
|
68 |
+
<magento_value>2</magento_value>
|
69 |
+
</not_active>
|
70 |
+
<unsubscribed>
|
71 |
+
<dolist_value>133,1,2,5,67,128,129,130,131,132</dolist_value>
|
72 |
+
<magento_value>3</magento_value>
|
73 |
+
</unsubscribed>
|
74 |
+
<temporary_error>
|
75 |
+
<dolist_value>4,6,150</dolist_value>
|
76 |
+
<magento_value>5</magento_value>
|
77 |
+
</temporary_error>
|
78 |
+
<final_error>
|
79 |
+
<dolist_value>7,66,99,200</dolist_value>
|
80 |
+
<magento_value>6</magento_value>
|
81 |
+
</final_error>
|
82 |
+
<spam>
|
83 |
+
<dolist_value>68</dolist_value>
|
84 |
+
<magento_value>7</magento_value>
|
85 |
+
</spam>
|
86 |
+
</optout_mapping>
|
87 |
+
<country_mapping>
|
88 |
+
|
89 |
+
</country_mapping>
|
90 |
+
<contact_export_row_adapter>
|
91 |
+
<default>
|
92 |
+
<adapter>dolist/dolistv8_export_adapter_default</adapter>
|
93 |
+
</default>
|
94 |
+
<email>
|
95 |
+
<header>Email</header>
|
96 |
+
</email>
|
97 |
+
<group_id />
|
98 |
+
<firstname>
|
99 |
+
<header>FirstName</header>
|
100 |
+
</firstname>
|
101 |
+
<lastname>
|
102 |
+
<header>LastName</header>
|
103 |
+
</lastname>
|
104 |
+
<dob>
|
105 |
+
<adapter>dolist/dolistv8_export_adapter_date_default</adapter>
|
106 |
+
<header>Birthdate</header>
|
107 |
+
</dob>
|
108 |
+
<company>
|
109 |
+
<adapter>dolist/dolistv8_export_adapter_company</adapter>
|
110 |
+
<header>Company</header>
|
111 |
+
</company>
|
112 |
+
<address1>
|
113 |
+
<adapter>dolist/dolistv8_export_adapter_address1</adapter>
|
114 |
+
<header>Address 1</header>
|
115 |
+
</address1>
|
116 |
+
<address2>
|
117 |
+
<adapter>dolist/dolistv8_export_adapter_address2</adapter>
|
118 |
+
<header>Address 2</header>
|
119 |
+
</address2>
|
120 |
+
<address3>
|
121 |
+
<adapter>dolist/dolistv8_export_adapter_address3</adapter>
|
122 |
+
<header>Address 3</header>
|
123 |
+
</address3>
|
124 |
+
<postcode>
|
125 |
+
<adapter>dolist/dolistv8_export_adapter_postcode</adapter>
|
126 |
+
<header>ZipCode</header>
|
127 |
+
</postcode>
|
128 |
+
<city>
|
129 |
+
<adapter>dolist/dolistv8_export_adapter_city</adapter>
|
130 |
+
<header>City</header>
|
131 |
+
</city>
|
132 |
+
<country>
|
133 |
+
<adapter>dolist/dolistv8_export_adapter_country</adapter>
|
134 |
+
<header>CountryID</header>
|
135 |
+
</country>
|
136 |
+
<phone>
|
137 |
+
<adapter>dolist/dolistv8_export_adapter_phone</adapter>
|
138 |
+
<header>Phone</header>
|
139 |
+
</phone>
|
140 |
+
<fax>
|
141 |
+
<adapter>dolist/dolistv8_export_adapter_fax</adapter>
|
142 |
+
<header>Fax</header>
|
143 |
+
</fax>
|
144 |
+
|
145 |
+
<!--
|
146 |
+
Specific attributes, for example Default billing address, date of birth
|
147 |
+
-->
|
148 |
+
|
149 |
+
<!-- Calculated attributes -->
|
150 |
+
<!-- Custom int fields -->
|
151 |
+
<calculated_attributes>
|
152 |
+
<varchar>
|
153 |
+
<is_subscriber>
|
154 |
+
<label>Subscriber state of the customer</label>
|
155 |
+
<adapter></adapter>
|
156 |
+
</is_subscriber>
|
157 |
+
</varchar>
|
158 |
+
<int>
|
159 |
+
<first_order_amount>
|
160 |
+
<label>First order amount excluding tax</label>
|
161 |
+
<adapter>dolist/dolistv8_export_adapter_int_firstOrderAmountExclTax</adapter>
|
162 |
+
</first_order_amount>
|
163 |
+
<first_order_amount_with_vat>
|
164 |
+
<label>First order amount including tax</label>
|
165 |
+
<adapter>dolist/dolistv8_export_adapter_int_firstOrderAmountInclTax</adapter>
|
166 |
+
</first_order_amount_with_vat>
|
167 |
+
<last_order_amount>
|
168 |
+
<label>Last order amount excluding tax</label>
|
169 |
+
<adapter>dolist/dolistv8_export_adapter_int_lastOrderAmountExclTax</adapter>
|
170 |
+
</last_order_amount>
|
171 |
+
<last_order_amount_with_vat>
|
172 |
+
<label>Last order amount including tax</label>
|
173 |
+
<adapter>dolist/dolistv8_export_adapter_int_lastOrderAmountInclTax</adapter>
|
174 |
+
</last_order_amount_with_vat>
|
175 |
+
<total_orders_amount>
|
176 |
+
<label>Total order amount excluding tax</label>
|
177 |
+
<adapter>dolist/dolistv8_export_adapter_int_totalOrderAmountExclTax</adapter>
|
178 |
+
</total_orders_amount>
|
179 |
+
<total_orders_amount_with_vat>
|
180 |
+
<label>Total order amount including tax</label>
|
181 |
+
<adapter>dolist/dolistv8_export_adapter_int_totalOrderAmountInclTax</adapter>
|
182 |
+
</total_orders_amount_with_vat>
|
183 |
+
<avg_order_amount_excl_tax>
|
184 |
+
<label>Average order amount excluding tax</label>
|
185 |
+
<adapter>dolist/dolistv8_export_adapter_int_avgOrderAmountExclTax</adapter>
|
186 |
+
</avg_order_amount_excl_tax>
|
187 |
+
<avg_order_amount_incl_tax>
|
188 |
+
<label>Average order amount including tax</label>
|
189 |
+
<adapter>dolist/dolistv8_export_adapter_int_avgOrderAmountInclTax</adapter>
|
190 |
+
</avg_order_amount_incl_tax>
|
191 |
+
<avg_nb_products_per_order>
|
192 |
+
<label>Average number of ordered products per order</label>
|
193 |
+
<adapter>dolist/dolistv8_export_adapter_int_avgNbProductsPerOrder</adapter>
|
194 |
+
</avg_nb_products_per_order>
|
195 |
+
<average_unique_product_count>
|
196 |
+
<label>Average number of different products per order</label>
|
197 |
+
<adapter>dolist/dolistv8_export_adapter_int_avgNbDifferentProductsPerOrder</adapter>
|
198 |
+
</average_unique_product_count>
|
199 |
+
<average_product_count_by_command_line>
|
200 |
+
<label>Average number of product per order line</label>
|
201 |
+
<adapter>dolist/dolistv8_export_adapter_int_avgNbDifferentProductsPerOrderLine</adapter>
|
202 |
+
</average_product_count_by_command_line>
|
203 |
+
<total_product_count>
|
204 |
+
<label>Total number of ordered products</label>
|
205 |
+
<adapter>dolist/dolistv8_export_adapter_int_totalOrderedProducts</adapter>
|
206 |
+
</total_product_count>
|
207 |
+
<total_orders_count>
|
208 |
+
<label>Total number of orders</label>
|
209 |
+
<adapter>dolist/dolistv8_export_adapter_int_totalOrders</adapter>
|
210 |
+
</total_orders_count>
|
211 |
+
<last_orders_range>
|
212 |
+
<label>Days number between the last two orders</label>
|
213 |
+
<adapter />
|
214 |
+
</last_orders_range>
|
215 |
+
|
216 |
+
<!-- Checkout quote -->
|
217 |
+
<last_unordered_cart_amount>
|
218 |
+
<label>Last not ordered cart amount excluding tax</label>
|
219 |
+
<adapter>dolist/dolistv8_export_adapter_int_lastNotOrderedCartAmountExclTax</adapter>
|
220 |
+
</last_unordered_cart_amount>
|
221 |
+
<last_unordered_cart_amount_with_vat>
|
222 |
+
<label>Last not ordered cart amount including tax</label>
|
223 |
+
<adapter>dolist/dolistv8_export_adapter_int_lastNotOrderedCartAmountInclTax</adapter>
|
224 |
+
</last_unordered_cart_amount_with_vat>
|
225 |
+
|
226 |
+
<!-- Promotions -->
|
227 |
+
<discount_rule_count>
|
228 |
+
<label>Number of promotion rules used</label>
|
229 |
+
<adapter>dolist/dolistv8_export_adapter_int_nbPromotionRulesUsed</adapter>
|
230 |
+
</discount_rule_count>
|
231 |
+
</int>
|
232 |
+
|
233 |
+
<!-- Custom date fields -->
|
234 |
+
<datetime>
|
235 |
+
<first_order_date>
|
236 |
+
<label>First order date</label>
|
237 |
+
<adapter>dolist/dolistv8_export_adapter_date_firstOrder</adapter>
|
238 |
+
</first_order_date>
|
239 |
+
<last_order_date>
|
240 |
+
<label>Last order date</label>
|
241 |
+
<adapter>dolist/dolistv8_export_adapter_date_lastOrder</adapter>
|
242 |
+
</last_order_date>
|
243 |
+
<last_unordered_cart_date>
|
244 |
+
<label>Last not ordered cart date</label>
|
245 |
+
<adapter>dolist/dolistv8_export_adapter_date_lastQuoteNotOrdered</adapter>
|
246 |
+
</last_unordered_cart_date>
|
247 |
+
</datetime>
|
248 |
+
</calculated_attributes>
|
249 |
+
</contact_export_row_adapter>
|
250 |
+
<temporary_errors><![CDATA[MethodUsageQuotaExceededException,TemplateNotEnabledException,DeliverabilityPackDisabledException,AuthenticationException]]></temporary_errors>
|
251 |
+
<limitreached_errors><![CDATA[MethodUsageQuotaExceededException]]></limitreached_errors>
|
252 |
+
</dolistparams>
|
253 |
+
|
254 |
+
<global>
|
255 |
+
|
256 |
+
<helpers>
|
257 |
+
<dolist>
|
258 |
+
<class>Dolist_Net_Helper</class>
|
259 |
+
</dolist>
|
260 |
+
</helpers>
|
261 |
+
|
262 |
+
<blocks>
|
263 |
+
<dolist>
|
264 |
+
<class>Dolist_Net_Block</class>
|
265 |
+
</dolist>
|
266 |
+
|
267 |
+
<!-- Slight rewrites to dispatch event => grabbed in Adminhtml Observer -->
|
268 |
+
<adminhtml>
|
269 |
+
<rewrite>
|
270 |
+
<customer_edit>Dolist_Net_Block_Adminhtml_Customer_Edit</customer_edit>
|
271 |
+
</rewrite>
|
272 |
+
</adminhtml>
|
273 |
+
<enterprise_customersegment>
|
274 |
+
<rewrite>
|
275 |
+
<adminhtml_customersegment_edit>Dolist_Net_Block_Adminhtml_Customersegment_Edit</adminhtml_customersegment_edit>
|
276 |
+
</rewrite>
|
277 |
+
</enterprise_customersegment>
|
278 |
+
</blocks>
|
279 |
+
|
280 |
+
<models>
|
281 |
+
<dolist>
|
282 |
+
<class>Dolist_Net_Model</class>
|
283 |
+
<resourceModel>dolist_mysql4</resourceModel>
|
284 |
+
</dolist>
|
285 |
+
|
286 |
+
<!-- Rewrite native email template send method to use Doslit-EMT webservice instead -->
|
287 |
+
<core>
|
288 |
+
<rewrite>
|
289 |
+
<email_template>Dolist_Net_Model_Dolistemt_Email_Template</email_template>
|
290 |
+
</rewrite>
|
291 |
+
</core>
|
292 |
+
|
293 |
+
<!-- Rewrite enterprise customer segment model only to add event prefix, then to plug observer -->
|
294 |
+
<enterprise_customersegment>
|
295 |
+
<rewrite>
|
296 |
+
<segment>Dolist_Net_Model_Customersegment</segment>
|
297 |
+
</rewrite>
|
298 |
+
</enterprise_customersegment>
|
299 |
+
|
300 |
+
<dolist_mysql4>
|
301 |
+
<class>Dolist_Net_Model_Mysql4</class>
|
302 |
+
<entities>
|
303 |
+
<dolistemt_template>
|
304 |
+
<table>dolist_dolistemt_template</table>
|
305 |
+
</dolistemt_template>
|
306 |
+
<dolistemt_message_queued>
|
307 |
+
<table>dolist_dolistemt_message_queue</table>
|
308 |
+
</dolistemt_message_queued>
|
309 |
+
<dolistv8_calculatedfields>
|
310 |
+
<table>dolist_dolistv8_calculatedfields</table>
|
311 |
+
</dolistv8_calculatedfields>
|
312 |
+
<dolistv8_customfields>
|
313 |
+
<table>dolist_dolistv8_customfields</table>
|
314 |
+
</dolistv8_customfields>
|
315 |
+
<reports>
|
316 |
+
<table>dolist_reports</table>
|
317 |
+
</reports>
|
318 |
+
</entities>
|
319 |
+
</dolist_mysql4>
|
320 |
+
</models>
|
321 |
+
|
322 |
+
<resources>
|
323 |
+
<dolist_setup>
|
324 |
+
<setup>
|
325 |
+
<module>Dolist_Net</module>
|
326 |
+
</setup>
|
327 |
+
<connection>
|
328 |
+
<use>core_setup</use>
|
329 |
+
</connection>
|
330 |
+
</dolist_setup>
|
331 |
+
|
332 |
+
<dolist_read>
|
333 |
+
<connection>
|
334 |
+
<use>core_read</use>
|
335 |
+
</connection>
|
336 |
+
</dolist_read>
|
337 |
+
|
338 |
+
<dolist_write>
|
339 |
+
<connection>
|
340 |
+
<use>core_write</use>
|
341 |
+
</connection>
|
342 |
+
</dolist_write>
|
343 |
+
</resources>
|
344 |
+
|
345 |
+
<rewrite>
|
346 |
+
<dolist_adminhtml_customerdolist>
|
347 |
+
<from><![CDATA[#^/admin/customerdolist/#]]></from>
|
348 |
+
<to>/dolist_adminhtml/customerdolist/</to>
|
349 |
+
</dolist_adminhtml_customerdolist>
|
350 |
+
</rewrite>
|
351 |
+
|
352 |
+
<events>
|
353 |
+
<newsletter_subscriber_save_before>
|
354 |
+
<observers>
|
355 |
+
<dolist_update_subscriber>
|
356 |
+
<class>dolist/observer</class>
|
357 |
+
<method>updateSubscriber</method>
|
358 |
+
</dolist_update_subscriber>
|
359 |
+
</observers>
|
360 |
+
</newsletter_subscriber_save_before>
|
361 |
+
<customer_login>
|
362 |
+
<observers>
|
363 |
+
<dolist_status_warning>
|
364 |
+
<class>dolist/observer</class>
|
365 |
+
<method>warnCustomerDolistStatus</method>
|
366 |
+
</dolist_status_warning>
|
367 |
+
</observers>
|
368 |
+
</customer_login>
|
369 |
+
</events>
|
370 |
+
|
371 |
+
</global>
|
372 |
+
|
373 |
+
<admin>
|
374 |
+
<routers>
|
375 |
+
<adminhtml>
|
376 |
+
<args>
|
377 |
+
<modules>
|
378 |
+
<dolist before="Mage_Adminhtml">Dolist_Net_Adminhtml</dolist>
|
379 |
+
</modules>
|
380 |
+
</args>
|
381 |
+
</adminhtml>
|
382 |
+
<dolist_adminhtml>
|
383 |
+
<use>admin</use>
|
384 |
+
<args>
|
385 |
+
<module>Dolist_Net_Adminhtml</module>
|
386 |
+
<frontName>dolist_adminhtml</frontName>
|
387 |
+
</args>
|
388 |
+
</dolist_adminhtml>
|
389 |
+
</routers>
|
390 |
+
</admin>
|
391 |
+
|
392 |
+
<adminhtml>
|
393 |
+
<translate>
|
394 |
+
<modules>
|
395 |
+
<Dolist_Net>
|
396 |
+
<files>
|
397 |
+
<default>Dolist_Net.csv</default>
|
398 |
+
</files>
|
399 |
+
</Dolist_Net>
|
400 |
+
</modules>
|
401 |
+
</translate>
|
402 |
+
|
403 |
+
<layout>
|
404 |
+
<updates>
|
405 |
+
<dolist>
|
406 |
+
<file>dolist.xml</file>
|
407 |
+
</dolist>
|
408 |
+
</updates>
|
409 |
+
</layout>
|
410 |
+
|
411 |
+
<events>
|
412 |
+
<customersegment_segment_save_after>
|
413 |
+
<observers>
|
414 |
+
<dolist_customersegment_check_save>
|
415 |
+
<class>dolist/adminhtml_observer</class>
|
416 |
+
<method>checkCustomerSegmentSave</method>
|
417 |
+
</dolist_customersegment_check_save>
|
418 |
+
</observers>
|
419 |
+
</customersegment_segment_save_after>
|
420 |
+
<admin_system_config_changed_section_dolist>
|
421 |
+
<observers>
|
422 |
+
<dolist_remove_flags>
|
423 |
+
<class>dolist/adminhtml_observer</class>
|
424 |
+
<method>removeDolistFlags</method>
|
425 |
+
</dolist_remove_flags>
|
426 |
+
</observers>
|
427 |
+
</admin_system_config_changed_section_dolist>
|
428 |
+
<dolist_customersegment_export>
|
429 |
+
<observers>
|
430 |
+
<add_customer_segment_export_button>
|
431 |
+
<class>dolist/adminhtml_observer</class>
|
432 |
+
<method>addCustomerSegmentExportButton</method>
|
433 |
+
</add_customer_segment_export_button>
|
434 |
+
</observers>
|
435 |
+
</dolist_customersegment_export>
|
436 |
+
<dolist_status_adminhtml_customer_warning>
|
437 |
+
<observers>
|
438 |
+
<warn_customer_dolist_status_adminhtml>
|
439 |
+
<class>dolist/adminhtml_observer</class>
|
440 |
+
<method>warnCustomerDolistStatus</method>
|
441 |
+
</warn_customer_dolist_status_adminhtml>
|
442 |
+
</observers>
|
443 |
+
</dolist_status_adminhtml_customer_warning>
|
444 |
+
</events>
|
445 |
+
</adminhtml>
|
446 |
+
|
447 |
+
<frontend>
|
448 |
+
<translate>
|
449 |
+
<modules>
|
450 |
+
<Dolist_Net>
|
451 |
+
<files>
|
452 |
+
<default>Dolist_Net.csv</default>
|
453 |
+
</files>
|
454 |
+
</Dolist_Net>
|
455 |
+
</modules>
|
456 |
+
</translate>
|
457 |
+
<events>
|
458 |
+
<sales_order_place_after>
|
459 |
+
<observers>
|
460 |
+
<dolist_sales_order_place_after>
|
461 |
+
<class>dolist/dolistv8_calculatedfields</class>
|
462 |
+
<method>onNewOrder</method>
|
463 |
+
</dolist_sales_order_place_after>
|
464 |
+
</observers>
|
465 |
+
</sales_order_place_after>
|
466 |
+
<checkout_cart_product_add_after>
|
467 |
+
<observers>
|
468 |
+
<dolist_checkout_cart_product_add_after>
|
469 |
+
<class>dolist/dolistv8_calculatedfields</class>
|
470 |
+
<method>onNewCart</method>
|
471 |
+
</dolist_checkout_cart_product_add_after>
|
472 |
+
</observers>
|
473 |
+
</checkout_cart_product_add_after>
|
474 |
+
<checkout_cart_save_after>
|
475 |
+
<observers>
|
476 |
+
<dolist_checkout_cart_save_after>
|
477 |
+
<class>dolist/dolistv8_calculatedfields</class>
|
478 |
+
<method>onNewCart</method>
|
479 |
+
</dolist_checkout_cart_save_after>
|
480 |
+
</observers>
|
481 |
+
</checkout_cart_save_after>
|
482 |
+
</events>
|
483 |
+
</frontend>
|
484 |
+
|
485 |
+
<crontab>
|
486 |
+
<jobs>
|
487 |
+
<dolist_prepare_nightly_differential_export>
|
488 |
+
<!-- Add all Dolist-V8 enabled stores to dolist_differential_export list (before dolist_differential_export)
|
489 |
+
Must be scheduled before dolist_differential_export -->
|
490 |
+
<schedule><cron_expr>55 1 * * *</cron_expr></schedule>
|
491 |
+
<run>
|
492 |
+
<model>dolist/observer::prepareNightlyDifferentialExport</model>
|
493 |
+
</run>
|
494 |
+
</dolist_prepare_nightly_differential_export>
|
495 |
+
<dolist_differential_export>
|
496 |
+
<!-- Either called every night @ 2:00am (before dolist_contact_import),
|
497 |
+
either called manually by Back Office button -->
|
498 |
+
<schedule><cron_expr>0 2 * * *</cron_expr></schedule>
|
499 |
+
<run>
|
500 |
+
<model>dolist/observer::differentialExport</model>
|
501 |
+
</run>
|
502 |
+
</dolist_differential_export>
|
503 |
+
<dolist_full_export>
|
504 |
+
<!-- Not performed automatically, but called by button -->
|
505 |
+
<run>
|
506 |
+
<model>dolist/observer::fullExport</model>
|
507 |
+
</run>
|
508 |
+
</dolist_full_export>
|
509 |
+
<dolist_contact_import>
|
510 |
+
<!-- Every night @ 3:00am -->
|
511 |
+
<schedule><cron_expr>0 3 * * *</cron_expr></schedule>
|
512 |
+
<run>
|
513 |
+
<model>dolist/observer::contactImport</model>
|
514 |
+
</run>
|
515 |
+
</dolist_contact_import>
|
516 |
+
<dolist_send_queued_messages>
|
517 |
+
<!-- Every 5 minutes -->
|
518 |
+
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
|
519 |
+
<run>
|
520 |
+
<model>dolist/observer::sendQueuedMessages</model>
|
521 |
+
</run>
|
522 |
+
</dolist_send_queued_messages>
|
523 |
+
</jobs>
|
524 |
+
</crontab>
|
525 |
+
|
526 |
+
</config>
|
app/code/community/Dolist/Net/etc/system.xml
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<dolist translate="label" module="dolist">
|
5 |
+
<label>Dolist</label>
|
6 |
+
<tab>customer</tab>
|
7 |
+
<frontend_type>text</frontend_type>
|
8 |
+
<sort_order>900</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>0</show_in_store>
|
12 |
+
<groups>
|
13 |
+
<dolist_v8 translate="label">
|
14 |
+
<label>Dolist-V8</label>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>10</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>0</show_in_store>
|
20 |
+
<fields>
|
21 |
+
<active translate="label">
|
22 |
+
<label>Enabled</label>
|
23 |
+
<frontend_type>select</frontend_type>
|
24 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
25 |
+
<sort_order>1</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>0</show_in_store>
|
29 |
+
</active>
|
30 |
+
<accountid translate="label">
|
31 |
+
<label>AccountID</label>
|
32 |
+
<frontend_type>text</frontend_type>
|
33 |
+
<sort_order>10</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>0</show_in_store>
|
37 |
+
</accountid>
|
38 |
+
<authentication_key translate="label">
|
39 |
+
<label>Authentication key</label>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<comment>This key must be generated from your Dolist-V8 account, in section G.2. Webservices.</comment>
|
42 |
+
<sort_order>20</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>0</show_in_store>
|
46 |
+
</authentication_key>
|
47 |
+
<login translate="label">
|
48 |
+
<label>Login</label>
|
49 |
+
<frontend_type>text</frontend_type>
|
50 |
+
<sort_order>30</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>0</show_in_store>
|
54 |
+
</login>
|
55 |
+
<password translate="label">
|
56 |
+
<label>Password</label>
|
57 |
+
<frontend_type>password</frontend_type>
|
58 |
+
<sort_order>40</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>1</show_in_website>
|
61 |
+
<show_in_store>0</show_in_store>
|
62 |
+
</password>
|
63 |
+
<test_connect_wizard translate="button_label">
|
64 |
+
<label></label>
|
65 |
+
<button_label>Test Dolist-V8 connection</button_label>
|
66 |
+
<frontend_model>dolist/adminhtml_system_config_dolistv8_testconnection</frontend_model>
|
67 |
+
<sort_order>50</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
</test_connect_wizard>
|
72 |
+
<export_page_size translate="label">
|
73 |
+
<label>Export page size</label>
|
74 |
+
<frontend_type>text</frontend_type>
|
75 |
+
<sort_order>103</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
</export_page_size>
|
80 |
+
|
81 |
+
</fields>
|
82 |
+
</dolist_v8>
|
83 |
+
<dolist_emt translate="label">
|
84 |
+
<label>Dolist-EMT</label>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>20</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>0</show_in_store>
|
90 |
+
<fields>
|
91 |
+
<active translate="label">
|
92 |
+
<label>Enabled</label>
|
93 |
+
<frontend_type>select</frontend_type>
|
94 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
95 |
+
<sort_order>1</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>0</show_in_store>
|
99 |
+
</active>
|
100 |
+
<asynchronous translate="label">
|
101 |
+
<label>Always queue mail</label>
|
102 |
+
<frontend_type>select</frontend_type>
|
103 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
104 |
+
<sort_order>1</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>0</show_in_store>
|
108 |
+
</asynchronous>
|
109 |
+
<accountid translate="label">
|
110 |
+
<label>AccountID</label>
|
111 |
+
<frontend_type>text</frontend_type>
|
112 |
+
<sort_order>10</sort_order>
|
113 |
+
<show_in_default>1</show_in_default>
|
114 |
+
<show_in_website>1</show_in_website>
|
115 |
+
<show_in_store>0</show_in_store>
|
116 |
+
</accountid>
|
117 |
+
<authentication_key translate="label">
|
118 |
+
<label>Authentication key</label>
|
119 |
+
<frontend_type>text</frontend_type>
|
120 |
+
<comment>This key must be generated from your Dolist-EMT account, in section G.2. Webservices.</comment>
|
121 |
+
<sort_order>20</sort_order>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>0</show_in_store>
|
125 |
+
</authentication_key>
|
126 |
+
<test_connect_wizard translate="button_label">
|
127 |
+
<label></label>
|
128 |
+
<button_label>Test Dolist-EMT connection</button_label>
|
129 |
+
<frontend_model>dolist/adminhtml_system_config_dolistemt_testconnection</frontend_model>
|
130 |
+
<sort_order>50</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>0</show_in_store>
|
134 |
+
<comment>Connection test refreshes Dolist-EMT template list</comment>
|
135 |
+
</test_connect_wizard>
|
136 |
+
<default_template translate="label">
|
137 |
+
<label>Default template</label>
|
138 |
+
<frontend_type>select</frontend_type>
|
139 |
+
<source_model>dolist/system_config_source_dolistemt_defaulttemplate</source_model>
|
140 |
+
<sort_order>60</sort_order>
|
141 |
+
<show_in_default>1</show_in_default>
|
142 |
+
<show_in_website>1</show_in_website>
|
143 |
+
<show_in_store>0</show_in_store>
|
144 |
+
</default_template>
|
145 |
+
<template_mapping translate="label">
|
146 |
+
<label>Template mapping</label>
|
147 |
+
<frontend_model>dolist/adminhtml_system_config_dolistemt_templatemapping</frontend_model>
|
148 |
+
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
149 |
+
<sort_order>70</sort_order>
|
150 |
+
<show_in_default>1</show_in_default>
|
151 |
+
<show_in_website>1</show_in_website>
|
152 |
+
<show_in_store>0</show_in_store>
|
153 |
+
<comment>Save configuration before adding first template mapping</comment>
|
154 |
+
</template_mapping>
|
155 |
+
</fields>
|
156 |
+
</dolist_emt>
|
157 |
+
</groups>
|
158 |
+
</dolist>
|
159 |
+
</sections>
|
160 |
+
</config>
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-install-0.0.1.0.php
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create table structures in database
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
|
14 |
+
// Create new table to store Dolist-EMT templates
|
15 |
+
$installer->run(
|
16 |
+
"
|
17 |
+
DROP TABLE IF EXISTS {$this->getTable('dolist_dolistemt_template')};
|
18 |
+
CREATE TABLE {$this->getTable('dolist_dolistemt_template')} (
|
19 |
+
`id` int(10) unsigned NOT NULL auto_increment,
|
20 |
+
`template_id` int(10) unsigned NOT NULL,
|
21 |
+
`template_name` varchar(255) NOT NULL default '',
|
22 |
+
PRIMARY KEY (`id`)
|
23 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='dolistemt templates';
|
24 |
+
"
|
25 |
+
);
|
26 |
+
|
27 |
+
// Add updated_at field in newsletter_subscriber table
|
28 |
+
try {
|
29 |
+
// Alter column only if column does not already exist
|
30 |
+
$installer->run(
|
31 |
+
"
|
32 |
+
ALTER TABLE {$this->getTable('newsletter_subscriber')}
|
33 |
+
ADD COLUMN `dolist_status` int(11) NOT NULL default '0',
|
34 |
+
ADD COLUMN `updated_at` datetime DEFAULT NULL;
|
35 |
+
"
|
36 |
+
);
|
37 |
+
} catch (Exception $e) {
|
38 |
+
Mage::logException($e);
|
39 |
+
}
|
40 |
+
|
41 |
+
// Add dolist_code field in directory_country table
|
42 |
+
try {
|
43 |
+
// Alter column only if column does not already exist
|
44 |
+
$installer->run(
|
45 |
+
"
|
46 |
+
ALTER TABLE {$this->getTable('directory_country')}
|
47 |
+
ADD COLUMN `dolist_code` varchar(3) NOT NULL default '999';
|
48 |
+
"
|
49 |
+
);
|
50 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '43' WHERE `country_id` = 'AD';");
|
51 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '645' WHERE `country_id` = 'AE';");
|
52 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '647' WHERE `country_id` = 'AE';");
|
53 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '660' WHERE `country_id` = 'AF';");
|
54 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '459' WHERE `country_id` = 'AG';");
|
55 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '446' WHERE `country_id` = 'AI';");
|
56 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '70' WHERE `country_id` = 'AL';");
|
57 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '77' WHERE `country_id` = 'AM';");
|
58 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '478' WHERE `country_id` = 'AN';");
|
59 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '330' WHERE `country_id` = 'AO';");
|
60 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '528' WHERE `country_id` = 'AR';");
|
61 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '38' WHERE `country_id` = 'AT';");
|
62 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '800' WHERE `country_id` = 'AU';");
|
63 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '474' WHERE `country_id` = 'AW';");
|
64 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '78' WHERE `country_id` = 'AZ';");
|
65 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '93' WHERE `country_id` = 'BA';");
|
66 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '469' WHERE `country_id` = 'BB';");
|
67 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '666' WHERE `country_id` = 'BD';");
|
68 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '2' WHERE `country_id` = 'BE';");
|
69 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '236' WHERE `country_id` = 'BF';");
|
70 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '68' WHERE `country_id` = 'BG';");
|
71 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '640' WHERE `country_id` = 'BH';");
|
72 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '328' WHERE `country_id` = 'BI';");
|
73 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '284' WHERE `country_id` = 'BJ';");
|
74 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '413' WHERE `country_id` = 'BM';");
|
75 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '703' WHERE `country_id` = 'BN';");
|
76 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '516' WHERE `country_id` = 'BO';");
|
77 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '508' WHERE `country_id` = 'BR';");
|
78 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '453' WHERE `country_id` = 'BS';");
|
79 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '675' WHERE `country_id` = 'BT';");
|
80 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '391' WHERE `country_id` = 'BW';");
|
81 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '73' WHERE `country_id` = 'BY';");
|
82 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '421' WHERE `country_id` = 'BZ';");
|
83 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '404' WHERE `country_id` = 'CA';");
|
84 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '306' WHERE `country_id` = 'CF';");
|
85 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '318' WHERE `country_id` = 'CG';");
|
86 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '36' WHERE `country_id` = 'CH';");
|
87 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '272' WHERE `country_id` = 'CI';");
|
88 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '512' WHERE `country_id` = 'CL';");
|
89 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '302' WHERE `country_id` = 'CM';");
|
90 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '720' WHERE `country_id` = 'CN';");
|
91 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '480' WHERE `country_id` = 'CO';");
|
92 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '436' WHERE `country_id` = 'CR';");
|
93 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '448' WHERE `country_id` = 'CU';");
|
94 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '247' WHERE `country_id` = 'CV';");
|
95 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '600' WHERE `country_id` = 'CY';");
|
96 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '61' WHERE `country_id` = 'CZ';");
|
97 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '4' WHERE `country_id` = 'DE';");
|
98 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '338' WHERE `country_id` = 'DJ';");
|
99 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '8' WHERE `country_id` = 'DK';");
|
100 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '460' WHERE `country_id` = 'DM';");
|
101 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '456' WHERE `country_id` = 'DO';");
|
102 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '208' WHERE `country_id` = 'DZ';");
|
103 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '22' WHERE `country_id` = 'EA';");
|
104 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '500' WHERE `country_id` = 'EC';");
|
105 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '53' WHERE `country_id` = 'EE';");
|
106 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '220' WHERE `country_id` = 'EG';");
|
107 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '336' WHERE `country_id` = 'ER';");
|
108 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '11' WHERE `country_id` = 'ES';");
|
109 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '334' WHERE `country_id` = 'ET';");
|
110 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '32' WHERE `country_id` = 'FI';");
|
111 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '815' WHERE `country_id` = 'FJ';");
|
112 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '529' WHERE `country_id` = 'FK';");
|
113 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '823' WHERE `country_id` = 'FM';");
|
114 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '25' WHERE `country_id` = 'FO';");
|
115 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '1' WHERE `country_id` = 'FR';");
|
116 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '314' WHERE `country_id` = 'GA';");
|
117 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '6' WHERE `country_id` = 'GB';");
|
118 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '473' WHERE `country_id` = 'GD';");
|
119 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '76' WHERE `country_id` = 'GE';");
|
120 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '496' WHERE `country_id` = 'GF';");
|
121 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '276' WHERE `country_id` = 'GH';");
|
122 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '44' WHERE `country_id` = 'GI';");
|
123 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '406' WHERE `country_id` = 'GL';");
|
124 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '252' WHERE `country_id` = 'GM';");
|
125 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '260' WHERE `country_id` = 'GN';");
|
126 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '458' WHERE `country_id` = 'GP';");
|
127 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '310' WHERE `country_id` = 'GQ';");
|
128 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '9' WHERE `country_id` = 'GR';");
|
129 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '416' WHERE `country_id` = 'GT';");
|
130 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '257' WHERE `country_id` = 'GW';");
|
131 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '488' WHERE `country_id` = 'GY';");
|
132 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '740' WHERE `country_id` = 'HK';");
|
133 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '424' WHERE `country_id` = 'HN';");
|
134 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '92' WHERE `country_id` = 'HR';");
|
135 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '452' WHERE `country_id` = 'HT';");
|
136 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '64' WHERE `country_id` = 'HU';");
|
137 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '21' WHERE `country_id` = 'IC';");
|
138 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '700' WHERE `country_id` = 'ID';");
|
139 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '7' WHERE `country_id` = 'IE';");
|
140 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '624' WHERE `country_id` = 'IL';");
|
141 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '664' WHERE `country_id` = 'IN';");
|
142 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '357' WHERE `country_id` = 'IO';");
|
143 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '612' WHERE `country_id` = 'IQ';");
|
144 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '616' WHERE `country_id` = 'IR';");
|
145 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '24' WHERE `country_id` = 'IS';");
|
146 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '5' WHERE `country_id` = 'IT';");
|
147 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '464' WHERE `country_id` = 'JM';");
|
148 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '628' WHERE `country_id` = 'JO';");
|
149 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '732' WHERE `country_id` = 'JP';");
|
150 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '346' WHERE `country_id` = 'KE';");
|
151 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '83' WHERE `country_id` = 'KG';");
|
152 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '696' WHERE `country_id` = 'KH';");
|
153 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '812' WHERE `country_id` = 'KI';");
|
154 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '375' WHERE `country_id` = 'KM';");
|
155 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '449' WHERE `country_id` = 'KN';");
|
156 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '724' WHERE `country_id` = 'KP';");
|
157 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '728' WHERE `country_id` = 'KR';");
|
158 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '636' WHERE `country_id` = 'KW';");
|
159 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '463' WHERE `country_id` = 'KY';");
|
160 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '79' WHERE `country_id` = 'KZ';");
|
161 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '684' WHERE `country_id` = 'LA';");
|
162 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '604' WHERE `country_id` = 'LB';");
|
163 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '465' WHERE `country_id` = 'LC';");
|
164 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '37' WHERE `country_id` = 'LI';");
|
165 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '669' WHERE `country_id` = 'LK';");
|
166 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '268' WHERE `country_id` = 'LR';");
|
167 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '395' WHERE `country_id` = 'LS';");
|
168 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '55' WHERE `country_id` = 'LT';");
|
169 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '23' WHERE `country_id` = 'LU';");
|
170 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '54' WHERE `country_id` = 'LV';");
|
171 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '216' WHERE `country_id` = 'LY';");
|
172 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '204' WHERE `country_id` = 'MA';");
|
173 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '825' WHERE `country_id` = 'MC';");
|
174 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '74' WHERE `country_id` = 'MD';");
|
175 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '370' WHERE `country_id` = 'MG';");
|
176 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '824' WHERE `country_id` = 'MH';");
|
177 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '96' WHERE `country_id` = 'MK';");
|
178 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '232' WHERE `country_id` = 'ML';");
|
179 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '676' WHERE `country_id` = 'MM';");
|
180 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '716' WHERE `country_id` = 'MN';");
|
181 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '743' WHERE `country_id` = 'MO';");
|
182 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '462' WHERE `country_id` = 'MQ';");
|
183 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '228' WHERE `country_id` = 'MR';");
|
184 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '46' WHERE `country_id` = 'MT';");
|
185 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '373' WHERE `country_id` = 'MU';");
|
186 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '667' WHERE `country_id` = 'MV';");
|
187 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '386' WHERE `country_id` = 'MW';");
|
188 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '412' WHERE `country_id` = 'MX';");
|
189 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '701' WHERE `country_id` = 'MY';");
|
190 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '366' WHERE `country_id` = 'MZ';");
|
191 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '389' WHERE `country_id` = 'NA';");
|
192 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '809' WHERE `country_id` = 'NC';");
|
193 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '240' WHERE `country_id` = 'NE';");
|
194 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '288' WHERE `country_id` = 'NG';");
|
195 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '432' WHERE `country_id` = 'NI';");
|
196 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '3' WHERE `country_id` = 'NL';");
|
197 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '28' WHERE `country_id` = 'NO';");
|
198 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '672' WHERE `country_id` = 'NP';");
|
199 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '803' WHERE `country_id` = 'NR';");
|
200 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '804' WHERE `country_id` = 'NZ';");
|
201 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '649' WHERE `country_id` = 'OM';");
|
202 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '442' WHERE `country_id` = 'PA';");
|
203 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '504' WHERE `country_id` = 'PE';");
|
204 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '822' WHERE `country_id` = 'PF';");
|
205 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '801' WHERE `country_id` = 'PG';");
|
206 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '708' WHERE `country_id` = 'PH';");
|
207 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '662' WHERE `country_id` = 'PK';");
|
208 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '60' WHERE `country_id` = 'PL';");
|
209 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '408' WHERE `country_id` = 'PM';");
|
210 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '813' WHERE `country_id` = 'PN';");
|
211 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '455' WHERE `country_id` = 'PR';");
|
212 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '10' WHERE `country_id` = 'PT';");
|
213 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '520' WHERE `country_id` = 'PY';");
|
214 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '644' WHERE `country_id` = 'QA';");
|
215 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '372' WHERE `country_id` = 'RE';");
|
216 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '66' WHERE `country_id` = 'RO';");
|
217 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '94' WHERE `country_id` = 'RS';");
|
218 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '75' WHERE `country_id` = 'RU';");
|
219 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '324' WHERE `country_id` = 'RW';");
|
220 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '632' WHERE `country_id` = 'SA';");
|
221 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '806' WHERE `country_id` = 'SB';");
|
222 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '355' WHERE `country_id` = 'SC';");
|
223 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '224' WHERE `country_id` = 'SD';");
|
224 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '30' WHERE `country_id` = 'SE';");
|
225 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '706' WHERE `country_id` = 'SG';");
|
226 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '329' WHERE `country_id` = 'SH';");
|
227 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '91' WHERE `country_id` = 'SI';");
|
228 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '63' WHERE `country_id` = 'SK';");
|
229 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '264' WHERE `country_id` = 'SL';");
|
230 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '248' WHERE `country_id` = 'SN';");
|
231 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '342' WHERE `country_id` = 'SO';");
|
232 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '492' WHERE `country_id` = 'SR';");
|
233 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '311' WHERE `country_id` = 'ST';");
|
234 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '428' WHERE `country_id` = 'SV';");
|
235 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '608' WHERE `country_id` = 'SY';");
|
236 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '393' WHERE `country_id` = 'SZ';");
|
237 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '454' WHERE `country_id` = 'TC';");
|
238 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '244' WHERE `country_id` = 'TD';");
|
239 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '280' WHERE `country_id` = 'TG';");
|
240 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '680' WHERE `country_id` = 'TH';");
|
241 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '82' WHERE `country_id` = 'TJ';");
|
242 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '80' WHERE `country_id` = 'TM';");
|
243 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '212' WHERE `country_id` = 'TN';");
|
244 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '817' WHERE `country_id` = 'TO';");
|
245 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '52' WHERE `country_id` = 'TR';");
|
246 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '472' WHERE `country_id` = 'TT';");
|
247 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '807' WHERE `country_id` = 'TV';");
|
248 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '736' WHERE `country_id` = 'TW';");
|
249 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '352' WHERE `country_id` = 'TZ';");
|
250 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '72' WHERE `country_id` = 'UA';");
|
251 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '350' WHERE `country_id` = 'UG';");
|
252 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '400' WHERE `country_id` = 'US';");
|
253 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '524' WHERE `country_id` = 'UY';");
|
254 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '81' WHERE `country_id` = 'UZ';");
|
255 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '45' WHERE `country_id` = 'VA';");
|
256 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '467' WHERE `country_id` = 'VC';");
|
257 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '484' WHERE `country_id` = 'VE';");
|
258 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '461' WHERE `country_id` = 'VG';");
|
259 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '690' WHERE `country_id` = 'VN';");
|
260 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '816' WHERE `country_id` = 'VU';");
|
261 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '811' WHERE `country_id` = 'WF';");
|
262 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '819' WHERE `country_id` = 'WS';");
|
263 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '653' WHERE `country_id` = 'YE';");
|
264 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '377' WHERE `country_id` = 'YT';");
|
265 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '48' WHERE `country_id` = 'YU';");
|
266 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '388' WHERE `country_id` = 'ZA';");
|
267 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '378' WHERE `country_id` = 'ZM';");
|
268 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '322' WHERE `country_id` = 'ZR';");
|
269 |
+
$installer->run("UPDATE {$this->getTable('directory_country')} SET `dolist_code` = '382' WHERE `country_id` = 'ZW';");
|
270 |
+
} catch (Exception $e) {
|
271 |
+
Mage::logException($e);
|
272 |
+
}
|
273 |
+
|
274 |
+
$installer->endSetup();
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.1.0-0.0.1.1.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* UPdate newsletter_subscriber table structure in database
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
|
14 |
+
// Change updated_at field format to timestamp to avoid timezone conflicts
|
15 |
+
try {
|
16 |
+
// Alter column only if column does not already exist
|
17 |
+
$installer->run(
|
18 |
+
"
|
19 |
+
ALTER TABLE {$this->getTable('newsletter_subscriber')}
|
20 |
+
DROP COLUMN `updated_at`,
|
21 |
+
ADD COLUMN `updated_at` int(10) DEFAULT 0;
|
22 |
+
"
|
23 |
+
);
|
24 |
+
} catch (Exception $e) {
|
25 |
+
Mage::logException($e);
|
26 |
+
}
|
27 |
+
|
28 |
+
$installer->endSetup();
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.1.1-0.0.2.0.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add table to store queued messages
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @copyright 2012 Dolist
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
|
14 |
+
// Change updated_at field format to timestamp to avoid timezone conflicts
|
15 |
+
try {
|
16 |
+
// Alter column only if column does not already exist
|
17 |
+
$installer->run(
|
18 |
+
"
|
19 |
+
DROP TABLE IF EXISTS {$this->getTable('dolist_dolistemt_message_queue')};
|
20 |
+
CREATE TABLE {$this->getTable('dolist_dolistemt_message_queue')} (
|
21 |
+
`id` bigint unsigned NOT NULL auto_increment,
|
22 |
+
`template_id` int(10) unsigned NOT NULL,
|
23 |
+
`serialized_message` LONGTEXT NOT NULL default '',
|
24 |
+
`store_id` smallint(5) unsigned NOT NULL default 0,
|
25 |
+
PRIMARY KEY (`id`)
|
26 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='dolistemt message queue';
|
27 |
+
"
|
28 |
+
);
|
29 |
+
} catch (Exception $e) {
|
30 |
+
Mage::logException($e);
|
31 |
+
}
|
32 |
+
|
33 |
+
$installer->endSetup();
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.2.0-0.0.3.0.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add table to store queued messages
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @author Clever Age
|
8 |
+
* @copyright Clever Age
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
|
12 |
+
/** @var Mage_Core_Model_Resource_Setup $installer */
|
13 |
+
$installer = $this;
|
14 |
+
$installer->startSetup();
|
15 |
+
|
16 |
+
|
17 |
+
$installer->run(
|
18 |
+
"
|
19 |
+
DROP TABLE IF EXISTS {$this->getTable('dolist_dolistv8_calculatedfields')};
|
20 |
+
CREATE TABLE {$this->getTable('dolist_dolistv8_calculatedfields')} (
|
21 |
+
`customer_id` int(10) unsigned,
|
22 |
+
`first_order_amount` decimal(12,4) DEFAULT NULL,
|
23 |
+
`first_order_amount_with_vat` decimal(12,4) DEFAULT NULL,
|
24 |
+
`last_order_amount` decimal(12,4) DEFAULT NULL,
|
25 |
+
`last_order_amount_with_vat` decimal(12,4) DEFAULT NULL,
|
26 |
+
`total_orders_amount` decimal(12,4) DEFAULT NULL,
|
27 |
+
`total_orders_amount_with_vat` decimal(12,4) DEFAULT NULL,
|
28 |
+
`average_unique_product_count` decimal(6,2) DEFAULT NULL,
|
29 |
+
`average_product_count_by_command_line` decimal(6,2) DEFAULT NULL,
|
30 |
+
`total_product_count` double DEFAULT NULL,
|
31 |
+
`total_orders_count` double DEFAULT NULL,
|
32 |
+
`last_unordered_cart_amount` decimal(12,4) DEFAULT NULL,
|
33 |
+
`last_unordered_cart_amount_with_vat` decimal(12,4) DEFAULT NULL,
|
34 |
+
`discount_rule_count` decimal(6,2) DEFAULT NULL,
|
35 |
+
`last_orders_range` double DEFAULT NULL,
|
36 |
+
`first_order_date` date DEFAULT NULL,
|
37 |
+
`last_order_date` date DEFAULT NULL,
|
38 |
+
`last_unordered_cart_date` date DEFAULT NULL,
|
39 |
+
`orders_expire` date DEFAULT NULL,
|
40 |
+
`cart_expire` date DEFAULT NULL,
|
41 |
+
`updated_at` datetime DEFAULT NULL,
|
42 |
+
`config` int DEFAULT NULL,
|
43 |
+
`start_date` date DEFAULT NULL,
|
44 |
+
|
45 |
+
PRIMARY KEY (`customer_id`)
|
46 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='dolistemt message queue';
|
47 |
+
"
|
48 |
+
);
|
49 |
+
|
50 |
+
$installer->endSetup();
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.3.0-0.0.4.0.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create table structures in database
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @author Clever Age
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** @var Mage_Core_Model_Resource_Setup $installer */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
// Create new table to store Dolist-EMT templates
|
16 |
+
$installer->run(
|
17 |
+
"
|
18 |
+
DROP TABLE IF EXISTS {$this->getTable('dolist_dolistv8_customfields')};
|
19 |
+
CREATE TABLE {$this->getTable('dolist_dolistv8_customfields')} (
|
20 |
+
`id` int(10) unsigned AUTO_INCREMENT,
|
21 |
+
`type` varchar(255) NOT NULL,
|
22 |
+
`name` varchar(255) NOT NULL,
|
23 |
+
`title` varchar(255) DEFAULT NULL,
|
24 |
+
`display` varchar(255) DEFAULT NULL,
|
25 |
+
`translationKey` varchar(255) DEFAULT NULL,
|
26 |
+
`displayRank` int(10) NOT NULL,
|
27 |
+
`isCustom` tinyint(1) NOT NULL DEFAULT 0,
|
28 |
+
`magento_field` varchar(255) DEFAULT NULL,
|
29 |
+
PRIMARY KEY (`id`)
|
30 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='dolistv8_customfields';
|
31 |
+
"
|
32 |
+
);
|
33 |
+
|
34 |
+
$installer->endSetup();
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.4.0-0.0.5.0.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create table structures in database
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @author Clever Age
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** @var Mage_Core_Model_Resource_Setup $installer */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
// Create new table to store Dolist-EMT templates
|
16 |
+
$installer->run(
|
17 |
+
"
|
18 |
+
DROP TABLE IF EXISTS {$this->getTable('dolist_reports')};
|
19 |
+
CREATE TABLE {$this->getTable('dolist_reports')} (
|
20 |
+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
21 |
+
`type` varchar(255) NOT NULL,
|
22 |
+
`name` varchar(255) NOT NULL,
|
23 |
+
`started_at` DATETIME DEFAULT NULL,
|
24 |
+
`ended_at` DATETIME DEFAULT NULL,
|
25 |
+
`progress_current` int(10) DEFAULT NULL,
|
26 |
+
`progress_end` int(10) DEFAULT NULL,
|
27 |
+
`logs` LONGTEXT NOT NULL,
|
28 |
+
`last_logs` varchar(255) NOT NULL,
|
29 |
+
`result` varchar(255) DEFAULT NULL,
|
30 |
+
`updated_at` DATETIME NOT NULL,
|
31 |
+
PRIMARY KEY (`id`)
|
32 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='dolist_reports';
|
33 |
+
"
|
34 |
+
);
|
35 |
+
|
36 |
+
$installer->endSetup();
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-0.0.5.0-0.0.6.0.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create table structures in database
|
4 |
+
*
|
5 |
+
* @category Dolist
|
6 |
+
* @package Dolist_Net
|
7 |
+
* @author Clever Age
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** @var Mage_Core_Model_Resource_Setup $installer */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
// Create new table to store Dolist-EMT templates
|
16 |
+
$installer->run(
|
17 |
+
"ALTER TABLE {$this->getTable('dolist_dolistv8_customfields')} ADD scope VARCHAR(8) AFTER magento_field, ADD scope_id INT AFTER scope;"
|
18 |
+
);
|
19 |
+
$installer->run(
|
20 |
+
"ALTER TABLE {$this->getTable('dolist_dolistv8_customfields')} ADD CONSTRAINT uc_namescope UNIQUE (name,scope_id)"
|
21 |
+
);
|
22 |
+
|
23 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/dolist.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<layout>
|
4 |
+
<adminhtml_customerdolist_index>
|
5 |
+
<reference name="content">
|
6 |
+
<block type="dolist/adminhtml_edit" name="dolist_edit" />
|
7 |
+
</reference>
|
8 |
+
<reference name="left">
|
9 |
+
<block type="dolist/adminhtml_system_config_switcher" name="adminhtml.system.config.switcher" before="-" template="dolist/store/switcher.phtml"/>
|
10 |
+
<block type="dolist/adminhtml_edit_tabs" name="dolist_edit_tabs">
|
11 |
+
<block type="dolist/adminhtml_edit_tab_export" name="dolist_edit_tab_export" template="dolist/customerexport.phtml" />
|
12 |
+
<block type="dolist/adminhtml_edit_tab_configuration" name="dolist_tab_configuration" template="dolist/configuration.phtml" />
|
13 |
+
<action method="addTab">
|
14 |
+
<name>dolist_edit_tab_export</name>
|
15 |
+
<block>dolist_edit_tab_export</block>
|
16 |
+
</action>
|
17 |
+
<action method="addTab">
|
18 |
+
<name>dolist_tab_configuration</name>
|
19 |
+
<block>dolist_tab_configuration</block>
|
20 |
+
</action>
|
21 |
+
</block>
|
22 |
+
</reference>
|
23 |
+
</adminhtml_customerdolist_index>
|
24 |
+
</layout>
|
app/design/adminhtml/default/default/template/dolist/configuration.phtml
ADDED
@@ -0,0 +1,372 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
|
3 |
+
$_colspan = 0;
|
4 |
+
$_limitRows = 0;
|
5 |
+
?>
|
6 |
+
<div class="entry-edit">
|
7 |
+
|
8 |
+
|
9 |
+
<?php foreach ($this->getForm()->getElements() as $_element): ?>
|
10 |
+
|
11 |
+
<?php if ($_element->getFieldsetContainerId()): ?>
|
12 |
+
<div id="<?php echo $_element->getFieldsetContainerId(); ?>">
|
13 |
+
<?php endif; ?>
|
14 |
+
<?php if ($_element->getLegend()): ?>
|
15 |
+
<div class="entry-edit-head">
|
16 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo $_element->getLegend() ?></h4>
|
17 |
+
<div class="form-buttons"><?php echo $_element->getHeaderBar() ?></div>
|
18 |
+
</div>
|
19 |
+
<?php endif; ?>
|
20 |
+
<?php if (!$_element->getNoContainer()): ?>
|
21 |
+
<div class="fieldset <?php echo $_element->getClass() ?>" id="<?php echo $_element->getHtmlId() ?>">
|
22 |
+
<?php endif; ?>
|
23 |
+
<div class="hor-scroll">
|
24 |
+
|
25 |
+
<?php if ($_element->getComment()): ?>
|
26 |
+
<p class="comment"><?php echo $this->escapeHtml($_element->getComment()) ?></p>
|
27 |
+
<?php endif; ?>
|
28 |
+
<?php if ($_element->hasHtmlContent()): ?>
|
29 |
+
<?php echo $_element->getHtmlContent(); ?>
|
30 |
+
<?php else: ?>
|
31 |
+
<table cellspacing="0" class="<?php echo $_element->hasTableClass() ? $_element->getTableClass() : 'form-list'?>">
|
32 |
+
<tbody>
|
33 |
+
<?php echo $_element->getChildrenHtml(); ?>
|
34 |
+
</tbody>
|
35 |
+
</table>
|
36 |
+
<?php endif; ?>
|
37 |
+
|
38 |
+
<?php if ($_element->getHtmlId() == 'dolist_conf_data_dolist_form_config_custom_fields'): ?>
|
39 |
+
<!-- Grid custom field Str -->
|
40 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>Str">
|
41 |
+
<h3><?php echo Mage::helper('dolist')->__('Custom string fields') ?></h3>
|
42 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
43 |
+
<tbody>
|
44 |
+
|
45 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>Str">
|
46 |
+
<?php foreach ($this->_columnsDate as $columnName => $column):?>
|
47 |
+
<th style="width: 45%;"><?php echo $column['label'] ?></th>
|
48 |
+
<?php endforeach;?>
|
49 |
+
<th style="width: 10%;"></th>
|
50 |
+
</tr>
|
51 |
+
|
52 |
+
<tr id="addRow<?php echo $_htmlId ?>Str">
|
53 |
+
<td colspan="<?php echo count($this->_columnsStr) ?>"></td>
|
54 |
+
<td <?php echo $_colspan?>>
|
55 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>Str">
|
56 |
+
<span><?php echo Mage::helper('dolist')->__('Add') ?></span>
|
57 |
+
</button>
|
58 |
+
</td>
|
59 |
+
</tr>
|
60 |
+
|
61 |
+
</tbody>
|
62 |
+
</table>
|
63 |
+
<input type="hidden" name="mappingStr[__empty]" value="" />
|
64 |
+
</div>
|
65 |
+
<!-- END Grid custom field Str -->
|
66 |
+
|
67 |
+
<!-- Grid custom field Int -->
|
68 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>Int">
|
69 |
+
<h3><?php echo Mage::helper('dolist')->__('Custom int fields') ?></h3>
|
70 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
71 |
+
<tbody>
|
72 |
+
|
73 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>Int">
|
74 |
+
<?php foreach ($this->_columnsDate as $columnName => $column):?>
|
75 |
+
<th style="width: 45%;"><?php echo $column['label'] ?></th>
|
76 |
+
<?php endforeach;?>
|
77 |
+
<th style="width: 10%;"></th>
|
78 |
+
</tr>
|
79 |
+
|
80 |
+
<tr id="addRow<?php echo $_htmlId ?>Int">
|
81 |
+
<td colspan="<?php echo count($this->_columnsInt) ?>"></td>
|
82 |
+
<td <?php echo $_colspan?>>
|
83 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>Int">
|
84 |
+
<span><?php echo Mage::helper('dolist')->__('Add') ?></span>
|
85 |
+
</button>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
|
89 |
+
</tbody>
|
90 |
+
</table>
|
91 |
+
<input type="hidden" name="mappingInt[__empty]" value="" />
|
92 |
+
</div>
|
93 |
+
<!-- END Grid custom field Int -->
|
94 |
+
|
95 |
+
<!-- Grid custom field Date -->
|
96 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>Date">
|
97 |
+
<h3><?php echo Mage::helper('dolist')->__('Custom date fields') ?></h3>
|
98 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
99 |
+
<tbody>
|
100 |
+
|
101 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>Date">
|
102 |
+
<?php foreach ($this->_columnsDate as $columnName => $column):?>
|
103 |
+
<th style="width: 45%;"><?php echo $column['label'] ?></th>
|
104 |
+
<?php endforeach;?>
|
105 |
+
<th style="width: 10%;"></th>
|
106 |
+
</tr>
|
107 |
+
|
108 |
+
<tr id="addRow<?php echo $_htmlId ?>Date">
|
109 |
+
<td colspan="<?php echo count($this->_columnsDate) ?>"></td>
|
110 |
+
<td <?php echo $_colspan?>>
|
111 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>Date">
|
112 |
+
<span><?php echo Mage::helper('dolist')->__('Add') ?></span>
|
113 |
+
</button>
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
|
117 |
+
</tbody>
|
118 |
+
</table>
|
119 |
+
<input type="hidden" name="mappingDate[__empty]" value="" />
|
120 |
+
</div>
|
121 |
+
<!-- END Grid custom field Date -->
|
122 |
+
|
123 |
+
<?php endif; ?>
|
124 |
+
</div>
|
125 |
+
<?php echo $_element->getSubFieldsetHtml() ?>
|
126 |
+
<?php if (!$_element->getNoContainer()): ?>
|
127 |
+
</div>
|
128 |
+
<?php endif; ?>
|
129 |
+
<?php if ($_element->getFieldsetContainerId()): ?>
|
130 |
+
</div>
|
131 |
+
<?php endif; ?>
|
132 |
+
<?php endforeach; ?>
|
133 |
+
</div>
|
134 |
+
|
135 |
+
<script type="text/javascript">
|
136 |
+
//<![CDATA[
|
137 |
+
function updateConfigStartDateVisibility() {
|
138 |
+
if($('dolist_conf_calculatedfieds_mode').value != 2) {
|
139 |
+
$('dolist_conf_calculatedfieds_date').ancestors()[1].hide();
|
140 |
+
$('dolist_conf_calculatedfieds_date').value = '';
|
141 |
+
}
|
142 |
+
else {
|
143 |
+
$('dolist_conf_calculatedfieds_date').ancestors()[1].show();
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
Event.observe('dolist_conf_calculatedfieds_mode', 'change', function() {
|
148 |
+
updateConfigStartDateVisibility();
|
149 |
+
});
|
150 |
+
updateConfigStartDateVisibility();
|
151 |
+
|
152 |
+
//]]>
|
153 |
+
</script>
|
154 |
+
|
155 |
+
<script type="text/javascript">
|
156 |
+
//<![CDATA[
|
157 |
+
// create row creator
|
158 |
+
var arrayRow<?php echo $_htmlId ?>Str = {
|
159 |
+
// define row prototypeJS template
|
160 |
+
template : new Template(
|
161 |
+
'<tr id="#{_id}Str">'
|
162 |
+
<?php foreach ($this->_columnsStr as $columnName => $column):?>
|
163 |
+
+'<td>'
|
164 |
+
+'<?php echo $this->_renderCellTemplateStr($columnName)?>'
|
165 |
+
+'<\/td>'
|
166 |
+
<?php endforeach;?>
|
167 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>Str.del(\'#{_id}Str\')" class="scalable delete" type="button"><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/button><\/td>'
|
168 |
+
+'<\/tr>'
|
169 |
+
),
|
170 |
+
|
171 |
+
rowsCount : 0,
|
172 |
+
|
173 |
+
add : function(templateData, insertAfterId)
|
174 |
+
{
|
175 |
+
// generate default template data
|
176 |
+
if ('' == templateData) {
|
177 |
+
var d = new Date();
|
178 |
+
var templateData = {
|
179 |
+
<?php foreach ($this->_columnsStr as $columnName => $column):?>
|
180 |
+
<?php echo $columnName ?> : '',
|
181 |
+
<?php endforeach;?>
|
182 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
183 |
+
};
|
184 |
+
}
|
185 |
+
|
186 |
+
// insert before last row
|
187 |
+
if ('' == insertAfterId) {
|
188 |
+
Element.insert($('addRow<?php echo $_htmlId ?>Str'), {before: this.template.evaluate(templateData)});
|
189 |
+
}
|
190 |
+
// insert after specified row
|
191 |
+
else {
|
192 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
193 |
+
}
|
194 |
+
|
195 |
+
<?php if ($this->_addAfter):?>
|
196 |
+
Event.observe('addAfterBtn' + templateData._id + 'Str', 'click', this.add.bind(this, '', templateData._id));
|
197 |
+
<?php endif;?>
|
198 |
+
|
199 |
+
this.rowsCount += 1;
|
200 |
+
|
201 |
+
},
|
202 |
+
|
203 |
+
del : function(rowId)
|
204 |
+
{
|
205 |
+
$(rowId).remove();
|
206 |
+
this.rowsCount -= 1;
|
207 |
+
|
208 |
+
|
209 |
+
$('addToEndBtn<?php echo $_htmlId ?>Str').show();
|
210 |
+
},
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
// bind add action to "Add" button in last row
|
215 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>Str', 'click', arrayRow<?php echo $_htmlId ?>Str.add.bind(arrayRow<?php echo $_htmlId ?>Str, '', ''));
|
216 |
+
|
217 |
+
// add existing rows
|
218 |
+
<?php
|
219 |
+
$_addAfterId = "headings{$_htmlId}Str";
|
220 |
+
foreach ($this->getMappingRowsString() as $_rowId => $_row) {
|
221 |
+
echo "arrayRow{$_htmlId}Str.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
222 |
+
$_addAfterId = $_rowId.'Str';
|
223 |
+
}
|
224 |
+
?>
|
225 |
+
//]]>
|
226 |
+
</script>
|
227 |
+
|
228 |
+
<script type="text/javascript">
|
229 |
+
//<![CDATA[
|
230 |
+
// create row creator
|
231 |
+
var arrayRow<?php echo $_htmlId ?>Int = {
|
232 |
+
// define row prototypeJS template
|
233 |
+
template : new Template(
|
234 |
+
'<tr id="#{_id}Int">'
|
235 |
+
<?php foreach ($this->_columnsInt as $columnName => $column):?>
|
236 |
+
+'<td>'
|
237 |
+
+'<?php echo $this->_renderCellTemplateInt($columnName)?>'
|
238 |
+
+'<\/td>'
|
239 |
+
<?php endforeach;?>
|
240 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>Int.del(\'#{_id}Int\')" class="scalable delete" type="button"><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/button><\/td>'
|
241 |
+
+'<\/tr>'
|
242 |
+
),
|
243 |
+
|
244 |
+
rowsCount : 0,
|
245 |
+
|
246 |
+
add : function(templateData, insertAfterId)
|
247 |
+
{
|
248 |
+
// generate default template data
|
249 |
+
if ('' == templateData) {
|
250 |
+
var d = new Date();
|
251 |
+
var templateData = {
|
252 |
+
<?php foreach ($this->_columnsInt as $columnName => $column):?>
|
253 |
+
<?php echo $columnName ?> : '',
|
254 |
+
<?php endforeach;?>
|
255 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
256 |
+
};
|
257 |
+
}
|
258 |
+
|
259 |
+
// insert before last row
|
260 |
+
if ('' == insertAfterId) {
|
261 |
+
Element.insert($('addRow<?php echo $_htmlId ?>Int'), {before: this.template.evaluate(templateData)});
|
262 |
+
}
|
263 |
+
// insert after specified row
|
264 |
+
else {
|
265 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
266 |
+
}
|
267 |
+
|
268 |
+
<?php if ($this->_addAfter):?>
|
269 |
+
Event.observe('addAfterBtn' + templateData._id + 'Int', 'click', this.add.bind(this, '', templateData._id));
|
270 |
+
<?php endif;?>
|
271 |
+
|
272 |
+
this.rowsCount += 1;
|
273 |
+
|
274 |
+
},
|
275 |
+
|
276 |
+
del : function(rowId)
|
277 |
+
{
|
278 |
+
$(rowId).remove();
|
279 |
+
this.rowsCount -= 1;
|
280 |
+
|
281 |
+
|
282 |
+
$('addToEndBtn<?php echo $_htmlId ?>Int').show();
|
283 |
+
},
|
284 |
+
|
285 |
+
}
|
286 |
+
|
287 |
+
// bind add action to "Add" button in last row
|
288 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>Int', 'click', arrayRow<?php echo $_htmlId ?>Int.add.bind(arrayRow<?php echo $_htmlId ?>Int, '', ''));
|
289 |
+
|
290 |
+
// add existing rows
|
291 |
+
<?php
|
292 |
+
$_addAfterId = "headings{$_htmlId}Int";
|
293 |
+
foreach ($this->getMappingRowsInt() as $_rowId => $_row) {
|
294 |
+
echo "arrayRow{$_htmlId}Int.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
295 |
+
$_addAfterId = $_rowId.'Int';
|
296 |
+
}
|
297 |
+
?>
|
298 |
+
//]]>
|
299 |
+
</script>
|
300 |
+
|
301 |
+
<script type="text/javascript">
|
302 |
+
//<![CDATA[
|
303 |
+
// create row creator
|
304 |
+
var arrayRow<?php echo $_htmlId ?>Date = {
|
305 |
+
// define row prototypeJS template
|
306 |
+
template : new Template(
|
307 |
+
'<tr id="#{_id}Date">'
|
308 |
+
<?php foreach ($this->_columnsDate as $columnName => $column):?>
|
309 |
+
+'<td>'
|
310 |
+
+'<?php echo $this->_renderCellTemplateDate($columnName)?>'
|
311 |
+
+'<\/td>'
|
312 |
+
<?php endforeach;?>
|
313 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>Date.del(\'#{_id}Date\')" class="scalable delete" type="button"><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/button><\/td>'
|
314 |
+
+'<\/tr>'
|
315 |
+
),
|
316 |
+
|
317 |
+
rowsCount : 0,
|
318 |
+
|
319 |
+
add : function(templateData, insertAfterId)
|
320 |
+
{
|
321 |
+
// generate default template data
|
322 |
+
if ('' == templateData) {
|
323 |
+
var d = new Date();
|
324 |
+
var templateData = {
|
325 |
+
<?php foreach ($this->_columnsDate as $columnName => $column):?>
|
326 |
+
<?php echo $columnName ?> : '',
|
327 |
+
<?php endforeach;?>
|
328 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
329 |
+
};
|
330 |
+
}
|
331 |
+
|
332 |
+
// insert before last row
|
333 |
+
if ('' == insertAfterId) {
|
334 |
+
Element.insert($('addRow<?php echo $_htmlId ?>Date'), {before: this.template.evaluate(templateData)});
|
335 |
+
}
|
336 |
+
// insert after specified row
|
337 |
+
else {
|
338 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
339 |
+
}
|
340 |
+
|
341 |
+
<?php if ($this->_addAfter):?>
|
342 |
+
Event.observe('addAfterBtn' + templateData._id + 'Date', 'click', this.add.bind(this, '', templateData._id));
|
343 |
+
<?php endif;?>
|
344 |
+
|
345 |
+
this.rowsCount += 1;
|
346 |
+
|
347 |
+
},
|
348 |
+
|
349 |
+
del : function(rowId)
|
350 |
+
{
|
351 |
+
$(rowId).remove();
|
352 |
+
this.rowsCount -= 1;
|
353 |
+
|
354 |
+
|
355 |
+
$('addToEndBtn<?php echo $_htmlId ?>Date').show();
|
356 |
+
},
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
// bind add action to "Add" button in last row
|
361 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>Date', 'click', arrayRow<?php echo $_htmlId ?>Date.add.bind(arrayRow<?php echo $_htmlId ?>Date, '', ''));
|
362 |
+
|
363 |
+
// add existing rows
|
364 |
+
<?php
|
365 |
+
$_addAfterId = "headings{$_htmlId}Date";
|
366 |
+
foreach ($this->getMappingRowsDate() as $_rowId => $_row) {
|
367 |
+
echo "arrayRow{$_htmlId}Date.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
368 |
+
$_addAfterId = $_rowId.'Date';
|
369 |
+
}
|
370 |
+
?>
|
371 |
+
//]]>
|
372 |
+
</script>
|
app/design/adminhtml/default/default/template/dolist/customerexport.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/** @var Dolist_Dolist_Block_Adminhtml_Edit_Tab_Export $this */
|
3 |
+
?>
|
4 |
+
<?php echo $this->getChildHtml(); ?>
|
5 |
+
<table class="form-list">
|
6 |
+
<tr>
|
7 |
+
<td class="scope-label">
|
8 |
+
<button onclick="setLocation('<?php echo $this->getFullExportUrl()?>')" type="button" class="scalable"><span><?php echo Mage::helper('dolist')->__('Full export') ?></span></button>
|
9 |
+
</td>
|
10 |
+
<td class="scope-label">
|
11 |
+
<?php echo Mage::helper('dolist')->__('Full export exportes all Magento contacts (newsletter subscribers) to Dolist-V8 platform.')?>
|
12 |
+
</td>
|
13 |
+
</tr>
|
14 |
+
<tr>
|
15 |
+
<td class="scope-label">
|
16 |
+
<button onclick="setLocation('<?php echo $this->getDifferentialExportUrl()?>')" type="button" class="scalable"><span><?php echo Mage::helper('dolist')->__('Differential export') ?></span></button>
|
17 |
+
</td>
|
18 |
+
<td class="scope-label">
|
19 |
+
<?php echo Mage::helper('dolist')->__('Differential export exports only Magento contacts modified from last full or differential export. At least one full export should have been performed.')?>
|
20 |
+
</td>
|
21 |
+
</tr>
|
22 |
+
<?php if ($this->showCustomerSegment()): ?>
|
23 |
+
<tr>
|
24 |
+
<td class="scope-label">
|
25 |
+
<button onclick="setLocation('<?php echo $this->getUpdateSegmentsUrl()?>')" type="button" class="scalable"><span><?php echo Mage::helper('dolist')->__('Update customer segments') ?></span></button>
|
26 |
+
</td>
|
27 |
+
<td class="scope-label">
|
28 |
+
<?php echo Mage::helper('dolist')->__('Exports again all already exported segments.')?>
|
29 |
+
</td>
|
30 |
+
</tr>
|
31 |
+
<?php endif; ?>
|
32 |
+
</table>
|
33 |
+
|
app/design/adminhtml/default/default/template/dolist/store/switcher.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/** @var Dolist_Dolist_Block_Adminhtml_System_Config_Switcher $this */
|
3 |
+
?>
|
4 |
+
<div class="switcher">
|
5 |
+
<label for="store_switcher"><?php echo $this->__('Current Configuration Scope:') ?></label>
|
6 |
+
<select id="store_switcher" class="system-config-store-switcher" onchange="location.href=this.options[this.selectedIndex].getAttribute('url')">
|
7 |
+
<?php foreach ($this->getStoreSelectOptions() as $_value=>$_option): ?>
|
8 |
+
<?php if (isset($_option['is_group'])): ?>
|
9 |
+
<?php if ($_option['is_close']): ?>
|
10 |
+
</optgroup>
|
11 |
+
<?php else: ?>
|
12 |
+
<optgroup label="<?php echo $_option['label'] ?>" style="<?php echo $_option['style'] ?>">
|
13 |
+
<?php endif; ?>
|
14 |
+
<?php continue ?>
|
15 |
+
<?php endif; ?>
|
16 |
+
<option value="<?php echo $_value ?>" url="<?php echo $_option['url'] ?>" <?php echo $_option['selected']?'selected="selected"':'' ?> style="<?php echo $_option['style'] ?>">
|
17 |
+
<?php echo $_option['label'] ?>
|
18 |
+
</option>
|
19 |
+
<?php endforeach ?>
|
20 |
+
</select>
|
21 |
+
</div>
|
app/design/adminhtml/default/default/template/dolist/system/config/dolistemt/testconnection.phtml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
function testEmtConnection() {
|
3 |
+
var elem = $('<?php echo $this->getHtmlId() ?>');
|
4 |
+
|
5 |
+
params = {
|
6 |
+
accountid: $('dolist_dolist_emt_accountid').value,
|
7 |
+
authentication_key: $('dolist_dolist_emt_authentication_key').value,
|
8 |
+
storeId: <?php echo $this->getStoreId() ?>
|
9 |
+
};
|
10 |
+
|
11 |
+
new Ajax.Request('<?php echo $this->getAjaxUrl() ?>', {
|
12 |
+
parameters: params,
|
13 |
+
onSuccess: function(response) {
|
14 |
+
result = '<?php echo $this->__('Connection KO. Try again?') ?>';
|
15 |
+
try {
|
16 |
+
var connectionStatus = response.responseJSON.connectionStatus;
|
17 |
+
var templateListUpdated = response.responseJSON.templateListUpdated;
|
18 |
+
var templateList = response.responseJSON.templateList;
|
19 |
+
|
20 |
+
if (connectionStatus == 1) {
|
21 |
+
result = '<?php echo $this->__('Connection OK') ?>';
|
22 |
+
elem.removeClassName('fail').addClassName('success')
|
23 |
+
|
24 |
+
// Check if Dolist-EMT template list has been updated
|
25 |
+
if (templateListUpdated) {
|
26 |
+
|
27 |
+
var optionsHtml = "";
|
28 |
+
for (var key in templateList) {
|
29 |
+
optionsHtml = optionsHtml + "<option value=\"" + key + "\">" + templateList[key] + "</option>\n";
|
30 |
+
}
|
31 |
+
|
32 |
+
// Update lists
|
33 |
+
$('dolist_dolist_emt_default_template').update(optionsHtml);
|
34 |
+
$$('select.dolistemt_email_template_select').each(function(selector) {
|
35 |
+
selector.update(optionsHtml);
|
36 |
+
});
|
37 |
+
|
38 |
+
// Warn administrator
|
39 |
+
alert("<?php echo $this->__('Warning! Dolist-EMT templates have been updated. Please double check your configuration in below fields') ?>");
|
40 |
+
}
|
41 |
+
} else {
|
42 |
+
elem.removeClassName('success').addClassName('fail')
|
43 |
+
}
|
44 |
+
} catch (e) {
|
45 |
+
elem.removeClassName('success').addClassName('fail')
|
46 |
+
}
|
47 |
+
$('dolist_emt_connection_test_result').update(result);
|
48 |
+
}
|
49 |
+
});
|
50 |
+
}
|
51 |
+
|
52 |
+
function resetEmtTestButton() {
|
53 |
+
var elem = $('<?php echo $this->getHtmlId() ?>');
|
54 |
+
var defaultmsg = '<?php echo $this->escapeHtml($this->getButtonLabel()) ?>';
|
55 |
+
elem.removeClassName('success').removeClassName('fail');
|
56 |
+
$('dolist_emt_connection_test_result').update(defaultmsg);
|
57 |
+
}
|
58 |
+
|
59 |
+
// Reset test button if fields are modified
|
60 |
+
$('dolist_dolist_emt_login').observe('change', resetEmtTestButton);
|
61 |
+
$('dolist_dolist_emt_password').observe('change', resetEmtTestButton);
|
62 |
+
</script>
|
63 |
+
<button onclick="javascript:testEmtConnection(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
|
64 |
+
<span id="dolist_emt_connection_test_result"><?php echo $this->escapeHtml($this->getButtonLabel()) ?></span>
|
65 |
+
</button>
|
app/design/adminhtml/default/default/template/dolist/system/config/dolistv8/array.phtml
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
|
3 |
+
|
4 |
+
$_colspan = 2;
|
5 |
+
if (!$this->_addAfter) {
|
6 |
+
$_colspan -= 1;
|
7 |
+
}
|
8 |
+
$_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
|
9 |
+
|
10 |
+
$_limitRows = $this->getLimitRows() ? $this->getLimitRows() : 0;
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>">
|
14 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
15 |
+
<tbody>
|
16 |
+
|
17 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>">
|
18 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
19 |
+
<th><?php echo $column['label'] ?></th>
|
20 |
+
<?php endforeach;?>
|
21 |
+
<th <?php echo $_colspan?>></th>
|
22 |
+
</tr>
|
23 |
+
|
24 |
+
<tr id="addRow<?php echo $_htmlId ?>">
|
25 |
+
<td colspan="<?php echo count($this->_columns) ?>"></td>
|
26 |
+
<td <?php echo $_colspan?>>
|
27 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>">
|
28 |
+
<span><?php echo $this->_addButtonLabel ?></span>
|
29 |
+
</button>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
+
|
33 |
+
</tbody>
|
34 |
+
</table>
|
35 |
+
<input type="hidden" name="<?php echo $this->getElement()->getName() ?>[__empty]" value="" />
|
36 |
+
</div>
|
37 |
+
<div id="empty<?php echo $_htmlId ?>">
|
38 |
+
<button style="" onclick="" class="scalable add" type="button" id="emptyAddBtn<?php echo $_htmlId ?>">
|
39 |
+
<span><?php echo $this->_addButtonLabel ?></span>
|
40 |
+
</button>
|
41 |
+
</div>
|
42 |
+
|
43 |
+
<script type="text/javascript">
|
44 |
+
//<![CDATA[
|
45 |
+
// create row creator
|
46 |
+
var arrayRow<?php echo $_htmlId ?> = {
|
47 |
+
// define row prototypeJS template
|
48 |
+
template : new Template(
|
49 |
+
'<tr id="#{_id}">'
|
50 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
51 |
+
+'<td>'
|
52 |
+
+'<?php echo $this->_renderCellTemplate($columnName)?>'
|
53 |
+
+'<\/td>'
|
54 |
+
<?php endforeach;?>
|
55 |
+
<?php if ($this->_addAfter):?>
|
56 |
+
+'<td><button onclick="" class="scalable add" type="button" id="addAfterBtn#{_id}"><span><?php echo Mage::helper('adminhtml')->__('Add after') ?><\/span><\/button><\/td>'
|
57 |
+
<?php endif;?>
|
58 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>.del(\'#{_id}\')" class="scalable delete" type="button"><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/button><\/td>'
|
59 |
+
+'<\/tr>'
|
60 |
+
),
|
61 |
+
|
62 |
+
rowsCount : 0,
|
63 |
+
|
64 |
+
add : function(templateData, insertAfterId)
|
65 |
+
{
|
66 |
+
// generate default template data
|
67 |
+
if ('' == templateData) {
|
68 |
+
var d = new Date();
|
69 |
+
var templateData = {
|
70 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
71 |
+
<?php echo $columnName ?> : '',
|
72 |
+
<?php endforeach;?>
|
73 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
74 |
+
};
|
75 |
+
}
|
76 |
+
|
77 |
+
// insert before last row
|
78 |
+
if ('' == insertAfterId) {
|
79 |
+
Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
|
80 |
+
}
|
81 |
+
// insert after specified row
|
82 |
+
else {
|
83 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
84 |
+
}
|
85 |
+
|
86 |
+
<?php if ($this->_addAfter):?>
|
87 |
+
Event.observe('addAfterBtn' + templateData._id, 'click', this.add.bind(this, '', templateData._id));
|
88 |
+
<?php endif;?>
|
89 |
+
|
90 |
+
this.rowsCount += 1;
|
91 |
+
|
92 |
+
if (this.rowsCount == <?php echo $_limitRows ?>) {
|
93 |
+
// Hide add button
|
94 |
+
$('addToEndBtn<?php echo $_htmlId ?>').hide();
|
95 |
+
}
|
96 |
+
},
|
97 |
+
|
98 |
+
del : function(rowId)
|
99 |
+
{
|
100 |
+
$(rowId).remove();
|
101 |
+
this.rowsCount -= 1;
|
102 |
+
if (0 == this.rowsCount) {
|
103 |
+
this.showButtonOnly();
|
104 |
+
}
|
105 |
+
|
106 |
+
$('addToEndBtn<?php echo $_htmlId ?>').show();
|
107 |
+
},
|
108 |
+
|
109 |
+
showButtonOnly : function()
|
110 |
+
{
|
111 |
+
$('grid<?php echo $_htmlId ?>').hide();
|
112 |
+
$('empty<?php echo $_htmlId ?>').show();
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
// bind add action to "Add" button in last row
|
117 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>', 'click', arrayRow<?php echo $_htmlId ?>.add.bind(arrayRow<?php echo $_htmlId ?>, '', ''));
|
118 |
+
|
119 |
+
// add existing rows
|
120 |
+
<?php
|
121 |
+
$_addAfterId = "headings{$_htmlId}";
|
122 |
+
foreach ($this->getArrayRows() as $_rowId => $_row) {
|
123 |
+
echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
124 |
+
$_addAfterId = $_rowId;
|
125 |
+
}
|
126 |
+
?>
|
127 |
+
|
128 |
+
// initialize standalone button
|
129 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
130 |
+
Event.observe('emptyAddBtn<?php echo $_htmlId ?>', 'click', function () {
|
131 |
+
$('grid<?php echo $_htmlId ?>').show();
|
132 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
133 |
+
arrayRow<?php echo $_htmlId ?>.add('', '');
|
134 |
+
});
|
135 |
+
|
136 |
+
// if no rows, hide grid and show button only
|
137 |
+
<?php if (!$this->getArrayRows()):?>
|
138 |
+
arrayRow<?php echo $_htmlId ?>.showButtonOnly();
|
139 |
+
<?php endif;?>
|
140 |
+
|
141 |
+
// toggle the grid, if element is disabled (depending on scope)
|
142 |
+
<?php if ($this->getElement()->getDisabled()):?>
|
143 |
+
toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
|
144 |
+
<?php endif;?>
|
145 |
+
//]]>
|
146 |
+
</script>
|
app/design/adminhtml/default/default/template/dolist/system/config/dolistv8/testconnection.phtml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
function testV8Connection() {
|
3 |
+
var elem = $('<?php echo $this->getHtmlId() ?>');
|
4 |
+
|
5 |
+
params = {
|
6 |
+
accountid: $('dolist_dolist_v8_accountid').value,
|
7 |
+
authentication_key: $('dolist_dolist_v8_authentication_key').value,
|
8 |
+
login: $('dolist_dolist_v8_login').value,
|
9 |
+
password: $('dolist_dolist_v8_password').value,
|
10 |
+
storeId: <?php echo $this->getStoreId() ?>
|
11 |
+
};
|
12 |
+
|
13 |
+
new Ajax.Request('<?php echo $this->getAjaxUrl() ?>', {
|
14 |
+
parameters: params,
|
15 |
+
onSuccess: function(response) {
|
16 |
+
result = '<?php echo $this->__('Connection KO. Try again?') ?>';
|
17 |
+
try {
|
18 |
+
var connectionStatus = response.responseJSON.connectionStatus;
|
19 |
+
|
20 |
+
if (connectionStatus == 1) {
|
21 |
+
result = '<?php echo $this->__('Connection OK') ?>';
|
22 |
+
elem.removeClassName('fail').addClassName('success')
|
23 |
+
|
24 |
+
} else {
|
25 |
+
elem.removeClassName('success').addClassName('fail')
|
26 |
+
|
27 |
+
// Display error if any
|
28 |
+
if (response.responseJSON.error != 0) {
|
29 |
+
if (typeof response.responseJSON.error == 'string') {
|
30 |
+
alert(response.responseJSON.error);
|
31 |
+
} else {
|
32 |
+
alert(
|
33 |
+
"Description: " + response.responseJSON.error.Description + "\n" +
|
34 |
+
"ErrorCode: " + response.responseJSON.error.ErrorCode + "\n" +
|
35 |
+
"ErrorCodeType: " + response.responseJSON.error.ErrorCodeType + "\n" +
|
36 |
+
"Message: " + response.responseJSON.error.Message + "\n" +
|
37 |
+
"Ticket: " + response.responseJSON.error.Ticket + "\n"
|
38 |
+
);
|
39 |
+
};
|
40 |
+
}
|
41 |
+
}
|
42 |
+
} catch (e) {
|
43 |
+
elem.removeClassName('success').addClassName('fail')
|
44 |
+
}
|
45 |
+
$('dolist_v8_connection_test_result').update(result);
|
46 |
+
}
|
47 |
+
});
|
48 |
+
}
|
49 |
+
|
50 |
+
function resetV8TestButton() {
|
51 |
+
var elem = $('<?php echo $this->getHtmlId() ?>');
|
52 |
+
var defaultmsg = '<?php echo $this->escapeHtml($this->getButtonLabel()) ?>';
|
53 |
+
elem.removeClassName('success').removeClassName('fail');
|
54 |
+
$('dolist_v8_connection_test_result').update(defaultmsg);
|
55 |
+
}
|
56 |
+
|
57 |
+
// Reset test button if fields are modified
|
58 |
+
$('dolist_dolist_v8_accountid').observe('change', resetV8TestButton);
|
59 |
+
$('dolist_dolist_v8_authentication_key').observe('change', resetV8TestButton);
|
60 |
+
$('dolist_dolist_v8_login').observe('change', resetV8TestButton);
|
61 |
+
$('dolist_dolist_v8_password').observe('change', resetV8TestButton);
|
62 |
+
</script>
|
63 |
+
<button onclick="javascript:testV8Connection(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
|
64 |
+
<span id="dolist_v8_connection_test_result"><?php echo $this->escapeHtml($this->getButtonLabel()) ?></span>
|
65 |
+
</button>
|
app/etc/modules/Dolist_Net.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Dolist_Net>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Dolist_Net>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/fr_FR/Dolist_Net.csv
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Dolist","Dolist"
|
2 |
+
"Dolist-V8","Dolist-V8"
|
3 |
+
"Dolist-EMT","Dolist-EMT"
|
4 |
+
"Always queue mail","Toujours différer les envois de mail"
|
5 |
+
"AccountID","AccountID"
|
6 |
+
"Authentication key","Clé d'authentification"
|
7 |
+
"This key must be generated from your Dolist-V8 account, in section G.2. Webservices.","La clé doit être générée depuis votre espace Dolist-V8, section G.2. Les Web Services."
|
8 |
+
"Login","Identifiant"
|
9 |
+
"Password","Mot de passe"
|
10 |
+
"Test Dolist-V8 connection","Tester la connexion Dolist-V8"
|
11 |
+
"Connection OK","Connexion OK"
|
12 |
+
"Connection KO. Try again?","Connexion KO. Réessayer ?"
|
13 |
+
"Email address","Adresse email"
|
14 |
+
"Group","Groupe"
|
15 |
+
"First name","Prénom"
|
16 |
+
"Last name","Nom"
|
17 |
+
"Birthdate","Date de naissance"
|
18 |
+
"Company","Société"
|
19 |
+
"Address 1","Adresse 1"
|
20 |
+
"Address 2","Adresse 2"
|
21 |
+
"Address 3","Adresse 3"
|
22 |
+
"Zipcode","Code postal"
|
23 |
+
"City","Ville"
|
24 |
+
"Country","Pays"
|
25 |
+
"Phone","Téléphone"
|
26 |
+
"Fax","Fax"
|
27 |
+
"Custom string fields","Champs personnalisés texte"
|
28 |
+
"Custom int fields","Champs personnalisés numérique"
|
29 |
+
"Custom date fields","Champs personnalisés date"
|
30 |
+
"Test Dolist-EMT connection","Tester la connexion Dolist-EMT"
|
31 |
+
"Default template","Gabarit par défaut"
|
32 |
+
"Template mapping","Correspondance des gabarits"
|
33 |
+
"Magento template","Gabarit Magento"
|
34 |
+
"Dolist-EMT template","Gabarit Dolist-EMT"
|
35 |
+
"Add Mapping","Ajouter Correspondance"
|
36 |
+
"Warning! Dolist-EMT templates have been updated. Please double check your configuration in below fields","Attention ! Les templates Dolist-EMT ont été mis à jour. Vérifiez la configuration des champs ci-dessous."
|
37 |
+
"Your email address is in temporary error.","Votre adresse email est en erreur temporaire."
|
38 |
+
"This contact email address is in temporary error.","L'adresse email de ce contact est en erreur temporaire."
|
39 |
+
"Your email address is in final error. Please correct it.","Votre adresse email est en erreur définitive. Merci de la corriger."
|
40 |
+
"This contact email address is in final error. Please correct it.","L'adresse email de ce contact est en erreur définitive. Merci de la corriger."
|
41 |
+
"Last sent message was signaled as spam.","Le dernier message envoyé a été signalé comme spam."
|
42 |
+
"Last message sent from this contact was signaled as spam.","Le dernier message envoyé par ce contact a été signalé comme spam."
|
43 |
+
"Exporting segment id %s to Dolist-V8 succeeded","L'export du segment id %s vers Dolist-V8 s'est déroulé avec succès."
|
44 |
+
"Exporting segment id %s to Dolist-V8 failed","L'export du segment id %s vers Dolist-V8 a échoué."
|
45 |
+
"Segment id %s couldn\'t be loaded","Le segment id % n'a pas pu être chargé."
|
46 |
+
"Segment id %s has not been exported because it is empty","Le segment id %s n'a pas été exporté car il est vide."
|
47 |
+
"All already exported segments have been exported again successfully","Tous les segments déjà exportés ont été exportés à nouveau avec succès."
|
48 |
+
"Update customer segments failed","La mise à jour des segments client a échoué."
|
49 |
+
"Dolist V-8 customer exports","Exports des clients vers Dolist-V8"
|
50 |
+
"Full export","Export complet"
|
51 |
+
"Differential export","Export différentiel"
|
52 |
+
"Update customer segments","Mise à jour des segments client"
|
53 |
+
"Full export exportes all Magento contacts (newsletter subscribers) to Dolist-V8 platform.","L'export complet exporte tous les contacts Magento vers la plateforme Dolist-V8."
|
54 |
+
"Full export has been scheduled and will be performed next Cron crossing.","L'export complet a été programmé et sera exécuté au prochain passage du Cron"
|
55 |
+
"Differential export exports only Magento contacts modified from last full or differential export. At least one full export should have been performed.","L'export différentiel exporte uniquement les contacts Magento modifiés depuis le dernier export complet ou différentiel. Au moins un export complet doit avoir été réalisé."
|
56 |
+
"Differential export has been scheduled and will be performed next time Cron runs.","L'export différentiel a été programmé et sera exécuté au prochain passage du Cron."
|
57 |
+
"Exports again all already exported segments.","Exporte à nouveau tous les segments déjà exportés."
|
58 |
+
"Cannot update customer segments because no segment has been exported","Impossible de mettre à jour les segments clients car aucun segment n'a encore été exporté."
|
59 |
+
"At least one error occured while segment updating. Please watch logs to get more details.","Au moins une erreur est survenue au cours de la mise à jour des segments. Consultez les logs pour obtenir des détails sur le problème."
|
60 |
+
"Export this segment to Dolist-V8","Exporter ce segment vers Dolist-V8"
|
61 |
+
"Customer attributes","Attributs client"
|
62 |
+
"Calculated attributes","Attributs calculés"
|
63 |
+
"Order","Commande"
|
64 |
+
"Cart","Panier"
|
65 |
+
"Promotion","Promotion"
|
66 |
+
"Days number between the last two orders","Nombre de jours entre les deux dernières commandes"
|
67 |
+
"First order amount excluding tax","Montant de la première commande HT"
|
68 |
+
"First order amount including tax","Montant de la première commande TTC"
|
69 |
+
"Last order amount excluding tax","Montant de la dernière commande HT"
|
70 |
+
"Last order amount including tax","Montant de la dernière commande TTC"
|
71 |
+
"Total order amount excluding tax","Montant total des commandes HT"
|
72 |
+
"Total order amount including tax","Montant total des commandes TTC"
|
73 |
+
"Average order amount excluding tax","Montant moyen des commandes HT"
|
74 |
+
"Average order amount including tax","Montant moyen des commandes TTC"
|
75 |
+
"Average number of ordered products per order","Moyenne du nombre de produits commandés par commande"
|
76 |
+
"Average number of different products per order","Moyenne du nombre de produits différents par commande"
|
77 |
+
"Average number of product per order line","Moyenne du nombre de produits par ligne de commande"
|
78 |
+
"Total number of ordered products","Nombre de produits commandés total"
|
79 |
+
"Total number of orders","Nombre de commandes total"
|
80 |
+
"Last not ordered cart amount excluding tax","Montant du dernier panier non converti en commande HT"
|
81 |
+
"Last not ordered cart amount including tax","Montant du dernier panier non converti en commande TTC"
|
82 |
+
"Number of promotion rules used","Nombre de règles promotionnelles utilisées"
|
83 |
+
"First order date","Date de première commande"
|
84 |
+
"Last order date","Date de dernière commande"
|
85 |
+
"Last not ordered cart date","Date de dernier panier non commandé"
|
86 |
+
"Export again this segment to Dolist-V8","Exporter à nouveau ce segment vers Dolist-V8"
|
87 |
+
"Remove this segment from exported list","Cesser l'export de ce segment"
|
88 |
+
"Connection test refreshes Dolist-EMT template list","Le test de connexion rafraîchit la liste des gabarits Dolist-EMT"
|
89 |
+
"Save configuration before adding first template mapping","Sauvegarder la configuration avant d'ajouter des correspondances de gabarits"
|
90 |
+
"Magento customer attribute","Attribut client Magento"
|
91 |
+
"Dolist-V8 attribute name","Nom attribut Dolist-V8"
|
92 |
+
"Full export could not be scheduled.","L'export complet n'a pas pu être programmé."
|
93 |
+
"Another export is already running. Please try again later.","Un autre export est déjà lancé. Merci de réessayer plus tard."
|
94 |
+
"Dolist-V8 is not enabled for selected website.","Dolist-V8 n'est pas activé sur le site web sélectionné."
|
95 |
+
"Double check that group, custom str fields, custom int field and custom date fields do not share same value.","Vérifiez que les champs Groupe, Champs personnalisés texte, Champs personnalisés numérique et Champs personnalisés date ne partagent pas la même valeur."
|
96 |
+
"Account Id could not be retrieved or is null","L'identifiant de compte ne peut pas être retrouvé ou est NULL"
|
97 |
+
"Use magento native email system","Utiliser les envois natifs Magento"
|
98 |
+
"Export","Export"
|
99 |
+
"Full Export","Export Complet"
|
100 |
+
"Name:","Intitulé :"
|
101 |
+
"Started At","Commencé à"
|
102 |
+
"Ended At","Finis à"
|
103 |
+
"Ended At:","Finis à :"
|
104 |
+
"Result:","Résultat :"
|
105 |
+
"Progression:","Avancement :"
|
106 |
+
"Time period for calculated fields","Période de référence champs calculés"
|
107 |
+
"All datas","Toutes les données"
|
108 |
+
"From a specified start date","Depuis une date spécifique"
|
109 |
+
"Data since 1 month","1 mois glissant"
|
110 |
+
"Data since 3 months","3 mois glissants"
|
111 |
+
"Data since 6 months","6 mois glissants"
|
112 |
+
"Data since 12 months","12 mois glissants"
|
113 |
+
"Data since 24 months","24 mois glissants"
|
114 |
+
"Start date for calculated fields","Depuis le"
|
115 |
+
"Export non subscribed customer with existing order","Synchronisation des clients non abonnés"
|
116 |
+
"Export page size","Taille de la page d’export"
|
117 |
+
"Synchronize Custom Fields","Mettre à jour la liste des champs Dolist-V8"
|
118 |
+
"Dolist custom field has been successfully updated.","Liste des champs Dolist-V8 mise à jour"
|
119 |
+
"Saved.","Sauvegardé."
|
120 |
+
"Save","Sauvegarder"
|
121 |
+
"This key must be generated from your Dolist-EMT account, in section G.2. Webservices.","La clé doit être générée depuis votre espace Dolist-EMT, ADMINISTRATION Section A.2. Accès à l’API."
|
122 |
+
"Custom Fields","Association des Champs Dolist"
|
123 |
+
"Report Information","Information du rapport"
|
124 |
+
"Subscriber state of the customer","Etat d'inscription à la newsletter"
|
125 |
+
"When you choose “From a specified start date“ for the time period of calculated fields, you must provide a start date.","En choisissant “Depuis une date spécifique“ comme période de calcul, vous devez fournir la date de départ du calcul."
|
126 |
+
"At least one full export should have been perfomed before generating unsubscribe file.","Au moins un export complet doit avoir été réalisé avant de générer le fichier de désabonnement"
|
127 |
+
"Nothing to export","Aucune donnée à exporter"
|
128 |
+
"Starting differential customer export Store id : %s","Début de l'export différentiel pour le magasin : %s"
|
129 |
+
"Starting full customer export Store id : %s","Début de l'export complet pour le magasin : %s"
|
130 |
+
"Unable to contact Dolist API.","Impossible de joindre l'API Dolist."
|
131 |
+
"newsletter subscriber","abonne newsletter"
|
132 |
+
"not subscribed newsletter","non abonne newsletter"
|
133 |
+
"Completed with error","Terminé avec erreurs"
|
134 |
+
"Initializing","Initialisation"
|
135 |
+
"Starting","Démarrage"
|
136 |
+
"Working","En cours"
|
137 |
+
"Completed","Terminé"
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version='1.0' encoding='utf-8'?>
|
2 |
+
<package><name>Dolist_Net</name><license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license><notes>v2</notes><time>23:25:37</time><__packager>build_package.py v0.0.3</__packager><summary>Official extension for Dolist email marketing solution.</summary><stability>stable</stability><__commit_hash>638d7fe891a1f30b96c68221053b14178b38646c</__commit_hash><version>2.0.0.0</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="9116ca5966c127c3a065d3ccf991f6dd" name="dolist.xml" /></dir><dir name="template"><dir name="dolist"><file hash="05db7ca8032551aea167c573c06d0287" name="configuration.phtml" /><file hash="930ce49748a97b9bd3b0024cf08ba026" name="customerexport.phtml" /><dir name="store"><file hash="4100093e08cf4ce57c317ee017cba630" name="switcher.phtml" /></dir><dir name="system"><dir name="config"><dir name="dolistemt"><file hash="ba10b87cd51fef3d88a0dcf747d8b8dc" name="testconnection.phtml" /></dir><dir name="dolistv8"><file hash="a9b57b458cb1dfb83f0f5061be82f9f9" name="array.phtml" /><file hash="5c89a07ee29d11640870592c2edfc114" name="testconnection.phtml" /></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Dolist"><dir name="Net"><dir name="Block"><dir name="Adminhtml"><file hash="b5c65ae9b68d820870fb38e78e100265" name="Customerexport.php" /><file hash="fd8f4ad560d6777587a9ed90223c18c4" name="Edit.php" /><file hash="2e37abf70940f00b110279cef8b82280" name="Report.php" /><dir name="Customer"><file hash="8f6d9965be320c972d998f34171c4a5a" name="Edit.php" /></dir><dir name="Customersegment"><file hash="cf6a52e571dd475b96e93c00a8e2b5f0" name="Edit.php" /></dir><dir name="Edit"><file hash="057c9ee5853ea17801c990b42385fa5f" name="Form.php" /><file hash="45aba333e3e017601eff3a730e2991df" name="Tabs.php" /><dir name="Tab"><file hash="d93a56df1f7d60a8f4d275886f150ddf" name="Configuration.php" /><file hash="d1299519d583afd8b8afdad5ddafc326" name="Export.php" /><file hash="a55d01b5e4d114b20adef94f5dc503db" name="Report.php" /></dir></dir><dir name="System"><dir name="Config"><file hash="8393df0943d5575c31cb596c8d368ce6" name="Abstract.php" /><file hash="77b6b112b2492beb3dae124efe0b924a" name="Date.php" /><file hash="59fa9be3d71a648ab9d4dfe697d2e183" name="Enable.php" /><file hash="c62a40696ae0028b2908ed34768d8c2a" name="Switcher.php" /><file hash="883194919f569b7f49a12fd9d4f83082" name="Templatelist.php" /><dir name="Dolistemt"><file hash="9193591b22b093d9e5baaf83b0818ec8" name="Templatelist.php" /><file hash="4025ca1026614c48996c57112b25cf1c" name="Templatemapping.php" /><file hash="b95697d6fea9d16003f01b5a1f63db6a" name="Testconnection.php" /></dir><dir name="Dolistv8"><file hash="5be525c4398c036956d6489aa8fa582d" name="Attributelist.php" /><file hash="88336cf98961a1df4e23bf2de819c17d" name="Customdatefields.php" /><file hash="485252191fb609780609f7ec6b9d0fad" name="Customerattributelist.php" /><file hash="96a8428b3503291204d8922500e39210" name="Customintfields.php" /><file hash="2011749c69cae4968ded68dc4cce6945" name="Customstrfields.php" /><file hash="cb016b986834178808cad7dd9c8d96c2" name="Testconnection.php" /></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file hash="dfce7888c77d8513b57e7350b34127fc" name="CustomerdolistController.php" /><dir name="System"><dir name="Config"><file hash="78864e5c011d2cd191f8cca803c74614" name="TestconnectionController.php" /></dir></dir></dir></dir><dir name="etc"><file hash="1f9d77e2b9f8e4b86f54f272eb213218" name="adminhtml.xml" /><file hash="275449ca9555ab7ab6cd9af6e1894b5e" name="config.xml" /><file hash="f0d6b4651431d1d11532fe9402fc5003" name="system.xml" /></dir><dir name="Helper"><file hash="1af278791380d5f544dcaa12cc66232a" name="Data.php" /><file hash="1d28b2acc7b47c17bb17af60e60c891d" name="Log.php" /><file hash="46b027b6f19b5a4ba72e1e992ac95269" name="Queue.php" /></dir><dir name="Model"><file hash="61da7cc29853bb9ce85b0bb587545c99" name="Customersegment.php" /><file hash="f305a9fa398d5069c68e8bd0fabc0f8a" name="Observer.php" /><file hash="df11dd8d15b4603d5434fabf9cbf1d0e" name="Reports.php" /><file hash="cd29bbe57089f7b674814be48463d16a" name="Service.php" /><dir name="Adminhtml"><file hash="c50d803637b3b679e1d944ed882c201e" name="Observer.php" /><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Serialized"><file hash="ce8002b5ba1bd19901b5de4db7200672" name="Array.php" /></dir></dir><dir name="Source"><file hash="d594a5df0ec9c76ca0f55ac0c4422f56" name="Timeperiods.php" /></dir></dir></dir></dir><dir name="Dolistemt"><file hash="67917ea713604769bdc5e348d04830b4" name="Template.php" /><dir name="Email"><file hash="7e39b7cdc9a6f62c784937317d344d0b" name="Template.php" /></dir><dir name="Message"><file hash="3dd939ec132047606cc1f322677bcc1c" name="Queued.php" /></dir></dir><dir name="Dolistv8"><file hash="c15976cfb0b7a5805e724f11f89fe417" name="Calculatedfields.php" /><file hash="b1d4006ddf6c62b46bcadeb6a6b56fc0" name="Customfields.php" /><file hash="6a91b08ff749b635ffaff68a267cee53" name="Ftp.php" /></dir><dir name="Exporter"><file hash="010c818b65be9e51519e476d59c5e735" name="Csv.php" /><dir name="Adapter"><file hash="f209e2d5c522c751e7047f8102e2fe97" name="Date.php" /><file hash="66b2ee18bdf3924011a068f936b8818a" name="Default.php" /><file hash="797f1a935a1f8e1a9ce213d6cf03c235" name="Int.php" /></dir></dir><dir name="Mysql4"><file hash="7a3a3de6ef2fd144c192ef60357e370f" name="Reports.php" /><dir name="Dolistemt"><file hash="f972ef82ba3003da8d849e60df044440" name="Template.php" /><dir name="Message"><file hash="466461ebec5e905d89659698a21ed0ed" name="Queued.php" /><dir name="Queued"><file hash="1b0ed0a91ecd7fb5941c694221d12578" name="Collection.php" /></dir></dir><dir name="Template"><file hash="7b845449076c1dfaee11a7b04cb50400" name="Collection.php" /></dir></dir><dir name="Dolistv8"><file hash="255c05052b1a4371193d6174ea9a8a94" name="Calculatedfields.php" /><file hash="0c66d48562faaa3641a190becc66f618" name="Customfields.php" /><dir name="Calculatedfields"><file hash="106dc6dd921c134378002992e4d94e08" name="Collection.php" /></dir><dir name="Customfields"><file hash="93a52bb46b05487e79471448b46ca51e" name="Collection.php" /></dir><dir name="Export"><dir name="Adapter"><file hash="5797a9663e5b3def46752f554aa6d55e" name="Abstract.php" /><file hash="83d064b83909ac3a4421d474397b5029" name="Address1.php" /><file hash="b9dc124ff88ecbaa750e580f97b246f2" name="Address2.php" /><file hash="b87316bf23926e93485b6868323f88a4" name="Address3.php" /><file hash="75e243f2a3526955ea7d94cad4798ec2" name="City.php" /><file hash="b2372fe91c4a61bd81549fbee4722e85" name="Company.php" /><file hash="176e3a58ab1371ffd87a8dd41ff6231b" name="Country.php" /><file hash="a47e3ada99704b2cfebd7ed151d39762" name="Default.php" /><file hash="a96d9b7d0d6e810533df36901e0dc7ac" name="Fax.php" /><file hash="f044aed5b697abb4b5b7722307413fef" name="Phone.php" /><file hash="1a84be76756c8b6e550a683301bf455f" name="Postcode.php" /><dir name="Date"><file hash="cf2f0078ea3cbc3de1ccb0e07b29bfec" name="Default.php" /><file hash="5e90b0c82c4c462d4c54354d4ded91eb" name="Firstorder.php" /><file hash="918c1394a1079430b1805d424766d057" name="Lastorder.php" /><file hash="0e27cb7666aa7d95c0208e86bf29f15c" name="Lastquotenotordered.php" /></dir><dir name="Int"><file hash="d7f2bf25cde508f18ef3591aa9b7239d" name="Avgnbdifferentproductsperorder.php" /><file hash="0e7cef58f9745684107006c1f19c3c18" name="Avgnbdifferentproductsperorderline.php" /><file hash="1072246ffeaaf5c65b2c44a831a9197c" name="Avgnbproductsperorder.php" /><file hash="01676e283d4796cb156d8e7ca9443f8b" name="Avgorderamountexcltax.php" /><file hash="aaa1d0f0019ded333b6f01c29ca30484" name="Avgorderamountincltax.php" /><file hash="695e7ca8c23c38962257db17c5de17f9" name="Firstorderamountexcltax.php" /><file hash="121c81d6629a62e03845391b263fc21a" name="Firstorderamountincltax.php" /><file hash="5e1363c976eb7cc14f3ca64ff1de9d1a" name="Lastnotorderedcartamountexcltax.php" /><file hash="383b2b6d23e6073c1719fcdda44f63fb" name="Lastnotorderedcartamountincltax.php" /><file hash="4ae1b5a8956d432aa224a07d39eda15b" name="Lastorderamountexcltax.php" /><file hash="0db2ba5e1f4a36aca38b003ba88daf3d" name="Lastorderamountincltax.php" /><file hash="c32efb9a18ad8f6645a940c9bd925c6c" name="Nbpromotionrulesused.php" /><file hash="b2d30d69093ac1e1971de239f2294414" name="Totalorderamountexcltax.php" /><file hash="fe7a821618d817fff93eb23a6e162c4c" name="Totalorderamountincltax.php" /><file hash="b203fbd80b38d7dd974fddb042661af0" name="Totalorderedproducts.php" /><file hash="d8fea3d3d98cd4ade81931d72b7eba0c" name="Totalorders.php" /></dir></dir></dir></dir><dir name="Reports"><file hash="3ec7cc4fd35c539db1411cbe0bf98a25" name="Collection.php" /></dir></dir><dir name="Service"><dir name="Dolistemt"><dir name="Request"><file hash="bfe76bef2f1301562f9003cacd82b5b1" name="Getauthenticationtoken.php" /><file hash="f08c835bbcb6ca69daf2bdeaaea28a4c" name="Gettemplatelist.php" /><file hash="06062e2ccf54c189874000d50d909de6" name="SendEmail.php" /></dir><dir name="Response"><file hash="387210c798ed818d410ac7a62a8f7a08" name="Getauthenticationtoken.php" /><file hash="ab3db8a6a1bc1e38dc163c28f64f9612" name="Gettemplatelist.php" /><file hash="45d3740fe05ecd90bf722b19725ad7d8" name="SendEmail.php" /></dir></dir><dir name="Dolistv8"><dir name="Request"><file hash="55a56a710b88398c99f1aaeb01816976" name="Createimport.php" /><file hash="af14961d044f007696452307b9f7a89e" name="Getauthenticationtoken.php" /><file hash="d085194dc5f599884969de6f5cc32f9d" name="Getcontact.php" /><file hash="d710c9e4d512a929e4aa2a0c32d1becc" name="Getfieldlist.php" /></dir><dir name="Response"><file hash="93e32967b4c1ba7ae0981023e49f9471" name="Createimport.php" /><file hash="5f14b532c12728495b6163092bce1003" name="Getauthenticationtoken.php" /><file hash="59c766c7fefe70fb1e18571f8904942a" name="Getcontact.php" /><file hash="1ab5aef6b09f671a382d5eef5a182bce" name="Getfieldlist.php" /></dir></dir><dir name="Message"><file hash="e10bee52c6cebf4ccd4c93a41afe5ae0" name="Abstract.php" /></dir></dir><dir name="System"><dir name="Config"><file hash="b64b291b560a8522094c203333cadae6" name="Check.php" /><dir name="Source"><file hash="3d7e993ac25b0ade883df78a9ef97b19" name="Group.php" /><dir name="Dolistemt"><file hash="de59edbfbae9db377ff561a49fcb8ff5" name="Defaulttemplate.php" /><file hash="6fe1abcf43f76468eaea0e3616584243" name="Errors.php" /><file hash="8debc19194b97203394b012b0258ac91" name="Template.php" /></dir><dir name="Dolistv8"><file hash="081e4f0dea584a9d4ff435069190671a" name="Customerattributelist.php" /><file hash="10485fb8f6477d5a55c2b8ddcd4c9d02" name="Customfield.php" /></dir><dir name="Email"><file hash="e5af986543b65db2684e4a62a3967a89" name="Template.php" /></dir></dir></dir></dir></dir><dir name="sql"><dir name="dolist_setup"><file hash="dfd2ee346a310bb35daafbe68c4794a3" name="mysql4-install-0.0.1.0.php" /><file hash="f073c48493bc6a0b9a58faec608c870c" name="mysql4-upgrade-0.0.1.0-0.0.1.1.php" /><file hash="cd2920e566d6733b9688720416ed5211" name="mysql4-upgrade-0.0.1.1-0.0.2.0.php" /><file hash="33db9c1fa136d893692a73e1b670caff" name="mysql4-upgrade-0.0.2.0-0.0.3.0.php" /><file hash="8b8d0544161894ab0c9ae56a5d2cca8c" name="mysql4-upgrade-0.0.3.0-0.0.4.0.php" /><file hash="afc7e28dd865ab008376ab58453a3221" name="mysql4-upgrade-0.0.4.0-0.0.5.0.php" /><file hash="33f55ec12f8b0481320491bfb71da3b1" name="mysql4-upgrade-0.0.5.0-0.0.6.0.php" /></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file hash="5c3a5d77ce534894afdaaabde6ef6af7" name="Dolist_Net.csv" /></dir></target><target name="magelocal"><dir name="modules"><file hash="73c963262d3cb6831bf1240a165b215e" name="Dolist_Net.xml" /></dir></target></contents><dependencies><required><php><min>5.3.2</min><max>5.6.0</max></php></required></dependencies><authors><author><name>Dolist</name><user>Dolist</user><email>magento@dolist.net</email></author></authors><date>2014-12-16</date><compatibile /><channel>community</channel><description>&lt;p&gt;Take simultaneous advantage from both Magento's Community Edition or Enterprise
|
3 |
+
Edition and Dolist's e-mail marketing platforms power. Dolist-V8 for e-mail marketing campaigns and
|
4 |
+
Dolist-EMT for
|
5 |
+
transactional messages in order to optimize both your prospects and customers relationship.&lt;/p&gt;&#xD;
|
6 |
+
&lt;ul&gt;&#xD;
|
7 |
+
&lt;li&gt;Have Dolist-V8 and Dolist-EMT platforms safely work together with your e-commerce solution
|
8 |
+
through an
|
9 |
+
API and retrieve the whole of the updated data within your Magento environment.&lt;/li&gt;&#xD;
|
10 |
+
&lt;li&gt;Use Dolist's platforms deliverability potential to better optimize and manage the actual
|
11 |
+
delivery
|
12 |
+
of your e-mail campaigns.&lt;/li&gt;&#xD;
|
13 |
+
&lt;li&gt;Turn your e-mail campaigns and transactional messages into powerful marketing tools thanks to
|
14 |
+
Dolist's
|
15 |
+
platforms customization capabilities (languages&#x200B;&#x200B;, formats, variables, dynamic content,
|
16 |
+
cross/up-selling ...).&lt;/li&gt;&#xD;
|
17 |
+
&lt;li&gt;Simply setup the open source Dolist for Magento API connector and make it suit your very
|
18 |
+
needs.&lt;/li&gt;&#xD;
|
19 |
+
&lt;/ul&gt;
|
20 |
+
</description></package>
|