Livedata_Solutions - Version 1.0.1

Version Notes

Syncronization and SMTP transactionals

Download this release

Release Info

Developer Toni
Extension Livedata_Solutions
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Livedata/README.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The folder Livedata must be located in the route:
2
+ app/code/community
3
+
4
+ The file Livedata_Trans.xml must be located in the route:
5
+ etc/modules
6
+ mv /var/www/magento/app/code/community/Livedata/Livedata_Trans.xml /var/www/magento/app/etc/modules/
7
+
8
+ Install the smtp pluggin from:
9
+ https://www.magentocommerce.com/magento-connect/smtp-pro-email-free-custom-smtp-email.html
10
+ "http://connect20.magentocommerce.com/community/ASchroder_SMTPPro"
11
+ SMTP config:
12
+
13
+
14
+ chmod 775
15
+
16
+ clear chache
app/code/community/Livedata/Trans/Helper/Contact.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Contact helper
5
+ *
6
+ * @author Livedata
7
+ */
8
+ class Livedata_Trans_Helper_Contact extends Mage_Core_Helper_Abstract
9
+ {
10
+ const ATTR_CREATION_CONTACT_DATE = 'custom_magentocreationcontactdate';
11
+ const ATTR_CREATION_ORDER_DATE = 'custom_magentocreationorderdate';
12
+ const ATTR_IMPORT = 'custom_magentoimport';
13
+ const ATTR_TOTAL_IMPORT = 'custom_magentototalimport';
14
+
15
+ /**
16
+ * add or update contact in database
17
+ *
18
+ * @param array $contact
19
+ * @return array
20
+ */
21
+ public function addOrUpdateContact($contact)
22
+ {
23
+ $environment = Mage::getStoreConfig('trans/view/api_url');
24
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
25
+ $username = Mage::getStoreConfig('trans/view/from_user');
26
+ $password = Mage::getStoreConfig('trans/view/from_password');
27
+ $result = array();
28
+ // input fields validation
29
+ $validation = $this->validateInputValues($environment, $baseId, $username, $password);
30
+ if($validation['code'] == 200) {
31
+ $headers = $this->generateWSSEHeader($username, $password);
32
+ // prepare contact fields
33
+ if(!is_null($contact->getAddressesCollection()->getFirstitem()->getPostcode()))
34
+ $zipcode = '&zipcode='.$contact->getAddressesCollection()->getFirstitem()->getPostcode();
35
+ else
36
+ $zipcode = "";
37
+ // change date of birtday format
38
+ if ($contact->getDob() != "")
39
+ $birthdate = '&birthdate='.date("Y-m-d", strtotime($contact->getDob()));
40
+ else
41
+ $birthdate = "";
42
+ // check if it's a new contact or updated
43
+ $ch = curl_init();
44
+ $httpMethod = 'GET';
45
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$contact->getEmail());
46
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
47
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
48
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
49
+ $response = curl_exec($ch);
50
+ curl_close($ch);
51
+ $getContact = json_decode($response, true);
52
+ // initializace custom attributes
53
+ if($getContact['statusCode'] == 200) {
54
+ // updated contact
55
+ $customAttrImport = '';
56
+ $customAttrTotalImport = '';
57
+ $created = '';
58
+ $result['contactExist'] = true;
59
+ } else {
60
+ // new contact
61
+ $customAttrImport = '&'.self::ATTR_IMPORT.'= 0.00';
62
+ $customAttrTotalImport = '&'.self::ATTR_TOTAL_IMPORT.'= 0.00';
63
+ $created = '&'.self::ATTR_CREATION_CONTACT_DATE.'='.date("Y-m-d");
64
+ $result['contactExist'] = false;
65
+ }
66
+
67
+ // add or update contact
68
+ $ch = curl_init();
69
+ $httpMethod = 'PUT';
70
+ // insert or update standar attributes
71
+ $fieldsString = 'firstname='.$contact->getFirstname().'&lastname='.$contact->getLastname()./*'&title='.$contact->getPrefix().*/$birthdate.$zipcode.$created.$customAttrImport.$customAttrTotalImport;
72
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$contact->getEmail());
73
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
74
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
75
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
76
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
77
+ $response = curl_exec($ch);
78
+ curl_close($ch);
79
+ $contactupdated = json_decode($response, true);
80
+ $result['code'] = $contactupdated['statusCode'];
81
+ $result['message'] = $contactupdated['message'];
82
+ } else {
83
+ $result['code'] = $validation['code'];
84
+ $result['message'] = $validation['message'];
85
+ }
86
+
87
+ return $result;
88
+ }
89
+
90
+ /**
91
+ * function to validate input fields are not blank
92
+ *
93
+ * @param string $environment
94
+ * @param string $baseId
95
+ * @param string $username
96
+ * @param string $password
97
+ * @return array
98
+ */
99
+ public function validateInputValues($environment, $baseId, $username, $password)
100
+ {
101
+ $result = array('code' => 200, 'message' => 'ok');
102
+ // validate username
103
+ if("" == $environment) {
104
+ Mage::getSingleton('core/session')->addError('API url field is empty and it is mandatory');
105
+ $result['code'] = 401;
106
+ $result['message'] = 'API url field is empty and it is mandatory';
107
+ }
108
+ if("" == $baseId) {
109
+ Mage::getSingleton('core/session')->addError('API key field is empty and it is mandatory');
110
+ $result['code'] = 401;
111
+ $result['message'] = 'API key field is empty and it is mandatory';
112
+ }
113
+ if("" == $username) {
114
+ Mage::getSingleton('core/session')->addError('Username field is empty and it is mandatory');
115
+ $result['code'] = 401;
116
+ $result['message'] = 'Username field is empty and it is mandatory';
117
+ }
118
+ if("" == $password) {
119
+ Mage::getSingleton('core/session')->addError('Password field is empty and it is mandatory');
120
+ $result['code'] = 401;
121
+ $result['message'] = 'Password field is empty and it is mandatory';
122
+ }
123
+
124
+ return $result;
125
+ }
126
+
127
+ /**
128
+ * function to generate wsseheader
129
+ *
130
+ * @param $username
131
+ * @param $password
132
+ * @return array
133
+ */
134
+ public function generateWSSEHeader($username, $password)
135
+ {
136
+ $created = date('c');
137
+ $nonce = substr(md5(uniqid('nonce_', true)),0,16);
138
+ $nonce64 = base64_encode($nonce);
139
+ $passwordDigest = base64_encode(sha1($nonce . $created . $password, true));
140
+
141
+ return array('X-WSSE: UsernameToken Username="' . $username . '", PasswordDigest="' . $passwordDigest . '", Nonce="' . $nonce64 . '", Created="'. $created . '"');
142
+ }
143
+
144
+ /**
145
+ * function to add a contact in a contact list
146
+ *
147
+ * @param string $email
148
+ * @param integer $listId
149
+ * @return array
150
+ */
151
+ public function insertContactToList($email, $listId)
152
+ {
153
+ $environment = Mage::getStoreConfig('trans/view/api_url');
154
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
155
+ $username = Mage::getStoreConfig('trans/view/from_user');
156
+ $password = Mage::getStoreConfig('trans/view/from_password');
157
+ $result = array();
158
+ // insert contact in list
159
+ $httpMethod = 'PUT';
160
+ $ch = curl_init();
161
+ $headers = $this->generateWSSEHeader($username, $password);
162
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contact_lists/'.$listId.'/contact/'.$email);
163
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
164
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
165
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
166
+ $response = curl_exec($ch);
167
+ curl_close($ch);
168
+ $result = json_decode($response, true);
169
+
170
+ return $result;
171
+ }
172
+
173
+ /**
174
+ * function to unsubscribe a contact
175
+ *
176
+ * @param $email
177
+ * @return array
178
+ */
179
+ public function unsubscribeContact($email)
180
+ {
181
+ $environment = Mage::getStoreConfig('trans/view/api_url');
182
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
183
+ $username = Mage::getStoreConfig('trans/view/from_user');
184
+ $password = Mage::getStoreConfig('trans/view/from_password');
185
+ $httpMethod = 'PUT';
186
+ $headers = $this->generateWSSEHeader($username, $password);
187
+
188
+ $ch = curl_init();
189
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$email.'/unsubscription');
190
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
191
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
192
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
193
+ $response = curl_exec($ch);
194
+ curl_close($ch);
195
+ $res = json_decode($response, true);
196
+
197
+ return $res;
198
+ }
199
+
200
+ /**
201
+ * function to resubscribe a contact
202
+ *
203
+ * @param $email
204
+ * @return array
205
+ */
206
+ public function resubscribeContact($email)
207
+ {
208
+ $environment = Mage::getStoreConfig('trans/view/api_url');
209
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
210
+ $username = Mage::getStoreConfig('trans/view/from_user');
211
+ $password = Mage::getStoreConfig('trans/view/from_password');
212
+ $httpMethod = 'PUT';
213
+ $headers = $this->generateWSSEHeader($username, $password);
214
+
215
+ $ch = curl_init();
216
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$email.'/resubscription');
217
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
218
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
219
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
220
+ $response = curl_exec($ch);
221
+ curl_close($ch);
222
+ $res = json_decode($response, true);
223
+
224
+ return $res;
225
+ }
226
+
227
+ /**
228
+ * function to update magento custom attributes when a payment has been done
229
+ *
230
+ * @param $email
231
+ * @param $import
232
+ * @return array
233
+ */
234
+ public function updateMagentoPaymentAttr($email, $import)
235
+ {
236
+ $environment = Mage::getStoreConfig('trans/view/api_url');
237
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
238
+ $username = Mage::getStoreConfig('trans/view/from_user');
239
+ $password = Mage::getStoreConfig('trans/view/from_password');
240
+ $httpMethod = 'PUT';
241
+ $headers = $this->generateWSSEHeader($username, $password);
242
+ $created = date("Y-m-d");
243
+ $ch = curl_init();
244
+ // get the value of total import from attribute
245
+ $currentTV = $this->getCurrentTotalImport($email,$import);
246
+ $fieldsString = self::ATTR_CREATION_ORDER_DATE.'='.$created.'&'.self::ATTR_IMPORT.'='.number_format($import, 2).'&'.self::ATTR_TOTAL_IMPORT.'='.number_format($currentTV, 2);
247
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$email);
248
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
249
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
250
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
251
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
252
+ $response = curl_exec($ch);
253
+ curl_close($ch);
254
+ $res = json_decode($response, true);
255
+
256
+ return $res;
257
+ }
258
+
259
+ /**
260
+ * add the import in the current total import
261
+ *
262
+ * @param $email
263
+ * @param $import
264
+ * @return array
265
+ */
266
+ private function getCurrentTotalImport($email, $import)
267
+ {
268
+ $environment = Mage::getStoreConfig('trans/view/api_url');
269
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
270
+ $username = Mage::getStoreConfig('trans/view/from_user');
271
+ $password = Mage::getStoreConfig('trans/view/from_password');
272
+ $httpMethod = 'GET';
273
+ $headers = $this->generateWSSEHeader($username, $password);
274
+ $ch = curl_init();
275
+ $totalimport = floatval($import);
276
+ $total = "";
277
+
278
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$email);
279
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
280
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
281
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
282
+ $response = curl_exec($ch);
283
+ curl_close($ch);
284
+ $res = json_decode($response, true);
285
+
286
+ if($res['statusCode'] == 200) {
287
+ if(array_key_exists('CUSTOM_MAGENTOTOTALIMPORT', $res['result'][0])) {
288
+ $val1 = $res['result'][0]['CUSTOM_MAGENTOTOTALIMPORT'];
289
+ $totalvalue = floatval($val1) + $totalimport;
290
+ $total = strval($totalvalue);
291
+ } else
292
+ $total = $totalimport;
293
+ }
294
+ return $total;
295
+ }
296
+ }
app/code/community/Livedata/Trans/Helper/Contactlist.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contact list helper
4
+ *
5
+ * @author Livedata
6
+ */
7
+ class Livedata_Trans_Helper_Contactlist extends Mage_Core_Helper_Abstract
8
+ {
9
+ /**
10
+ * get the contact list availables
11
+ *
12
+ * @return array
13
+ */
14
+ public function getAllLists()
15
+ {
16
+ $environment = Mage::getStoreConfig('trans/view/api_url');
17
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
18
+ $username = Mage::getStoreConfig('trans/view/from_user');
19
+ $password = Mage::getStoreConfig('trans/view/from_password');
20
+ $httpMethod = 'GET';
21
+ $result = array();
22
+ // check that all the fields are not empty
23
+ if(!empty($environment) && !empty($baseId) && !empty($username) && !empty($password)) {
24
+ $ch = curl_init();
25
+ $headers = $this->generateWSSEHeader($username, $password);
26
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contact_lists');
27
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
28
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
29
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
30
+
31
+ $response = curl_exec($ch);
32
+ curl_close($ch);
33
+ $contactLists = json_decode($response, true);
34
+
35
+ if ($contactLists['statusCode'] == 200)
36
+ $result = $contactLists['result']['data'];
37
+ }
38
+
39
+ return $result;
40
+ }
41
+
42
+ /**
43
+ * create new contact list
44
+ *
45
+ * @return array
46
+ */
47
+ public function createNewList()
48
+ {
49
+ $listName = Mage::getStoreConfig('trans/list/from_list_name');
50
+ $environment = Mage::getStoreConfig('trans/view/api_url');
51
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
52
+ $username = Mage::getStoreConfig('trans/view/from_user');
53
+ $password = Mage::getStoreConfig('trans/view/from_password');
54
+ $contact = Mage::getSingleton('admin/session')->getUser()->getEmail();
55
+ $fieldsString = '';
56
+ $httpMethod = 'PUT';
57
+ $result = array('code' => 400, 'message' => 'Some mandatory parameters are not defined');
58
+ // check that all the fields are not empty
59
+ if(!empty($environment) && !empty($baseId) && !empty($username) && !empty($password)) {
60
+ $ch = curl_init();
61
+ $headers = $this->generateWSSEHeader($username, $password);
62
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contact_lists');
63
+ $fields = array('name' => urlencode($listName),
64
+ 'description' => urlencode($username.' created this list from Magento'),
65
+ 'emaillist' => urlencode($contact),
66
+ 'batList' => urlencode('false')
67
+ );
68
+ foreach($fields as $key=>$value) { $fieldsString .= $key.'='.$value.'&'; }
69
+ rtrim($fieldsString, '&');
70
+
71
+ curl_setopt($ch, CURLOPT_POST, count($fields));
72
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
73
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
74
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
75
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
76
+
77
+ $response = curl_exec($ch);
78
+ curl_close($ch);
79
+ $result = json_decode($response, true);
80
+ }
81
+
82
+ return $result;
83
+ }
84
+
85
+ /**
86
+ * function to generate wsseheader
87
+ *
88
+ * @param $username
89
+ * @param $password
90
+ * @return array
91
+ */
92
+ private function generateWSSEHeader($username, $password)
93
+ {
94
+ $created = date('c');
95
+ $nonce = substr(md5(uniqid('nonce_', true)),0,16);
96
+ $nonce64 = base64_encode($nonce);
97
+ $passwordDigest = base64_encode(sha1($nonce . $created . $password, true));
98
+
99
+ return array('X-WSSE: UsernameToken Username="' . $username . '", PasswordDigest="' . $passwordDigest . '", Nonce="' . $nonce64 . '", Created="'. $created . '"');
100
+ }
101
+ }
app/code/community/Livedata/Trans/Model/Observer.php ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Livedata_Trans_Model_Observer
4
+ {
5
+ const ATTR_CREATION_CONTACT_DATE = 'custom_magentocreationcontactdate';
6
+ const ATTR_CREATION_ORDER_DATE = 'custom_magentocreationorderdate';
7
+ const ATTR_IMPORT = 'custom_magentoimport';
8
+ const ATTR_TOTAL_IMPORT = 'custom_magentototalimport';
9
+
10
+ /**
11
+ * event to sync the existing contacts to livedata database
12
+ *
13
+ */
14
+ public function adminSystemConfigChangedSection()
15
+ {
16
+ $customExist = false;
17
+ // check if enable send transactionals is allowed
18
+ if (Mage::getStoreConfig('trans/view/sendtrans')) {
19
+ // validate that the contact attributes are not created
20
+ $customExist = $this->checkCustomAttr();
21
+ // if some custome does not exist, create them
22
+ if(!$customExist) {
23
+ // create custom attributes
24
+ $customCreated = $this->createCustomAttr();
25
+ if($customCreated['code'] != 200)
26
+ Mage::getSingleton('core/session')->addError('An error ocurred while creating some custom attributes: ' . $customCreated['message'] . ' Please contact with Livedata support team.');
27
+ else
28
+ $customExist = true;
29
+ }
30
+ }
31
+
32
+ // check if enable syncronize all contacts pluggin is selected
33
+ if (Mage::getStoreConfig('trans/view/enabled')) {
34
+ // validate that the contact attributes are created
35
+ if($customExist) {
36
+ // get the magento contacts
37
+ $contacts = $this->getCustomerContacts();
38
+ $updated = true;
39
+ foreach ($contacts as $user) {
40
+ $contactdb = $user->getData();
41
+ // get only the active contacts
42
+ if($contactdb['is_active'] == '1') {
43
+ // get customer postcode
44
+ $contactdb['postcode'] = $this->getCustomerAddress($contactdb['email']);
45
+ // get cutomer grand total
46
+ $customerAmount = $this->getCustomerGrandTotal($contactdb['email']);
47
+ $contactdb['totalAmount'] = $customerAmount['total'];
48
+ $contactdb['lastAmount'] = $customerAmount['last'];
49
+ // sync contact: add/update contact with standard attr in database
50
+ $contact = $this->addOrUpdateContact($contactdb);
51
+ if($contact['code'] == 200 || $contact['code'] == 201) {
52
+ // if the contact has been inserted or updated, and there is a contact list selected and allowed, insert it in the list
53
+ $listId = Mage::getStoreConfig('trans/selectlist/from_list');
54
+ if($listId != 0)
55
+ Mage::helper('livedata_trans/contact')->insertContactToList($contactdb['email'], $listId);
56
+ } else
57
+ $updated = false;
58
+ // if it is a new contact, unsubscribe it if it is not subscribed in the newsletter
59
+ if($contact['code'] == 201) {
60
+ //unsubscribe contact
61
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($contactdb['email']);
62
+ if (array_key_exists('subscriber_status', $subscriber) && $subscriber['subscriber_status'] == 3) {
63
+ $unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($contactdb['email']);
64
+ if($unsubscribeContact['statusCode'] != 200)
65
+ $updated = false;
66
+ } elseif (!array_key_exists('subscriber_status', $subscriber)) {
67
+ $unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($contactdb['email']);
68
+ if($unsubscribeContact['statusCode'] != 200)
69
+ $updated = false;
70
+ }
71
+ }
72
+ }
73
+ }
74
+ // if some contact has not been inserted or included in the list or unsubscribe it show a notice
75
+ if(!$updated)
76
+ Mage::getSingleton('core/session')->addNotice('Some contact has not been inserted correctly in the synchronization process');
77
+ } else
78
+ Mage::getSingleton('core/session')->addError('Custom Attributes are not already created. Enable the "Enable send Transactionals with Livedata" option.');
79
+ } else
80
+ Mage::getSingleton('core/session')->addNotice('You have not allowed the Livedata synchronization settings. Check it if you want to syncronize all the existing contacts.');
81
+
82
+ // create new contact list
83
+ if (Mage::getStoreConfig('trans/list/enabled_list')) {
84
+ $contactlist = Mage::helper('livedata_trans/contactlist')->createNewList();
85
+ if($contactlist['statusCode'] != 200)
86
+ Mage::getSingleton('core/session')->addError('An error ocurred while creating the contact list: ' . $contactlist['message'] . ' Please contact with Livedata support team.');
87
+ }
88
+ }
89
+
90
+ /**
91
+ * add or update contact in database
92
+ *
93
+ * @param array $contact
94
+ * @return array
95
+ */
96
+ public function addOrUpdateContact($contact)
97
+ {
98
+ $environment = Mage::getStoreConfig('trans/view/api_url');
99
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
100
+ $username = Mage::getStoreConfig('trans/view/from_user');
101
+ $password = Mage::getStoreConfig('trans/view/from_password');
102
+ $httpMethod = 'PUT';
103
+ $result = array();
104
+ // input fields validation
105
+ $validation = Mage::helper('livedata_trans/contact')->validateInputValues($environment, $baseId, $username, $password);
106
+ if($validation['code'] == 200) {
107
+ // change date of birtday format
108
+ if (array_key_exists('dob', $contact) && $contact['dob'] != "")
109
+ $birthdate = '&birthdate='.date("Y-m-d", strtotime($contact['dob']));
110
+ else
111
+ $birthdate = "";
112
+ if(array_key_exists('prefix', $contact))
113
+ $prefix = $contact['prefix'];
114
+ else
115
+ $prefix = "";
116
+ $contactCreated = date("Y-m-d", strtotime($contact['created_at']));
117
+ // add or update contact
118
+ $ch = curl_init();
119
+ $headers = Mage::helper('livedata_trans/contact')->generateWSSEHeader($username, $password);
120
+ // insert or update standar attributes
121
+ $fieldsString = 'firstname='.$contact['firstname'].'&lastname='.$contact['lastname'].'&title='.$prefix.$birthdate.'&zipcode='.$contact['postcode'].'&'.self::ATTR_CREATION_CONTACT_DATE.'='.$contactCreated.'&'.self::ATTR_IMPORT.'='.$contact['lastAmount'].'&'.self::ATTR_TOTAL_IMPORT.'='.$contact['totalAmount'];
122
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/contacts/'.$contact['email']);
123
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
124
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
125
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
126
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
127
+ $response = curl_exec($ch);
128
+ curl_close($ch);
129
+ $contact = json_decode($response, true);
130
+ $result['code'] = $contact['statusCode'];
131
+ $result['message'] = $contact['message'];
132
+ } else {
133
+ $result['code'] = $validation['code'];
134
+ $result['message'] = $validation['message'];
135
+ }
136
+
137
+ return $result;
138
+ }
139
+
140
+ /**
141
+ * function to create magento custom attributes
142
+ *
143
+ * @return array
144
+ */
145
+ private function createCustomAttr()
146
+ {
147
+ $environment = Mage::getStoreConfig('trans/view/api_url');
148
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
149
+ $username = Mage::getStoreConfig('trans/view/from_user');
150
+ $password = Mage::getStoreConfig('trans/view/from_password');
151
+ $result = array('code' => 200, 'message' => 'ok');
152
+ $customAttr = array();
153
+ $customAttr[] = 'name=magento_creation_contact_date&type=date';
154
+ $customAttr[] = 'name=magento_creation_order_date&type=date';
155
+ $customAttr[] = 'name=magento_import&type=string';
156
+ $customAttr[] = 'name=magento_total_import&type=string';
157
+ // insert contact in list
158
+ $httpMethod = 'PUT';
159
+ $headers = Mage::helper('livedata_trans/contact')->generateWSSEHeader($username, $password);
160
+ foreach ($customAttr as $fieldsString) {
161
+ $ch = curl_init();
162
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/attributes/customs');
163
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
164
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
165
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
166
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
167
+ $response = curl_exec($ch);
168
+ curl_close($ch);
169
+ $res = json_decode($response, true);
170
+ if($res['statusCode'] != 201) {
171
+ $result['code'] = $res['statusCode'];
172
+ $result['message'] = $res['message'];
173
+ }
174
+ }
175
+
176
+ return $result;
177
+ }
178
+
179
+ /**
180
+ * function to check if contact attributes are already created
181
+ *
182
+ * @return boolean
183
+ */
184
+ private function checkCustomAttr()
185
+ {
186
+ $result = false;
187
+ $environment = Mage::getStoreConfig('trans/view/api_url');
188
+ $baseId = Mage::getStoreConfig('trans/view/api_key');
189
+ $username = Mage::getStoreConfig('trans/view/from_user');
190
+ $password = Mage::getStoreConfig('trans/view/from_password');
191
+ $httpMethod = 'GET';
192
+ $headers = Mage::helper('livedata_trans/contact')->generateWSSEHeader($username, $password);
193
+ $ch = curl_init();
194
+ curl_setopt($ch, CURLOPT_URL, $environment.$baseId.'/attributes');
195
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
196
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
197
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
198
+ $response = curl_exec($ch);
199
+ curl_close($ch);
200
+ $res = json_decode($response, true);
201
+ // search the attributes in all lists
202
+ if(200 == $res['statusCode']) {
203
+ if($this->searchForName('magento_creation_contact_date',$res['result']['data']) && $this->searchForName('magento_creation_order_date',$res['result']['data']) && $this->searchForName('magento_import',$res['result']['data']) && $this->searchForName('magento_total_import',$res['result']['data']))
204
+ $result = true;
205
+ }
206
+
207
+ return $result;
208
+ }
209
+
210
+ /**
211
+ * function to search in array of arrays
212
+ *
213
+ * @param string
214
+ * @param array
215
+ * @return boolean
216
+ */
217
+ function searchForName($id, $array) {
218
+ foreach ($array as $key => $val) {
219
+ if ($val['name'] === $id)
220
+ return true;
221
+ }
222
+ return false;
223
+ }
224
+
225
+ /**
226
+ * function to get the customer contacts
227
+ *
228
+ * @return array
229
+ */
230
+ private function getCustomerContacts()
231
+ {
232
+ $users = mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('prefix')->addAttributeToSelect('dob');
233
+ return $users;
234
+ }
235
+
236
+ /**
237
+ * function to get the customer addresses by email
238
+ *
239
+ * @param string $email
240
+ * @return array
241
+ */
242
+ private function getCustomerAddress($email)
243
+ {
244
+ $contactAddress = Mage::getResourceModel('customer/address_collection')->addAttributeToSelect('*')->joinTable(array('customer'=>'customer/entity'),'entity_id = parent_id',array('*'));
245
+ $postcode = "";
246
+ foreach ($contactAddress as $address) {
247
+ $addressData = $address->getData();
248
+ if($addressData['email'] == $email && array_key_exists('postcode', $addressData))
249
+ $postcode = $addressData['postcode'];
250
+ }
251
+ return $postcode;
252
+ }
253
+
254
+ /**
255
+ * function to get the total amount and the last amount
256
+ *
257
+ * @param string $email
258
+ * @return array
259
+ */
260
+ private function getCustomerGrandTotal($email)
261
+ {
262
+ $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_email', $email);
263
+ $sum = floatval('0.00');
264
+ if(count($orders) > 0) {
265
+ foreach ($orders as $order) {
266
+ $total = $order->getGrandTotal();
267
+ $lastAmount = $total;
268
+ $sum+= $total;
269
+ }
270
+ } else {
271
+ $lastAmount = '0.00';
272
+ $sum = '0.00';
273
+ }
274
+
275
+ return array('total' => strval($sum), 'last' => $lastAmount);
276
+ }
277
+
278
+ /**
279
+ * event to add registers in livedata db
280
+ *
281
+ */
282
+ public function addRegisterToDB(Varien_Event_Observer $observer)
283
+ {
284
+ // get the post data
285
+ $request = $observer->getEvent();
286
+ $customerData = $request->getCustomer();
287
+ // add contact to database
288
+ $contact = Mage::helper('livedata_trans/contact')->addOrUpdateContact($customerData);
289
+ // if contact added or updated
290
+ if($contact['code'] == 201 || $contact['code'] == 200) {
291
+ // if the contact has been inserted or updated, and there is a contact list selected and allowed, insert it in the list
292
+ $listId = Mage::getStoreConfig('trans/selectlist/from_list');
293
+ if($listId != '0')
294
+ $insertToList = Mage::helper('livedata_trans/contact')->insertContactToList($customerData->getEmail(), $listId);
295
+ // if it's a new contact, unsubscribe it
296
+ if(!$contact['contactExist']) {
297
+ $unsubscribed = Mage::helper('livedata_trans/contact')->unsubscribeContact($customerData->getEmail());
298
+ if($unsubscribed['statusCode'] != 200)
299
+ Mage::getSingleton('core/session')->addError('An error ocurred while inserting the contact status: ' . $unsubscribed['message'] . ' Please contact with Livedata support team.');
300
+ }
301
+ } else
302
+ Mage::getSingleton('core/session')->addError('An error ocurred while saving the contact: ' . $contact['message'] . ' Please contact with Livedata support team.');
303
+ }
304
+
305
+ /**
306
+ * event when subscribe in newsletter
307
+ *
308
+ */
309
+ public function subscribedToNewsletter(Varien_Event_Observer $observer)
310
+ {
311
+ $event = $observer->getEvent();
312
+ $subscriber = $event->getDataObject();
313
+ $data = $subscriber->getData();
314
+ $email = $data['subscriber_email'];
315
+ $statusChange = $subscriber->getIsStatusChanged();
316
+ // Trigger if user is now subscribed and there has been a status change:
317
+ if ($data['subscriber_status'] == "1" && $statusChange == true) {
318
+ //resubscribe contact
319
+ $resubscribeContact = Mage::helper('livedata_trans/contact')->resubscribeContact($email);
320
+ if($resubscribeContact['statusCode'] != 200)
321
+ Mage::getSingleton('core/session')->addNotice('An error ocurred while activating the contact: ' . $resubscribeContact['message']);
322
+ } elseif ($data['subscriber_status'] == "3" && $statusChange == true) {
323
+ //unsubscribe contact
324
+ $unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($email);
325
+ if($unsubscribeContact['statusCode'] != 200)
326
+ Mage::getSingleton('core/session')->addError('An error ocurred while unsubsribing the contact: ' . $unsubscribeContact['message'] . ' Please contact with Livedata support team.');
327
+ }
328
+ }
329
+
330
+ /**
331
+ * event when subscribe in newsletter
332
+ *
333
+ */
334
+ public function onCustomerDelete(Varien_Event_Observer $observer)
335
+ {
336
+ $event = $observer->getEvent();
337
+ $subscriber = $event->getDataObject();
338
+ $data = $subscriber->getData();
339
+ $email = $data['email'];
340
+ //unsubscribe contact
341
+ $unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($email);
342
+ if($unsubscribeContact['statusCode'] != 200)
343
+ Mage::getSingleton('core/session')->addError('An error ocurred while removing the contact: ' . $unsubscribeContact['message'] . ' Please contact with Livedata support team.');
344
+ }
345
+
346
+ /**
347
+ * event customer pay an order
348
+ *
349
+ */
350
+ public function onPayOrder(Varien_Event_Observer $observer)
351
+ {
352
+ $event = $observer->getEvent();
353
+ $order = $event->getInvoice()->getOrder();
354
+ $data = $order->getData();
355
+ $import = $data["grand_total"];
356
+ $email = $order->getCustomerEmail();
357
+ // update contact custom attributes
358
+ $contact = Mage::helper('livedata_trans/contact')->updateMagentoPaymentAttr($email, $import);
359
+ if($contact['statusCode'] != 200)
360
+ Mage::getSingleton('core/session')->addError('Livedata attributes has not been updated: ' . $contact['message'] . ' Please contact with Livedata support team.');
361
+ }
362
+ }
app/code/community/Livedata/Trans/Model/System/Config/Source/Contactlists.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Livedata_Trans_Model_System_Config_Source_Contactlists
4
+ {
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ $contactlist = Mage::helper('livedata_trans/contactlist')->getAllLists();
13
+ $arrayList = array();
14
+
15
+ foreach ($contactlist as $list) {
16
+ $arrayList[] = array('value' => $list['id'], 'label' => $list['name']);
17
+ }
18
+ $arrayList[] = array('value' => 0, 'label' => 'Select List');
19
+
20
+ return $arrayList;
21
+ }
22
+
23
+ /**
24
+ * Get options in "key-value" format
25
+ *
26
+ * @return array
27
+ */
28
+ public function toArray()
29
+ {
30
+ $contactlist = Mage::helper('livedata_trans/contactlist')->getAllLists();
31
+ $arrayList = array();
32
+
33
+ foreach ($contactlist as $list) {
34
+ $arrayList[$list['id']] = $list['name'];
35
+ }
36
+ $arrayList[0] = 'Select List';
37
+
38
+ return $arrayList;
39
+ }
40
+ }
app/code/community/Livedata/Trans/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <trans translate="title" module="livedata_trans">
12
+ <title>Livedata Management</title>
13
+ </trans>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Livedata/Trans/etc/config.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Livedata_Trans>
6
+ <version>1.0.0.0.1</version>
7
+ </Livedata_Trans>
8
+ </modules>
9
+ <global>
10
+ <!-- models sections -->
11
+ <models>
12
+ <livedata_trans>
13
+ <class>Livedata_Trans_Model</class>
14
+ <resourceModel>news_resource</resourceModel>
15
+ </livedata_trans>
16
+ </models>
17
+ <!-- end models sections -->
18
+ <helpers>
19
+ <livedata_trans>
20
+ <class>Livedata_Trans_Helper</class>
21
+ </livedata_trans>
22
+ </helpers>
23
+ <!-- event to change config -->
24
+ <events>
25
+ <admin_system_config_changed_section_trans>
26
+ <observers>
27
+ <livedata_trans>
28
+ <type>singleton</type>
29
+ <class>livedata_trans/observer</class>
30
+ <method>adminSystemConfigChangedSection</method>
31
+ </livedata_trans>
32
+ </observers>
33
+ </admin_system_config_changed_section_trans>
34
+ <customer_save_after>
35
+ <observers>
36
+ <livedata_trans>
37
+ <type>singleton</type>
38
+ <class>livedata_trans/observer</class>
39
+ <method>addRegisterToDB</method>
40
+ </livedata_trans>
41
+ </observers>
42
+ </customer_save_after>
43
+ <newsletter_subscriber_save_commit_after>
44
+ <observers>
45
+ <livedata_trans>
46
+ <type>singleton</type>
47
+ <class>livedata_trans/observer</class>
48
+ <method>subscribedToNewsletter</method>
49
+ </livedata_trans>
50
+ </observers>
51
+ </newsletter_subscriber_save_commit_after>
52
+ <customer_delete_before>
53
+ <observers>
54
+ <livedata_trans>
55
+ <type>singleton</type>
56
+ <class>livedata_trans/observer</class>
57
+ <method>onCustomerDelete</method>
58
+ </livedata_trans >
59
+ </observers>
60
+ </customer_delete_before>
61
+ <sales_order_payment_pay>
62
+ <observers>
63
+ <livedata_trans>
64
+ <type>singleton</type>
65
+ <class>livedata_trans/observer</class>
66
+ <method>onPayOrder</method>
67
+ </livedata_trans >
68
+ </observers>
69
+ </sales_order_payment_pay>
70
+ </events>
71
+ </global>
72
+ <default>
73
+ <trans>
74
+ <view>
75
+ <sendtrans>0</sendtrans>
76
+ <enabled>0</enabled>
77
+ </view>
78
+ </trans>
79
+ </default>
80
+ </config>
app/code/community/Livedata/Trans/etc/system.xml ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <trans>
5
+ <class>separator-top</class>
6
+ <label>Livedata-Solutions</label>
7
+ <tab>general</tab>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>500</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <groups>
14
+ <view translate="label">
15
+ <label>Livedata View Settings</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>10</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <fields>
22
+ <sendtrans translate="label">
23
+ <label>Enable send Transactionals with Livedata</label>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <sort_order>10</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </sendtrans>
31
+
32
+ <enabled translate="label">
33
+ <label>Enable syncronize contacts with Livedata</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>20</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </enabled>
41
+
42
+ <api_url translate="label">
43
+ <label>API url</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>30</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <comment>Enter the API url provided by Livedata-Solutions</comment>
50
+ </api_url>
51
+
52
+ <api_key translate="label">
53
+ <label>API Key</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>40</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ <comment>Enter the API Key provided by Livedata-Solutions</comment>
60
+ </api_key>
61
+
62
+ <from_user translate="label">
63
+ <label>User</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>50</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <comment>Enter the user name</comment>
70
+ </from_user>
71
+
72
+ <from_password translate="label">
73
+ <label>Password</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>60</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <comment>Enter the Password</comment>
80
+ </from_password>
81
+ </fields>
82
+ </view>
83
+ <selectlist translate="label">
84
+ <label>Select contact list</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>20</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <fields>
91
+ <from_list translate="label">
92
+ <label>Select List</label>
93
+ <frontend_type>select</frontend_type>
94
+ <source_model>livedata_trans/system_config_source_contactlists</source_model>
95
+ <sort_order>60</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ <comment>Select the list you want add the contact</comment>
100
+ <depends><sendtrans><fieldset>view</fieldset><value>1</value></sendtrans></depends>
101
+ </from_list>
102
+ </fields>
103
+ </selectlist>
104
+ <list translate="label">
105
+ <label>Create new list</label>
106
+ <frontend_type>text</frontend_type>
107
+ <sort_order>30</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ <fields>
112
+ <enabled_list translate="label">
113
+ <label>Create new contact list</label>
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ <sort_order>10</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </enabled_list>
121
+ <from_list_name translate="label">
122
+ <label>Contact list name</label>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>20</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ <depends><enabled_list>1</enabled_list></depends>
129
+ </from_list_name>
130
+ </fields>
131
+ </list>
132
+ <scenario translate="label">
133
+ <label>Scenario</label>
134
+ <frontend_type>text</frontend_type>
135
+ <sort_order>40</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ <fields>
140
+ <enabled_scn translate="label">
141
+ <label>Syncronise with scenario program</label>
142
+ <frontend_type>select</frontend_type>
143
+ <source_model>adminhtml/system_config_source_yesno</source_model>
144
+ <sort_order>10</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ </enabled_scn>
149
+ <from_scenario_id translate="label">
150
+ <label>Scenario id</label>
151
+ <frontend_type>text</frontend_type>
152
+ <sort_order>20</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ <depends><enabled_scn>1</enabled_scn></depends>
157
+ </from_scenario_id>
158
+ </fields>
159
+ </scenario>
160
+ </groups>
161
+ </trans>
162
+ </sections>
163
+ </config>
app/etc/modules/Livedata_Trans.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Livedata_Trans>
6
+ <active>true</active>
7
+ <codePool>community</codePool>
8
+ </Livedata_Trans>
9
+ </modules>
10
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Livedata_Solutions</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
@@ -11,8 +11,8 @@
11
  <notes>Syncronization and SMTP transactionals</notes>
