Sarbacane_Sarbacanedesktop - Version 1.0.0.8

Version Notes

We improved performance on synchronization.
It should be more efficient and nearly instant on most websites.

Download this release

Release Info

Developer Sarbacane Software
Extension Sarbacane_Sarbacanedesktop
Version 1.0.0.8
Comparing to
See all releases


Code changes from version 1.0.0.7 to 1.0.0.8

Files changed (22) hide show
  1. app/code/community/Sarbacane/Sarbacanedesktop/Block/Adminhtml/Sarbacanedesktop.php +1 -2
  2. app/code/community/Sarbacane/Sarbacanedesktop/Helper/Data.php +187 -119
  3. app/code/community/Sarbacane/Sarbacanedesktop/Model/Observer.php +155 -0
  4. app/code/community/Sarbacane/Sarbacanedesktop/controllers/Adminhtml/SarbacanedesktopController.php +118 -94
  5. app/code/community/Sarbacane/Sarbacanedesktop/controllers/IndexController.php +497 -348
  6. app/code/community/Sarbacane/Sarbacanedesktop/etc/config.xml +139 -125
  7. app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-install-1.0.0.0.php +0 -52
  8. app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.0-1.0.0.1.php +0 -25
  9. app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.1-1.0.0.2.php +0 -25
  10. app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.2-1.0.0.3.php +0 -25
  11. app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.3-1.0.0.4.php +0 -87
  12. app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.7-1.0.0.8.php +113 -0
  13. app/design/adminhtml/default/default/layout/sarbacanedesktop.xml +6 -6
  14. app/design/adminhtml/default/default/template/sarbacanedesktop/sarbacanedesktop.phtml +260 -244
  15. app/etc/modules/Sarbacane_Sarbacanedesktop.xml +1 -1
  16. app/locale/en_US/Sarbacane_Sarbacanedesktop.csv +4 -2
  17. app/locale/fr_FR/Sarbacane_Sarbacanedesktop.csv +5 -3
  18. package.xml +7 -7
  19. skin/adminhtml/default/default/images/{sd.png → sarbacanedesktop.png} +0 -0
  20. skin/adminhtml/default/default/js/Sarbacane_SarbacaneDesktop/sarbacanedesktop.js +0 -95
  21. skin/adminhtml/default/default/{css/Sarbacane_SarbacaneDesktop/sarbacanedesktop.css → sarbacanedesktop.css} +4 -6
  22. skin/adminhtml/default/default/sarbacanedesktop.js +74 -0
app/code/community/Sarbacane/Sarbacanedesktop/Block/Adminhtml/Sarbacanedesktop.php CHANGED
@@ -18,8 +18,7 @@
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
-
22
  class Sarbacane_Sarbacanedesktop_Block_Adminhtml_Sarbacanedesktop extends Mage_Adminhtml_Block_Template
23
  {
24
 
25
- }
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
 
21
  class Sarbacane_Sarbacanedesktop_Block_Adminhtml_Sarbacanedesktop extends Mage_Adminhtml_Block_Template
22
  {
23
 
24
+ }
app/code/community/Sarbacane/Sarbacanedesktop/Helper/Data.php CHANGED
@@ -18,133 +18,201 @@
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
-
22
  class Sarbacane_Sarbacanedesktop_Helper_Data extends Mage_Core_Helper_Abstract