12
  <authors><author><name>Toni</name><user>Toni</user><email>tcarreno@livedata-solutions.com</email></author></authors>
13
  <date>2016-08-04</date>
14
- <time>14:54:09</time>
15
- <contents><target name="mageetc"><dir name="."><dir name="app"><dir name="etc"><dir name="modules"><file name="Livedata_Trans.xml" hash=""/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><package><name>Aschroder_ SMTPPro</name><channel>local</channel><min>1.6</min><max>1.9.2</max><files><file target="." path="app/etc/modules/Aschroder_SMTPPro.xml"/></files></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Livedata_Solutions</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
11
  <notes>Syncronization and SMTP transactionals</notes>
12
  <authors><author><name>Toni</name><user>Toni</user><email>tcarreno@livedata-solutions.com</email></author></authors>
13
  <date>2016-08-04</date>
14
+ <time>15:39:43</time>
15
+ <contents><target name="magecommunity"><dir name="Livedata"><file name="README.txt" hash="4a13fca9b721970cedb5a70de913f6f6"/><dir name="Trans"><dir name="Helper"><file name="Contact.php" hash="2c89ccc9aa67c629dabe3e65471d8544"/><file name="Contactlist.php" hash="dd614e048cdb909f903dadfa661f166b"/></dir><dir name="Model"><file name="Observer.php" hash="8b944f9ce05d4387885d25d89d18c2c1"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Contactlists.php" hash="246ecc00a9381e3468062ec4b10c6584"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="86910cfba6392ca627a6cf23938a87b7"/><file name="config.xml" hash="ffd0664ef4aa93904c6ab5f04bbcb67d"/><file name="system.xml" hash="4ab9449263fedec4b2ebd8cdbf8116d6"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Livedata_Trans.xml" hash="513a947383ede06a9fa880a3bcacebf7"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><package><name>Aschroder_ SMTPPro</name><channel>local</channel><min>1.6</min><max>1.9.2</max><files><file target="." path="app/etc/modules/Aschroder_SMTPPro.xml "/></files></package></required></dependencies>
18
  </package>