23
  {
24
 
25
- public function getStoresArray()
26
- {
27
- $stores = Mage::app()->getStores();
28
- $stores_array = array();
29
- foreach ($stores as $store) {
30
- $stores_array[] = array('store_id' => $store->store_id, 'store_name' => $store->name);
31
- }
32
- return $stores_array;
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- public function getStoreidFromList($list)
36
- {
37
- if (substr($list, -1) == 'N' || substr($list, -1) == 'C') {
38
- return substr($list, 0, -1);
39
- } else {
40
- return substr($list, 0, -2);
41
- }
42
- }
 
 
 
 
 
 
 
43
 
44
- public function getListTypeFromList($list)
45
- {
46
- if (substr($list, -1) == 'N' || substr($list, -1) == 'C') {
47
- return substr($list, -1);
48
- } else {
49
- return substr($list, -2, 1);
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- public function getListTypeArray()
54
- {
55
- return array('N', 'C');
56
- }
 
 
 
 
 
 
 
57
 
58
- public function getListConfiguration($return = 'string')
59
- {
60
- $sd_list = $this->getConfiguration('sd_list');
61
- if ($return == 'string') {
62
- return $sd_list;
63
- } else {
64
- if (strlen($sd_list) != 0) {
65
- return explode(',', $sd_list);
66
- }
67
- return array();
68
- }
69
- }
70
 
71
- public function resetList($list_id = '')
72
- {
73
- $id_shop = $this->getStoreidFromList($list_id);
74
- $list_type = $this->getListTypeFromList($list_id);
75
-
76
- $resource = Mage::getSingleton('core/resource');
77
- $db_write = $resource->getConnection('core_write');
78
- $sarbacanedesktop = $resource->getTableName('sarbacanedesktop_users');
79
- $rq_sql = '
80
- DELETE FROM `' . $sarbacanedesktop . '`
81
- WHERE `sd_type` = "sd_id"
82
- AND `list_id` = ' . $db_write->quote($id_shop.$list_type);
83
- $db_write->query($rq_sql);
84
- }
 
 
 
 
 
 
85
 
86
- public function getToken()
87
- {
88
- $str = $this->getConfiguration('sd_token');
89
- $str = $str . substr(Mage::helper('core')->encrypt('SecurityTokenForModule'), 0, 11) . $str;
90
- $str = md5($str);
91
- return $str;
92
- }
 
 
 
 
 
 
 
 
 
 
 
93
 
94
- public function getConfiguration($return = 'nb_configured')
95
- {
96
- $resource = Mage::getSingleton('core/resource');
97
- $db_read = $resource->getConnection('core_read');
98
- $sarbacanedesktop_users = $resource->getTableName('sarbacanedesktop_users');
99
- $rq_sql = '
100
- SELECT *
101
- FROM `' . $sarbacanedesktop_users . '`
102
- WHERE `sd_type` = \'sd_token\'
103
- OR `sd_type` = \'sd_list\'';
104
- $rq = $db_read->query($rq_sql);
105
- $sd_token = '';
106
- $sd_list = '';
107
- while ($r = $rq->fetch()) {
108
- if ($r['sd_type'] == 'sd_token') {
109
- $sd_token = $r['sd_value'];
110
- }
111
- else if ($r['sd_type'] == 'sd_list') {
112
- $sd_list = $r['sd_value'];
113
- }
114
- }
115
- if ($return == 'sd_token' || $return == 'sd_list') {
116
- if ($return == 'sd_token') {
117
- return $sd_token;
118
- }
119
- else if ($return == 'sd_list') {
120
- return $sd_list;
121
- }
122
- } else {
123
- if ($return == 'all') {
124
- return array(
125
- 'sd_token' => $sd_token,
126
- 'sd_list' => $sd_list
127
- );
128
- } else {
129
- $nb_configured = 0;
130
- if ($sd_token != '') {
131
- $nb_configured++;
132
- }
133
- if ($sd_list != '') {
134
- $nb_configured++;
135
- }
136
- return $nb_configured;
137
- }
138
- }
139
- }
140
-
141
- public function deleteSdid($sd_id){
142
- $resource = Mage::getSingleton('core/resource');
143
- $db_write = $resource->getConnection('core_write');
144
- $sarbacanedesktop_users = $resource->getTableName('sarbacanedesktop_users');
145
-
146
- $rq_sql = 'DELETE FROM '.$sarbacanedesktop_users.' WHERE sd_value = "'.$sd_id.'" AND sd_type="sd_id"';
147
- $db_write->query($rq_sql);
148
- }
149
 
150
- }
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
 
21
  class Sarbacane_Sarbacanedesktop_Helper_Data extends Mage_Core_Helper_Abstract
22
  {
23
 
24
+ public function getShopsArray()
25
+ {
26
+ $shops = Mage::app()->getStores();
27
+ $shops_array = array();
28
+ foreach ($shops as $shop) {
29
+ $shops_array[] = array(
30
+ 'store_id' => $shop->store_id,
31
+ 'name' => $shop->name
32
+ );
33
+ }
34
+ $shops_array[] = array(
35
+ 'store_id' => '0',
36
+ 'name' => $this->__('Other')
37
+ );
38
+ return $shops_array;
39
+ }
40
+
41
+ public function getIdShopFromList($list)
42
+ {
43
+ if (substr($list, -1) == 'N' || substr($list, -1) == 'C') {
44
+ return substr($list, 0, -1);
45
+ } else {
46
+ return substr($list, 0, -2);
47
+ }
48
+ }
49
+
50
+ public function getListTypeFromList($list)
51
+ {
52
+ if (substr($list, -1) == 'N' || substr($list, -1) == 'C') {
53
+ return substr($list, -1);
54
+ } else {
55
+ return substr($list, -2, 1);
56
+ }
57
+ }
58
+
59
+ public function getListTypeArray()
60
+ {
61
+ return array('N', 'C');
62
+ }
63
+
64
+ public function getListConfiguration($return = 'string')
65
+ {
66
+ $sd_list = $this->getConfiguration('sd_list');
67
+ if ($return == 'string') {
68
+ return $sd_list;
69
+ } else {
70
+ if (strlen($sd_list) != 0) {
71
+ return explode(',', $sd_list);
72
+ }
73
+ return array();
74
+ }
75
+ }
76
 
77
+ public function getToken()
78
+ {
79
+ $str = $this->getConfiguration('sd_token');
80
+ $str = explode('-', $str);
81
+ $token = '';
82
+ foreach ($str as $key => $s) {
83
+ if ($key == 0) {
84
+ $token = $s . substr(Mage::helper('core')->encrypt('SecurityTokenForModule'), 0, 11) . $s;
85
+ $token = md5($token);
86
+ }else {
87
+ $token .= $s;
88
+ }
89
+ }
90
+ return $token;
91
+ }
92
 
93
+ public function getConfiguration($return = 'nb_configured')
94
+ {
95
+ $sd_configuration_loaded = false;
96
+ if (isset($this->sd_configuration)) {
97
+ if (isset($this->sd_configuration['sd_token']) && isset($this->sd_configuration['sd_list'])
98
+ && isset($this->sd_configuration['sd_is_user']) && isset($this->sd_configuration['sd_last_update'])
99
+ && isset($this->sd_configuration['sd_nb_failed'])) {
100
+ $sd_configuration_loaded = true;
101
+ }
102
+ }
103
+ if ( ! $sd_configuration_loaded) {
104
+ $resource = Mage::getSingleton('core/resource');
105
+ $db_read = $resource->getConnection('core_read');
106
+ $sd_data = $resource->getTableName('sd_data');
107
+ $sd_configuration = array(
108
+ 'sd_token' => '',
109
+ 'sd_list' => '',
110
+ 'sd_is_user' => '',
111
+ 'sd_last_update' => '',
112
+ 'sd_nb_failed' => 0
113
+ );
114
+ $rq_sql = '
115
+ SELECT *
116
+ FROM `' . $sd_data . '`
117
+ WHERE `sd_type` IN (\'sd_token\', \'sd_list\', \'sd_is_user\', \'sd_last_update\', \'sd_nb_failed\')';
118
+ $rq = $db_read->query($rq_sql);
119
+ while ($r = $rq->fetch()) {
120
+ $sd_configuration[$r['sd_type']] = $r['sd_value'];
121
+ }
122
+ $sd_configuration['sd_nb_failed'] = (int)$sd_configuration['sd_nb_failed'];
123
+ $this->sd_configuration = $sd_configuration;
124
+ }
125
+ if ($return == 'sd_token' || $return == 'sd_list' || $return == 'sd_is_user' || $return == 'sd_last_update' || $return == 'sd_nb_failed') {
126
+ return $this->sd_configuration[$return];
127
+ } else {
128
+ if ($return == 'all') {
129
+ return $this->sd_configuration;
130
+ } else {
131
+ $nb_configured = 0;
132
+ if ($this->sd_configuration['sd_token'] != '') {
133
+ $nb_configured = 3;
134
+ } else {
135
+ if ($this->sd_configuration['sd_list'] != '') {
136
+ $nb_configured++;
137
+ }
138
+ if ($this->sd_configuration['sd_is_user'] != '') {
139
+ $nb_configured++;
140
+ }
141
+ }
142
+ return $nb_configured;
143
+ }
144
+ }
145
+ }
146
 
147
+ public function updateConfiguration($name, $value) {
148
+ $resource = Mage::getSingleton('core/resource');
149
+ $db_write = $resource->getConnection('core_write');
150
+ $sd_data = $resource->getTableName('sd_data');
151
+ $rq_sql = '
152
+ UPDATE `' . $sd_data . '`
153
+ SET `sd_value` = ' . $db_write->quote($value) . '
154
+ WHERE `sd_type` = ' . $db_write->quote($name);
155
+ $db_write->query($rq_sql);
156
+ unset($this->sd_configuration);
157
+ }
158
 
159
+ public function deleteSdid($sd_id)
160
+ {
161
+ $resource = Mage::getSingleton('core/resource');
162
+ $db_write = $resource->getConnection('core_write');
163
+ $sd_users = $resource->getTableName('sd_users');
164
+ $rq_sql = '
165
+ DELETE
166
+ FROM `' . $sd_users . '`
167
+ WHERE `sd_id` = ' . $db_write->quote($sd_id);
168
+ $db_write->query($rq_sql);
169
+ }
 
170
 
171
+ public function checkNeedUserInsertSdUpdates($store_id, $list_type)
172
+ {
173
+ $sd_list_array = $this->getListConfiguration('array');
174
+ $sd_list_string = implode(',', $sd_list_array);
175
+ if (strpos($sd_list_string, $list_type) === false) {
176
+ return false;
177
+ }
178
+ if ($list_type == 'N') {
179
+ $in_array = in_array($store_id . 'N0', $sd_list_array);
180
+ } else {
181
+ $in_array = in_array($store_id . 'C0', $sd_list_array) || in_array($store_id . 'C1', $sd_list_array);
182
+ }
183
+ if ($in_array) {
184
+ $sd_synchronized_lists_array = $this->getSynchronizedListsArray();
185
+ if (in_array($store_id . $list_type, $sd_synchronized_lists_array)) {
186
+ return true;
187
+ }
188
+ }
189
+ return false;
190
+ }
191
 
192
+ public function getSynchronizedListsArray() {
193
+ if ( ! isset($this->sd_synchronized_lists_array)) {
194
+ $resource = Mage::getSingleton('core/resource');
195
+ $db_read = $resource->getConnection('core_read');
196
+ $sd_users = $resource->getTableName('sd_users');
197
+ $sd_synchronized_lists_array = array();
198
+ $rq_sql = '
199
+ SELECT `list_id`
200
+ FROM `' . $sd_users . '`
201
+ GROUP BY `list_id`';
202
+ $rq = $db_read->query($rq_sql);
203
+ while ($r = $rq->fetch()) {
204
+ $sd_synchronized_lists_array[] = $r['list_id'];
205
+ }
206
+ $this->sd_synchronized_lists_array = $sd_synchronized_lists_array;
207
+ }
208
+ return $this->sd_synchronized_lists_array;
209
+ }
210
 
211
+ public function checkFailed() {
212
+ if ($this->getConfiguration('sd_nb_failed') < 1000000) {
213
+ return false;
214
+ }
215
+ return true;
216
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
+ }
app/code/community/Sarbacane/Sarbacanedesktop/Model/Observer.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Sarbacane
16
+ * @package Sarbacane_Sarbacanedesktop
17
+ * @author Sarbacane Software <contact@sarbacane.com>
18
+ * @copyright 2015 Sarbacane Software
19
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
+ */
21
+ class Sarbacane_Sarbacanedesktop_Model_Observer
22
+ {
23
+
24
+ public function customerSave(Varien_Event_Observer $observer)
25
+ {
26
+ try {
27
+ if (Mage::app()->getRequest()->getActionName() != 'saveOrder') {
28
+ $old_data = $observer->getCustomer()->getOrigData();
29
+ $new_data = $observer->getCustomer()->getData();
30
+ if (isset($old_data['email']) && isset($new_data['email']) && isset($old_data['store_id']) && isset($new_data['store_id']) && isset($old_data['website_id']) && isset($new_data['website_id'])) {
31
+ $old_website_id = $old_data['website_id'];
32
+ $new_website_id = $new_data['website_id'];
33
+ if ($old_website_id != 0 || $new_website_id != 0) {
34
+ $old_email = $old_data['email'];
35
+ $new_email = $new_data['email'];
36
+ $old_store_id = $old_data['store_id'];
37
+ $new_store_id = $new_data['store_id'];
38
+ if ($old_email != $new_email || $old_store_id != $new_store_id) {
39
+ $now = gmdate('Y-m-d H:i:s');
40
+ $this->userInsertSdUpdatesIfNecessary($old_email, $old_store_id, 'C', 'U', $now);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ catch(Exception $e) {}
47
+ }
48
+
49
+ public function customerDelete(Varien_Event_Observer $observer)
50
+ {
51
+ try {
52
+ $data = $observer->getCustomer()->getData();
53
+ if (isset($data['email']) && isset($data['entity_id']) && isset($data['store_id']) && isset($data['website_id'])) {
54
+ $website_id = $data['website_id'];
55
+ if ($website_id != 0) {
56
+ $email = $data['email'];
57
+ $store_id = $data['store_id'];
58
+ $now = gmdate('Y-m-d H:i:s');
59
+ $this->userInsertSdUpdatesIfNecessary($email, $store_id, 'C', 'U', $now);
60
+ }
61
+ }
62
+ }
63
+ catch(Exception $e) {}
64
+ }
65
+
66
+ public function newsletterSubscriberSave(Varien_Event_Observer $observer)
67
+ {
68
+ try {
69
+ $action_name = Mage::app()->getRequest()->getActionName();
70
+ if ($action_name != 'saveOrder') {
71
+ $data = $observer->getSubscriber()->getData();
72
+ if (isset($data['subscriber_email']) && isset($data['store_id']) && isset($data['subscriber_status'])) {
73
+ $new_email = $data['subscriber_email'];
74
+ $new_store_id = $data['store_id'];
75
+ $new_status = $data['subscriber_status'];
76
+ if ($new_status == '1' || $new_status == '3') {
77
+ $now = gmdate('Y-m-d H:i:s');
78
+ $mass_unsubscribe_subscribers = false;
79
+ if ($action_name == 'massUnsubscribe') {
80
+ if (Mage::app()->getRequest()->getParam('subscriber')) {
81
+ $mass_unsubscribe_subscribers = true;
82
+ }
83
+ }
84
+ if ($mass_unsubscribe_subscribers) {
85
+ $this->userInsertSdUpdatesIfNecessary($new_email, $new_store_id, 'N', 'U', $now);
86
+ } else {
87
+ if (isset($data['subscriber_id'])) {
88
+ $resource = Mage::getSingleton('core/resource');
89
+ $db_read = $resource->getConnection('core_read');
90
+ $newsletter_subscriber = $resource->getTableName('newsletter_subscriber');
91
+ $rq_sql = '
92
+ SELECT `subscriber_email`, `store_id`, `subscriber_status`
93
+ FROM `' . $newsletter_subscriber . '`
94
+ WHERE `subscriber_id` = ' . (int)$data['subscriber_id'];
95
+ $rq = $db_read->query($rq_sql);
96
+ while ($r = $rq->fetch()) {
97
+ $old_email = $r['subscriber_email'];
98
+ $old_store_id = $r['store_id'];
99
+ $old_status = $r['subscriber_status'];
100
+ if ($old_email != $new_email || $old_store_id != $new_store_id) {
101
+ if ($old_status == '1') {
102
+ $this->userInsertSdUpdatesIfNecessary($old_email, $old_store_id, 'N', 'U', $now);
103
+ }
104
+ } else {
105
+ if ($old_status == '1' && $new_status == '3') {
106
+ $this->userInsertSdUpdatesIfNecessary($new_email, $new_store_id, 'N', 'U', $now);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ if ($new_status == '1') {
112
+ $this->userInsertSdUpdatesIfNecessary($new_email, $new_store_id, 'N', 'S', $now);
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ catch(Exception $e) {}
120
+ }
121
+
122
+ public function newsletterSubscriberDelete(Varien_Event_Observer $observer)
123
+ {
124
+ try {
125
+ $data = $observer->getSubscriber()->getData();
126
+ if (isset($data['subscriber_email']) && isset($data['store_id']) && isset($data['subscriber_status'])) {
127
+ $subscriber_email = $data['subscriber_email'];
128
+ $store_id = $data['store_id'];
129
+ $subscriber_status = $data['subscriber_status'];
130
+ if ($subscriber_status == '1') {
131
+ $now = gmdate('Y-m-d H:i:s');
132
+ $this->userInsertSdUpdatesIfNecessary($subscriber_email, $store_id, 'N', 'U', $now);
133
+ }
134
+ }
135
+ }
136
+ catch(Exception $e) {}
137
+ }
138
+
139
+ private function userInsertSdUpdatesIfNecessary($email, $store_id, $list_type, $action, $now)
140
+ {
141
+ if (Mage::helper('sarbacanedesktop')->checkNeedUserInsertSdUpdates($store_id, $list_type)) {
142
+ $resource = Mage::getSingleton('core/resource');
143
+ $db_write = $resource->getConnection('core_write');
144
+ $sd_updates = $resource->getTableName('sd_updates');
145
+ $rq_sql = '
146
+ INSERT INTO `' . $sd_updates . '` VALUES
147
+ (' . $db_write->quote($email) . ', ' . (int)$store_id . ', ' . $db_write->quote($list_type) . ', ' . $db_write->quote($action) . ', ' . $db_write->quote($now) . ')
148
+ ON DUPLICATE KEY UPDATE
149
+ `action` = VALUES(`action`),
150
+ `update_date` = VALUES(`update_date`)';
151
+ $db_write->query($rq_sql);
152
+ }
153
+ }
154
+
155
+ }
app/code/community/Sarbacane/Sarbacanedesktop/controllers/Adminhtml/SarbacanedesktopController.php CHANGED
@@ -18,103 +18,127 @@
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
-
22
  class Sarbacane_Sarbacanedesktop_Adminhtml_SarbacanedesktopController extends Mage_Adminhtml_Controller_Action
23
  {
24
 
25
- public function indexAction(){
26
- if (Mage::app()->getRequest()->getParam('submit_configuration') || Mage::app()->getRequest()->getParam('submit_parameter_key')) {
27
- if (Mage::app()->getRequest()->getParam('submit_configuration')) {
28
- $this->saveListConfiguration();
29
- if (Mage::helper('sarbacanedesktop')->getConfiguration('sd_token') == '') {
30
- $this->saveTokenParameterConfiguration();
31
- }
32
- $this->_getSession()->addSuccess($this->__('Your settings have been saved'));
33
- }
34
- else if (Mage::app()->getRequest()->getParam('submit_parameter_key')) {
35
- $this->saveTokenParameterConfiguration();
36
- $this->_getSession()->addSuccess($this->__('Your settings have been saved'));
37
- }
38
- }
39
-
40
- $this->loadLayout();
41
- $block = $this->getLayout()->getBlock('sarbacanedesktop');
42
- $block->setSdFormKey($this->getSdFormKey());
43
- $block->setKeyForSynchronisation($this->getKeyForSynchronisation());
44
- $block->setListConfiguration(Mage::helper('sarbacanedesktop')->getListConfiguration('array'));
45
- $block->setGeneralConfiguration(Mage::helper('sarbacanedesktop')->getConfiguration('nb_configured'));
46
- $block->setStoresArray(Mage::helper('sarbacanedesktop')->getStoresArray());
47
- if(Mage::app()->getRequest()->getParam("sd_is_user")){
48
- Mage::getSingleton("core/session")->setData("sd_is_user",Mage::app()->getRequest()->getParam("sd_is_user"));
49
- }
50
- $this->_title($this->__('Sarbacane Desktop'));
51
- $this->_setActiveMenu('newsletter');
52
- $this->renderLayout();
53
- }
54
-
55
- private function saveListConfiguration()
56
- {
57
- $resource = Mage::getSingleton('core/resource');
58
- $db_write = $resource->getConnection('core_write');
59
- $sarbacanedesktop_users = $resource->getTableName('sarbacanedesktop_users');
60
- $shops = '';
61
- if (Mage::app()->getRequest()->getParam('store_id')) {
62
- $stores_id = Mage::app()->getRequest()->getParam('store_id');
63
- if (is_array($stores_id)) {
64
- foreach ($stores_id as $store_id) {
65
- $shops .= $store_id . ',';
66
- }
67
- $shops = substr($shops, 0, strlen($shops)-1);
68
- }
69
- }
70
- $old_sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
71
- $rq_sql = '
72
- UPDATE `' . $sarbacanedesktop_users . '`
73
- SET `sd_value` = ' . $db_write->quote($shops) . '
74
- WHERE `sd_type` = \'sd_list\'';
75
- $db_write->query($rq_sql);
76
- $sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
77
- foreach ($sd_list_array as $sd_list)
78
- {
79
- if (!in_array($sd_list, $old_sd_list_array))
80
- {
81
- Mage::helper('sarbacanedesktop')->resetList($sd_list);
82
- }
83
- }
84
- }
85
- private function createTokenParameterConfiguration(){
86
- $resource = Mage::getSingleton('core/resource');
87
- $db_write = $resource->getConnection('core_write');
88
- $sarbacanedesktop_users = $resource->getTableName('sarbacanedesktop_users');
89
- $rq_sql = 'TRUNCATE `' . $sarbacanedesktop_users . '`';
90
- $db_write->query($rq_sql);
91
- $token_parameter = rand(100000, 999999) . Mage::getModel('core/date')->timestamp(time());
92
- $rq_sql = 'INSERT INTO `' . $sarbacanedesktop_users . '` (`sd_value`,`sd_type`) VALUES (' . $db_write->quote($token_parameter) . ',\'sd_token\')';
93
- $db_write->query($rq_sql);
94
- return $token_parameter;
95
- }
96
- private function saveTokenParameterConfiguration()
97
- {
98
- $resource = Mage::getSingleton('core/resource');
99
- $db_write = $resource->getConnection('core_write');
100
- $sarbacanedesktop_users = $resource->getTableName('sarbacanedesktop_users');
101
- $token_parameter = rand(100000, 999999) . Mage::getModel('core/date')->timestamp(time());
102
- $rq_sql = '
103
- UPDATE `' . $sarbacanedesktop_users . '`
104
- SET `sd_value` = ' . $db_write->quote($token_parameter) . '
105
- WHERE `sd_type` = \'sd_token\'';
106
- $db_write->query($rq_sql);
107
- return $token_parameter;
108
- }
 
 
 
 
 
 
 
 
 
 
 
109
 
110
- private function getKeyForSynchronisation()
111
- {
112
- return str_rot13('sarbacanedesktop?stk=' . Mage::helper('sarbacanedesktop')->getToken());
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
- private function getSdFormKey()
116
- {
117
- return substr(Mage::helper('core')->encrypt('SarbacaneDesktopForm'), 0, 15);
118
- }
119
 
120
- }
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
 
21
  class Sarbacane_Sarbacanedesktop_Adminhtml_SarbacanedesktopController extends Mage_Adminhtml_Controller_Action
22
  {
23
 
24
+ protected function _isAllowed()
25
+ {
26
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/sarbacanedesktop');
27
+ }
28
+
29
+ public function indexAction()
30
+ {
31
+ $general_configuration = Mage::helper('sarbacanedesktop')->getConfiguration('nb_configured');
32
+ $displayed_step = 1;
33
+ if ($general_configuration == 1) {
34
+ $displayed_step = 2;
35
+ } else if ($general_configuration == 2 || $general_configuration == 3) {
36
+ $displayed_step = 3;
37
+ }
38
+ if (Mage::app()->getRequest()->getParam('submit_is_user')) {
39
+ $this->saveSdIsUser();
40
+ $general_configuration = Mage::helper('sarbacanedesktop')->getConfiguration('nb_configured');
41
+ $displayed_step = 2;
42
+ } else if (Mage::app()->getRequest()->getParam('submit_configuration')) {
43
+ $this->saveListConfiguration();
44
+ if (Mage::helper('sarbacanedesktop')->getConfiguration('sd_token') == '') {
45
+ $this->saveTokenParameterConfiguration();
46
+ }
47
+ $general_configuration = Mage::helper('sarbacanedesktop')->getConfiguration('nb_configured');
48
+ $displayed_step = 3;
49
+ } else if (Mage::app()->getRequest()->getParam('submit_parameter_key')) {
50
+ $this->saveTokenParameterConfiguration();
51
+ }
52
+ $this->loadLayout();
53
+ $block = $this->getLayout()->getBlock('sarbacanedesktop');
54
+ $block->setSdFormKey($this->getSdFormKey());
55
+ $block->setKeyForSynchronisation($this->getKeyForSynchronisation());
56
+ $block->setCheckFailed(Mage::helper('sarbacanedesktop')->checkFailed());
57
+ $block->setListConfiguration(Mage::helper('sarbacanedesktop')->getListConfiguration('array'));
58
+ $block->setGeneralConfiguration($general_configuration);
59
+ $block->setSdIsUser(Mage::helper('sarbacanedesktop')->getConfiguration('sd_is_user'));
60
+ $block->setDisplayedStep($displayed_step);
61
+ $block->setShopsArray(Mage::helper('sarbacanedesktop')->getShopsArray());
62
+ $this->_title($this->__('Sarbacane Desktop'));
63
+ $this->_setActiveMenu('newsletter');
64
+ $this->renderLayout();
65
+ }
66
+
67
+ private function saveSdIsUser()
68
+ {
69
+ if (Mage::app()->getRequest()->getParam('sd_is_user')) {
70
+ $sd_is_user = Mage::app()->getRequest()->getParam('sd_is_user');
71
+ Mage::helper('sarbacanedesktop')->updateConfiguration('sd_is_user', $sd_is_user);
72
+ }
73
+ }
74
+
75
+ private function saveTokenParameterConfiguration()
76
+ {
77
+ $resource = Mage::getSingleton('core/resource');
78
+ $db_write = $resource->getConnection('core_write');
79
+ $sd_updates = $resource->getTableName('sd_updates');
80
+ $sd_users = $resource->getTableName('sd_users');
81
+ Mage::helper('sarbacanedesktop')->updateConfiguration('sd_nb_failed', '');
82
+ $rq_sql = 'TRUNCATE `' . $sd_updates . '`';
83
+ $db_write->query($rq_sql);
84
+ $rq_sql = 'TRUNCATE `' . $sd_users . '`';
85
+ $db_write->query($rq_sql);
86
+ $token_parameter = rand(100000, 999999) . time() . '-';
87
+ $characters = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
88
+ $nb_characters = strlen($characters);
89
+ for ($i = 0; $i < 30; $i++) {
90
+ $token_parameter .= substr($characters, mt_rand(0, $nb_characters - 1), 1);
91
+ }
92
+ Mage::helper('sarbacanedesktop')->updateConfiguration('sd_token', $token_parameter);
93
+ }
94
+
95
+ private function getKeyForSynchronisation()
96
+ {
97
+ return str_rot13('sarbacanedesktop?stk=' . Mage::helper('sarbacanedesktop')->getToken());
98
+ }
99
+
100
+ private function saveListConfiguration()
101
+ {
102
+ $shops = '';
103
+ if (Mage::app()->getRequest()->getParam('store_id')) {
104
+ $stores_id = Mage::app()->getRequest()->getParam('store_id');
105
+ if (is_array($stores_id)) {
106
+ $sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
107
+ foreach ($sd_list_array as $sd_list) {
108
+ if ( ! in_array($sd_list, $stores_id)) {
109
+ $store_id = Mage::helper('sarbacanedesktop')->getIdShopFromList($sd_list);
110
+ $list_type = Mage::helper('sarbacanedesktop')->getListTypeFromList($sd_list);
111
+ $this->deleteListData($list_type, $store_id);
112
+ }
113
+ }
114
+ $shops = implode(',', $stores_id);
115
+ }
116
+ }
117
+ Mage::helper('sarbacanedesktop')->updateConfiguration('sd_list', $shops);
118
+ }
119
 
120
+ private function deleteListData($list_type, $store_id)
121
+ {
122
+ $resource = Mage::getSingleton('core/resource');
123
+ $db_write = $resource->getConnection('core_write');
124
+ $sd_updates = $resource->getTableName('sd_updates');
125
+ $sd_users = $resource->getTableName('sd_users');
126
+ $rq_sql = '
127
+ DELETE
128
+ FROM `' . $sd_updates . '`
129
+ WHERE `store_id` = ' . (int)$store_id . '
130
+ AND `list_type` = ' . $db_write->quote($list_type);
131
+ $db_write->query($rq_sql);
132
+ $rq_sql = '
133
+ DELETE
134
+ FROM `' . $sd_users . '`
135
+ WHERE `list_id` = ' . $db_write->quote($store_id . $list_type);
136
+ $db_write->query($rq_sql);
137
+ }
138
 
139
+ private function getSdFormKey()
140
+ {
141
+ return substr(Mage::helper('core')->encrypt('SarbacaneDesktopForm'), 0, 15);
142
+ }
143
 
144
+ }
app/code/community/Sarbacane/Sarbacanedesktop/controllers/IndexController.php CHANGED
@@ -18,353 +18,502 @@
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
- class Sarbacane_Sarbacanedesktop_IndexController extends Mage_Core_Controller_Front_Action {
22
- private function saveSdid($sdid, $list) {
23
- $resource = Mage::getSingleton ( 'core/resource' );
24
- $db_write = $resource->getConnection ( 'core_write' );
25
- $sarbacanedesktop_users = $resource->getTableName ( 'sarbacanedesktop_users' );
26
-
27
- $rq_sql = 'DELETE FROM `' . $sarbacanedesktop_users . '` WHERE sd_type=\'sd_id\' AND sd_value=\'' . $sdid . '\' AND list_id=\'' . $list . '\'';
28
- $rq = $db_write->query ( $rq_sql );
29
- $rq_sql = '
30
- INSERT INTO `' . $sarbacanedesktop_users . '` (`sd_type`, `sd_value`, `list_id`, `last_call_date` ) VALUES
31
- (\'sd_id\', ' . $db_write->quote ( $sdid ) . ', \'' . $list . '\', \'' . date ( 'Y-m-d H:i:s' ) . '\')';
32
- $rq = $db_write->query ( $rq_sql );
33
- return;
34
- }
35
- public function indexAction() {
36
- if (Mage::app ()->getRequest ()->getParam ( 'stk' ) && Mage::app ()->getRequest ()->getParam ( 'sdid' )) {
37
- $sdid = Mage::app ()->getRequest ()->getParam ( 'sdid' );
38
- if (Mage::app ()->getRequest ()->getParam ( 'stk' ) == Mage::helper ( 'sarbacanedesktop' )->getToken () && $sdid != '') {
39
- $identifier = Mage::helper ( 'sarbacanedesktop' )->getConfiguration ( 'identifier' );
40
- $sd_id = "";
41
- $configuration = Mage::helper ( 'sarbacanedesktop' )->getConfiguration ( 'all' );
42
- if ($configuration ['sd_token'] != '' && $configuration ['sd_list'] != '') {
43
- $sd_list_array = Mage::helper ( 'sarbacanedesktop' )->getListConfiguration ( 'array' );
44
- if ($sd_list_array != '') {
45
- if (Mage::app ()->getRequest ()->getParam ( 'list' )) {
46
- $list = Mage::app ()->getRequest ()->getParam ( 'list' );
47
- $store_id = Mage::helper ( 'sarbacanedesktop' )->getStoreidFromList ( $list );
48
- $list_type = Mage::helper ( 'sarbacanedesktop' )->getListTypeFromList ( $list );
49
- $list_type_array = Mage::helper ( 'sarbacanedesktop' )->getListTypeArray ();
50
- if (in_array ( $list_type, $list_type_array )) {
51
- $id_and_list = $store_id . $list_type;
52
- if (($list_type == 'N' && in_array ( $id_and_list . '0', $sd_list_array )) || ($list_type == 'C' && (in_array ( $id_and_list . '0', $sd_list_array ) || in_array ( $id_and_list . '1', $sd_list_array )))) {
53
- $this->processNewUnsubcribersAndSubscribers ( $list_type, $store_id, $sdid );
54
- $sd_id = $this->saveSdid ( $sdid, $list );
55
- } else {
56
- header ( 'HTTP/1.1 404 Not found' );
57
- header ( "Content-type: application/json ; charset=utf-8" );
58
- die ( 'FAILED_ID' );
59
- }
60
- } else {
61
- header ( 'HTTP/1.1 404 Not found' );
62
- header ( "Content-type: application/json ; charset=utf-8" );
63
- die ( 'FAILED_ID' );
64
- }
65
- } else {
66
- if ('reset' == Mage::app ()->getRequest ()->getParam ( 'action' )) {
67
- Mage::helper ( 'sarbacanedesktop' )->deleteSdid ( $sd_id );
68
- } else {
69
- $this->getFormattedContentShops ( $sdid );
70
- }
71
- }
72
- }
73
- }
74
- } else {
75
- header ( "HTTP/1.1 403 Unauthorized" );
76
- header ( "Content-type: application/json; charset=utf-8" );
77
- die ( 'FAILED_SDTOKEN' );
78
- }
79
- } else {
80
- echo "Param&egrave;tre[s] manquant[s]";
81
- }
82
- }
83
- private function processNewUnsubcribersAndSubscribers($list_type, $store_id, $sd_id) {
84
- $resource = Mage::getSingleton ( 'core/resource' );
85
- $db_read = $resource->getConnection ( 'core_read' );
86
- $sarbacanedesktop_users = $resource->getTableName ( 'sarbacanedesktop_users' );
87
- $rq_sql = 'SELECT last_call_date FROM ' . $sarbacanedesktop_users . ' WHERE sd_type=\'sd_id\' AND sd_value=\'' . $sd_id . '\' AND list_id=\'' . $store_id . $list_type . '\'';
88
- $last_call_date = $db_read->fetchOne ( $rq_sql );
89
-
90
- $line = 'email;lastname;firstname';
91
- if ($list_type == 'C') {
92
- if ($this->checkIfListWithCustomerData ( $list_type, $store_id )) {
93
- $line .= ';date_first_order;date_last_order;amount_min_order;amount_max_order;amount_avg_order;nb_orders;amount_all_orders;most_profitable_category';
94
- }
95
- }
96
- $line .= ';action'."\r\n";
97
- echo $line;
98
- $this->processNewUnsubscribers ( $list_type, $store_id, $sd_id, 'display', $last_call_date );
99
- $this->processNewSubscribers ( $list_type, $store_id, $sd_id, 'display', $last_call_date );
100
- }
101
- private function getListTypeArray() {
102
- return array (
103
- 'N',
104
- 'C'
105
- );
106
- }
107
- private function checkIfListWithCustomerData($list_type, $store_id) {
108
- $sd_list_array = Mage::helper ( 'sarbacanedesktop' )->getListConfiguration ( 'array' );
109
- if (in_array ( $store_id . $list_type . '1', $sd_list_array )) {
110
- return true;
111
- }
112
- return false;
113
- }
114
- private function getFormattedContentShops($sd_id) {
115
- $stores = Mage::helper ( 'sarbacanedesktop' )->getStoresArray ();
116
- echo 'list_id;name;reset;is_updated;type;version' . "\n";
117
- $sd_list_array = Mage::helper ( 'sarbacanedesktop' )->getListConfiguration ( 'array' );
118
- $list_array = array ();
119
- foreach ( $sd_list_array as $list ) {
120
- $store_id = Mage::helper ( 'sarbacanedesktop' )->getStoreidFromList ( $list );
121
- $list_type = Mage::helper ( 'sarbacanedesktop' )->getListTypeFromList ( $list );
122
- array_push ( $list_array, array (
123
- 'store_id' => $store_id,
124
- 'list_type' => $list_type,
125
- 'list_id' => $list
126
- ) );
127
- }
128
- foreach ( $stores as $store ) {
129
- foreach ( $list_array as $list ) {
130
- if ($store ['store_id'] == $list ['store_id']) {
131
- $store_list = "" . $store ['store_id'] . $list ['list_type'] . ';' . $this->dQuote ( $store ['store_name'] ) . ';'; // TEST
132
- $store_list .= $this->listIsResetted ( $store ['store_id'] . $list ['list_type'], $sd_id ) . ';';
133
- $store_list .= $this->listIsUpdated ( $store ['store_id'], $list ['list_type'], $sd_id ) . ';';
134
- $store_list .= 'Magento;1.0.0.7' . "\r\n";
135
- echo $store_list;
136
- }
137
- }
138
- }
139
- }
140
- private function listIsResetted($list_id, $sd_id) {
141
- $resource = Mage::getSingleton ( 'core/resource' );
142
- $db_read = $resource->getConnection ( 'core_read' );
143
- $sarbacanedesktop_users = $resource->getTableName ( 'sarbacanedesktop_users' );
144
- $rq_sql = '
145
- SELECT count(*) AS `nb_in_table`
146
- FROM ' . $sarbacanedesktop_users . '
147
- WHERE `sd_type` = "sd_id"
148
- AND `sd_value` = ' . $db_read->quote ( $sd_id ) . ' AND list_id="' . $list_id . '"';
149
- $nb_in_table = $db_read->fetchOne ( $rq_sql );
150
- if ($nb_in_table == 0)
151
- return 'Y';
152
- return 'N';
153
- }
154
- private function listIsUpdated($store_id, $list_type, $sd_id) {
155
- $resource = Mage::getSingleton ( 'core/resource' );
156
- $db_read = $resource->getConnection ( 'core_read' );
157
- $sarbacanedesktop_users = $resource->getTableName ( 'sarbacanedesktop_users' );
158
- $rq_sql = 'SELECT last_call_date FROM ' . $sarbacanedesktop_users . ' WHERE sd_type=\'sd_id\' AND sd_value=\'' . $sd_id . '\' AND list_id=\'' . $store_id . $list_type . '\'';
159
- $last_call_date = $db_read->fetchOne ( $rq_sql );
160
-
161
- $is_updated_list = 'N';
162
- if ($this->processNewUnsubscribers ( $list_type, $store_id, $sd_id, 'is_updated', $last_call_date ) > 0) {
163
- $is_updated_list = 'Y';
164
- }
165
- if ($this->processNewSubscribers ( $list_type, $store_id, $sd_id, 'is_updated', $last_call_date ) > 0) {
166
- $is_updated_list = 'Y';
167
- }
168
- return $is_updated_list;
169
- }
170
- private function dQuote($value) {
171
- $value = str_replace ( '"', '""', $value );
172
- if (strpos ( $value, ' ' ) || strpos ( $value, ';' )) {
173
- $value = '"' . $value . '"';
174
- }
175
- return $value;
176
- }
177
- private function processNewSubscribers($list_type, $store_id, $sd_id, $type_action = 'display', $last_call_date) {
178
- $resource = Mage::getSingleton ( 'core/resource' );
179
- $db_read = $resource->getConnection ( 'core_read' );
180
- $db_write = $resource->getConnection ( 'core_write' );
181
- $sd_updates = $resource->getTableName ( 'sd_updates' );
182
- $newsletter_subscriber = $resource->getTableName ( 'newsletter_subscriber' );
183
- $sales_flat_order = $resource->getTableName ( 'sales_flat_order' );
184
- $sales_flat_order_item = $resource->getTableName ( 'sales_flat_order_item' );
185
- $catalog_category_product = $resource->getTableName ( 'catalog_category_product' );
186
- $catalog_category_entity_varchar = $resource->getTableName ( 'catalog_category_entity_varchar' );
187
- $customer_entity = $resource->getTableName ( 'customer_entity' );
188
- $customer_entity_varchar = $resource->getTableName ( 'customer_entity_varchar' );
189
- $core_store = $resource->getTableName ( 'core_store' ); // core store
190
- $attr_firstname = Mage::getModel ( 'customer/customer' )->getAttribute ( 'firstname' )->getAttributeId ();
191
- $attr_lastname = Mage::getModel ( 'customer/customer' )->getAttribute ( 'lastname' )->getAttributeId ();
192
- if ($list_type == 'N') {
193
- if ($last_call_date != null && $last_call_date != '') {
194
- $rq_sql = 'SELECT sdu.`email` AS `email`, IFNULL(lastname.`value`, \'\') AS `lastname`, IFNULL(firstname.`value`, \'\') AS `firstname`
195
- FROM `' . $sd_updates . '` AS `sdu`
196
- LEFT JOIN ' . $newsletter_subscriber . ' ns ON ns.subscriber_email = sdu.email
197
- LEFT JOIN ' . $customer_entity_varchar . ' AS `lastname` ON lastname.`entity_id` = ns.`customer_id` AND lastname.`attribute_id` = ' . ( int ) $attr_lastname . '
198
- LEFT JOIN ' . $customer_entity_varchar . ' AS `firstname` ON firstname.`entity_id` = ns.`customer_id` AND firstname.`attribute_id` = ' . ( int ) $attr_firstname . '
199
- WHERE ns.`subscriber_status` = 1 AND sdu.update_time > "' . $last_call_date . '" AND sdu.list_type="N" AND sdu.action="S"
200
- AND ns.`store_id` = ' . ( int ) $store_id;
201
- } else {
202
- $rq_sql = '
203
- SELECT ns.`subscriber_email` AS `email`, IFNULL(lastname.`value`, \'\') AS `lastname`, IFNULL(firstname.`value`, \'\') AS `firstname`
204
- FROM `' . $newsletter_subscriber . '` AS `ns`
205
- LEFT JOIN ' . $customer_entity_varchar . ' AS `lastname` ON lastname.`entity_id` = ns.`customer_id` AND lastname.`attribute_id` = ' . ( int ) $attr_lastname . '
206
- LEFT JOIN ' . $customer_entity_varchar . ' AS `firstname` ON firstname.`entity_id` = ns.`customer_id` AND firstname.`attribute_id` = ' . ( int ) $attr_firstname . '
207
- WHERE ns.`subscriber_status` = 1
208
- AND ns.`store_id` = ' . ( int ) $store_id;
209
- }
210
- } else if ($list_type == 'C') {
211
- $add_customer_data = $this->checkIfListWithCustomerData ( $list_type, $store_id );
212
- if ($add_customer_data) {
213
- $rq_sql = "SELECT
214
- c.email,
215
- cevln.value AS lastname,
216
- cevfn.value AS firstname,
217
- MAX(sfo.base_grand_total) AS amount_max_order,
218
- MIN(sfo.base_grand_total) AS amount_min_order,
219
- AVG(sfo.base_grand_total) AS amount_avg_order,
220
- MIN(sfo.created_at) AS date_first_order,
221
- MAX(sfo.created_at) AS date_last_order,
222
- COUNT(sfo.entity_id) AS nb_orders,
223
- SUM(sfo.base_grand_total) AS amount_all_orders,
224
- (SELECT
225
- ccev.value AS category
226
- FROM
227
- $sales_flat_order AS sfo2
228
- LEFT JOIN
229
- $sales_flat_order_item AS sfoi ON sfo2.entity_id = sfoi.order_id
230
- LEFT JOIN
231
- $catalog_category_product AS ccp ON ccp.product_id = sfoi.product_id
232
- LEFT JOIN
233
- $catalog_category_entity_varchar AS ccev ON ccev.entity_id = ccp.category_id
234
- AND ccev.attribute_id = 41
235
- AND ccev.entity_type_id = 3
236
- WHERE sfo2.customer_id = c.entity_id AND sfo.store_id=$store_id
237
- GROUP BY category
238
- ORDER BY SUM(sfoi.row_total) DESC
239
- LIMIT 1) AS category
240
- FROM
241
- $customer_entity AS c
242
- LEFT JOIN
243
- $customer_entity_varchar AS cevfn ON cevfn.entity_id = c.entity_id
244
- AND cevfn.attribute_id = 5
245
- LEFT JOIN
246
- $customer_entity_varchar AS cevln ON cevln.entity_id = c.entity_id
247
- AND cevln.attribute_id = 7
248
- LEFT JOIN
249
- $sales_flat_order AS sfo ON sfo.customer_id = c.entity_id AND c.store_id = sfo.store_id
250
- WHERE c.store_id = " . $store_id;
251
- if ($last_call_date != null && $last_call_date != '') {
252
- $rq_sql .= " AND (c.created_at > '" . $last_call_date . "' OR c.updated_at > '" . $last_call_date . "' ";
253
- $rq_sql .= " OR sfo.created_at > '" . $last_call_date . "' OR sfo.updated_at > '" . $last_call_date . "') ";
254
- }
255
- $rq_sql .= " GROUP BY c.entity_id ";
256
- $rq_sql .= " UNION (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
- SELECT
259
- sfo.customer_email AS email, sfo.customer_lastname AS lastname,sfo.customer_firstname AS firstname,
260
- MAX(sfo.base_grand_total) AS amount_max_order,
261
- MIN(sfo.base_grand_total) AS amount_min_order,
262
- AVG(sfo.base_grand_total) AS amount_avg_order,
263
- MIN(sfo.created_at) AS date_first_order,
264
- MAX(sfo.created_at) AS date_last_order,
265
- COUNT(sfo.entity_id) AS nb_orders,
266
- SUM(sfo.base_grand_total) AS amount_all_orders,
267
- (SELECT
268
- ccev.value AS category
269
- FROM
270
- $sales_flat_order AS sfo2
271
- LEFT JOIN
272
- $sales_flat_order_item AS sfoi ON sfo2.entity_id = sfoi.order_id
273
- LEFT JOIN
274
- $catalog_category_product AS ccp ON ccp.product_id = sfoi.product_id
275
- LEFT JOIN
276
- $catalog_category_entity_varchar AS ccev ON ccev.entity_id = ccp.category_id
277
- AND ccev.attribute_id = 41
278
- AND ccev.entity_type_id = 3
279
- WHERE sfo2.customer_email = sfo.customer_email AND sfo2.customer_is_guest = 1 AND sfo2.store_id = sfo.store_id
280
- GROUP BY category
281
- ORDER BY SUM(sfoi.row_total) DESC
282
- LIMIT 1) AS most_profitable_category
283
- FROM
284
- $sales_flat_order AS sfo
285
- WHERE sfo.customer_is_guest = 1 AND sfo.store_id = " . $store_id;
286
- if ($last_call_date != null && $last_call_date != '') {
287
- $rq_sql .= " AND (sfo.created_at > '" . $last_call_date . "' OR sfo.updated_at > '" . $last_call_date . "') ";
288
- }
289
- $rq_sql .= " GROUP BY sfo.customer_email)";
290
- } else {
291
- $rq_sql = " SELECT t.email, t.lastname, t.firstname ";
292
- $rq_sql .= " FROM ( SELECT c.email AS email,cevln.value AS lastname, cevfn.value AS firstname ";
293
- $rq_sql .= " FROM $customer_entity c LEFT JOIN $customer_entity_varchar cevln ON cevln.entity_id = c.entity_id AND cevln.attribute_id=7
294
- LEFT JOIN $customer_entity_varchar cevfn ON cevfn.entity_id = c.entity_id AND cevfn.attribute_id = 5";
295
- $rq_sql .= " WHERE c.store_id = " . $store_id;
296
- if ($last_call_date != null && $last_call_date != '') {
297
- $rq_sql .= " AND (c.created_at > '" . $last_call_date . "' OR c.updated_at > '" . $last_call_date . "')";
298
- }
299
- $rq_sql .= " GROUP BY c.email
300
- UNION
301
- SELECT sfo.customer_email AS email ,sfo.customer_lastname as lastname, sfo.customer_firstname as firstname";
302
- $rq_sql .= " FROM $sales_flat_order sfo ";
303
- $rq_sql .= " WHERE sfo.customer_id IS NULL AND sfo.store_id = " . $store_id;
304
- if ($last_call_date != null && $last_call_date != '') {
305
- $rq_sql .= " AND (sfo.created_at > '" . $last_call_date . "' OR sfo.updated_at > '" . $last_call_date . "') ";
306
- }
307
- $rq_sql .= " GROUP BY email ";
308
-
309
- $rq_sql .= " ) as t ";
310
- $rq_sql .= " GROUP BY t.email;";
311
- }
312
- } else {
313
- return;
314
- }
315
- if ($type_action == 'is_updated') {
316
- $rq_sql .= ' LIMIT 0, 1 ';
317
- $rq = $db_read->fetchAll ( $rq_sql );
318
- return count ( $rq );
319
- } else {
320
- $rq = $db_read->query ( $rq_sql );
321
- while ( $r = $rq->fetch () ) {
322
- $line = $this->dQuote ( $r ['email'] ) . ';'; // TEST
323
- $line .= $this->dQuote ( $r ['lastname'] ) . ';' . $this->dQuote ( $r ['firstname'] );
324
- if ($list_type == 'C') {
325
- if ($add_customer_data) {
326
- $line .= ';' . $this->dQuote ( $r ['date_first_order'] ) . ';' . $this->dQuote ( $r ['date_last_order'] );
327
- $line .= ';' . ( float ) $r ['amount_min_order'] . ';' . ( float ) $r ['amount_max_order'] . ';' . ( float ) $r ['amount_avg_order'];
328
- $line .= ';' . $r ['nb_orders'] . ';' . ( float ) $r ['amount_all_orders'] . ';' . $r ['category'];
329
- }
330
- }
331
- $line .= ';S'."\r\n";
332
- echo $line;
333
- }
334
- }
335
- }
336
- private function processNewUnsubscribers($list_type, $store_id, $sd_id, $type_action = 'display', $last_call_date) {
337
- $resource = Mage::getSingleton ( 'core/resource' );
338
- $db_read = $resource->getConnection ( 'core_read' );
339
-
340
- $sd_updates = $resource->getTableName ( 'sd_updates' );
341
-
342
- switch ($list_type) {
343
- case 'N' :
344
- case 'C' :
345
- $rq_sql = 'SELECT email FROM ' . $sd_updates . ' WHERE list_type="' . $list_type . '" AND action = "U"';
346
- if ($last_call_date != null && $last_call_date != '') {
347
- $rq_sql .= ' AND update_time > "' . $last_call_date . '"';
348
- }
349
- break;
350
- default :
351
- return;
352
- }
353
- if ($type_action == 'is_updated') {
354
- $rq = $db_read->fetchAll ( $rq_sql );
355
- return count ( $rq );
356
- } else {
357
- $rq = $db_read->query ( $rq_sql );
358
- while ( $r = $rq->fetch () ) {
359
- $line = $this->dQuote ( $r ['email'] ) . ';;'; // TEST
360
- if ($list_type == 'C') {
361
- if ($this->checkIfListWithCustomerData ( $list_type, $store_id )) {
362
- $line .= ';;;;;;;;';
363
- }
364
- }
365
- $line .= ';U' . "\r\n";
366
- echo $line;
367
- }
368
- }
369
- }
370
  }
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
+ class Sarbacane_Sarbacanedesktop_IndexController extends Mage_Core_Controller_Front_Action
22
+ {
23
+
24
+ public function indexAction()
25
+ {
26
+ if (Mage::app()->getRequest()->getParam('stk') && Mage::app()->getRequest()->getParam('sdid')) {
27
+ $sdid = Mage::app()->getRequest()->getParam('sdid');
28
+ $stk = Mage::helper('sarbacanedesktop')->getToken();
29
+ if (Mage::app()->getRequest()->getParam('stk') == $stk && strlen($stk) > 30 && ! Mage::helper('sarbacanedesktop')->checkFailed()) {
30
+ if ($sdid != '' && Mage::helper('sarbacanedesktop')->getConfiguration('nb_configured') == 3) {
31
+ header('Content-type: text/plain; charset=utf-8');
32
+ $configuration = Mage::helper('sarbacanedesktop')->getConfiguration('all');
33
+ if ($configuration['sd_token'] != '' && $configuration['sd_list'] != '' && $configuration['sd_is_user'] != '') {
34
+ $sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
35
+ if (is_array($sd_list_array) && count($sd_list_array) > 0) {
36
+ if (Mage::app()->getRequest()->getParam('list')) {
37
+ $list = Mage::app()->getRequest()->getParam('list');
38
+ $store_id = Mage::helper('sarbacanedesktop')->getIdShopFromList($list);
39
+ $list_type = Mage::helper('sarbacanedesktop')->getListTypeFromList($list);
40
+ $list_type_array = Mage::helper('sarbacanedesktop')->getListTypeArray();
41
+ if (in_array($list_type, $list_type_array)) {
42
+ if (($list_type == 'N' && in_array($list . '0', $sd_list_array))
43
+ || ($list_type == 'C' && (in_array($list . '0', $sd_list_array) || in_array($list . '1', $sd_list_array)))) {
44
+ $now = gmdate('Y-m-d H:i:s');
45
+ $this->processNewUnsubcribersAndSubscribers($list_type, $store_id, $sdid);
46
+ $this->saveSdid($sdid, $list, $now);
47
+ $this->clearHistory($list_type, $store_id);
48
+ } else {
49
+ header('HTTP/1.1 404 Not found');
50
+ die('FAILED_ID');
51
+ }
52
+ } else {
53
+ header('HTTP/1.1 404 Not found');
54
+ die('FAILED_ID');
55
+ }
56
+ } else {
57
+ if (Mage::app()->getRequest()->getParam('action') == 'reset') {
58
+ Mage::helper('sarbacanedesktop')->deleteSdid($sdid);
59
+ } else {
60
+ $this->setDataToUpdate();
61
+ $this->getFormattedContentShops($sdid);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ } else {
68
+ $this->updateFailed();
69
+ header("HTTP/1.1 403 Unauthorized");
70
+ die('FAILED_SDTOKEN');
71
+ }
72
+ die;
73
+ }
74
+ }
75
+
76
+ private function saveSdid($sd_id, $list, $now)
77
+ {
78
+ $resource = Mage::getSingleton('core/resource');
79
+ $db_write = $resource->getConnection('core_write');
80
+ $sd_users = $resource->getTableName('sd_users');
81
+ $rq_sql = '
82
+ INSERT INTO `' . $sd_users . '` VALUES
83
+ (' . $db_write->quote($sd_id) . ', ' . $db_write->quote($list) . ', ' . $db_write->quote($now) . ')
84
+ ON DUPLICATE KEY UPDATE
85
+ `last_call_date` = VALUES(`last_call_date`)';
86
+ $db_write->query($rq_sql);
87
+ }
88
+
89
+ private function updateFailed() {
90
+ if ( ! Mage::helper('sarbacanedesktop')->checkFailed()) {
91
+ Mage::helper('sarbacanedesktop')->updateConfiguration('sd_nb_failed', Mage::helper('sarbacanedesktop')->getConfiguration('sd_nb_failed') + 1);
92
+ }
93
+ }
94
+
95
+ private function setDataToUpdate()
96
+ {
97
+ $resource = Mage::getSingleton('core/resource');
98
+ $db_write = $resource->getConnection('core_write');
99
+ $sd_updates = $resource->getTableName('sd_updates');
100
+ $sales_flat_order = $resource->getTableName('sales_flat_order');
101
+ $customer_entity = $resource->getTableName('customer_entity');
102
+ $now = gmdate('Y-m-d H:i:s');
103
+ if (count(Mage::helper('sarbacanedesktop')->getSynchronizedListsArray() > 0)) {
104
+ $sd_last_update = Mage::helper('sarbacanedesktop')->getConfiguration('sd_last_update');
105
+ if ($sd_last_update != '') {
106
+ $sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
107
+ if (count($sd_list_array) > 0) {
108
+ $id_shops_customer_array = array();
109
+ foreach ($sd_list_array as $sd_list) {
110
+ $store_id = substr($sd_list, 0, -2);
111
+ if (strpos($sd_list, 'C') !== false) {
112
+ if (Mage::helper('sarbacanedesktop')->checkNeedUserInsertSdUpdates($store_id, 'C')) {
113
+ $id_shops_customer_array[] = (int)$store_id;
114
+ }
115
+ }
116
+ }
117
+ if (count($id_shops_customer_array) > 0) {
118
+ $id_shops_customer = implode(', ', $id_shops_customer_array);
119
+ for ($i = 0; $i < 2; $i++) {
120
+ if ($i == 0) {
121
+ $rq_sql_action = 'S';
122
+ $rq_sql_where = '`is_active` = 1';
123
+ } else {
124
+ $rq_sql_action = 'U';
125
+ $rq_sql_where = '`is_active` = 0';
126
+ }
127
+ $rq_sql = '
128
+ INSERT INTO `' . $sd_updates . '`
129
+ SELECT `email`, `store_id`, \'C\' AS `list_type`, \'' . $rq_sql_action . '\' AS `action`, ' . $db_write->quote($now) . ' AS `update_date`
130
+ FROM `' . $customer_entity . '`
131
+ WHERE `updated_at` >= ' . $db_write->quote($sd_last_update) . '
132
+ AND `updated_at` < ' . $db_write->quote($now) . '
133
+ AND `store_id` IN (' . $id_shops_customer . ')
134
+ AND `website_id` != 0
135
+ AND ' . $rq_sql_where . '
136
+ ON DUPLICATE KEY UPDATE
137
+ `action` = VALUES(`action`),
138
+ `update_date` = VALUES(`update_date`)';
139
+ $db_write->query($rq_sql);
140
+ }
141
+ $rq_sql = '
142
+ INSERT INTO `' . $sd_updates . '`
143
+ SELECT IFNULL(`c`.`email`, `sfo`.`customer_email`) AS `email`, `sfo`.`store_id`, \'C\' AS `list_type`, \'S\' AS `action`, ' . $db_write->quote($now) . ' AS `update_date`
144
+ FROM `' . $sales_flat_order . '` AS `sfo`
145
+ LEFT JOIN `' . $customer_entity . '` AS `c`
146
+ ON `c`.`entity_id` = `sfo`.`customer_id`
147
+ AND `c`.`store_id` = `sfo`.`store_id`
148
+ AND `c`.`website_id` != 0
149
+ WHERE `sfo`.`updated_at` >= ' . $db_write->quote($sd_last_update) . '
150
+ AND `sfo`.`updated_at` < ' . $db_write->quote($now) . '
151
+ AND `sfo`.`store_id` IN (' . $id_shops_customer . ')
152
+ ON DUPLICATE KEY UPDATE
153
+ `action` = VALUES(`action`),
154
+ `update_date` = VALUES(`update_date`)';
155
+ $db_write->query($rq_sql);
156
+ }
157
+ }
158
+ }
159
+ }
160
+ Mage::helper('sarbacanedesktop')->updateConfiguration('sd_last_update', $now);
161
+ }
162
+
163
+ private function processNewUnsubcribersAndSubscribers($list_type, $store_id, $sd_id)
164
+ {
165
+ $resource = Mage::getSingleton('core/resource');
166
+ $db_read = $resource->getConnection('core_read');
167
+ $sd_users = $resource->getTableName('sd_users');
168
+ $rq_sql = '
169
+ SELECT `last_call_date`
170
+ FROM `' . $sd_users . '`
171
+ WHERE `sd_id` = ' . $db_read->quote($sd_id) . '
172
+ AND `list_id` = ' . $db_read->quote($store_id . $list_type);
173
+ $last_call_date = $db_read->fetchOne($rq_sql);
174
+ if ($last_call_date == null || $last_call_date == '') {
175
+ $last_call_date = false;
176
+ }
177
+ $line = 'email;lastname;firstname';
178
+ if ($list_type == 'C') {
179
+ if ($this->checkIfListWithCustomerData('C', $store_id)) {
180
+ $line .= ';date_first_order;date_last_order;amount_min_order;amount_max_order;amount_avg_order;nb_orders;amount_all_orders';
181
+ }
182
+ }
183
+ $line .= ';action' . "\n";
184
+ echo $line;
185
+ $this->processNewUnsubscribers($list_type, $store_id, $last_call_date, 'display');
186
+ $this->processNewSubscribers($list_type, $store_id, $last_call_date, 'display');
187
+ }
188
+
189
+ private function checkIfListWithCustomerData($list_type, $store_id)
190
+ {
191
+ $sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
192
+ if (in_array($store_id . $list_type . '1', $sd_list_array)) {
193
+ return true;
194
+ }
195
+ return false;
196
+ }
197
+
198
+ private function getFormattedContentShops($sd_id)
199
+ {
200
+ $shops = Mage::helper('sarbacanedesktop')->getShopsArray();
201
+ echo 'list_id;name;reset;is_updated;type;version' . "\n";
202
+ $sd_list_array = Mage::helper('sarbacanedesktop')->getListConfiguration('array');
203
+ foreach ($sd_list_array as $list) {
204
+ foreach ($shops as $shop) {
205
+ $store_id = Mage::helper('sarbacanedesktop')->getIdShopFromList($list);
206
+ $list_type = Mage::helper('sarbacanedesktop')->getListTypeFromList($list);
207
+ if ($shop['store_id'] == $store_id) {
208
+ $shop_list = $store_id . $list_type . ';' . $this->dQuote($shop['name']) . ';';
209
+ $shop_list .= $this->listStatus($store_id, $list_type, $sd_id) . ';';
210
+ $shop_list .= 'Magento;1.0.0.8' . "\n";//
211
+ echo $shop_list;
212
+ }
213
+ }
214
+ }
215
+ }
216
+
217
+ private function listStatus($store_id, $list_type, $sd_id)
218
+ {
219
+ $resource = Mage::getSingleton('core/resource');
220
+ $db_read = $resource->getConnection('core_read');
221
+ $sd_users = $resource->getTableName('sd_users');
222
+ $list_is_resetted = 'Y';
223
+ $list_is_updated = 'N';
224
+ $last_call_date = false;
225
+ if ( ! isset($this->sd_used_lists)) {
226
+ $rq_sql = '
227
+ SELECT `sd_id`, `list_id`, `last_call_date`
228
+ FROM `' . $sd_users . '`';
229
+ $this->sd_used_lists = $db_read->fetchAll($rq_sql);
230
+ }
231
+ if (is_array($this->sd_used_lists)) {
232
+ foreach ($this->sd_used_lists as $r) {
233
+ if ($r['sd_id'] == $sd_id && $r['list_id'] == $store_id . $list_type) {
234
+ $list_is_resetted = 'N';
235
+ $last_call_date = $r['last_call_date'];
236
+ if ($last_call_date == null || $last_call_date == '') {
237
+ $last_call_date = false;
238
+ }
239
+ break;
240
+ }
241
+ }
242
+ }
243
+ if ($this->processNewUnsubscribers($list_type, $store_id, $last_call_date, 'is_updated') > 0) {
244
+ $list_is_updated = 'Y';
245
+ } else if ($this->processNewSubscribers($list_type, $store_id, $last_call_date, 'is_updated') > 0) {
246
+ $list_is_updated = 'Y';
247
+ }
248
+ return $list_is_resetted . ';' . $list_is_updated;
249
+ }
250
+
251
+ private function dQuote($value)
252
+ {
253
+ $value = str_replace('"', '""', $value);
254
+ if (strpos($value, ' ') !== false || strpos($value, ';') !== false) {
255
+ $value = '"' . $value . '"';
256
+ }
257
+ return $value;
258
+ }
259
+
260
+ private function processNewSubscribers($list_type, $store_id, $last_call_date, $type_action = 'display')
261
+ {
262
+ $resource = Mage::getSingleton('core/resource');
263
+ $db_read = $resource->getConnection('core_read');
264
+ $sd_updates = $resource->getTableName('sd_updates');
265
+ $newsletter_subscriber = $resource->getTableName('newsletter_subscriber');
266
+ $sales_flat_order = $resource->getTableName('sales_flat_order');
267
+ $customer_entity = $resource->getTableName('customer_entity');
268
+ $customer_entity_varchar = $resource->getTableName('customer_entity_varchar');
269
+ $attr_firstname = Mage::getModel('customer/customer')->getAttribute('firstname')->getAttributeId();
270
+ $attr_lastname = Mage::getModel('customer/customer')->getAttribute('lastname')->getAttributeId();
271
+ if ($list_type == 'N') {
272
+ $rq_sql_select = '
273
+ SELECT `ns`.`subscriber_email` AS `email`,
274
+ IFNULL(`lastname`.`value`, SUBSTRING_INDEX(GROUP_CONCAT(`sfo`.`customer_lastname` ORDER BY `sfo`.`updated_at` DESC SEPARATOR \'||\'), \'||\', 1)) AS `lastname`,
275
+ IFNULL(`firstname`.`value`, SUBSTRING_INDEX(GROUP_CONCAT(`sfo`.`customer_firstname` ORDER BY `sfo`.`updated_at` DESC SEPARATOR \'||\'), \'||\', 1)) AS `firstname`';
276
+ $rq_sql_from = '
277
+ LEFT JOIN `' . $customer_entity . '` AS `c`
278
+ ON `c`.`email` = `ns`.`subscriber_email`
279
+ AND `c`.`store_id` = `ns`.`store_id`
280
+ AND `c`.`website_id` != 0
281
+ LEFT JOIN `' . $customer_entity_varchar . '` AS `lastname`
282
+ ON `lastname`.`entity_id` = `c`.`entity_id`
283
+ AND `lastname`.`attribute_id` = ' . (int)$attr_lastname . '
284
+ LEFT JOIN `' . $customer_entity_varchar . '` AS `firstname`
285
+ ON `firstname`.`entity_id` = `c`.`entity_id`
286
+ AND `firstname`.`attribute_id` = ' . (int)$attr_firstname . '
287
+ LEFT JOIN `' . $sales_flat_order . '` AS `sfo`
288
+ ON `sfo`.`customer_email` = `ns`.`subscriber_email`
289
+ AND `sfo`.`store_id` = `ns`.`store_id`';
290
+ $rq_sql_group_by = '
291
+ GROUP BY `ns`.`subscriber_email`';
292
+ if ( ! $last_call_date) {
293
+ $rq_sql =
294
+ $rq_sql_select . '
295
+ FROM `' . $newsletter_subscriber . '` AS `ns`
296
+ ' . $rq_sql_from . '
297
+ WHERE `ns`.`subscriber_status` = 1
298
+ AND `ns`.`store_id` = ' . (int)$store_id .
299
+ $rq_sql_group_by;
300
+ } else {
301
+ $rq_sql =
302
+ $rq_sql_select . '
303
+ FROM `' . $sd_updates . '` AS `s`
304
+ INNER JOIN `' . $newsletter_subscriber . '` AS `ns`
305
+ ON `ns`.`subscriber_email` = `s`.`email`
306
+ AND `ns`.`store_id` = `s`.`store_id`
307
+ AND `ns`.`subscriber_status` = 1
308
+ ' . $rq_sql_from . '
309
+ WHERE `s`.`update_date` >= ' . $db_read->quote($last_call_date) . '
310
+ AND `s`.`list_type` = \'N\'
311
+ AND `s`.`store_id` = ' . (int)$store_id .
312
+ $rq_sql_group_by;
313
+ }
314
+ } else if ($list_type == 'C') {
315
+ $add_customer_data = $this->checkIfListWithCustomerData('C', $store_id);
316
+ if ($add_customer_data) {
317
+ $rq_sql_select = '
318
+ SELECT `t`.`email`, `t`.`lastname`, `t`.`firstname`,
319
+ MIN(`t`.`date_first_order`) AS `date_first_order`, MAX(`t`.`date_last_order`) AS `date_last_order`,
320
+ MIN(`t`.`amount_min_order`) AS `amount_min_order`, MAX(`t`.`amount_max_order`) AS `amount_max_order`,
321
+ ROUND(SUM(`t`.`amount_all_orders`)/SUM(`t`.`nb_orders`), 6) AS `amount_avg_order`, SUM(`t`.`nb_orders`) AS `nb_orders`,
322
+ SUM(`t`.`amount_all_orders`) AS `amount_all_orders`
323
+ FROM
324
+ (';
325
+ $rq_sql_select_table_1 = '
326
+ SELECT `c`.`email`, `lastname`.`value` AS `lastname`, `firstname`.`value` AS `firstname`,
327
+ MIN(`sfo`.`created_at`) AS `date_first_order`, MAX(`sfo`.`created_at`) AS `date_last_order`,
328
+ MIN(`sfo`.`base_grand_total`) AS `amount_min_order`, MAX(`sfo`.`base_grand_total`) AS `amount_max_order`,
329
+ COUNT(`sfo`.`created_at`) AS `nb_orders`, SUM(`sfo`.`base_grand_total`) AS `amount_all_orders`';
330
+ $rq_sql_select_table_2 = '
331
+ SELECT `sfo`.`customer_email` AS `email`,
332
+ SUBSTRING_INDEX(GROUP_CONCAT(`sfo`.`customer_lastname` ORDER BY `sfo`.`updated_at` DESC SEPARATOR \'||\'), \'||\', 1) AS `lastname`,
333
+ SUBSTRING_INDEX(GROUP_CONCAT(`sfo`.`customer_firstname` ORDER BY `sfo`.`updated_at` DESC SEPARATOR \'||\'), \'||\', 1) AS `firstname`,
334
+ MIN(`sfo`.`created_at`) AS `date_first_order`, MAX(`sfo`.`created_at`) AS `date_last_order`,
335
+ MIN(`sfo`.`base_grand_total`) AS `amount_min_order`, MAX(`sfo`.`base_grand_total`) AS `amount_max_order`,
336
+ COUNT(`sfo`.`created_at`) AS `nb_orders`, SUM(`sfo`.`base_grand_total`) AS `amount_all_orders`';
337
+ $rq_sql_from = '
338
+ INNER JOIN `' . $customer_entity_varchar . '` AS `lastname`
339
+ ON `lastname`.`entity_id` = `c`.`entity_id`
340
+ AND `lastname`.`attribute_id` = 7
341
+ INNER JOIN `' . $customer_entity_varchar . '` AS `firstname`
342
+ ON `firstname`.`entity_id` = `c`.`entity_id`
343
+ AND `firstname`.`attribute_id` = 5
344
+ LEFT JOIN `' . $sales_flat_order . '` AS `sfo`
345
+ ON `sfo`.`customer_id` = `c`.`entity_id`
346
+ AND `sfo`.`store_id` = `c`.`store_id`';
347
+ $rq_sql_group_by = '
348
+ ) AS `t`
349
+ GROUP BY `t`.`email`';
350
+ } else {
351
+ $rq_sql_select = '
352
+ SELECT `t`.`email`, `t`.`lastname`, `t`.`firstname`
353
+ FROM
354
+ (';
355
+ $rq_sql_select_table_1 = '
356
+ SELECT `c`.`email`, `lastname`.`value` AS `lastname`, `firstname`.`value` AS `firstname`';
357
+ $rq_sql_select_table_2 = '
358
+ SELECT `sfo`.`customer_email` AS `email`,
359
+ SUBSTRING_INDEX(GROUP_CONCAT(`sfo`.`customer_lastname` ORDER BY `sfo`.`updated_at` DESC SEPARATOR \'||\'), \'||\', 1) AS `lastname`,
360
+ SUBSTRING_INDEX(GROUP_CONCAT(`sfo`.`customer_firstname` ORDER BY `sfo`.`updated_at` DESC SEPARATOR \'||\'), \'||\', 1) AS `firstname`';
361
+ $rq_sql_from = '
362
+ INNER JOIN `' . $customer_entity_varchar . '` AS `lastname`
363
+ ON `lastname`.`entity_id` = `c`.`entity_id`
364
+ AND `lastname`.`attribute_id` = 7
365
+ INNER JOIN `' . $customer_entity_varchar . '` AS `firstname`
366
+ ON `firstname`.`entity_id` = `c`.`entity_id`
367
+ AND `firstname`.`attribute_id` = 5';
368
+ $rq_sql_group_by = '
369
+ ) AS `t`
370
+ GROUP BY `t`.`email`';
371
+ }
372
+ if ( ! $last_call_date) {
373
+ $rq_sql =
374
+ $rq_sql_select . '
375
+ (
376
+ ' . $rq_sql_select_table_1 . '
377
+ FROM `' . $customer_entity . '` AS `c`
378
+ ' . $rq_sql_from . '
379
+ WHERE `c`.`store_id` = ' . (int)$store_id . '
380
+ AND `c`.`website_id` != 0
381
+ GROUP BY `c`.`email`
382
+ )
383
+ UNION ALL
384
+ (
385
+ ' . $rq_sql_select_table_2 . '
386
+ FROM `' . $sales_flat_order . '` AS `sfo`
387
+ LEFT JOIN `' . $customer_entity . '` AS `c`
388
+ ON `c`.`entity_id` = `sfo`.`customer_id`
389
+ AND `c`.`store_id` = `sfo`.`store_id`
390
+ AND `c`.`website_id` != 0
391
+ WHERE `c`.`entity_id` IS NULL
392
+ AND `sfo`.`store_id` = ' . (int)$store_id . '
393
+ GROUP BY `sfo`.`customer_email`
394
+ )' .
395
+ $rq_sql_group_by;
396
+ } else {
397
+ $rq_sql =
398
+ $rq_sql_select . '
399
+ (
400
+ ' . $rq_sql_select_table_1 . '
401
+ FROM `' . $sd_updates . '` AS `s`
402
+ INNER JOIN `' . $customer_entity . '` AS `c`
403
+ ON `c`.`email` = `s`.`email`
404
+ AND `c`.`store_id` = `s`.`store_id`
405
+ AND `c`.`website_id` != 0
406
+ ' . $rq_sql_from . '
407
+ WHERE `s`.`store_id` = ' . (int)$store_id . '
408
+ AND `s`.`list_type` = \'C\'
409
+ AND `s`.`update_date` >= ' . $db_read->quote($last_call_date) . '
410
+ GROUP BY `c`.`email`
411
+ )
412
+ UNION ALL
413
+ (
414
+ ' . $rq_sql_select_table_2 . '
415
+ FROM `' . $sd_updates . '` AS `s`
416
+ INNER JOIN `' . $sales_flat_order . '` AS `sfo`
417
+ ON `sfo`.`customer_email` = `s`.`email`
418
+ AND `sfo`.`store_id` = `s`.`store_id`
419
+ LEFT JOIN `' . $customer_entity . '` AS `c`
420
+ ON `c`.`entity_id` = `sfo`.`customer_id`
421
+ AND `c`.`store_id` = `s`.`store_id`
422
+ AND `c`.`website_id` != 0
423
+ WHERE `c`.`entity_id` IS NULL
424
+ AND `s`.`store_id` = ' . (int)$store_id . '
425
+ AND `s`.`list_type` = \'C\'
426
+ AND `s`.`update_date` >= ' . $db_read->quote($last_call_date) . '
427
+ GROUP BY `sfo`.`customer_email`
428
+ )' .
429
+ $rq_sql_group_by;
430
+ }
431
+ } else {
432
+ if ($type_action == 'is_updated') {
433
+ return 0;
434
+ } else {
435
+ return;
436
+ }
437
+ }
438
+ $rq = $db_read->query($rq_sql);
439
+ while ($r = $rq->fetch()) {
440
+ if ($type_action == 'is_updated') {
441
+ return 1;
442
+ }
443
+ $line = $this->dQuote($r['email']) . ';';
444
+ $line .= $this->dQuote($r['lastname']) . ';' . $this->dQuote($r['firstname']);
445
+ if ($list_type == 'C') {
446
+ if ($add_customer_data) {
447
+ $line .= ';' . $this->dQuote($r ['date_first_order']) . ';' . $this->dQuote($r['date_last_order']);
448
+ $line .= ';' . (float)$r['amount_min_order'] . ';' . (float)$r['amount_max_order'] . ';' . (float)$r['amount_avg_order'];
449
+ $line .= ';' . $r['nb_orders'] . ';' . (float)$r['amount_all_orders'];
450
+ }
451
+ }
452
+ $line .= ';S' . "\n";
453
+ echo $line;
454
+ }
455
+ }
456
+
457
+ private function processNewUnsubscribers($list_type, $store_id, $last_call_date, $type_action = 'display')
458
+ {
459
+ $resource = Mage::getSingleton('core/resource');
460
+ $db_read = $resource->getConnection('core_read');
461
+ $sd_updates = $resource->getTableName('sd_updates');
462
+ if ($last_call_date !== false && ($list_type == 'N' || $list_type == 'C')) {
463
+ $rq_sql = '
464
+ SELECT `email`
465
+ FROM `' . $sd_updates . '`
466
+ WHERE `list_type` = ' . $db_read->quote($list_type) . '
467
+ AND `store_id` = ' . (int)$store_id . '
468
+ AND `action` = \'U\'
469
+ AND `update_date` >= ' . $db_read->quote($last_call_date);
470
+ $rq = $db_read->query($rq_sql);
471
+ while ($r = $rq->fetch()) {
472
+ if ($type_action == 'is_updated') {
473
+ return 1;
474
+ }
475
+ $line = $this->dQuote($r['email']) . ';;';
476
+ if ($list_type == 'C') {
477
+ if ($this->checkIfListWithCustomerData('C', $store_id)) {
478
+ $line .= ';;;;;;;;';
479
+ }
480
+ }
481
+ $line .= ';U' . "\n";
482
+ echo $line;
483
+ }
484
+ }
485
+ else {
486
+ if ($type_action == 'is_updated') {
487
+ return 0;
488
+ }
489
+ }
490
+ }
491
+
492
+ private function clearHistory($list_type, $store_id)
493
+ {
494
+ $resource = Mage::getSingleton('core/resource');
495
+ $db_write = $resource->getConnection('core_write');
496
+ $sd_updates = $resource->getTableName('sd_updates');
497
+ $sd_users = $resource->getTableName('sd_users');
498
+ $rq_sql = '
499
+ DELETE
500
+ FROM `' . $sd_updates . '`
501
+ WHERE `store_id` = ' . (int)$store_id . '
502
+ AND `list_type` = ' . $db_write->quote($list_type) . '
503
+ AND `update_date` <= (
504
+ SELECT MIN(`last_call_date`)
505
+ FROM `' . $sd_users . '`
506
+ WHERE `list_id` = ' . $db_write->quote($store_id . $list_type) . '
507
+ )';
508
+ $db_write->query($rq_sql);
509
+ $rq_sql = '
510
+ DELETE
511
+ FROM `' . $sd_updates . '`
512
+ WHERE `update_date` <= (
513
+ SELECT MIN(`last_call_date`)
514
+ FROM `' . $sd_users . '`
515
+ )';
516
+ $db_write->query($rq_sql);
517
+ }
518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
app/code/community/Sarbacane/Sarbacanedesktop/etc/config.xml CHANGED
@@ -21,128 +21,142 @@
21
  */
22
  -->
23
  <config>
24
- <modules>
25
- <Sarbacane_Sarbacanedesktop>
26
- <version>1.0.0.7</version>
27
- </Sarbacane_Sarbacanedesktop>
28
- </modules>
29
- <frontend>
30
- <routers>
31
- <sarbacanedesktop>
32
- <use>standard</use>
33
- <args>
34
- <module>Sarbacane_Sarbacanedesktop</module>
35
- <frontName>sarbacanedesktop</frontName>
36
- </args>
37
- </sarbacanedesktop>
38
- </routers>
39
- <!--
40
- <layout>
41
- <updates>
42
- <sarbacanedesktop>
43
- <file>sarbacanedesktop.xml</file>
44
- </sarbacanedesktop>
45
- </updates>
46
- </layout>
47
- -->
48
- </frontend>
49
- <admin>
50
- <routers>
51
- <adminhtml>
52
- <args>
53
- <modules>
54
- <sarbacanedesktop before="Mage_Adminhtml">Sarbacane_Sarbacanedesktop_Adminhtml</sarbacanedesktop>
55
- </modules>
56
- </args>
57
- </adminhtml>
58
- </routers>
59
- <!--
60
- <routers>
61
- <sarbacanedesktop>
62
- <use>admin</use>
63
- <args>
64
- <module>Sarbacane_Sarbacanedesktop</module>
65
- <frontName>sarbacanedesktop</frontName>
66
- </args>
67
- </sarbacanedesktop>
68
- </routers>
69
- -->
70
- </admin>
71
- <adminhtml>
72
- <menu>
73
- <newsletter>
74
- <children>
75
- <items module="sarbacanedesktop" translate="title">
76
- <title>Sarbacane Desktop</title>
77
- <sort_order>120</sort_order>
78
- <action>adminhtml/sarbacanedesktop</action>
79
- </items>
80
- </children>
81
- </newsletter>
82
- </menu>
83
- <acl>
84
- <resources>
85
- <admin>
86
- <children>
87
- <newsletter>
88
- <children>
89
- <sarbacanedesktop translate="title">
90
- <title>Sarbacane Desktop</title>
91
- <sort_order>120</sort_order>
92
- </sarbacanedesktop>
93
- </children>
94
- </newsletter>
95
- </children>
96
- </admin>
97
- </resources>
98
- </acl>
99
- <layout>
100
- <updates>
101
- <sarbacanedesktop>
102
- <file>sarbacanedesktop.xml</file>
103
- </sarbacanedesktop>
104
- </updates>
105
- </layout>
106
- <translate>
107
- <modules>
108
- <Sarbacane_Sarbacanedesktop>
109
- <files>
110
- <default>Sarbacane_Sarbacanedesktop.csv</default>
111
- </files>
112
- </Sarbacane_Sarbacanedesktop>
113
- </modules>
114
- </translate>
115
- </adminhtml>
116
- <global>
117
- <helpers>
118
- <sarbacanedesktop>
119
- <class>Sarbacane_Sarbacanedesktop_Helper</class>
120
- </sarbacanedesktop>
121
- </helpers>
122
- <blocks>
123
- <sarbacanedesktop>
124
- <class>Sarbacane_Sarbacanedesktop_Block</class>
125
- </sarbacanedesktop>
126
- </blocks>
127
- <resources>
128
- <sarbacanedesktop_setup>
129
- <setup>
130
- <module>Sarbacane_Sarbacanedesktop</module>
131
- </setup>
132
- <connection>
133
- <use>core_setup</use>
134
- </connection>
135
- </sarbacanedesktop_setup>
136
- <sarbacanedesktop_write>
137
- <connection>
138
- <use>core_write</use>
139
- </connection>
140
- </sarbacanedesktop_write>
141
- <sarbacanedesktop_read>
142
- <connection>
143
- <use>core_read</use>
144
- </connection>
145
- </sarbacanedesktop_read>
146
- </resources>
147
- </global>
148
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  */
22
  -->
23
  <config>
24
+ <modules>
25
+ <Sarbacane_Sarbacanedesktop>
26
+ <version>1.0.0.8</version>
27
+ </Sarbacane_Sarbacanedesktop>
28
+ </modules>
29
+ <frontend>
30
+ <routers>
31
+ <sarbacanedesktop>
32
+ <use>standard</use>
33
+ <args>
34
+ <module>Sarbacane_Sarbacanedesktop</module>
35
+ <frontName>sarbacanedesktop</frontName>
36
+ </args>
37
+ </sarbacanedesktop>
38
+ </routers>
39
+ </frontend>
40
+ <admin>
41
+ <routers>
42
+ <adminhtml>
43
+ <args>
44
+ <modules>
45
+ <sarbacanedesktop before="Mage_Adminhtml">Sarbacane_Sarbacanedesktop_Adminhtml</sarbacanedesktop>
46
+ </modules>
47
+ </args>
48
+ </adminhtml>
49
+ </routers>
50
+ </admin>
51
+ <adminhtml>
52
+ <menu>
53
+ <newsletter>
54
+ <children>
55
+ <sarbacanedesktop module="sarbacanedesktop" translate="title">
56
+ <title>Sarbacane Desktop</title>
57
+ <sort_order>120</sort_order>
58
+ <action>adminhtml/sarbacanedesktop</action>
59
+ </sarbacanedesktop>
60
+ </children>
61
+ </newsletter>
62
+ </menu>
63
+ <acl>
64
+ <resources>
65
+ <admin>
66
+ <children>
67
+ <newsletter>
68
+ <children>
69
+ <sarbacanedesktop translate="title">
70
+ <title>Sarbacane Desktop</title>
71
+ <sort_order>120</sort_order>
72
+ </sarbacanedesktop>
73
+ </children>
74
+ </newsletter>
75
+ </children>
76
+ </admin>
77
+ </resources>
78
+ </acl>
79
+ <layout>
80
+ <updates>
81
+ <sarbacanedesktop>
82
+ <file>sarbacanedesktop.xml</file>
83
+ </sarbacanedesktop>
84
+ </updates>
85
+ </layout>
86
+ <translate>
87
+ <modules>
88
+ <Sarbacane_Sarbacanedesktop>
89
+ <files>
90
+ <default>Sarbacane_Sarbacanedesktop.csv</default>
91
+ </files>
92
+ </Sarbacane_Sarbacanedesktop>
93
+ </modules>
94
+ </translate>
95
+ </adminhtml>
96
+ <global>
97
+ <events>
98
+ <customer_save_before>
99
+ <observers>
100
+ <sarbacanedesktop_customer_save>
101
+ <class>Sarbacane_Sarbacanedesktop_Model_Observer</class>
102
+ <method>customerSave</method>
103
+ </sarbacanedesktop_customer_save>
104
+ </observers>
105
+ </customer_save_before>
106
+ <customer_delete_before>
107
+ <observers>
108
+ <sarbacanedesktop_customer_delete>
109
+ <class>Sarbacane_Sarbacanedesktop_Model_Observer</class>
110
+ <method>customerDelete</method>
111
+ </sarbacanedesktop_customer_delete>
112
+ </observers>
113
+ </customer_delete_before>
114
+ <newsletter_subscriber_save_before>
115
+ <observers>
116
+ <sarbacanedesktop_newsletter_subscriber_save>
117
+ <class>Sarbacane_Sarbacanedesktop_Model_Observer</class>
118
+ <method>newsletterSubscriberSave</method>
119
+ </sarbacanedesktop_newsletter_subscriber_save>
120
+ </observers>
121
+ </newsletter_subscriber_save_before>
122
+ <newsletter_subscriber_delete_before>
123
+ <observers>
124
+ <sarbacanedesktop_newsletter_subscriber_delete>
125
+ <class>Sarbacane_Sarbacanedesktop_Model_Observer</class>
126
+ <method>newsletterSubscriberDelete</method>
127
+ </sarbacanedesktop_newsletter_subscriber_delete>
128
+ </observers>
129
+ </newsletter_subscriber_delete_before>
130
+ </events>
131
+ <helpers>
132
+ <sarbacanedesktop>
133
+ <class>Sarbacane_Sarbacanedesktop_Helper</class>
134
+ </sarbacanedesktop>
135
+ </helpers>
136
+ <blocks>
137
+ <sarbacanedesktop>
138
+ <class>Sarbacane_Sarbacanedesktop_Block</class>
139
+ </sarbacanedesktop>
140
+ </blocks>
141
+ <resources>
142
+ <sarbacanedesktop_setup>
143
+ <setup>
144
+ <module>Sarbacane_Sarbacanedesktop</module>
145
+ </setup>
146
+ <connection>
147
+ <use>core_setup</use>
148
+ </connection>
149
+ </sarbacanedesktop_setup>
150
+ <sarbacanedesktop_write>
151
+ <connection>
152
+ <use>core_write</use>
153
+ </connection>
154
+ </sarbacanedesktop_write>
155
+ <sarbacanedesktop_read>
156
+ <connection>
157
+ <use>core_read</use>
158
+ </connection>
159
+ </sarbacanedesktop_read>
160
+ </resources>
161
+ </global>
162
+ </config>
app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-install-1.0.0.0.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @category Sarbacane
16
- * @package Sarbacane_Sarbacanedesktop
17
- * @author Sarbacane Software <contact@sarbacane.com>
18
- * @copyright 2015 Sarbacane Software
19
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
- */
21
-
22
- $installer = $this;
23
- $installer->startSetup();
24
-
25
- $installer->run("
26
- DROP TABLE IF EXISTS `{$this->getTable('sarbacanedesktop')}`;
27
- DROP TABLE IF EXISTS `{$this->getTable('sarbacanedesktop_users')}`;
28
-
29
- CREATE TABLE `{$this->getTable('sarbacanedesktop')}` (
30
- `email` varchar(150) NOT NULL,
31
- `list_type` varchar(20) NOT NULL,
32
- `store_id` varchar(20) NOT NULL,
33
- `sd_id` varchar(20) NOT NULL,
34
- `lastname` varchar(150) NOT NULL,
35
- `firstname` varchar(150) NOT NULL,
36
- `orders_data` varchar(150) NOT NULL,
37
- PRIMARY KEY(`email`,`store_id`,`list_type`,`sd_id`)
38
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39
-
40
- CREATE TABLE `{$this->getTable('sarbacanedesktop_users')}` (
41
- `sd_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
42
- `sd_type` varchar(20) NOT NULL,
43
- `sd_value` varchar(200) NOT NULL,
44
- PRIMARY KEY(`sd_id`)
45
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
46
-
47
- INSERT INTO `{$this->getTable('sarbacanedesktop_users')}` (`sd_type`, `sd_value`) VALUES
48
- ('sd_token', ''),
49
- ('sd_list', '');
50
-
51
- ");
52
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.0-1.0.0.1.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @category Sarbacane
16
- * @package Sarbacane_Sarbacanedesktop
17
- * @author Sarbacane Software <contact@sarbacane.com>
18
- * @copyright 2015 Sarbacane Software
19
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
- */
21
-
22
- $installer = $this;
23
- $installer->startSetup();
24
-
25
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.1-1.0.0.2.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @category Sarbacane
16
- * @package Sarbacane_Sarbacanedesktop
17
- * @author Sarbacane Software <contact@sarbacane.com>
18
- * @copyright 2015 Sarbacane Software
19
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
- */
21
-
22
- $installer = $this;
23
- $installer->startSetup();
24
-
25
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.2-1.0.0.3.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @category Sarbacane
16
- * @package Sarbacane_Sarbacanedesktop
17
- * @author Sarbacane Software <contact@sarbacane.com>
18
- * @copyright 2015 Sarbacane Software
19
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
- */
21
-
22
- $installer = $this;
23
- $installer->startSetup();
24
-
25
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.3-1.0.0.4.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @category Sarbacane
16
- * @package Sarbacane_Sarbacanedesktop
17
- * @author Sarbacane Software <contact@sarbacane.com>
18
- * @copyright 2015 Sarbacane Software
19
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
- */
21
-
22
- $installer = $this;
23
- $installer->startSetup();
24
-
25
- $installer->run("DROP TABLE IF EXISTS `{$this->getTable('sarbacanedesktop')}`;");
26
- $installer->run("DROP TABLE IF EXISTS `{$this->getTable('sd_updates')}`;");
27
-
28
- $installer->run("ALTER TABLE `{$this->getTable('sarbacanedesktop_users')}` ADD COLUMN `list_id` VARCHAR(50) NULL DEFAULT NULL AFTER `sd_value`;");
29
- $installer->run("ALTER TABLE `{$this->getTable('sarbacanedesktop_users')}` ADD COLUMN `last_call_date` VARCHAR(50) NULL DEFAULT NULL AFTER `list_id`;");
30
-
31
- $installer->run("
32
- CREATE TABLE `{$this->getTable('sd_updates')}` (
33
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
34
- `email` VARCHAR(50) NOT NULL COLLATE 'utf8_bin',
35
- `update_time` DATETIME NOT NULL,
36
- `action` VARCHAR(5) NOT NULL COLLATE 'utf8_bin',
37
- `list_type` VARCHAR(10) NULL DEFAULT NULL COLLATE 'utf8_bin',
38
- PRIMARY KEY (`id`),
39
- INDEX `update_time_action` (`update_time`, `action`)
40
- )
41
- COMMENT='Contains useful data used by SD/MF plugin'
42
- COLLATE='utf8_bin'
43
- ENGINE=InnoDB
44
- ;");
45
-
46
- $installer->run("DROP TRIGGER IF EXISTS sd_newsletter_update;");
47
- $installer->run("DROP TRIGGER IF EXISTS sd_customer_delete;");
48
-
49
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
50
-
51
- $sql= "
52
- CREATE TRIGGER `sd_newsletter_update`
53
- AFTER UPDATE ON `{$this->getTable('newsletter_subscriber')}`
54
- FOR EACH ROW BEGIN
55
- DELETE FROM {$this->getTable('sd_updates')} WHERE email=NEW.subscriber_email AND list_type='N';
56
- IF NEW.subscriber_status = 1 THEN
57
- INSERT INTO {$this->getTable('sd_updates')} (email,update_time,action,list_type) VALUES (NEW.subscriber_email,UTC_TIMESTAMP(),'S','N');
58
- ELSE
59
- INSERT INTO {$this->getTable('sd_updates')} (email,update_time,action,list_type) VALUES (NEW.subscriber_email,UTC_TIMESTAMP(),'U','N');
60
- END IF;
61
- END;";
62
- $write->exec($sql);
63
-
64
- $sql= "
65
- CREATE TRIGGER `sd_newsletter_insert`
66
- AFTER INSERT ON `{$this->getTable('newsletter_subscriber')}`
67
- FOR EACH ROW BEGIN
68
- DELETE FROM {$this->getTable('sd_updates')} WHERE email=NEW.subscriber_email AND list_type='N';
69
- IF NEW.subscriber_status = 1 THEN
70
- INSERT INTO {$this->getTable('sd_updates')} (email,update_time,action,list_type) VALUES (NEW.subscriber_email,UTC_TIMESTAMP(),'S','N');
71
- ELSE
72
- INSERT INTO {$this->getTable('sd_updates')} (email,update_time,action,list_type) VALUES (NEW.subscriber_email,UTC_TIMESTAMP(),'U','N');
73
- END IF;
74
- END;";
75
- $write->exec($sql);
76
-
77
- $sql = "
78
- CREATE TRIGGER `sd_customer_delete`
79
- BEFORE DELETE ON `{$this->getTable('customer_entity')}`
80
- FOR EACH ROW BEGIN
81
- DELETE FROM {$this->getTable('sd_updates')} WHERE email=OLD.email AND list_type='C';
82
- INSERT INTO {$this->getTable('sd_updates')} (email,update_time,action,list_type) VALUES (OLD.email,UTC_TIMESTAMP(),'U','C');
83
- END";
84
- $write->exec($sql);
85
-
86
-
87
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sarbacane/Sarbacanedesktop/sql/sarbacanedesktop_setup/mysql4-upgrade-1.0.0.7-1.0.0.8.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Sarbacane
16
+ * @package Sarbacane_Sarbacanedesktop
17
+ * @author Sarbacane Software <contact@sarbacane.com>
18
+ * @copyright 2015 Sarbacane Software
19
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+ $installer->startSetup();
24
+
25
+ try{
26
+ $installer->run("DROP TRIGGER IF EXISTS sd_newsletter_update;");
27
+ }
28
+ catch(Exception $e) {}
29
+ try{
30
+ $installer->run("DROP TRIGGER IF EXISTS sd_newsletter_insert;");
31
+ }
32
+ catch(Exception $e) {}
33
+ try{
34
+ $installer->run("DROP TRIGGER IF EXISTS sd_customer_delete;");
35
+ }
36
+ catch(Exception $e) {}
37
+
38
+ $installer->run("
39
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('sarbacanedesktop_users')}` (
40
+ `sd_type` varchar(20) NOT NULL,
41
+ `sd_value` varchar(200) NOT NULL,
42
+ PRIMARY KEY(`sd_type`)
43
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
44
+ ");
45
+
46
+ $db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
47
+ $sd_token = '';
48
+ $sd_list = '';
49
+ $sd_is_user = '';
50
+ $sd_nb_failed = '';
51
+ $sd_last_update = '';
52
+
53
+ $rq_sql = "
54
+ SELECT `sd_type`, `sd_value`
55
+ FROM `{$this->getTable('sarbacanedesktop_users')}`
56
+ WHERE `sd_type` IN ('sd_token', 'sd_list');";
57
+ $rq = $db_read->query($rq_sql);
58
+ while ($r = $rq->fetch()) {
59
+ if ($r['sd_type'] == 'sd_token') {
60
+ $sd_token = $r['sd_value'];
61
+ } else if ($r['sd_type'] == 'sd_list') {
62
+ $sd_list = $r['sd_value'];
63
+ }
64
+ }
65
+
66
+ if ($sd_token != '' || $sd_list != '') {
67
+ $sd_is_user = 'yes';
68
+ }
69
+
70
+ $installer->run("
71
+ DROP TABLE IF EXISTS `{$this->getTable('sarbacanedesktop')}`;
72
+
73
+ DROP TABLE IF EXISTS `{$this->getTable('sarbacanedesktop_users')}`;
74
+
75
+ DROP TABLE IF EXISTS `{$this->getTable('sd_updates')}`;
76
+
77
+ DROP TABLE IF EXISTS `{$this->getTable('sd_users')}`;
78
+
79
+ DROP TABLE IF EXISTS `{$this->getTable('sd_data')}`;
80
+
81
+ CREATE TABLE `{$this->getTable('sd_updates')}` (
82
+ `email` varchar(50) NOT NULL,
83
+ `store_id` int(11) unsigned NOT NULL,
84
+ `list_type` varchar(10) NOT NULL,
85
+ `action` varchar(5) NOT NULL,
86
+ `update_date` datetime NOT NULL,
87
+ PRIMARY KEY (`email`, `store_id`, `list_type`)
88
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
89
+
90
+ CREATE TABLE `{$this->getTable('sd_users')}` (
91
+ `sd_id` varchar(200) NOT NULL,
92
+ `list_id` varchar(50) NOT NULL,
93
+ `last_call_date` datetime NOT NULL,
94
+ PRIMARY KEY(`sd_id`, `list_id`)
95
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
96
+
97
+ CREATE TABLE `{$this->getTable('sd_data')}` (
98
+ `sd_type` varchar(20) NOT NULL,
99
+ `sd_value` varchar(200) NOT NULL,
100
+ PRIMARY KEY(`sd_type`)
101
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
102
+
103
+ INSERT INTO `{$this->getTable('sd_data')}`
104
+ (`sd_type`, `sd_value`)
105
+ VALUES
106
+ ('sd_token', {$db_read->quote($sd_token)}),
107
+ ('sd_list', {$db_read->quote($sd_list)}),
108
+ ('sd_is_user', {$db_read->quote($sd_is_user)}),
109
+ ('sd_nb_failed', {$db_read->quote($sd_nb_failed)}),
110
+ ('sd_last_update', {$db_read->quote($sd_last_update)});
111
+ ");
112
+
113
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/sarbacanedesktop.xml CHANGED
@@ -21,9 +21,9 @@
21
  */
22
  -->
23
  <layout>
24
- <adminhtml_sarbacanedesktop_index>
25
- <reference name="content">
26
- <block type="sarbacanedesktop/adminhtml_sarbacanedesktop" name="sarbacanedesktop" template="sarbacanedesktop/sarbacanedesktop.phtml"/>
27
- </reference>
28
- </adminhtml_sarbacanedesktop_index>
29
- </layout>
21
  */
22
  -->
23
  <layout>
24
+ <adminhtml_sarbacanedesktop_index>
25
+ <reference name="content">
26
+ <block type="sarbacanedesktop/adminhtml_sarbacanedesktop" name="sarbacanedesktop" template="sarbacanedesktop/sarbacanedesktop.phtml"/>
27
+ </reference>
28
+ </adminhtml_sarbacanedesktop_index>
29
+ </layout>
app/design/adminhtml/default/default/template/sarbacanedesktop/sarbacanedesktop.phtml CHANGED
@@ -18,249 +18,265 @@
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
- $key_for_synchronisation = $this->getKeyForSynchronisation ();
22
- $list_configuration = $this->getListConfiguration ();
23
- $general_configuration = $this->getGeneralConfiguration ();
24
- $stores_array = $this->getStoresArray ();
 
 
 
25
  ?>
26
- <link rel="stylesheet" type="text/css" href="<?=$this->getSkinUrl('css/Sarbacane_SarbacaneDesktop/sarbacanedesktop.css')?>" />
27
- <script type="text/javascript" src="<?=$this->getSkinUrl('js/Sarbacane_SarbacaneDesktop/sarbacanedesktop.js')?>"></script>
28
  <div id="sarbacanedesktop">
29
- <div class="sd_header">
30
- <div class="sd_logo_<?=$this->__('sarbacane') ?>"></div>
31
- </div>
32
- <p class="sd_title"><?=$this->__('It\'s easy to manage your newsletter and email campaigns')?></p>
33
- <div class="sd_title_separator_page"></div>
34
- <div class="sd_video_config_container">
35
- <div class="sd_video_container">
36
- <iframe width="565" height="315" src="<?=$this->__('https://www.youtube.com/embed/eLMy2tSSYgE')?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
37
- </div>
38
- <div class="sd_config_container">
39
- <p><?=$this->__('This Magento module enables you to synchronize clients and accounts that have subscribed to your newsletter from your shop online using Sarbacane Desktop\'s email marketing software.')?></p>
40
- <p>
41
- <input type="button" onclick="document.location = '#sd_step'" class="sd_config_button" value="<?=$this->__('Begin the set-up')?>" />
42
- </p>
43
- </div>
44
- </div>
45
- <div class="sd_separator"></div>
46
- <div class="sd_detail_description_container">
47
- <div>
48
- <div>
49
- <div>
50
- <div class="sd_picto1"></div>
51
- <p class="sd_long_subtitle"><?=$this->__('Synchronization of your shop data')?></p>
52
- </div>
53
- </div>
54
- <div>
55
- <div>
56
- <div class="sd_picto2"></div>
57
- <p class="sd_long_subtitle"><?=$this->__('Responsive visual editor')?></p>
58
- </div>
59
- </div>
60
- <div>
61
- <div>
62
- <div class="sd_picto3"></div>
63
- <p class="sd_short_subtitle"><?=$this->__('Detailed statistics')?></p>
64
- </div>
65
- </div>
66
- <div>
67
- <div>
68
- <div class="sd_picto4"></div>
69
- <p class="sd_short_subtitle"><?=$this->__('Optimal deliverability')?></p>
70
- </div>
71
- </div>
72
- </div>
73
- <div>
74
- <div>
75
- <div>
76
- <div class="sd_subtitle_separator"></div>
77
- <p><?=$this->__('Synchronize and manage all the email lists from your Magento store')?></p>
78
- </div>
79
- </div>
80
- <div>
81
- <div>
82
- <div class="sd_subtitle_separator"></div>
83
- <p><?=$this->__('NEW! Create awesome, responsive newsletters thanks to the EmailBuilder')?></p>
84
- </div>
85
- </div>
86
- <div>
87
- <div>
88
- <div class="sd_subtitle_separator"></div>
89
- <p><?=$this->__('Geolocation, openings, opening time, clicks, opt-outs...')?></p>
90
- </div>
91
- </div>
92
- <div>
93
- <div>
94
- <div class="sd_subtitle_separator"></div>
95
- <p><?=$this->__('Optimal deliverability thanks to our renowned professional routing platform')?></p>
96
- </div>
97
- </div>
98
- </div>
99
- </div>
100
- <div class="sd_separator"></div>
101
- <div class="sd_account_offer_container">
102
- <p class="sd_account"><?=$this->__('Create your account for free and start sending emails')?></p>
103
- <p class="sd_offer"><?=$this->__('No strings attached')?></p>
104
- <div class="sd_title_separator_account_offer"></div>
105
- </div>
106
- <div class="sd_info_container">
107
- <div class="sd_info_container_left">
108
- <div>
109
- <p class="sd_info_title"><?=$this->__('Why choose Sarbacane?')?></p>
110
- <div>
111
- <p><?=$this->__('Create your account for free and start sending emails')?></p>
112
- <p><?=$this->__('Trusted by over 20,000 users worldwide.')?></p>
113
- <p><?=$this->__('Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)')?></p>
114
- <p><?=$this->__('All you need to succeed: design, customize, send, and follow-up on your campaigns')?></p>
115
- <p><?=$this->__('A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips...')?></p>
116
- </div>
117
- </div>
118
- </div>
119
- <div class="sd_info_container_right">
120
- <div>
121
- <p class="sd_info_title"><?=$this->__('Need help?')?></p>
122
- <div>
123
- <p><?=$this->__('Email:')?> <?=$this->__('support@sarbacane.com')?></p>
124
- <p><?=$this->__('Tel:')?> <?=$this->__('+33(0) 328 328 040')?></p>
125
- <p>
126
- <?=$this->__('Website:')?>
127
- <a href="<?=$this->__('http://www.sarbacane.com/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento')?>" target="_blank"><?=$this->__('http://www.sarbacane.com')?></a>
128
- </p>
129
- </div>
130
- </div>
131
- </div>
132
- </div>
133
- <div id="sd_step"></div>
134
- <!-- ETAPE 1 -->
135
- <div id="sd_step1" class="sd_step <?php if(Mage::getSingleton("core/session")->getData("sd_is_user") == null && $general_configuration<2){?>sd_show_step<?php }?>">
136
- <p class="sd_step_title"><?=$this->__('How to set up the module?')?></p>
137
- <div class="sd_step_line"></div>
138
- <p class="sd_step1_instruction"><?=$this->__('Do you already have a Sarbacane Desktop account?')?></p>
139
- <form autocomplete="off" action="<?= Mage::helper('adminhtml')->getUrl("*/*/*/"); ?>#sd_step" method="post">
140
- <p class="sd_step1_selection">
141
- <span> <input onclick="sdUserYesNoDisplayButton('yes')" type="radio" id="sd_user_click_yes" name="sd_is_user" value="yes" <?php if(Mage::getSingleton("core/session")->getData("sd_is_user") == "yes"){?>checked="checked"<?php }?>/> <label for="sd_user_click_yes"><?=$this->__('Yes')?></label>
142
- </span> <span> <input onclick="sdUserYesNoDisplayButton('no')" type="radio" id="sd_user_click_no" name="sd_is_user" value="no" /> <label for="sd_user_click_no" <?php if(Mage::getSingleton("core/session")->getData("sd_is_user") == "no"){?>checked="checked"<?php }?>><?=$this->__('No')?></label>
143
- </span>
144
- </p>
145
- <div class="sd_step_buttons">
146
- <div class="sd_step_buttons_right">
147
- <input type="hidden" name="submit_is_user" value="1" /> <input type="hidden" name="form_key" value="<?= $this->getFormKey()?>" /> <input type="submit" class="sd_button" value="<?=$this->__('Next')?>" />
148
- </div>
149
- </div>
150
- </form>
151
- </div>
152
-
153
- <!-- ETAPE 2 -->
154
- <div id="sd_step2" class="sd_step <?php if((Mage::getSingleton("core/session")->getData("sd_is_user") == "yes" || Mage::getSingleton("core/session")->getData("sd_is_user") == "no") && $general_configuration<2 ){?>sd_show_step<?php }?>">
155
- <div class="sd_step_line"></div>
156
- <p class="sd_step2_instruction"><?=$this->__('Select your shop and pick your settings')?></p>
157
- <form autocomplete="off" action="<?= Mage::helper('adminhtml')->getUrl("*/*/*/"); ?>#sd_step" method="post">
158
- <div class="sd_step2_selection">
159
- <?php foreach ($stores_array as $store){?>
160
-
161
- <div class="sd_step2_selection_list">
162
- <p class="sd_step2_selection_shop_title"><?=$store['store_name']?></p>
163
- <div class="sd_step2_selection_shop">
164
- <div class="sd_step2_selection_shop_input">
165
- <input type="checkbox" name="store_id[]" value="<?=$store['store_id']?>N0" <?php if(in_array($store['store_id']+"N0",$list_configuration)){?>checked="checked"<?php }?> />&nbsp;
166
- </div>
167
- <div class="sd_step2_selection_shop_text">
168
- <?=$this->__('Create a list in Sarbacane Desktop with newsletter opt-ins')?>
169
- </div>
170
- </div>
171
- <div class="sd_step2_selection_shop">
172
- <div class="sd_step2_selection_shop_input">
173
- <?php
174
- $storeValue = "";
175
- $storeChecked = false;
176
- $storeWithCustomersData=false;
177
- if(in_array($store['store_id']."C1", $list_configuration)){
178
- $storeValue = $store['store_id'].'C1';
179
- $storeWithCustomersData=true;
180
- $storeChecked = true;
181
- }else if(in_array($store['store_id']."C0", $list_configuration)){
182
- $storeValue = $store['store_id']."C0";
183
- $storeChecked = true;
184
- }
185
-
186
- ?>
187
- <input id="id_shop_<?=$store['store_id']?>C" type="checkbox" name="store_id[]" onclick="changeOptionOrdersDataDisplay('<?=$store['store_id']?>C', this.checked)" value="<?=$storeValue?>" <?php if($storeChecked){ ?>checked="checked"<?php }?>/>&nbsp;
188
- </div>
189
- <div class="sd_step2_selection_shop_text">
190
- <?=$this->__('Create a list in Sarbacane Desktop with your clients who have an account or who have placed an order online')?>
191
- </div>
192
- </div>
193
- <div class="sd_step2_selection_shop_option">
194
- <div class="sd_step2_selection_shop_input">
195
- <input id="customer_data_<?=$store['store_id']?>C" type="checkbox" onclick="changeOptionOrdersData('<?=$store['store_id']?>C', this.checked)" value="<?php if($storeWithCustomersData){ echo $store['store_id'].'C1';} ?>" <?php if($storeWithCustomersData){?>checked="checked"<?php }?> />&nbsp;
196
- </div>
197
- <div class="sd_step2_selection_shop_text">
198
- <?=$this->__('Add order data (date, amount, etc...)')?>
199
- </div>
200
- <div onclick="sdInfoDataOrdersClick('<?=$store['store_id']?>C')" onmouseover="sdInfoDataOrdersHover('<?=$store['store_id']?>C')" onmouseout="sdInfoDataOrdersOut('<?=$store['store_id']?>C')" class="sd_step2_info"></div>
201
- </div>
202
- </div>
203
- <div id="sd_tooltip_<?=$store['store_id']?>C" class="sd_tooltip">
204
- <div>
205
- <?=$this->__('As you enable data from orders, you can also gather extra info in your contact list, and target your recipients in Sarbacane Desktop.')?>
206
- <br /><?=$this->__('Below are pieces of information that will be added to your contact list:')?>
207
- <br /><?=$this->__('- Date of first order')?>
208
- <br /><?=$this->__('- Date of latest order')?>
209
- <br /><?=$this->__('- Total number of orders')?>
210
- <br /><?=$this->__('- Total amount of orders')?>
211
- <br /><?=$this->__('- Amount of the cheapest order')?>
212
- <br /><?=$this->__('- Amount of the most expensive order')?>
213
- <br /><?=$this->__('- Average amount of the orders placed')?>
214
- </div>
215
- </div>
216
- <?php }?>
217
- </div>
218
- <div class="sd_step_buttons">
219
- <div class="sd_step_buttons_left">
220
- <input type="button" onclick="sdDisplayStep(1)" value="<?=$this->__('Previous')?>" />
221
- </div>
222
- <div class="sd_step_buttons_right">
223
- <input type="hidden" name="submit_configuration" value="1" /> <input type="hidden" name="submit_is_user" value="<?=$this->getIsUser()?>" /> <input type="hidden" name="form_key" value="<?= $this->getFormKey()?>" /> <input type="submit" class="sd_button" value="<?=$this->__('Next')?>" />
224
- </div>
225
- </div>
226
- </form>
227
- </div>
228
- <!-- ETAPE 3 -->
229
- <div id="sd_step3" class="sd_step <?php if($general_configuration>=2){?>sd_show_step<?php }?>">
230
- <div class="sd_step_line"></div>
231
-
232
- <div class="sd_step3_instruction">
233
- <div id="3_step_block" <?php if(Mage::getSingleton("core/session")->getData("sd_is_user") == "yes" || Mage::getSingleton("core/session")->getData("sd_is_user") == null){?> class="HIDDEN" <?php }?>>
234
- <p>
235
- 1/ <a href="<?=$this->__('https://www.sarbacane.com/ws/soft-redirect.asp?key=heXmrxBEUO&com=MagentoInfo')?>" target="_blank"><?=$this->__('Download and install Sarbacane')?></a>
236
- </p>
237
- <p>2/ <?=$this->__('Create your free account')?></p>
238
- <p>3/ <?=$this->__('Enable the Magento extension in our extensions menu, and then fill in the following fields:')?></p>
239
- </div>
240
- <div id="1_step_block" <?php if(Mage::getSingleton("core/session")->getData("sd_is_user") == "no"){?> class="HIDDEN" <?php }?>>
241
- <p><?=$this->__('Enable the Magento extension in our extensions menu, and then fill in the following fields:')?></p>
242
- </div>
243
- <form autocomplete="off" action="<?= Mage::helper('adminhtml')->getUrl("*/*/*/"); ?>#sd_step" method="post">
244
- <div class="sd_key_container">
245
- <p><?=$this->__('Url')?></p>
246
- <input value="<?=Mage::getBaseUrl() ?>" onclick="this.select()" type="text" readonly />
247
- </div>
248
- <div class="sd_key_container">
249
- <p><?=$this->__('Key')?></p>
250
- <input value="<?=$key_for_synchronisation?>" onclick="this.select()" type="text" readonly />
251
- </div>
252
- <p class="sd_key_button_container">
253
- <input type="hidden" name="submit_parameter_key" value="1" /> <input type="hidden" name="form_key" value="<?=$this->getFormKey()?>" /> <input type="submit" class="sd_key_button" value="<?=$this->__('Generate a new key')?>" />
254
- </p>
255
- </form>
256
- </div>
257
- <div class="sd_step_buttons">
258
- <div class="sd_step_buttons_left">
259
- <input type="button" onclick="sdDisplayStep(2)" value="<?=$this->__('Previous')?>" />
260
- </div>
261
- <div class="sd_step3_right">
262
- <?=$this->__('Read more')?>, <a href="<?=$this->__('http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento')?>" target="_blank"><?=$this->__('in the help section online')?></a>
263
- </div>
264
- </div>
265
- </div>
266
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  * @copyright 2015 Sarbacane Software
19
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
  */
21
+ $key_for_synchronisation = $this->getKeyForSynchronisation();
22
+ $check_failed = $this->getCheckFailed();
23
+ $list_configuration = $this->getListConfiguration();
24
+ $general_configuration = $this->getGeneralConfiguration();
25
+ $sd_is_user = $this->getSdIsUser();
26
+ $displayed_step = $this->getDisplayedStep();
27
+ $shops_array = $this->getShopsArray();
28
  ?>
29
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('sarbacanedesktop.css') ?>"/>
30
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('sarbacanedesktop.js') ?>"></script>
31
  <div id="sarbacanedesktop">
32
+ <div class="sd_header">
33
+ <div class="sd_logo_<?php echo $this->__('sarbacane') ?>"></div>
34
+ </div>
35
+ <p class="sd_title"><?php echo $this->__('It\'s easy to manage your newsletter and email campaigns') ?></p>
36
+ <div class="sd_title_separator_page"></div>
37
+ <div class="sd_video_config_container">
38
+ <div class="sd_video_container">
39
+ <iframe width="565" height="315" src="<?php echo $this->__('https://www.youtube.com/embed/eLMy2tSSYgE') ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
40
+ </div>
41
+ <div class="sd_config_container">
42
+ <p><?php echo $this->__('This Magento module enables you to synchronize clients and accounts that have subscribed to your newsletter from your shop online using Sarbacane Desktop\'s email marketing software.') ?></p>
43
+ <p>
44
+ <input type="button" onclick="sdDisplaySteps()" class="sd_config_button" value="<?php echo $this->__('Begin the set-up') ?>"/>
45
+ </p>
46
+ </div>
47
+ </div>
48
+ <div class="sd_separator"></div>
49
+ <div class="sd_detail_description_container">
50
+ <div>
51
+ <div>
52
+ <div>
53
+ <div class="sd_picto1"></div>
54
+ <p class="sd_long_subtitle"><?php echo $this->__('Synchronization of your shop data') ?></p>
55
+ </div>
56
+ </div>
57
+ <div>
58
+ <div>
59
+ <div class="sd_picto2"></div>
60
+ <p class="sd_long_subtitle"><?php echo $this->__('Responsive visual editor') ?></p>
61
+ </div>
62
+ </div>
63
+ <div>
64
+ <div>
65
+ <div class="sd_picto3"></div>
66
+ <p class="sd_short_subtitle"><?php echo $this->__('Detailed statistics') ?></p>
67
+ </div>
68
+ </div>
69
+ <div>
70
+ <div>
71
+ <div class="sd_picto4"></div>
72
+ <p class="sd_short_subtitle"><?php echo $this->__('Optimal deliverability') ?></p>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ <div>
77
+ <div>
78
+ <div>
79
+ <div class="sd_subtitle_separator"></div>
80
+ <p><?php echo $this->__('Synchronize and manage all the email lists from your Magento store') ?></p>
81
+ </div>
82
+ </div>
83
+ <div>
84
+ <div>
85
+ <div class="sd_subtitle_separator"></div>
86
+ <p><?php echo $this->__('NEW! Create awesome, responsive newsletters thanks to the EmailBuilder') ?></p>
87
+ </div>
88
+ </div>
89
+ <div>
90
+ <div>
91
+ <div class="sd_subtitle_separator"></div>
92
+ <p><?php echo $this->__('Geolocation, openings, opening time, clicks, opt-outs...') ?></p>
93
+ </div>
94
+ </div>
95
+ <div>
96
+ <div>
97
+ <div class="sd_subtitle_separator"></div>
98
+ <p><?php echo $this->__('Optimal deliverability thanks to our renowned professional routing platform') ?></p>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ <div class="sd_separator"></div>
104
+ <div class="sd_account_offer_container">
105
+ <p class="sd_account"><?php echo $this->__('Create your account for free and start sending emails') ?></p>
106
+ <p class="sd_offer"><?php echo $this->__('No strings attached') ?></p>
107
+ <div class="sd_title_separator_account_offer"></div>
108
+ </div>
109
+ <div class="sd_info_container">
110
+ <div class="sd_info_container_left">
111
+ <div>
112
+ <p class="sd_info_title"><?php echo $this->__('Why choose Sarbacane?') ?></p>
113
+ <div>
114
+ <p><?php echo $this->__('Create your account for free and start sending emails') ?></p>
115
+ <p><?php echo $this->__('Trusted by over 20,000 users worldwide') ?></p>
116
+ <p><?php echo $this->__('Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)') ?></p>
117
+ <p><?php echo $this->__('All you need to succeed: design, customize, send, and follow-up on your campaigns') ?></p>
118
+ <p><?php echo $this->__('A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips...') ?></p>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ <div class="sd_info_container_right">
123
+ <div>
124
+ <p class="sd_info_title"><?php echo $this->__('Need help?') ?></p>
125
+ <div>
126
+ <p><?php echo $this->__('Email:') ?> <?php echo $this->__('support@sarbacane.com') ?></p>
127
+ <p><?php echo $this->__('Tel:') ?> <?php echo $this->__('+33(0) 328 328 040') ?></p>
128
+ <p>
129
+ <?php echo $this->__('Website:') ?>
130
+ <a href="<?php echo $this->__('http://www.sarbacane.com/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento') ?>" target="_blank"><?php echo $this->__('http://www.sarbacane.com') ?></a>
131
+ </p>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ <div id="sd_step"></div>
137
+ <!-- STEP 1 -->
138
+ <div id="sd_step1" class="sd_step<?php if ($displayed_step == 1) { ?> sd_show_step<?php } ?>">
139
+ <p class="sd_step_title"><?php echo $this->__('How to set up the module?') ?></p>
140
+ <div class="sd_step_line"></div>
141
+ <p class="sd_step1_instruction"><?php echo $this->__('Do you already have a Sarbacane Desktop account?') ?></p>
142
+ <form autocomplete="off" action="<?php echo Mage::helper('adminhtml')->getUrl("*/*/*/") ?>#sd_step" method="POST">
143
+ <p class="sd_step1_selection">
144
+ <span>
145
+ <input onclick="sdUserYesNoDisplayButton('yes')" type="radio" id="sd_user_click_yes" name="sd_is_user" value="yes"<?php if ($sd_is_user == "yes") { ?> checked="checked"<?php } ?>/>
146
+ <label for="sd_user_click_yes"><?php echo $this->__('Yes') ?></label>
147
+ </span>
148
+ <span>
149
+ <input onclick="sdUserYesNoDisplayButton('no')" type="radio" id="sd_user_click_no" name="sd_is_user" value="no"<?php if ($sd_is_user == "no") { ?> checked="checked"<?php } ?>/>
150
+ <label for="sd_user_click_no"><?php echo $this->__('No') ?></label>
151
+ </span>
152
+ </p>
153
+ <div class="sd_step_buttons">
154
+ <div class="sd_step_buttons_right">
155
+ <input type="hidden" name="submit_is_user" value="1"/>
156
+ <input type="hidden" name="form_key" value="<?php echo $this->getFormKey() ?>"/>
157
+ <input type="submit" class="sd_button" value="<?php echo $this->__('Next') ?>"/>
158
+ </div>
159
+ </div>
160
+ </form>
161
+ </div>
162
+ <!-- STEP 2 -->
163
+ <div id="sd_step2" class="sd_step<?php if ($displayed_step == 2) { ?> sd_show_step<?php } ?>">
164
+ <div class="sd_step_line"></div>
165
+ <p class="sd_step2_instruction"><?php echo $this->__('Select your shop and pick your settings') ?></p>
166
+ <form autocomplete="off" action="<?php echo Mage::helper('adminhtml')->getUrl("*/*/*/") ?>#sd_step" method="POST">
167
+ <div class="sd_step2_selection">
168
+ <?php foreach ($shops_array as $shop) { ?>
169
+ <div class="sd_step2_selection_list">
170
+ <p class="sd_step2_selection_shop_title"><?php echo $shop['name'] ?></p>
171
+ <div class="sd_step2_selection_shop">
172
+ <div class="sd_step2_selection_shop_input">
173
+ <?php
174
+ $store_value = $shop['store_id'] . 'N0';
175
+ $store_checked = $general_configuration < 3 || in_array($shop['store_id'] . 'N0', $list_configuration);
176
+ ?>
177
+ <input type="checkbox" name="store_id[]" value="<?php echo $store_value ?>"<?php if ($store_checked) { ?> checked="checked"<?php } ?>/>
178
+ </div>
179
+ <div class="sd_step2_selection_shop_text">
180
+ <?php echo $this->__('Create a list in Sarbacane Desktop with newsletter opt-ins') ?>
181
+ </div>
182
+ </div>
183
+ <div class="sd_step2_selection_shop">
184
+ <div class="sd_step2_selection_shop_input">
185
+ <?php
186
+ $store_value = '';
187
+ $store_checked = false;
188
+ $store_with_customer_data = false;
189
+ if (in_array($shop['store_id'] . 'C1', $list_configuration)) {
190
+ $store_value = $shop['store_id'] . 'C1';
191
+ $store_with_customer_data = true;
192
+ $store_checked = true;
193
+ } else if ($general_configuration < 3 || in_array($shop['store_id'] . 'C0', $list_configuration)) {
194
+ $store_value = $shop['store_id'] . 'C0';
195
+ $store_checked = true;
196
+ }
197
+ ?>
198
+ <input id="id_shop_<?php echo $shop['store_id'] ?>C" type="checkbox" name="store_id[]" onclick="changeOptionOrdersDataDisplay('<?php echo $shop['store_id'] ?>C', this.checked)" value="<?php echo $store_value ?>"<?php if ($store_checked) { ?> checked="checked"<?php } ?>/>
199
+ </div>
200
+ <div class="sd_step2_selection_shop_text">
201
+ <?php echo $this->__('Create a list in Sarbacane Desktop with your clients who have an account or who have placed an order online') ?>
202
+ </div>
203
+ </div>
204
+ <div class="sd_step2_selection_shop_option<?php if ($shop['store_id'] == '0') { ?> sd_hidden<?php } ?>">
205
+ <div class="sd_step2_selection_shop_input">
206
+ <input id="customer_data_<?php echo $shop['store_id'] ?>C" type="checkbox" onclick="changeOptionOrdersData('<?php echo $shop['store_id'] ?>C', this.checked)" <?php if ($store_with_customer_data) { ?>checked="checked"<?php } ?>/>
207
+ </div>
208
+ <div class="sd_step2_selection_shop_text">
209
+ <?php echo $this->__('Add order data (date, amount, etc...)') ?>
210
+ </div>
211
+ <div onclick="sdInfoDataOrdersClick('<?php echo $shop['store_id'] ?>C')" onmouseover="sdInfoDataOrdersHover('<?php echo $shop['store_id'] ?>C')" onmouseout="sdInfoDataOrdersOut('<?php echo $shop['store_id'] ?>C')" class="sd_step2_info"></div>
212
+ </div>
213
+ </div>
214
+ <div id="sd_tooltip_<?php echo $shop['store_id'] ?>C" class="sd_tooltip">
215
+ <div>
216
+ <?php echo $this->__('As you enable data from orders, you can also gather extra info in your contact list, and target your recipients in Sarbacane Desktop.') ?>
217
+ <br/><?php echo $this->__('Below are pieces of information that will be added to your contact list:') ?>
218
+ <br/><?php echo $this->__('- Date of first order') ?>
219
+ <br/><?php echo $this->__('- Date of latest order') ?>
220
+ <br/><?php echo $this->__('- Total number of orders') ?>
221
+ <br/><?php echo $this->__('- Total amount of orders') ?>
222
+ <br/><?php echo $this->__('- Amount of the cheapest order') ?>
223
+ <br/><?php echo $this->__('- Amount of the most expensive order') ?>
224
+ <br/><?php echo $this->__('- Average amount of the orders placed') ?>
225
+ </div>
226
+ </div>
227
+ <?php } ?>
228
+ </div>
229
+ <div class="sd_step_buttons">
230
+ <div class="sd_step_buttons_left">
231
+ <input type="button" onclick="sdDisplayStep(1)" value="<?php echo $this->__('Previous') ?>"/>
232
+ </div>
233
+ <div class="sd_step_buttons_right">
234
+ <input type="hidden" name="submit_configuration" value="1"/>
235
+ <input type="hidden" name="submit_is_user" value="<?php echo $this->getIsUser() ?>"/>
236
+ <input type="hidden" name="form_key" value="<?php echo $this->getFormKey() ?>"/>
237
+ <input type="submit" class="sd_button" value="<?php echo $this->__('Next') ?>"/>
238
+ </div>
239
+ </div>
240
+ </form>
241
+ </div>
242
+ <!-- STEP 3 -->
243
+ <div id="sd_step3" class="sd_step<?php if ($displayed_step == 3) { ?> sd_show_step<?php } ?>">
244
+ <div class="sd_step_line"></div>
245
+ <div class="sd_step3_instruction">
246
+ <?php if ($sd_is_user == "yes") { ?>
247
+ <p>1/ <a href="<?php echo $this->__('https://www.sarbacane.com/ws/soft-redirect.asp?key=heXmrxBEUO&com=MagentoInfo') ?>" target="_blank"><?php echo $this->__('Download and install Sarbacane') ?></a></p>
248
+ <p>2/ <?php echo $this->__('Create your free account') ?></p>
249
+ <p>3/ <?php echo $this->__('Enable the Magento extension in our extensions menu, and then fill in the following fields:') ?></p>
250
+ <?php } else if ($sd_is_user == "no") { ?>
251
+ <p><?php echo $this->__('Enable the Magento extension in our extensions menu, and then fill in the following fields:') ?></p>
252
+ <?php } ?>
253
+ <form autocomplete="off" action="<?php echo Mage::helper('adminhtml')->getUrl("*/*/*/") ?>#sd_step" method="POST">
254
+ <div class="sd_key_container">
255
+ <p><?php echo $this->__('Url') ?></p>
256
+ <input value="<?php echo Mage::getBaseUrl() ?>" onclick="this.select()" type="text" readonly/>
257
+ </div>
258
+ <div class="sd_key_container">
259
+ <p><?php echo $this->__('Key') ?></p>
260
+ <?php if ( ! $check_failed) { ?>
261
+ <input value="<?php echo $key_for_synchronisation ?>" onclick="this.select()" type="text" readonly/>
262
+ <?php } else { ?>
263
+ <span><?php echo $this->__('Please generate a new key') ?></span>
264
+ <?php } ?>
265
+ </div>
266
+ <p class="sd_key_button_container">
267
+ <input type="hidden" name="submit_parameter_key" value="1"/>
268
+ <input type="hidden" name="form_key" value="<?php echo $this->getFormKey() ?>"/>
269
+ <input type="submit" class="sd_key_button" value="<?php echo $this->__('Generate a new key') ?>"/>
270
+ </p>
271
+ </form>
272
+ </div>
273
+ <div class="sd_step_buttons">
274
+ <div class="sd_step_buttons_left">
275
+ <input type="button" onclick="sdDisplayStep(2)" value="<?php echo $this->__('Previous') ?>"/>
276
+ </div>
277
+ <div class="sd_step3_right">
278
+ <?php echo $this->__('Read more') ?>, <a href="<?php echo $this->__('http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento') ?>" target="_blank"><?php echo $this->__('in the help section online') ?></a>
279
+ </div>
280
+ </div>
281
+ </div>
282
+ </div>
app/etc/modules/Sarbacane_Sarbacanedesktop.xml CHANGED
@@ -27,4 +27,4 @@
27
  <codePool>community</codePool>
28
  </Sarbacane_Sarbacanedesktop>
29
  </modules>
30
- </config>
27
  <codePool>community</codePool>
28
  </Sarbacane_Sarbacanedesktop>
29
  </modules>
30
+ </config>
app/locale/en_US/Sarbacane_Sarbacanedesktop.csv CHANGED
@@ -1,3 +1,5 @@
 
 
1
  "sarbacane","sarbacane"
2
  "It's easy to manage your newsletter and email campaigns","It's easy to manage your newsletter and email campaigns"
3
  "https://www.youtube.com/embed/eLMy2tSSYgE","https://www.youtube.com/embed/eLMy2tSSYgE"
@@ -14,8 +16,7 @@
14
  "Create your account for free and start sending emails","Create your account for free and start sending emails"
15
  "No strings attached","No strings attached"
16
  "Why choose Sarbacane?","Why choose Sarbacane?"
17
- "Create your account for free and start sending emails,","Create your account for free and start sending emails,"
18
- "Trusted by over 20,000 users worldwide.","Trusted by over 20,000 users worldwide."
19
  "Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)","Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)"
20
  "All you need to succeed: design, customize, send, and follow-up on your campaigns","All you need to succeed: design, customize, send, and follow-up on your campaigns"
21
  "A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips...","A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips..."
@@ -52,6 +53,7 @@
52
  "Enable the Magento extension in our extensions menu, and then fill in the following fields:","Enable the Magento extension in our extensions menu, and then fill in the following fields:"
53
  "Url","Url"
54
  "Key","Key"
 
55
  "Generate a new key","Generate a new key"
56
  "Read more","Read more"
57
  "http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento","http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento"
1
+ "Sarbacane Desktop","Sarbacane Desktop"
2
+ "Other","Other"
3
  "sarbacane","sarbacane"
4
  "It's easy to manage your newsletter and email campaigns","It's easy to manage your newsletter and email campaigns"
5
  "https://www.youtube.com/embed/eLMy2tSSYgE","https://www.youtube.com/embed/eLMy2tSSYgE"
16
  "Create your account for free and start sending emails","Create your account for free and start sending emails"
17
  "No strings attached","No strings attached"
18
  "Why choose Sarbacane?","Why choose Sarbacane?"
19
+ "Trusted by over 20,000 users worldwide","Trusted by over 20,000 users worldwide"
 
20
  "Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)","Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)"
21
  "All you need to succeed: design, customize, send, and follow-up on your campaigns","All you need to succeed: design, customize, send, and follow-up on your campaigns"
22
  "A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips...","A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips..."
53
  "Enable the Magento extension in our extensions menu, and then fill in the following fields:","Enable the Magento extension in our extensions menu, and then fill in the following fields:"
54
  "Url","Url"
55
  "Key","Key"
56
+ "Please generate a new key","Please generate a new key"
57
  "Generate a new key","Generate a new key"
58
  "Read more","Read more"
59
  "http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento","http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento"
app/locale/fr_FR/Sarbacane_Sarbacanedesktop.csv CHANGED
@@ -1,3 +1,5 @@
 
 
1
  "sarbacane","sarbacane"
2
  "It's easy to manage your newsletter and email campaigns","G&eacute;rez vos newsletters et emailing en toute simplicit&eacute;"
3
  "https://www.youtube.com/embed/eLMy2tSSYgE","https://www.youtube.com/embed/eLMy2tSSYgE"
@@ -14,8 +16,7 @@
14
  "Create your account for free and start sending emails","Cr&eacute;ation de compte gratuit et premiers envois offerts"
15
  "No strings attached","Offre sans engagement"
16
  "Why choose Sarbacane?","Pourquoi choisir Sarbacane ?"
17
- "Create your account for free and start sending emails,"
18
- "Trusted by over 20,000 users worldwide.","Plus de 20 000 utilisateurs rien qu'en France d&eacute;j&agrave; conquis par Sarbacane"
19
  "Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)","Elue Meilleure Solution Emailing par Bsoco Awards (comparatif de solutions emailing)"
20
  "All you need to succeed: design, customize, send, and follow-up on your campaigns","Tout ce dont vous avez besoin pour r&eacute;ussir : conception, personnalisation, envoi et suivi des retours de vos campagnes"
21
  "A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips...","Un support technique &agrave; votre &eacute;coute et de nombreuses ressources pour vous aider : vid&eacute;os, tutoriels, guides, conseils..."
@@ -24,7 +25,7 @@
24
  "support@sarbacane.com","support@sarbacane.com"
25
  "Tel:","Tel:"
26
  "+33(0) 328 328 040","+33(0) 328 328 040"
27
- "Website:","Site : "
28
  "http://www.sarbacane.com/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento","http://www.sarbacane.com/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento"
29
  "http://www.sarbacane.com","http://www.sarbacane.com"
30
  "How to set up the module?","Comment configurer le module ?"
@@ -52,6 +53,7 @@
52
  "Enable the Magento extension in our extensions menu, and then fill in the following fields:","Rendez-vous dans la section ''extensions'' et activez l'extension Magento, puis renseignez les &eacute;l&eacute;ments suivants :"
53
  "Url","Url"
54
  "Key","Cl&eacute;"
 
55
  "Generate a new key","G&eacute;n&eacute;rer une nouvelle cl&eacute;"
56
  "Read more","Pour plus de d&eacute;tails"
57
  "http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento","http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento"
1
+ "Sarbacane Desktop","Sarbacane Desktop"
2
+ "Other","Autre"
3
  "sarbacane","sarbacane"
4
  "It's easy to manage your newsletter and email campaigns","G&eacute;rez vos newsletters et emailing en toute simplicit&eacute;"
5
  "https://www.youtube.com/embed/eLMy2tSSYgE","https://www.youtube.com/embed/eLMy2tSSYgE"
16
  "Create your account for free and start sending emails","Cr&eacute;ation de compte gratuit et premiers envois offerts"
17
  "No strings attached","Offre sans engagement"
18
  "Why choose Sarbacane?","Pourquoi choisir Sarbacane ?"
19
+ "Trusted by over 20,000 users worldwide","Plus de 20 000 utilisateurs rien qu'en France d&eacute;j&agrave; conquis par Sarbacane"
 
20
  "Awarded Best Emailing Solution by Bsoco Awards (an index that compares emailing solutions)","Elue Meilleure Solution Emailing par Bsoco Awards (comparatif de solutions emailing)"
21
  "All you need to succeed: design, customize, send, and follow-up on your campaigns","Tout ce dont vous avez besoin pour r&eacute;ussir : conception, personnalisation, envoi et suivi des retours de vos campagnes"
22
  "A tech heldpdesk and a variety of resources to help: videos, tutorials, manuals, tips...","Un support technique &agrave; votre &eacute;coute et de nombreuses ressources pour vous aider : vid&eacute;os, tutoriels, guides, conseils..."
25
  "support@sarbacane.com","support@sarbacane.com"
26
  "Tel:","Tel:"
27
  "+33(0) 328 328 040","+33(0) 328 328 040"
28
+ "Website:","Site :"
29
  "http://www.sarbacane.com/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento","http://www.sarbacane.com/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento"
30
  "http://www.sarbacane.com","http://www.sarbacane.com"
31
  "How to set up the module?","Comment configurer le module ?"
53
  "Enable the Magento extension in our extensions menu, and then fill in the following fields:","Rendez-vous dans la section ''extensions'' et activez l'extension Magento, puis renseignez les &eacute;l&eacute;ments suivants :"
54
  "Url","Url"
55
  "Key","Cl&eacute;"
56
+ "Please generate a new key","Merci de g&eacute;n&eacute;rer une nouvelle cl&eacute;"
57
  "Generate a new key","G&eacute;n&eacute;rer une nouvelle cl&eacute;"
58
  "Read more","Pour plus de d&eacute;tails"
59
  "http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento","http://www.sarbacane.com/faq/extensions/configuration-plugin-magento/?utm_source=module-magento&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=magento"
package.xml CHANGED
@@ -1,12 +1,12 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sarbacane_Sarbacanedesktop</name>
4
- <version>1.0.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/academic.php">AFL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary> The extension synchronizes your e-shop Magento and the emailing solution software Sarbacane Desktop </summary>
10
  <description>&lt;i&gt;With Sarbacane Desktop, easily create and send stunning newsletters to inform your community and increase customer loyalty.&lt;/i&gt;&#xD;
11
  &lt;br /&gt;&#xD;
12
  &lt;h2&gt;Merchant Benefits&lt;/h2&gt;&#xD;
@@ -60,10 +60,10 @@
60
  &lt;/ul&gt;</description>
61
  <notes>We improved performance on synchronization.&#xD;
62
  It should be more efficient and nearly instant on most websites.</notes>
63
- <authors><author><name>Sarbacane Software</name><user>egavard</user><email>connectors@sarbacane.com</email></author></authors>
64
- <date>2015-12-03</date>
65
- <time>16:21:24</time>
66
- <contents><target name="magecommunity"><dir name="Sarbacane"><dir name="Sarbacanedesktop"><dir name="Block"><dir name="Adminhtml"><file name="Sarbacanedesktop.php" hash="96c46a692c69e8c13942d73509436af5"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f3ea000b4a07fdf9e5eea9ef0b48f21a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SarbacanedesktopController.php" hash="a8b2442a589cb30411eed7e47a743563"/></dir><file name="IndexController.php" hash="b4b950e5f45c13feb3a01bf76471f39c"/></dir><dir name="etc"><file name="config.xml" hash="0acdd0ab6ff2ecb1f4cd89ff610a9278"/></dir><dir name="sql"><dir name="sarbacanedesktop_setup"><file name="mysql4-install-1.0.0.0.php" hash="82834af7ce95c1bd9d3063ffdf3a11f5"/><file name="mysql4-upgrade-1.0.0.0-1.0.0.1.php" hash="35660ae27bb6ef74c885ad86284f9071"/><file name="mysql4-upgrade-1.0.0.1-1.0.0.2.php" hash="35660ae27bb6ef74c885ad86284f9071"/><file name="mysql4-upgrade-1.0.0.2-1.0.0.3.php" hash="35660ae27bb6ef74c885ad86284f9071"/><file name="mysql4-upgrade-1.0.0.3-1.0.0.4.php" hash="a2a43fe29d015f53eae5479f2d5fcb3d"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><dir name="Sarbacane_SarbacaneDesktop"><file name="sarbacanedesktop.css" hash="6fcee54bdab10db72a361ec5a139cc7c"/></dir></dir><dir name="images"><file name="sd.png" hash="2038d3c503e8f59d14177a131bef7537"/></dir><dir name="js"><dir name="Sarbacane_SarbacaneDesktop"><file name="sarbacanedesktop.js" hash="d38d9ec858dfdce14e0156acc87c1c50"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sarbacanedesktop.xml" hash="4ec1fc007e23a1eb2d96c719f1e7c128"/></dir><dir name="template"><dir name="sarbacanedesktop"><file name="sarbacanedesktop.phtml" hash="c402cc70b2bc30f8c22d4d7abf54889c"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Sarbacane_Sarbacanedesktop.xml" hash="a922981e127e22e989a09b8c33be6f85"/></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Sarbacane_Sarbacanedesktop.csv" hash="dc86c83c4fc641e7d4f9c648d36aa415"/></dir><dir name="en_US"><file name="Sarbacane_Sarbacanedesktop.csv" hash="fdcdf13b7d458e846ee673a60b9beab4"/></dir></target></contents>
67
  <compatible/>
68
- <dependencies><required><php><min>5.0.0</min><max>5.6.15</max></php></required></dependencies>
69
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sarbacane_Sarbacanedesktop</name>
4
+ <version>1.0.0.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/academic.php">AFL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>The extension synchronizes your e-shop Magento and the emailing solution software Sarbacane Desktop</summary>
10
  <description>&lt;i&gt;With Sarbacane Desktop, easily create and send stunning newsletters to inform your community and increase customer loyalty.&lt;/i&gt;&#xD;
11
  &lt;br /&gt;&#xD;
12
  &lt;h2&gt;Merchant Benefits&lt;/h2&gt;&#xD;
60
  &lt;/ul&gt;</description>
61
  <notes>We improved performance on synchronization.&#xD;
62
  It should be more efficient and nearly instant on most websites.</notes>
63
+ <authors><author><name>Sarbacane Software</name><user>sarbacane</user><email>connectors@sarbacane.com</email></author></authors>
64
+ <date>2017-06-19</date>
65
+ <time>13:14:06</time>
66
+ <contents><target name="magecommunity"><dir name="Sarbacane"><dir name="Sarbacanedesktop"><dir name="Block"><dir name="Adminhtml"><file name="Sarbacanedesktop.php" hash="37acc8335d82b2312609121c7ba7c3aa"/></dir></dir><dir name="Helper"><file name="Data.php" hash="fef9ce9208336fd6ac8ae05b6bcd005b"/></dir><dir name="Model"><file name="Observer.php" hash="9b16a9af99bda0a4d9dbe5e5cf8596db"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SarbacanedesktopController.php" hash="191d391986e63f5654c43a10ac9c56d1"/></dir><file name="IndexController.php" hash="e8f1e9e3e2881590474f9ebd1c02a514"/></dir><dir name="etc"><file name="config.xml" hash="77537c85b83b1acc510d48e2925f52a5"/></dir><dir name="sql"><dir name="sarbacanedesktop_setup"><file name="mysql4-upgrade-1.0.0.7-1.0.0.8.php" hash="27721deaf97fd972aa8540d4bfbb41ba"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="sarbacanedesktop.css" hash="5cfd44b2883bede9f389f195dc65e6ff"/><dir name="images"><file name="sarbacanedesktop.png" hash="2038d3c503e8f59d14177a131bef7537"/></dir><file name="sarbacanedesktop.js" hash="15096b017322b4141926f7469600586c"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sarbacanedesktop.xml" hash="8dbeb59dbc0a5d5a86256880a77b0189"/></dir><dir name="template"><dir name="sarbacanedesktop"><file name="sarbacanedesktop.phtml" hash="145cb3eafd17a8fc6c181ec33c0b0d7a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sarbacane_Sarbacanedesktop.xml" hash="2ad128064122d112a5b087c0967399d6"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Sarbacane_Sarbacanedesktop.csv" hash="3468b7d20d57c6a5d3d2ffa505f347f0"/></dir><dir name="en_US"><file name="Sarbacane_Sarbacanedesktop.csv" hash="ae45c5263eafa7057e1a4bb84ae55091"/></dir></target></contents>
67
  <compatible/>
68
+ <dependencies><required><php><min>5.0.0</min><max>8.0.0</max></php></required></dependencies>
69
  </package>
skin/adminhtml/default/default/images/{sd.png → sarbacanedesktop.png} RENAMED
File without changes
skin/adminhtml/default/default/js/Sarbacane_SarbacaneDesktop/sarbacanedesktop.js DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * Magento
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Academic Free License (AFL 3.0)
7
- * that is bundled with this package in the file LICENSE.txt.
8
- * It is also available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/afl-3.0.php
10
- * If you did not receive a copy of the license and are unable to
11
- * obtain it through the world-wide-web, please send an email
12
- * to license@magentocommerce.com so we can send you a copy immediately.
13
- *
14
- * @category Sarbacane
15
- * @package Sarbacane_Sarbacanedesktop
16
- * @author Sarbacane Software <contact@sarbacane.com>
17
- * @copyright 2015 Sarbacane Software
18
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
- */
20
-
21
- function changeOptionOrdersData(id_shop_c, value) {
22
- if(value == true) {
23
- document.getElementById('id_shop_' + id_shop_c).value=id_shop_c + '1';
24
- }
25
- else {
26
- document.getElementById('id_shop_' + id_shop_c).value=id_shop_c + '0';
27
- }
28
- }
29
-
30
- function changeOptionOrdersDataDisplay(id_shop_c, value) {
31
- if(value == true) {
32
- document.getElementById('customer_data_' + id_shop_c).disabled=false;
33
- document.getElementById('id_shop_' + id_shop_c).value=id_shop_c + '0';
34
-
35
- }
36
- else {
37
- document.getElementById('id_shop_' + id_shop_c).value='';
38
- document.getElementById('customer_data_' + id_shop_c).disabled=true;
39
- document.getElementById('customer_data_' + id_shop_c).checked=false;
40
- }
41
- }
42
-
43
- function sdUserYesNoDisplayButton(user_selection) {
44
- Element.removeClassName("sd_step1 .sd_button","sd_step1_button");
45
- }
46
-
47
- function sdDisplayStep(step) {
48
- var otherSteps = $$(".sd_step");
49
- if(otherSteps != null && otherSteps.length > 0 ){
50
- otherSteps.each(function(item,i){
51
- Element.removeClassName(item,"sd_show_step");
52
- });
53
- }
54
- Element.addClassName("sd_step"+step,"sd_show_step");
55
- window.location.href = '#sd_step';
56
- }
57
-
58
- function sdInfoDataOrdersHover(id_shop_c) {
59
- Element.addClassName('sd_tooltip_' + id_shop_c,"sd_tooltip_show");
60
- }
61
-
62
- function sdInfoDataOrdersOut(id_shop_c) {
63
- Element.removeClassName('sd_tooltip_' + id_shop_c,"sd_tooltip_show");
64
- // $('#sd_tooltip_' + id_shop_c).removeClass('sd_tooltip_show');
65
- }
66
-
67
- function sdInfoDataOrdersClick(id_shop_c) {
68
- Element.toggleClassName('sd_tooltip_' + id_shop_c,"sd_tooltip_show");
69
- // $('#sd_tooltip_' + id_shop_c).toggleClass('sd_tooltip_show');
70
- }
71
- var isAlreadyUser = false;
72
- function showStep2(){
73
- if($(sd_user_click_yes).checked){
74
- $(sd_step1).removeClassName("sd_show_step");
75
- $(sd_step2).addClassName("sd_show_step");
76
- $("3_step_block").hide();
77
- isAlreadyUser = true;
78
- }else{
79
- if($(sd_user_click_no).checked){
80
- $(sd_step1).removeClassName("sd_show_step");
81
- $(sd_step2).addClassName("sd_show_step");
82
- $("1_step_block").hide();
83
- }else{
84
- }
85
- }
86
- }
87
- function showStep3(){
88
- $(sd_step2).removeClassName("sd_show_step");
89
- $(sd_step3).addClassName("sd_show_step");
90
- if(isAlreadyUser){
91
- $("3_step_block").hide();
92
- }else{
93
- $("1_step_block").hide();
94
- }
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
skin/adminhtml/default/default/{css/Sarbacane_SarbacaneDesktop/sarbacanedesktop.css → sarbacanedesktop.css} RENAMED
@@ -23,7 +23,7 @@
23
  #sarbacanedesktop p, #sarbacanedesktop form p{margin:0 0 8.5px;padding:0;}
24
  #sarbacanedesktop a{color:#f06800;}
25
  #sarbacanedesktop .sd_header{padding-top:20px;padding-bottom:20px;}
26
- #sarbacanedesktop .sd_logo_sarbacane, #sarbacanedesktop .sd_logo_mailify, #sarbacanedesktop .sd_picto1, #sarbacanedesktop .sd_picto2, #sarbacanedesktop .sd_picto3, #sarbacanedesktop .sd_picto4, #sarbacanedesktop .sd_info_container_left > div > div > p, #sarbacanedesktop .sd_info_line,#sarbacanedesktop .sd_step_line, #sarbacanedesktop .sd_step2_info, #sarbacanedesktop .sd_info_container_right{background-repeat:no-repeat;background-image:url('../../images/sd.png');}
27
  #sarbacanedesktop .sd_logo_sarbacane{margin:auto;width:318px;height:45px;background-position:-150px -99px;}
28
  #sarbacanedesktop .sd_logo_mailify{margin:auto;width:192px;height:55px;background-position:-469px -98px;}
29
  #sarbacanedesktop .sd_separator{border-top:1px solid #ebedf2;padding-bottom:5px;margin-top:5px;}
@@ -73,9 +73,9 @@
73
  #sarbacanedesktop .sd_step_buttons_left{float:left;width:340px;text-align:left;}
74
  #sarbacanedesktop .sd_step_buttons_right{float:right;width:340px;text-align:right;}
75
  #sarbacanedesktop .sd_step3_right{float:right;width:340px;text-align:right;padding-top:10px;}
76
- #sarbacanedesktop .sd_step_buttons input[type="button"], #sarbacanedesktop .sd_step_buttons input[type="submit"], #sarbacanedesktop input[type="submit"].sd_key_button,.sd_button{color:white;padding:10px 20px;border:none;cursor:pointer;}
77
  #sarbacanedesktop .sd_step_buttons .sd_step_buttons_left input[type="button"], #sarbacanedesktop input[type="submit"].sd_key_button{background:#808080;}
78
- #sarbacanedesktop .sd_step_buttons .sd_step_buttons_right input[type="submit"],.sd_button{background:#78a13a;}
79
  #sarbacanedesktop .sd_step1_instruction, #sarbacanedesktop .sd_step2_instruction{font-size:16px;text-align:center;}
80
  #sarbacanedesktop .sd_step1_selection{padding:10px 0px;text-align:center;}
81
  #sarbacanedesktop .sd_step1_selection span{padding:0 20px;}
@@ -102,6 +102,4 @@
102
  #sarbacanedesktop .sd_tooltip_show{display:block;}
103
  #sarbacanedesktop .sd_tooltip *{font-size:11px;line-height:13px;}
104
  #sarbacanedesktop .sd_tooltip div{background:#858585;border:1px solid white;position:absolute;right:15px;width:360px;bottom:25px;padding:20px;}
105
- .HIDDEN{
106
- display:none;
107
- }
23
  #sarbacanedesktop p, #sarbacanedesktop form p{margin:0 0 8.5px;padding:0;}
24
  #sarbacanedesktop a{color:#f06800;}
25
  #sarbacanedesktop .sd_header{padding-top:20px;padding-bottom:20px;}
26
+ #sarbacanedesktop .sd_logo_sarbacane, #sarbacanedesktop .sd_logo_mailify, #sarbacanedesktop .sd_picto1, #sarbacanedesktop .sd_picto2, #sarbacanedesktop .sd_picto3, #sarbacanedesktop .sd_picto4, #sarbacanedesktop .sd_info_container_left > div > div > p, #sarbacanedesktop .sd_info_line,#sarbacanedesktop .sd_step_line, #sarbacanedesktop .sd_step2_info, #sarbacanedesktop .sd_info_container_right{background-repeat:no-repeat;background-image:url('images/sarbacanedesktop.png');}
27
  #sarbacanedesktop .sd_logo_sarbacane{margin:auto;width:318px;height:45px;background-position:-150px -99px;}
28
  #sarbacanedesktop .sd_logo_mailify{margin:auto;width:192px;height:55px;background-position:-469px -98px;}
29
  #sarbacanedesktop .sd_separator{border-top:1px solid #ebedf2;padding-bottom:5px;margin-top:5px;}
73
  #sarbacanedesktop .sd_step_buttons_left{float:left;width:340px;text-align:left;}
74
  #sarbacanedesktop .sd_step_buttons_right{float:right;width:340px;text-align:right;}
75
  #sarbacanedesktop .sd_step3_right{float:right;width:340px;text-align:right;padding-top:10px;}
76
+ #sarbacanedesktop .sd_step_buttons input[type="button"], #sarbacanedesktop .sd_step_buttons input[type="submit"], #sarbacanedesktop input[type="submit"].sd_key_button, #sarbacanedesktop .sd_button{color:white;padding:10px 20px;border:none;cursor:pointer;}
77
  #sarbacanedesktop .sd_step_buttons .sd_step_buttons_left input[type="button"], #sarbacanedesktop input[type="submit"].sd_key_button{background:#808080;}
78
+ #sarbacanedesktop .sd_step_buttons .sd_step_buttons_right input[type="submit"], #sarbacanedesktop .sd_button{background:#78a13a;}
79
  #sarbacanedesktop .sd_step1_instruction, #sarbacanedesktop .sd_step2_instruction{font-size:16px;text-align:center;}
80
  #sarbacanedesktop .sd_step1_selection{padding:10px 0px;text-align:center;}
81
  #sarbacanedesktop .sd_step1_selection span{padding:0 20px;}
102
  #sarbacanedesktop .sd_tooltip_show{display:block;}
103
  #sarbacanedesktop .sd_tooltip *{font-size:11px;line-height:13px;}
104
  #sarbacanedesktop .sd_tooltip div{background:#858585;border:1px solid white;position:absolute;right:15px;width:360px;bottom:25px;padding:20px;}
105
+ #sarbacanedesktop .sd_hidden{display:none;}
 
 
skin/adminhtml/default/default/sarbacanedesktop.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Academic Free License (AFL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/afl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Sarbacane
15
+ * @package Sarbacane_Sarbacanedesktop
16
+ * @author Sarbacane Software <contact@sarbacane.com>
17
+ * @copyright 2015 Sarbacane Software
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+
21
+ function changeOptionOrdersData(id_shop_c, value) {
22
+ if (value == true) {
23
+ document.getElementById('id_shop_' + id_shop_c).value = id_shop_c + '1';
24
+ }
25
+ else {
26
+ document.getElementById('id_shop_' + id_shop_c).value = id_shop_c + '0';
27
+ }
28
+ }
29
+
30
+ function changeOptionOrdersDataDisplay(id_shop_c, value) {
31
+ if (value == true) {
32
+ document.getElementById('customer_data_' + id_shop_c).disabled = false;
33
+ document.getElementById('id_shop_' + id_shop_c).value=id_shop_c + '0';
34
+
35
+ }
36
+ else {
37
+ document.getElementById('id_shop_' + id_shop_c).value='';
38
+ document.getElementById('customer_data_' + id_shop_c).disabled = true;
39
+ document.getElementById('customer_data_' + id_shop_c).checked = false;
40
+ }
41
+ }
42
+
43
+ function sdUserYesNoDisplayButton(user_selection) {
44
+ Element.removeClassName('sd_step1 .sd_button', 'sd_step1_button');
45
+ }
46
+
47
+ function sdDisplaySteps() {
48
+ window.location.href = '#sd_step';
49
+ }
50
+
51
+ function sdDisplayStep(step) {
52
+ $$('.sd_step').each(function(item) {
53
+ Element.removeClassName(item, 'sd_show_step');
54
+ });
55
+ Element.addClassName('sd_step' + step, 'sd_show_step');
56
+ window.location.href = '#sd_step';
57
+ }
58
+
59
+ function sdInfoDataOrdersHover(id_shop_c) {
60
+ Element.addClassName('sd_tooltip_' + id_shop_c, 'sd_tooltip_show');
61
+ }
62
+
63
+ function sdInfoDataOrdersOut(id_shop_c) {
64
+ Element.removeClassName('sd_tooltip_' + id_shop_c, 'sd_tooltip_show');
65
+ }
66
+
67
+ function sdInfoDataOrdersClick(id_shop_c) {
68
+ Element.toggleClassName('sd_tooltip_' + id_shop_c, 'sd_tooltip_show');
69
+ }
70
+
71
+ function sdErrorTryReinstall() {
72
+ Element.addClassName('sd_error_try_reinstall', 'sd_hidden');
73
+ Element.removeClassName('sd_error_try_reinstall_inactive', 'sd_hidden');
74
+ }