Sendinblue - Version 1.1.9

Version Notes

Synchronize your Magento contacts with SendinBlue platform, send your marketing and transactional emails and SMS

Download this release

Release Info

Developer Sendinblue
Extension Sendinblue
Version 1.1.9
Comparing to
See all releases


Code changes from version 1.1.0 to 1.1.9

app/code/local/Sendinblue/Sendinblue/Block/Sendinblue.php CHANGED
@@ -20,71 +20,99 @@ class Sendinblue_Sendinblue_Block_Sendinblue extends Mage_Core_Block_Template
20
  }
21
 
22
  protected function _toHtml()
23
- {
24
-
25
- $get_Enable_Status = Mage::getModel('sendinblue/sendinblue')->getEnableStatus();
26
-
27
- $get_Tracking_Status = Mage::getModel('sendinblue/sendinblue')->getTrackingStatus();
28
-
29
- $get_order_status = Mage::getModel('sendinblue/sendinblue')->getOrderSmsStatus();
30
-
31
- $get_User_lists = Mage::getModel('sendinblue/sendinblue')->getUserlists();
32
-
33
-
34
- $value = Mage::getModel('sendinblue/sendinblue')->TrackingSmtp();
35
-
36
- $orders = Mage::getModel('sales/order')->getCollection();
37
-
38
- $order = $orders->getLastItem();
39
- $order_Data = $order->getPayment()->getData();
40
- $customer = Mage::getSingleton('customer/session')->getCustomer();
41
- $orderaddress = Mage::getModel('sales/order')->loadByIncrementId($order->increment_id);
42
-
43
- $mobile = $customer->getPrimaryBillingAddress()->getTelephone();
44
- $email = $customer->getEmail();// for email address
45
- $firstname = $customer->getFirstname();// For first name
46
- $lastname= $customer->getLastname();// For last name
47
- $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
48
- $nlStatus = $costomer_data->getStatus();
49
- if ($get_Enable_Status == 1 && $get_Tracking_Status == 1 && $nlStatus == 1)
50
- {
51
 
52
- $value_config = Mage::getModel('sendinblue/sendinblue')->getApiConfigValue();
53
- if ($value_config->date_format == 'dd-mm-yyyy')
54
- $date = date('d-m-Y', strtotime($order->created_at));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  else
56
- $date = date('m-d-Y', strtotime($order->created_at));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- $html = '';
59
-
60
- $html .= '<script type="text/javascript">
61
- /**Code for NB tracking*/
62
- function loadScript(url,callback){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){
63
- if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;callback(url)}}}else{
64
- script.onload=function(){callback(url)}}script.src=url;if(document.body){document.body.appendChild(script)}else{
65
- document.head.appendChild(script)}}
66
- var nbJsURL = (("https:" == document.location.protocol) ? "https://my-tracking-orders.googlecode.com/files" : "http://my-tracking-orders.googlecode.com/files");
67
- var nbBaseURL = "http://tracking.mailin.fr/";
68
- loadScript(nbJsURL+"/nbv2.js",
69
- function(){
70
- /*You can put your custom variables here as shown in example.*/
71
- try {
72
- var nbTracker = nb.getTracker(nbBaseURL , "'.$value->result->tracking_data->site_id.'");
73
- var list = ["'.$get_User_lists.'"];
74
- var attributes = ["EMAIL","PRENOM","NOM","ORDER_ID","ORDER_DATE","ORDER_PRICE"];
75
- var values = ["'.$email.'","'.$firstname.'","'.$lastname.'","'.$order->increment_id.'","'.$date.'","'.$order_Data[amount_ordered].'"];
76
- nbTracker.setListData(list);
77
- nbTracker.setTrackingData(attributes,values);
78
- nbTracker.trackPageView();
79
- } catch( err ) {}
80
- });
81
-
82
- </script>';
83
-
84
- echo $html;
85
- }
86
 
87
- }
88
 
89
 
90
  }
20
  }
21
 
22
  protected function _toHtml()
23
+ {
24
+ $sendinblueData = Mage::getModel('sendinblue/sendinblue');
25
+ $get_Enable_Status = $sendinblueData->getEnableStatus();
26
+ $get_Tracking_Status = $sendinblueData->getTrackingStatus();
27
+ $get_order_status = $sendinblueData->getOrderSmsStatus();
28
+ $get_User_lists = $sendinblueData->getUserlists();
29
+ $value = $sendinblueData->TrackingSmtp();
30
+
31
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
32
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
33
+ $order = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ if($get_Enable_Status && $get_order_status)
36
+ {
37
+ $locale = Mage::app()->getLocale()->getLocaleCode();
38
+ $mobile = $order->getBillingAddress()->getTelephone();
39
+ $countryid = $order->getBillingAddress()->getCountryId();
40
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
41
+ $sql = 'SELECT * FROM '.$tableCountry.' WHERE iso_code = "'.$countryid.'" ';
42
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
43
+ $data = $connection->fetchRow($sql);
44
+
45
+ $mobile = $sendinblueData->checkMobileNumber($mobile,$data['country_prefix']);
46
+ $email = $order->getBillingAddress()->getEmail();
47
+ $firstname = $order->getBillingAddress()->getFirstname();
48
+ $lastname = $order->getBillingAddress()->getLastname();
49
+ $ref_num = $order->getIncrementId();
50
+ $orderprice = $order->getGrandTotal();
51
+ $currencycode = $order->getBaseCurrencyCode();
52
+ $orderdate = $order->getCreatedAt();
53
+ if ($locale == 'fr_FR')
54
+ $ord_date = date('d/m/Y', strtotime($orderdate));
55
  else
56
+ $ord_date = date('m/d/Y', strtotime($orderdate));
57
+ $total_pay = $orderprice.' '.$currencycode;
58
+ $msgbody = $sendinblueData->getSendSmsmOrderMessage();
59
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
60
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
61
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
62
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
63
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
64
+
65
+ $arr = array();
66
+ $arr['to'] = $mobile;
67
+ $arr['from'] = $sendinblueData->getSendSmsOrderSubject();
68
+ $arr['text'] = $msgbody;
69
+ $responce = $sendinblueData->sendSmsApi($arr);
70
+ }
71
+
72
+ $email = $customer->getEmail();// for email address
73
+ $firstName = $customer->getFirstname();// For first name
74
+ $lastName= $customer->getLastname();// For last name
75
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
76
+ $nlStatus = $costomer_data->getStatus();
77
+ if ($get_Enable_Status == 1 && $get_Tracking_Status == 1 && $nlStatus == 1)
78
+ {
79
+
80
+ $value_config = $sendinblueData->getApiConfigValue();
81
+ if ($value_config->date_format == 'dd-mm-yyyy')
82
+ $date = date('d-m-Y', strtotime($order->getCreatedAt()));
83
+ else
84
+ $date = date('m-d-Y', strtotime($order->getCreatedAt()));
85
 
86
+ $html = '';
87
+
88
+ $html .= '<script type="text/javascript">
89
+ /**Code for NB tracking*/
90
+ function loadScript(url,callback){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){
91
+ if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;callback(url)}}}else{
92
+ script.onload=function(){callback(url)}}script.src=url;if(document.body){document.body.appendChild(script)}else{
93
+ document.head.appendChild(script)}}
94
+ var nbJsURL = (("https:" == document.location.protocol) ? "https://my-tracking-orders.googlecode.com/files" : "http://my-tracking-orders.googlecode.com/files");
95
+ var nbBaseURL = "http://tracking.mailin.fr/";
96
+ loadScript(nbJsURL+"/nbv2.js",
97
+ function(){
98
+ /*You can put your custom variables here as shown in example.*/
99
+ try {
100
+ var nbTracker = nb.getTracker(nbBaseURL , "'.$value->result->tracking_data->site_id.'");
101
+ var list = ["'.$get_User_lists.'"];
102
+ var attributes = ["EMAIL","PRENOM","NOM","ORDER_ID","ORDER_DATE","ORDER_PRICE"];
103
+ var values = ["'.$email.'","'.$firstName.'","'.$lastName.'","'.$order->getIncrementId().'","'.$date.'","'.$order->getGrandTotal().'"];
104
+ nbTracker.setListData(list);
105
+ nbTracker.setTrackingData(attributes,values);
106
+ nbTracker.trackPageView();
107
+ } catch( err ) {}
108
+ });
109
+
110
+ </script>';
111
+
112
+ echo $html;
113
+ }
114
 
115
+ }
116
 
117
 
118
  }
app/code/local/Sendinblue/Sendinblue/Model/Observer.php CHANGED
@@ -12,14 +12,15 @@ class Sendinblue_Sendinblue_Model_Observer
12
  protected static $fields = array ();
13
  public function adminSubcriberDelete($observer)
14
  {
15
- $params = (Mage::app()->getRequest()->getParams())? Mage::app()->getRequest()->getParams() : array();
 
16
  if (isset($params['subscriber']) && count($params['subscriber'] > 0))
17
  {
18
  $customer_email = array();
19
  foreach ($params['subscriber'] as $costomer_id)
20
  {
21
  $costomer_data = Mage::getModel('newsletter/subscriber')->load($costomer_id)->toArray();
22
- $customer_email[] = $costomer_data['subscriber_email'];
23
  }
24
  $customer_emails = implode('|', $customer_email);
25
  $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customer_emails);
@@ -30,14 +31,15 @@ class Sendinblue_Sendinblue_Model_Observer
30
  }
31
  public function adminCustomerDelete($observer)
32
  {
33
- $params = (Mage::app()->getRequest()->getParams())? Mage::app()->getRequest()->getParams() : array();
 
34
  if (isset($params['customer']) && count($params['customer'] > 0))
35
  {
36
  $customer_email = array();
37
  foreach ($params['customer'] as $costomer_id)
38
  {
39
  $costomer_data = Mage::getModel('customer/customer')->load($costomer_id)->toArray();
40
- $customer_email[] = $costomer_data['email'];
41
  }
42
  $customer_emails = implode('|', $customer_email);
43
  $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customer_emails);
@@ -48,14 +50,15 @@ class Sendinblue_Sendinblue_Model_Observer
48
  }
49
  public function adminCustomerSubscribe($observer)
50
  {
51
- $params = (Mage::app()->getRequest()->getParams())? Mage::app()->getRequest()->getParams() : array();
 
52
  if (isset($params['customer']) && count($params['customer'] > 0))
53
  {
54
  $customer_email = array();
55
  foreach ($params['customer'] as $costomer_id)
56
  {
57
  $costomer_data = Mage::getModel('customer/customer')->load($costomer_id)->toArray();
58
- $customer_email[] = $costomer_data['email'];
59
  }
60
  $customer_emails = implode('|', $customer_email);
61
  $responce = Mage::getModel('sendinblue/sendinblue')->addEmailList($customer_emails);
@@ -66,71 +69,107 @@ class Sendinblue_Sendinblue_Model_Observer
66
  }
67
  public function subscribeObserver($observer)
68
  {
69
- $params = (Mage::app()->getRequest()->getParams())? Mage::app()->getRequest()->getParams() : array();
 
 
 
 
70
  $client = 0;
71
- $extra = ''.'|'.''.'|'.$client.'|'.'';
72
- $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($params['email'], $extra);
73
  return $this;
74
  }
75
  public function updateNewObserver($observer)
76
  {
77
- $extra = null;
78
- $params = (Mage::app()->getRequest()->getParams())? Mage::app()->getRequest()->getParams() : array();
79
-
80
  $cus_session = Mage::getSingleton('customer/session')->getCustomer();
81
- $customer = ($cus_session->getEmail())? $cus_session : $observer->getCustomer();
 
 
 
 
 
 
82
  $cus_data = $cus_session->getData();
83
- $email = (isset($params['email']))? $params['email'] : $customer->getEmail();
 
 
 
 
84
  $cid = $customer->getEntityid();
 
 
85
  $fname = $customer->getFirstname();
86
  $fname = empty($fname)?'':$fname;
87
  $lname = $customer->getLastname();
88
  $lname = empty($lname)?'':$lname;
89
-
90
- $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToFilter('parent_id',$cid);
 
91
  $telephone = '';
92
  foreach ($collectionAddress as $customerPhno) {
93
- $telephone = $customerPhno->getData('telephone');
94
- $firstname = $customerPhno->getData('firstname');
95
- $lastname = $customerPhno->getData('lastname');
 
 
 
96
 
97
  }
98
- $telephone = empty($telephone)?'':$telephone;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  $firstname = empty($firstname)?'':$firstname;
100
  $lastname = empty($lastname)?'':$lastname;
101
 
102
- if ($fname != '' || $lname != '')
103
  $client = 1;
104
  else
105
  $client = 0;
106
-
107
- $is_subscribed = (isset($params['is_subscribed']))? $params['is_subscribed'] : '';
108
 
109
- $is_subscribedupdate = (isset($params['is_subscribed']))? 1 : 0;
110
- if ( isset($params['is_subscribed']) == '' ) {
111
  $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
112
  $nlStatus = $costomer_data->getStatus();
113
- $is_subscribedupdate = 1;
114
- if ($nlStatus == '') {
115
- $is_subscribedupdate = 0;
 
 
 
116
  }
117
- }
118
- if ($fname != '' || $lname != '' || $telephone != '' || $email != '')
119
- {
120
- $extra = $fname.'|'.$lname.'|'.$client.'|'.$telephone;
121
- if (isset($is_subscribed) && $is_subscribed == 1)
122
- $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($email, $extra);
123
-
124
- if (isset($is_subscribedupdate) && $is_subscribedupdate == 1) {
125
  $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($email, $extra);
126
- }
127
  }
128
 
129
- if (isset($is_subscribed) && $is_subscribed != '' && $is_subscribed === 0) {
130
- Mage::getSingleton('core/session')->addSuccess($is_subscribed);
131
  $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($email);
132
  }
 
133
  return $this;
 
134
  }
135
  public function syncData()
136
  {
@@ -145,106 +184,74 @@ class Sendinblue_Sendinblue_Model_Observer
145
  {
146
  $history = $order->getShipmentsCollection();
147
  $history_array=$history->toarray();
148
- $order_id = $history_array['items']['0']['order_id'];
149
- $shippingaddrid = $history_array['items']['0']['shipping_address_id'];
150
- $_order = Mage::getModel('sales/order')->load($order_id);
151
- $_shippingAddress = $_order->getShippingAddress();
152
- $locale = Mage::app()->getLocale()->getLocaleCode();
153
- $mobile = $_shippingAddress->getTelephone();
154
- $countryid = $_shippingAddress->getCountryId();
155
- $sql = 'SELECT * FROM sendinblue_country_codes WHERE iso_code = "'.$countryid.'" ';
156
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
157
- $data = $connection->fetchRow($sql);
158
-
159
- $mobile = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($mobile,$data['country_prefix']);
160
- $firstname = $_shippingAddress->getFirstname();
161
- $lastname = $_shippingAddress->getLastname();
162
- $ref_num = $_order->getIncrementId();
163
- $orderprice = $_order->getGrandTotal();
164
- $courrencycode = $_order->getBaseCurrencyCode();
165
- $orderdate = $_order->getCreatedAt();
166
- if ($locale == 'fr_FR')
167
- $ord_date = date('d/m/Y', strtotime($orderdate));
168
- else
169
- $ord_date = date('m/d/Y', strtotime($orderdate));
170
- $total_pay = $orderprice.' '.$courrencycode;
171
- $msgbody = Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingMessage();
172
- $fname = str_replace('{first_name}', $firstname, $msgbody);
173
- $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
174
- $procuct_price = str_replace('{order_price}', $total_pay, $lname);
175
- $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
176
- $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
177
-
178
- $arr = array();
179
- $arr['to'] = $mobile;
180
- $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingSubject();
181
- $arr['text'] = $msgbody;
182
- Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
183
-
184
- }
185
- }
186
- public function ordersucess($observer)
187
- {
188
- $get_Enable_Status = Mage::getModel('sendinblue/sendinblue')->getEnableStatus();
189
- $get_order_status = Mage::getModel('sendinblue/sendinblue')->getOrderSmsStatus();
190
- $get_User_lists = Mage::getModel('sendinblue/sendinblue')->getUserlists();
191
- $get_Tracking_Status = Mage::getModel('sendinblue/sendinblue')->getTrackingStatus();
192
- $value = Mage::getModel('sendinblue/sendinblue')->TrackingSmtp();
193
-
194
- $orders = Mage::getModel('sales/order')->getCollection();
195
- $order = $orders->getLastItem();
196
 
197
- $order_Data = $order->getPayment()->getData();
198
-
199
- $customer = Mage::getSingleton('customer/session')->getCustomer();
200
- $orderaddress = Mage::getModel('sales/order')->loadByIncrementId($order->increment_id);
201
-
202
- //for order sms send
203
- if($get_Enable_Status && $get_order_status)
204
- {
205
- $locale = Mage::app()->getLocale()->getLocaleCode();
206
- $mobile = $orderaddress->getBillingAddress()->getTelephone();
207
- $countryid = $orderaddress->getBillingAddress()->getCountryId();
208
- $sql = 'SELECT * FROM sendinblue_country_codes WHERE iso_code = "'.$countryid.'" ';
209
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
210
- $data = $connection->fetchRow($sql);
211
-
212
- $mobile = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($mobile,$data['country_prefix']);
213
- $email = $orderaddress->getBillingAddress()->getEmail();
214
- $firstname = $orderaddress->getBillingAddress()->getFirstname();
215
- $lastname = $orderaddress->getBillingAddress()->getLastname();
216
- $ref_num = $order->getIncrementId();
217
- $orderprice = $order->getGrandTotal();
218
- $currencycode = $order->getBaseCurrencyCode();
219
- $orderdate = $order->getCreatedAt();
220
- if ($locale == 'fr_FR')
221
- $ord_date = date('d/m/Y', strtotime($orderdate));
222
- else
223
- $ord_date = date('m/d/Y', strtotime($orderdate));
224
- $total_pay = $orderprice.' '.$currencycode;
225
- $msgbody = Mage::getModel('sendinblue/sendinblue')->getSendSmsmOrderMessage();
226
- $fname = str_replace('{first_name}', $firstname, $msgbody);
227
- $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
228
- $procuct_price = str_replace('{order_price}', $total_pay, $lname);
229
- $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
230
- $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
231
-
232
- $arr = array();
233
- $arr['to'] = $mobile;
234
- $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsOrderSubject();
235
- $arr['text'] = $msgbody;
236
- $responce = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
237
  }
238
-
239
  }
 
240
  public function subscribedToNewsletter($observer)
241
  {
242
- $data = $observer->subscriber;
243
- if($data->subscriber_status == 3)
244
- Mage::getModel('sendinblue/sendinblue')->emailDelete($data->subscriber_email);
245
- else if ($data->subscriber_status == 1)
246
- Mage::getModel('sendinblue/sendinblue')->emailSubscribe($data->subscriber_email);
247
-
 
 
 
 
 
 
 
248
  }
249
  public function disableCache(Varien_Event_Observer $observer)
250
  {
@@ -256,5 +263,6 @@ class Sendinblue_Sendinblue_Model_Observer
256
  Mage::getSingleton('core/session')->addSuccess('Done successfully');
257
  $cache->banUse('full_page'); // Tell Magento to 'ban' the use of FPC for this request
258
  }
259
- }
 
260
  }
12
  protected static $fields = array ();
13
  public function adminSubcriberDelete($observer)
14
  {
15
+ $params = Mage::app()->getRequest()->getParams();
16
+ $params = empty($params)?array():$params;
17
  if (isset($params['subscriber']) && count($params['subscriber'] > 0))
18
  {
19
  $customer_email = array();
20
  foreach ($params['subscriber'] as $costomer_id)
21
  {
22
  $costomer_data = Mage::getModel('newsletter/subscriber')->load($costomer_id)->toArray();
23
+ $customer_email[] = empty($costomer_data['subscriber_email'])?array():$costomer_data['subscriber_email'];
24
  }
25
  $customer_emails = implode('|', $customer_email);
26
  $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customer_emails);
31
  }
32
  public function adminCustomerDelete($observer)
33
  {
34
+ $params = Mage::app()->getRequest()->getParams();
35
+ $params = empty($params)?array():$params;
36
  if (isset($params['customer']) && count($params['customer'] > 0))
37
  {
38
  $customer_email = array();
39
  foreach ($params['customer'] as $costomer_id)
40
  {
41
  $costomer_data = Mage::getModel('customer/customer')->load($costomer_id)->toArray();
42
+ $customer_email[] = empty($costomer_data['email'])?array():$costomer_data['email'];
43
  }
44
  $customer_emails = implode('|', $customer_email);
45
  $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($customer_emails);
50
  }
51
  public function adminCustomerSubscribe($observer)
52
  {
53
+ $params = Mage::app()->getRequest()->getParams();
54
+ $params = empty($params)?array():$params;
55
  if (isset($params['customer']) && count($params['customer'] > 0))
56
  {
57
  $customer_email = array();
58
  foreach ($params['customer'] as $costomer_id)
59
  {
60
  $costomer_data = Mage::getModel('customer/customer')->load($costomer_id)->toArray();
61
+ $customer_email[] = empty($costomer_data['email'])?array():$costomer_data['email'];
62
  }
63
  $customer_emails = implode('|', $customer_email);
64
  $responce = Mage::getModel('sendinblue/sendinblue')->addEmailList($customer_emails);
69
  }
70
  public function subscribeObserver($observer)
71
  {
72
+ $params = Mage::app()->getRequest()->getParams();
73
+ $params = empty($params)?array():$params;
74
+ if ($params['email'] != '')
75
+ $newsletter_status = 0;
76
+
77
  $client = 0;
78
+ $extra = ''.'|'.''.'|'.''.'|'.$client.'|'.'';
79
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($params['email'], $extra, $newsletter_status);
80
  return $this;
81
  }
82
  public function updateNewObserver($observer)
83
  {
84
+ $extra = null;
85
+ $params = Mage::app()->getRequest()->getParams();
86
+ $params = empty($params)?array():$params;
87
  $cus_session = Mage::getSingleton('customer/session')->getCustomer();
88
+
89
+ $customerSessionEmail = $cus_session->getEmail();
90
+ $customer = $cus_session;
91
+ if (empty($customerSessionEmail)) {
92
+ $customer = $observer->getCustomer();
93
+ }
94
+
95
  $cus_data = $cus_session->getData();
96
+ $user_lang = isset($cus_data['created_in'])? $cus_data['created_in'] :'';
97
+
98
+ $customerEmail = $customer->getEmail();
99
+ $email = isset($params['email'])? $params['email'] : $customerEmail;
100
+
101
  $cid = $customer->getEntityid();
102
+ $cid = isset($cid)?$cid:'';
103
+
104
  $fname = $customer->getFirstname();
105
  $fname = empty($fname)?'':$fname;
106
  $lname = $customer->getLastname();
107
  $lname = empty($lname)?'':$lname;
108
+
109
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToFilter('parent_id',$cid);
110
+
111
  $telephone = '';
112
  foreach ($collectionAddress as $customerPhno) {
113
+ $phone_sms = $customerPhno->getData('telephone');
114
+ $firstname_value = $customerPhno->getData('firstname');
115
+ $lastname_value = $customerPhno->getData('lastname');
116
+ $telephone = empty($phone_sms)?'':$phone_sms;
117
+ $firstname = empty($firstname_value)?'':$firstname_value;
118
+ $lastname = empty($lastname_value)?'':$lastname_value;
119
 
120
  }
121
+ $telephone_no = isset($params['telephone'])?$params['telephone']:'';
122
+ if (!empty($telephone_no) || (isset($params['default_billing']) && $params['default_billing'] == 1))
123
+ {
124
+ $country_idvalue = isset($params['country_id'])?$params['country_id']:'';
125
+ if(!empty($params['country_id']))
126
+ {
127
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
128
+ $sql = 'SELECT country_prefix FROM '.$tableCountry.' WHERE iso_code = "'.$country_idvalue.'"';
129
+ $country_id = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
130
+ }
131
+ $country_id_code = empty($country_id['country_prefix'])?'':$country_id['country_prefix'];
132
+ $telephone = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($telephone_no, $country_id_code);
133
+ }
134
+ else
135
+ {
136
+ $telephone = !empty($telephone)?$telephone:'';
137
+ }
138
+
139
  $firstname = empty($firstname)?'':$firstname;
140
  $lastname = empty($lastname)?'':$lastname;
141
 
142
+ if (!empty($fname)|| !empty($lname))
143
  $client = 1;
144
  else
145
  $client = 0;
146
+
147
+ $is_subscribed = isset($params['is_subscribed'])?$params['is_subscribed']:'';
148
 
149
+ if (!empty($fname) || !empty($lname) || !empty($telephone) || !empty($email))
150
+ {
151
  $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
152
  $nlStatus = $costomer_data->getStatus();
153
+
154
+ $extra = $fname.'|'.$lname.'|'.$user_lang.'|'.$client.'|'.$telephone;
155
+ if (isset($is_subscribed) && $is_subscribed == 1 && empty($nlStatus))
156
+ {
157
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($email, $extra, $is_subscribed);
158
+ Mage::getModel('sendinblue/sendinblue')->sendWsTemplateMail($email);
159
  }
160
+ elseif (!empty($nlStatus))
161
+ {
 
 
 
 
 
 
162
  $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($email, $extra);
163
+ }
164
  }
165
 
166
+ if (isset($is_subscribed) && !empty($is_subscribed) && $is_subscribed === 0) {
167
+
168
  $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($email);
169
  }
170
+
171
  return $this;
172
+
173
  }
174
  public function syncData()
175
  {
184
  {
185
  $history = $order->getShipmentsCollection();
186
  $history_array=$history->toarray();
187
+ if($history_array['totalRecords'] > 0)
188
+ {
189
+ $order_id = isset($history_array['items']['0']['order_id'])?$history_array['items']['0']['order_id']:'';
190
+ $shippingaddrid = isset($history_array['items']['0']['shipping_address_id'])?$history_array['items']['0']['shipping_address_id']:'';
191
+ $_order = Mage::getModel('sales/order')->load($order_id);
192
+ $_shippingAddress = $_order->getShippingAddress();
193
+ $locale = Mage::app()->getLocale()->getLocaleCode();
194
+ $mobile_sms = $_shippingAddress->getTelephone();
195
+ $mobile_sms = !empty($mobile_sms)?$mobile_sms:'';
196
+ $countryid = $_shippingAddress->getCountryId();
197
+ $countryid = !empty($countryid)?$countryid:'';
198
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
199
+ $sql = 'SELECT * FROM '.$tableCountry.' WHERE iso_code = "'.$countryid.'" ';
200
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
201
+ $data = $connection->fetchRow($sql);
202
+ $mobile = '';
203
+ $country_prefix = $data['country_prefix'];
204
+ if(isset($country_prefix) && !empty($country_prefix))
205
+ $mobile = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($mobile_sms,$country_prefix);
206
+ $firstname = $_shippingAddress->getFirstname();
207
+ $firstname = !empty($firstname )?$firstname :'';
208
+ $lastname = $_shippingAddress->getLastname();
209
+ $lastname = !empty($lastname)?$lastname:'';
210
+ $ref_num = $_order->getIncrementId();
211
+ $ref_num = !empty($ref_num)?$ref_num:'';
212
+ $orderprice = $_order->getGrandTotal();
213
+ $orderprice = !empty($orderprice)?$orderprice:'';
214
+ $courrencycode = $_order->getBaseCurrencyCode();
215
+ $courrencycode = !empty($courrencycode)?$courrencycode:'';
216
+ $orderdate = $_order->getCreatedAt();
217
+ $orderdate = !empty($orderdate)?$orderdate:'';
218
+ if ($locale == 'fr_FR')
219
+ $ord_date = date('d/m/Y', strtotime($orderdate));
220
+ else
221
+ $ord_date = date('m/d/Y', strtotime($orderdate));
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
+ $total_pay = $orderprice.' '.$courrencycode;
224
+ $msgbody = Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingMessage();
225
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
226
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
227
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
228
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
229
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
230
+
231
+ $arr = array();
232
+ $arr['to'] = $mobile;
233
+ $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingSubject();
234
+ $arr['text'] = $msgbody;
235
+ Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
236
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  }
 
238
  }
239
+
240
  public function subscribedToNewsletter($observer)
241
  {
242
+ $data = $observer->subscriber;
243
+ $params = Mage::app()->getRequest()->getParams();
244
+ $params = empty($params)?array():$params;
245
+ if (!isset($params['firstname']) && !isset($params['lastname']))
246
+ {
247
+ if($data->subscriber_status == 3)
248
+ Mage::getModel('sendinblue/sendinblue')->emailDelete($data->subscriber_email);
249
+ else if ($data->subscriber_status == 1)
250
+ {
251
+ Mage::getModel('sendinblue/sendinblue')->emailSubscribe($data->subscriber_email);
252
+ Mage::getModel('sendinblue/sendinblue')->sendWsTemplateMail($data->subscriber_email);
253
+ }
254
+ }
255
  }
256
  public function disableCache(Varien_Event_Observer $observer)
257
  {
263
  Mage::getSingleton('core/session')->addSuccess('Done successfully');
264
  $cache->banUse('full_page'); // Tell Magento to 'ban' the use of FPC for this request
265
  }
266
+ }
267
+
268
  }
app/code/local/Sendinblue/Sendinblue/Model/Sendinblue.php CHANGED
@@ -30,27 +30,49 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
30
  {
31
  $scope = ($this->getScope()) ? $this->getScope() : Mage::app()->getStore()->getStoreId();
32
  $this->module_enable = $this->getEnableStatus($scope);
33
- $this->api_url = 'http://ws.mailin.fr/';
34
- $this->api_url2 = 'https://www.sendinblue.com/ws/getamd/';
35
  $this->api_key = $this->getApiKey();
36
  if (!$this->lists_ids)
37
  $this->lists_ids = str_replace(',', '|', $this->getUserlists($scope));
38
- $this->CreateFolderCaseTwo();
 
 
 
 
39
  }
40
 
41
  public function checkMobileNumber($number, $call_prefix)
42
  {
43
- $number = preg_replace('/\s+/', '', $number);
44
- $charone = substr($number, 0, 1);
45
- $chartwo = substr($number, 0, 2);
46
- if ($charone == '0' && $chartwo != '00')
47
- return '00'.$call_prefix.substr($number, 1);
48
- else if ($chartwo == '00')
49
- return $number;
50
- else if ($charone == '+')
51
- return '00'.substr($number, 1);
52
- else if ($charone != '0')
53
- return '00'.$call_prefix.$number;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
  /**
56
  * functions used for getting module status
@@ -183,6 +205,16 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
183
  return $apikey;
184
  }
185
  /**
 
 
 
 
 
 
 
 
 
 
186
  * functions used for getting smtp status
187
  */
188
  public function getSmtpStatus()
@@ -197,7 +229,18 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
197
  */
198
  public function getTrackingStatus()
199
  {
200
- $status = $this->getSendinTrackingCodeStatus('code', Mage::app()->getStore()->getStoreId());
 
 
 
 
 
 
 
 
 
 
 
201
  if (!$status) {
202
  return false;
203
  }
@@ -214,6 +257,26 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
214
  return $userlist;
215
  }
216
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  * functions used for getting general config
218
  */
219
  public function getGeneralConfig($field, $store = null)
@@ -227,7 +290,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
227
  {
228
  return Mage::getStoreConfig('sendinblue/smtp/'.$field, $store);
229
  }
230
- public function getSyncronizeStatus()
231
  {
232
  return $this->getGeneralConfig('syncronize', Mage::app()->getStore()->getStoreId());
233
  }
@@ -238,6 +301,13 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
238
  {
239
  return Mage::getStoreConfig('sendinblue/tracking/'.$field, $store);
240
  }
 
 
 
 
 
 
 
241
  /**
242
  * functions used for module functionality
243
  */
@@ -248,7 +318,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
248
  /**
249
  * functions used for email adds
250
  */
251
- public function emailAdd($email, $extra)
252
  {
253
  if ($this->module_enable == 1 && $this->getSyncronizeStatus())
254
  {
@@ -258,10 +328,17 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
258
  $params = array();
259
  $params['email'] = $email;
260
  $params['id'] = '';
261
- $params['blacklisted'] = '';
 
 
262
  if ($extra != null)
263
  {
264
- $params['attributes_name'] = 'PRENOM|NOM|CLIENT|SMS';
 
 
 
 
 
265
  $params['attributes_value'] = $extra;
266
  } else
267
  {
@@ -269,6 +346,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
269
 
270
  }
271
  $params['listid'] = $this->lists_ids;
 
272
  return $this->callServer('USERCREADITM', $params);
273
  } else
274
  return false;
@@ -313,17 +391,26 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
313
  $result_arr = $response->result;
314
  $collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo()->toArray();
315
  $subscriber_data = $collection['items'];
 
 
 
 
 
 
 
316
  if (count($result_arr) > 0)
317
  {
318
- $emails = array();
319
  foreach ($result_arr as $key => $value)
320
  {
321
  foreach ($value as $user_data)
322
  {
323
- foreach ($subscriber_data as $data)
324
- {
 
 
 
325
  $temp_sub_status = ($data['subscriber_status'] == 3) ? 1 : 0;
326
- if (($data['subscriber_email'] == $user_data->email) && ($temp_sub_status != $user_data->blacklisted))
327
  {
328
  $emails[] = $data['subscriber_email'];
329
  $subscribe_data['subscriber_id'] = $data['subscriber_id'];
@@ -359,7 +446,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
359
  $params = array();
360
  $params['email'] = $email;
361
  $params['id'] = '';
362
- $params['blacklisted'] = '';
363
  $params['attributes_name'] = '';
364
  $params['attributes_value'] = '';
365
  $params['listid'] = $this->lists_ids;
@@ -392,7 +479,9 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
392
  $params['key'] = $api_key;
393
  $response = $this->callServer('DISPLAYLISTDATA', $params);
394
  if (isset($response->errorMsg) && !empty($response->errorMsg))
395
- return $lists['error'] = $response->errorMsg;
 
 
396
  }
397
  /**
398
  * functions used for smtp details and order tracking
@@ -496,36 +585,24 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
496
  $exist_list = $result[2];
497
  if (empty($result[1]))
498
  {
499
- $params = array();
500
  $params['foldername'] = 'magento';
501
- $response = $this->callServer('ADDFOLDER', $params);
502
- $folder_id = $response->folder_id;
503
- $params = array();
504
- $params['listname'] = $list_name;
505
  $params['list_parent'] = $folder_id; //folder id
506
- $list_response = $this->callServer('NEWLIST', $params);
507
  $this->sendAllMailIDToSendin($list_response);
508
  } elseif (empty($exist_list))
509
  {
510
- $params = array();
511
- $params['listname'] = $list_name;
512
  $params['list_parent'] = $folder_id; //folder id
513
- $list_response = $this->callServer('NEWLIST', $params);
514
  $this->sendAllMailIDToSendin($list_response);
515
  }
516
  }
517
- /**
518
- * Method is used getambassador Services.
519
- */
520
- public function amdRequest($api)
521
- {
522
- $data['key'] = $api;
523
- $data['campaign_id'] = '2147';
524
- $data['campaign_short_code'] = 'zHzc';
525
-
526
- return $list_response = $this->curlRequest($data);
527
-
528
- }
529
 
530
  /**
531
  * folder create in Sendinblue after installing
@@ -537,10 +614,10 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
537
  $result = $this->checkFolderList();
538
  if (empty($result[1]))
539
  {
540
- $params = array();
541
  $params['foldername'] = 'magento';
542
- $response = $this->callServer('ADDFOLDER', $params);
543
- $folder_id = $response->folder_id;
544
  $exist_list = '';
545
  } else
546
  {
@@ -571,7 +648,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
571
  $list_name = 'magento_'.$date;
572
  }
573
  else
574
- $list_name = 'magento';
575
  $params = array();
576
  $params['listname'] = $list_name;
577
  $params['list_parent'] = $response;
@@ -585,30 +662,44 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
585
  */
586
  public function createAttributesName()
587
  {
 
588
  $params = array();
589
- $params['normal_attributes'] = 'PRENOM,text|NOM,text|SMS,text|CLIENT,number';
 
 
 
 
590
  $params['transactional_attributes'] = 'ORDER_ID,id|ORDER_DATE,date|ORDER_PRICE,number';
591
  $this->callServer('ATTRIBUTES_CREATION', $params);
592
  }
593
- /**
594
  * Method is used to send all the subscribers from magento to
595
  * Sendinblue for adding / updating purpose.
596
  */
597
- public function sendAllMailIDToSendin($list)
598
- {
599
- $allemail = $this->getcustomers();
600
- $params = array();
601
- $params['webaction'] = 'MULTI-USERCREADIT';
602
- $params['key'] = $this->api_key;
603
- $params['attributes'] = $allemail;
604
- $params['listid'] = $list->result;
605
- $response = $this->callServer('MULTI-USERCREADIT', $params);
606
- $sendin_switch = new Mage_Core_Model_Config();
607
- $sendin_switch->saveConfig('sendinblue/list', $list->result, 'default', 0);
608
- }
 
 
 
 
 
 
 
 
 
609
  /**
610
- * Send SMS from Sendin.
611
- */
612
  public function sendSmsApi($array)
613
  {
614
  $params = array();
@@ -619,29 +710,30 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
619
  return $this->callServer('SENDSMS', $params);
620
  }
621
 
622
- public function sendOrder($mobile)
623
  {
624
  $sendin_switch = new Mage_Core_Model_Config();
625
-
626
  if (isset($mobile))
627
  {
628
  $arr = array();
629
  $arr['to'] = $mobile;
630
  $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsOrderSubject();
631
  $arr['text'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsmOrderMessage();
632
-
633
  return $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
634
  }
635
-
636
  }
637
  public function notifySmsEmail()
638
  {
639
  $sendin_switch = new Mage_Core_Model_Config();
 
640
  if($this->getSmsCredit() < $this->getNotifyValueStatus() && $this->module_enable == 1 && $this->getNotifySmsStatus() == 1)
641
  {
642
  if($this->getNotifyCronStatus() == 0)
643
- {
644
- $sendin_switch->saveConfig('Sendin_Notify_Cron_Executed', 1, 'default', 0);
645
  $locale = Mage::app()->getLocale()->getLocaleCode();
646
  $email_template_variables = array();
647
  if ($locale == 'fr_FR')
@@ -685,7 +777,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
685
  }
686
  else
687
  {
688
- $sendin_switch->saveConfig('Sendin_Notify_Cron_Executed', 0, 'default', 0);
689
  }
690
 
691
  Mage::getSingleton('core/session')->addSuccess(Mage::helper('sendinblue')->__('Notification mail has been sent'));
@@ -698,8 +790,16 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
698
  $params = array();
699
  $params['key'] = $this->api_key;
700
  $result = $this->callServer('USER-CURRENT-PLAN', $params);
701
- if ($result['1']->plan_type == 'SMS')
702
- return $result['1']->credits;
 
 
 
 
 
 
 
 
703
  }
704
  /**
705
  * Method is used to send test email to the user.
@@ -739,62 +839,117 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
739
  */
740
  public function getcustomers()
741
  {
 
742
  $data = array();
743
- $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname');
744
  foreach ($collection as $customer)
745
  {
746
-
747
- $email = $customer->getData('email');
748
- $firstname = $customer->getData('firstname');
749
- $lastname = $customer->getData('lastname');
750
- $cid = $customer->getData('entity_id');
751
-
752
- $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
753
- $telephone = '';
754
- foreach ($collectionAddress as $customerPhno) {
755
- $telephone = $customerPhno->getData('telephone');
756
- $country_id = $customerPhno->getData('country_id');
757
- }
758
-
759
- $customer_select[$email] = array(
760
  'email' => $email,
761
- 'PRENOM' => $firstname,
762
- 'NOM' => $lastname,
763
- 'SMS' => $telephone,
764
- 'country_id' => $country_id,
765
- 'CLIENT' => $cid>0?1:0
766
- );
 
767
  }
 
 
 
 
 
 
 
 
768
 
769
- $newsletterArr = array();
770
- $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_status', array('eq' => 1))->load();
771
- $cnt = 0;
772
- foreach ( $newsletter->getItems() as $subscriber )
773
- {
774
- $customer_id = $subscriber->getCustomerId();;
775
- $subscriber_email = $subscriber->getSubscriberEmail();
776
- $subscriber_status = $subscriber->getSubscriberStatus();
777
-
778
- if ( !empty($customer_select[$subscriber_email]) ) {
779
- $newsletterArr[$cnt] = $customer_select[$subscriber_email];
780
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
781
- unset($customer_select[$subscriber_email]);
782
- }
783
- else {
784
- $newsletterArr[$cnt] = array(
785
- 'email' => $subscriber_email,
786
- 'PRENOM' => '',
787
- 'NOM' => '',
788
- 'SMS' => '',
789
- 'country_id' => ''
790
- );
791
- $newsletterArr[$cnt]['CLIENT'] = $customer_id>0?1:0;
792
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
793
- }
794
- $cnt++;
795
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
 
797
- return json_encode($newsletterArr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
798
  }
799
  /**
800
  * This method is used to fetch all users from the default newsletter table to list
@@ -802,26 +957,22 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
802
  */
803
  public function getNewsletterSubscribe($start, $per_page)
804
  {
805
- $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname');
 
806
  foreach ($collection as $customer)
807
  {
 
 
808
 
809
- $email = $customer->getData('email');
810
- $firstname = $customer->getData('firstname');
811
- $lastname = $customer->getData('lastname');
812
- $cid = $customer->getData('entity_id');
813
-
814
- $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
815
- $telephone = '';
816
  foreach ($collectionAddress as $customerPhno) {
817
  $telephone = $customerPhno->getData('telephone');
818
  $country_id = $customerPhno->getData('country_id');
819
  }
820
 
821
  $customer_select[$email] = array(
822
- 'email' => $email,
823
- 'firstname' => $firstname,
824
- 'lastname' => $lastname,
825
  'telephone' => $telephone,
826
  'country_id' => $country_id,
827
  'customer_id' => $cid
@@ -846,8 +997,6 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
846
  else {
847
  $newsletterArr[$cnt] = array(
848
  'email' => $subscriber_email,
849
- 'firstname' => '',
850
- 'lastname' => '',
851
  'telephone' => '',
852
  'country_id' => ''
853
  );
@@ -944,12 +1093,14 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
944
  */
945
  public function getNewsletterUnSubscribeCount()
946
  {
947
- $sql = 'SELECT count(*) as totalcoutn FROM customer_entity CE
948
- LEFT JOIN newsletter_subscriber
949
- ON CE.entity_id=newsletter_subscriber.customer_id WHERE subscriber_status != 1 or subscriber_status is null';
 
 
950
  $unsubs_count1 = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
951
 
952
- $sql = 'SELECT count(*) as totalcoutn FROM newsletter_subscriber WHERE customer_id = 0 AND subscriber_status = 3';
953
  $unsubs_count2 = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
954
  return ($unsubs_count1['totalcoutn'] + $unsubs_count2['totalcoutn']);
955
 
@@ -960,7 +1111,8 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
960
  */
961
  public function getNewsletterSubscribeCount()
962
  {
963
- $sql = 'SELECT count(*) as totalvalue from newsletter_subscriber where subscriber_status = 1';
 
964
  $data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
965
  return $data['totalvalue'];
966
  }
@@ -976,7 +1128,7 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
976
  $params = array();
977
  $params['key'] = $this->api_key;
978
  $params['email'] = $email;
979
- $response = $this->callServer('USERS-STATUS', $params);
980
  $response = json_encode($response);
981
  return json_decode($response, true);
982
  }
@@ -1007,14 +1159,10 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
1007
  */
1008
  public function curlRequest($data)
1009
  {
1010
- $url1 = $this->api_url;
1011
- $url2 = $this->api_url2;
1012
- if (array_key_exists('campaign_short_code', $data))
1013
- $url = $url2; // WS URL
1014
- else
1015
- $url = $url1; // WS URL
1016
  $ch = curl_init();
1017
  $ndata = '';
 
1018
  if (is_array($data))
1019
  {
1020
  foreach ($data as $key => $value)
@@ -1033,7 +1181,38 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
1033
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1034
  curl_setopt($ch, CURLOPT_URL, $url);
1035
  $data2 = curl_exec($ch);
1036
- curl_close($ch);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1037
  return $data2;
1038
  }
1039
 
@@ -1057,16 +1236,164 @@ class Sendinblue_Sendinblue_Model_Sendinblue extends Mage_Core_Model_Abstract
1057
  $this->_modifyResourceDb(self::TYPE_DB_UNINSTALL, $version, '');
1058
  return $this;
1059
  }
1060
- /**
1061
- * API config value from SendinBlue.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1062
  */
1063
- public function getApiConfigValue()
1064
  {
1065
  $data = array();
1066
  $data['key'] = $this->api_key;
1067
- $data['webaction'] = 'PLUGIN-CONFIG';
1068
- $value_config = $this->curlRequest($data);
1069
- $result = json_decode($value_config);
1070
- return $result;
1071
- }
1072
- }
 
30
  {
31
  $scope = ($this->getScope()) ? $this->getScope() : Mage::app()->getStore()->getStoreId();
32
  $this->module_enable = $this->getEnableStatus($scope);
33
+ $this->api_url = 'http://ws.mailin.fr/';
 
34
  $this->api_key = $this->getApiKey();
35
  if (!$this->lists_ids)
36
  $this->lists_ids = str_replace(',', '|', $this->getUserlists($scope));
37
+
38
+ $params = Mage::app()->getRequest()->getParams();
39
+ $params = empty($params)?array():$params;
40
+ if (isset($params['sendin_apikey']) && $params['sendin_apikey'] != '')
41
+ $this->CreateFolderCaseTwo();
42
  }
43
 
44
  public function checkMobileNumber($number, $call_prefix)
45
  {
46
+ $number = preg_replace('/\s+/', '', $number);
47
+ $charone = substr($number, 0, 1);
48
+ $chartwo = substr($number, 0, 2);
49
+
50
+ if (preg_match('/^'.$call_prefix.'/', $number))
51
+ return '00'.$number;
52
+
53
+ else if ($charone == '0' && $chartwo != '00')
54
+ {
55
+ if (preg_match('/^0'.$call_prefix.'/', $number))
56
+ return '00'.substr($number, 1);
57
+ else
58
+ return '00'.$call_prefix.substr($number, 1);
59
+ }
60
+ elseif ($chartwo == '00')
61
+ {
62
+ if (preg_match('/^00'.$call_prefix.'/', $number))
63
+ return $number;
64
+ else
65
+ return '00'.$call_prefix.substr($number, 2);
66
+ }
67
+ elseif ($charone == '+')
68
+ {
69
+ if (preg_match('/^\+'.$call_prefix.'/', $number))
70
+ return '00'.substr($number, 1);
71
+ else
72
+ return '00'.$call_prefix.substr($number, 1);
73
+ }
74
+ elseif ($charone != '0')
75
+ return '00'.$call_prefix.$number;
76
  }
77
  /**
78
  * functions used for getting module status
205
  return $apikey;
206
  }
207
  /**
208
+ * functions used for get user name
209
+ */
210
+ public function getUserName()
211
+ {
212
+ $userName = $this->getSendinSmtpStatus('username', Mage::app()->getStore()->getStoreId());
213
+ if (!$userName)
214
+ return false;
215
+ return $userName;
216
+ }
217
+ /**
218
  * functions used for getting smtp status
219
  */
220
  public function getSmtpStatus()
229
  */
230
  public function getTrackingStatus()
231
  {
232
+ $status = $this->getSendinTrackingCodeStatus('code', Mage::app()->getStore()->getStoreId());
233
+ if (!$status) {
234
+ return false;
235
+ }
236
+ return $status;
237
+ }
238
+ /**
239
+ * functions used for getting tracking status
240
+ */
241
+ public function getTrackingHistoryStatus()
242
+ {
243
+ $status = $this->getSendinTrackingHistoryStatus('history', Mage::app()->getStore()->getStoreId());
244
  if (!$status) {
245
  return false;
246
  }
257
  return $userlist;
258
  }
259
  /**
260
+ * functions used for getting importOldSubscribers status
261
+ */
262
+ public function getImportOldSubsStatus()
263
+ {
264
+ $importStatus = $this->getGeneralConfig('importOldUserStatus', Mage::app()->getStore()->getStoreId());
265
+ if (!$importStatus)
266
+ return false;
267
+ return $importStatus;
268
+ }
269
+ /**
270
+ * functions used for get templateid
271
+ */
272
+ public function getTemplateId()
273
+ {
274
+ $TemplateId = $this->getGeneralConfig('Sendin_Template_Id', Mage::app()->getStore()->getStoreId());
275
+ if (!$TemplateId)
276
+ return false;
277
+ return $TemplateId;
278
+ }
279
+ /**
280
  * functions used for getting general config
281
  */
282
  public function getGeneralConfig($field, $store = null)
290
  {
291
  return Mage::getStoreConfig('sendinblue/smtp/'.$field, $store);
292
  }
293
+ public function getSyncronizeStatus()
294
  {
295
  return $this->getGeneralConfig('syncronize', Mage::app()->getStore()->getStoreId());
296
  }
301
  {
302
  return Mage::getStoreConfig('sendinblue/tracking/'.$field, $store);
303
  }
304
+ /**
305
+ * functions used for get sendin tracking history status
306
+ */
307
+ public function getSendinTrackingHistoryStatus($field, $store = null)
308
+ {
309
+ return Mage::getStoreConfig('sendinblue/improt/'.$field, $store);
310
+ }
311
  /**
312
  * functions used for module functionality
313
  */
318
  /**
319
  * functions used for email adds
320
  */
321
+ public function emailAdd($email, $extra, $is_subscribed = '')
322
  {
323
  if ($this->module_enable == 1 && $this->getSyncronizeStatus())
324
  {
328
  $params = array();
329
  $params['email'] = $email;
330
  $params['id'] = '';
331
+ if ($is_subscribed != '')
332
+ $params['blacklisted'] = 0;
333
+
334
  if ($extra != null)
335
  {
336
+ $value_langauge = $this->getApiConfigValue();
337
+ if ($value_langauge->language == 'fr')
338
+ $params['attributes_name'] = 'PRENOM|NOM|MAGENTO_LANG|CLIENT|SMS';
339
+ else
340
+ $params['attributes_name'] = 'NAME|SURNAME|MAGENTO_LANG|CLIENT|SMS';
341
+
342
  $params['attributes_value'] = $extra;
343
  } else
344
  {
346
 
347
  }
348
  $params['listid'] = $this->lists_ids;
349
+
350
  return $this->callServer('USERCREADITM', $params);
351
  } else
352
  return false;
391
  $result_arr = $response->result;
392
  $collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo()->toArray();
393
  $subscriber_data = $collection['items'];
394
+ $emails = array();
395
+ $subscriber_data_email = array();
396
+ foreach($subscriber_data as $s)
397
+ {
398
+ $subscriber_data_email[$s['subscriber_email']] = $s;
399
+ }
400
+
401
  if (count($result_arr) > 0)
402
  {
 
403
  foreach ($result_arr as $key => $value)
404
  {
405
  foreach ($value as $user_data)
406
  {
407
+ if(isset($subscriber_data_email[$user_data->email]))
408
+ {
409
+
410
+ // on a trouvé le subscriber magento
411
+ $data = $subscriber_data_email[$user_data->email];
412
  $temp_sub_status = ($data['subscriber_status'] == 3) ? 1 : 0;
413
+ if ($temp_sub_status != $user_data->blacklisted)
414
  {
415
  $emails[] = $data['subscriber_email'];
416
  $subscribe_data['subscriber_id'] = $data['subscriber_id'];
446
  $params = array();
447
  $params['email'] = $email;
448
  $params['id'] = '';
449
+ $params['blacklisted'] = 0;
450
  $params['attributes_name'] = '';
451
  $params['attributes_value'] = '';
452
  $params['listid'] = $this->lists_ids;
479
  $params['key'] = $api_key;
480
  $response = $this->callServer('DISPLAYLISTDATA', $params);
481
  if (isset($response->errorMsg) && !empty($response->errorMsg))
482
+ return $lists['error'] = $response->errorMsg;
483
+
484
+
485
  }
486
  /**
487
  * functions used for smtp details and order tracking
585
  $exist_list = $result[2];
586
  if (empty($result[1]))
587
  {
588
+ $params = array();
589
  $params['foldername'] = 'magento';
590
+ $res = $this->callServer('ADDFOLDER', $params);
591
+ $folder_id = $res->folder_id;
592
+ $params = array();
593
+ $params['listname'] = $list_name;
594
  $params['list_parent'] = $folder_id; //folder id
595
+ $list_response = $this->callServer('NEWLIST', $params);
596
  $this->sendAllMailIDToSendin($list_response);
597
  } elseif (empty($exist_list))
598
  {
599
+ $params = array();
600
+ $params['listname'] = $list_name;
601
  $params['list_parent'] = $folder_id; //folder id
602
+ $list_response = $this->callServer('NEWLIST', $params);
603
  $this->sendAllMailIDToSendin($list_response);
604
  }
605
  }
 
 
 
 
 
 
 
 
 
 
 
 
606
 
607
  /**
608
  * folder create in Sendinblue after installing
614
  $result = $this->checkFolderList();
615
  if (empty($result[1]))
616
  {
617
+ $params = array();
618
  $params['foldername'] = 'magento';
619
+ $res = $this->callServer('ADDFOLDER', $params);
620
+ $folder_id = $res->folder_id;
621
  $exist_list = '';
622
  } else
623
  {
648
  $list_name = 'magento_'.$date;
649
  }
650
  else
651
+ $list_name = 'magento';
652
  $params = array();
653
  $params['listname'] = $list_name;
654
  $params['list_parent'] = $response;
662
  */
663
  public function createAttributesName()
664
  {
665
+ $value_langauge = $this->getApiConfigValue();
666
  $params = array();
667
+ if ($value_langauge->language == 'fr')
668
+ $params['normal_attributes'] = 'PRENOM,text|NOM,text|MAGENTO_LANG,text|SMS,text|CLIENT,number';
669
+ else
670
+ $params['normal_attributes'] = 'NAME,text|SURNAME,text|MAGENTO_LANG,text|SMS,text|CLIENT,number';
671
+
672
  $params['transactional_attributes'] = 'ORDER_ID,id|ORDER_DATE,date|ORDER_PRICE,number';
673
  $this->callServer('ATTRIBUTES_CREATION', $params);
674
  }
675
+ /**
676
  * Method is used to send all the subscribers from magento to
677
  * Sendinblue for adding / updating purpose.
678
  */
679
+ public function sendAllMailIDToSendin($list)
680
+ {
681
+ $allemail = $this->getcustomers();
682
+ $params = array();
683
+ $params['webaction'] = 'IMPORTUSERS';
684
+ $params['key'] = $this->api_key;
685
+ $params['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportSubUsersToSendinblue.csv';
686
+ $params['listids'] = $list->result;
687
+ $params['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptySubsUserToSendinblue';
688
+ $responce_data = $this->curlRequestAsyc($params);
689
+
690
+ $sendin_switch = new Mage_Core_Model_Config();
691
+ $sendin_switch->saveConfig('sendinblue/list', $list->result, 'default', 0);
692
+ $res_value = json_decode($responce_data);
693
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 0, 'default', 0);
694
+ if (empty($res_value->process_id))
695
+ {
696
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 1);
697
+ }
698
+
699
+ }
700
  /**
701
+ * Send SMS from Sendin.
702
+ */
703
  public function sendSmsApi($array)
704
  {
705
  $params = array();
710
  return $this->callServer('SENDSMS', $params);
711
  }
712
 
713
+ public function sendOrder($mobile)
714
  {
715
  $sendin_switch = new Mage_Core_Model_Config();
716
+
717
  if (isset($mobile))
718
  {
719
  $arr = array();
720
  $arr['to'] = $mobile;
721
  $arr['from'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsOrderSubject();
722
  $arr['text'] = Mage::getModel('sendinblue/sendinblue')->getSendSmsmOrderMessage();
723
+
724
  return $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
725
  }
726
+
727
  }
728
  public function notifySmsEmail()
729
  {
730
  $sendin_switch = new Mage_Core_Model_Config();
731
+
732
  if($this->getSmsCredit() < $this->getNotifyValueStatus() && $this->module_enable == 1 && $this->getNotifySmsStatus() == 1)
733
  {
734
  if($this->getNotifyCronStatus() == 0)
735
+ {
736
+ $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 1, 'default', 0);
737
  $locale = Mage::app()->getLocale()->getLocaleCode();
738
  $email_template_variables = array();
739
  if ($locale == 'fr_FR')
777
  }
778
  else
779
  {
780
+ $sendin_switch->saveConfig('sendinblue/Sendin_Notify_Cron_Executed', 0, 'default', 0);
781
  }
782
 
783
  Mage::getSingleton('core/session')->addSuccess(Mage::helper('sendinblue')->__('Notification mail has been sent'));
790
  $params = array();
791
  $params['key'] = $this->api_key;
792
  $result = $this->callServer('USER-CURRENT-PLAN', $params);
793
+
794
+ foreach($result as $val)
795
+ {
796
+ if(is_object($val)){
797
+ if($val->plan_type=='SMS')
798
+ {
799
+ return $val->credits;
800
+ }
801
+ }
802
+ }
803
  }
804
  /**
805
  * Method is used to send test email to the user.
839
  */
840
  public function getcustomers()
841
  {
842
+ $value_langauge = $this->getApiConfigValue();
843
  $data = array();
844
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('created_in');
845
  foreach ($collection as $customer)
846
  {
847
+ $email = $customer->getData('email');
848
+ $firstname = $customer->getData('firstname');
849
+ $lastname = $customer->getData('lastname');
850
+ $cid = $customer->getData('entity_id');
851
+ $user_lang = $customer->getData('created_in');
852
+
853
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
854
+ $telephone = '';
855
+ foreach ($collectionAddress as $customerPhno) {
856
+ $telephone = $customerPhno->getData('telephone');
857
+ $country_id = $customerPhno->getData('country_id');
858
+ }
859
+ $customer_select[$email] = array(
 
860
  'email' => $email,
861
+ 'NAME' => $firstname,
862
+ 'SURNAME' => $lastname,
863
+ 'SMS' => $telephone,
864
+ 'country_id' => $country_id,
865
+ 'MAGENTO_LANG' => $user_lang,
866
+ 'CLIENT' => $cid>0?1:0
867
+ );
868
  }
869
+ $newsletterArr = array();
870
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter('subscriber_status', array('eq' => 1))->load();
871
+ $cnt = 0;
872
+ foreach ( $newsletter->getItems() as $subscriber )
873
+ {
874
+ $customer_id = $subscriber->getCustomerId();;
875
+ $subscriber_email = $subscriber->getSubscriberEmail();
876
+ $subscriber_status = $subscriber->getSubscriberStatus();
877
 
878
+ if ( !empty($customer_select[$subscriber_email]) ) {
879
+ $newsletterArr[$cnt] = $customer_select[$subscriber_email];
880
+ $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
881
+ unset($customer_select[$subscriber_email]);
882
+ }
883
+ else {
884
+ $newsletterArr[$cnt] = array(
885
+ 'email' => $subscriber_email,
886
+ 'NAME' => '',
887
+ 'SURNAME' => '',
888
+ 'MAGENTO_LANG' => '',
889
+ 'SMS' => '',
890
+ 'country_id' => ''
891
+ );
892
+ $newsletterArr[$cnt]['CLIENT'] = $customer_id>0?1:0;
893
+ $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
894
+ }
895
+ $cnt++;
896
+ }
897
+
898
+
899
+ if (!is_dir(Mage::getBaseDir('media').'/sendinblue_csv'))
900
+ mkdir(Mage::getBaseDir('media').'/sendinblue_csv', 0777, true);
901
+ if ($value_langauge->language == 'fr')
902
+ {
903
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportSubUsersToSendinblue.csv', 'w+');
904
+ $key_value[] = 'EMAIL,PRENOM,NOM,MAGENTO_LANG,SMS,CLIENT';
905
+ foreach ($key_value as $linedata)
906
+ fwrite($handle, $linedata."\n");
907
+ }
908
+ else {
909
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportSubUsersToSendinblue.csv', 'w+');
910
+ $key_value[] = 'EMAIL,NAME,SURNAME,MAGENTO_LANG,SMS,CLIENT';
911
+ foreach ($key_value as $linedata)
912
+ fwrite($handle, $linedata."\n");
913
+
914
+ }
915
+
916
+ foreach ($newsletterArr as $newsdata)
917
+ {
918
+ if(!empty($newsdata['country_id']))
919
+ {
920
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
921
+ $sql = 'SELECT country_prefix FROM '.$tableCountry.' WHERE iso_code = "'.$newsdata['country_id'].'"';
922
+ $country_id = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
923
+ }
924
+ if(!empty($newsdata['SMS']))
925
+ $phone_number = $this->checkMobileNumber($newsdata['SMS'], $country_id['country_prefix']);
926
+ else
927
+ $phone_number = '';
928
 
929
+ if ($value_langauge->language == 'fr')
930
+ {
931
+ $key_value = array(
932
+ 'email' => $newsdata['email'],
933
+ 'PRENOM' => $newsdata['NAME']?$newsdata['NAME']:'',
934
+ 'NOM' => $newsdata['SURNAME']?$newsdata['SURNAME']:'',
935
+ 'MAGENTO_LANG' => $newsdata['MAGENTO_LANG']?$newsdata['MAGENTO_LANG']:'',
936
+ 'SMS' => $phone_number?$phone_number:'',
937
+ 'CLIENT' => $newsdata['CLIENT']
938
+ );
939
+ }
940
+ else {
941
+ $key_value = array(
942
+ 'email' => $newsdata['email'],
943
+ 'NAME' => $newsdata['NAME']?$newsdata['NAME']:'',
944
+ 'SURNAME' => $newsdata['SURNAME']?$newsdata['SURNAME']:'',
945
+ 'MAGENTO_LANG' => $newsdata['MAGENTO_LANG']?$newsdata['MAGENTO_LANG']:'',
946
+ 'SMS' => $phone_number?$phone_number:'',
947
+ 'CLIENT' => $newsdata['CLIENT']
948
+ );
949
+ }
950
+ fputcsv($handle, $key_value);
951
+
952
+ } fclose($handle);
953
  }
954
  /**
955
  * This method is used to fetch all users from the default newsletter table to list
957
  */
958
  public function getNewsletterSubscribe($start, $per_page)
959
  {
960
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email');
961
+
962
  foreach ($collection as $customer)
963
  {
964
+ $email = $customer->getData('email');
965
+ $cid = $customer->getData('entity_id');
966
 
967
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
968
+ $telephone = '';
 
 
 
 
 
969
  foreach ($collectionAddress as $customerPhno) {
970
  $telephone = $customerPhno->getData('telephone');
971
  $country_id = $customerPhno->getData('country_id');
972
  }
973
 
974
  $customer_select[$email] = array(
975
+ 'email' => $email,
 
 
976
  'telephone' => $telephone,
977
  'country_id' => $country_id,
978
  'customer_id' => $cid
997
  else {
998
  $newsletterArr[$cnt] = array(
999
  'email' => $subscriber_email,
 
 
1000
  'telephone' => '',
1001
  'country_id' => ''
1002
  );
1093
  */
1094
  public function getNewsletterUnSubscribeCount()
1095
  {
1096
+ $tableCustomer = Mage::getSingleton('core/resource')->getTableName('customer/entity');
1097
+ $tableNewsletter = Mage::getSingleton('core/resource')->getTableName('newsletter/subscriber');
1098
+ $sql = 'SELECT count(*) as totalcoutn FROM '.$tableCustomer.' CE
1099
+ LEFT JOIN '.$tableNewsletter.' NS
1100
+ ON CE.entity_id=NS.customer_id WHERE subscriber_status != 1 or subscriber_status is null';
1101
  $unsubs_count1 = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
1102
 
1103
+ $sql = 'SELECT count(*) as totalcoutn FROM '.$tableNewsletter.' WHERE customer_id = 0 AND subscriber_status = 3';
1104
  $unsubs_count2 = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
1105
  return ($unsubs_count1['totalcoutn'] + $unsubs_count2['totalcoutn']);
1106
 
1111
  */
1112
  public function getNewsletterSubscribeCount()
1113
  {
1114
+ $tableNewsletter = Mage::getSingleton('core/resource')->getTableName('newsletter/subscriber');
1115
+ $sql = 'SELECT count(*) as totalvalue from '.$tableNewsletter.' where subscriber_status = 1';
1116
  $data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchRow($sql);
1117
  return $data['totalvalue'];
1118
  }
1128
  $params = array();
1129
  $params['key'] = $this->api_key;
1130
  $params['email'] = $email;
1131
+ $response = $this->callServer('USERS-STATUS-BLACKLIST', $params);
1132
  $response = json_encode($response);
1133
  return json_decode($response, true);
1134
  }
1159
  */
1160
  public function curlRequest($data)
1161
  {
1162
+ $url = $this->api_url; // WS URL
 
 
 
 
 
1163
  $ch = curl_init();
1164
  $ndata = '';
1165
+ $data['source'] = 'MagentoNew';
1166
  if (is_array($data))
1167
  {
1168
  foreach ($data as $key => $value)
1181
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1182
  curl_setopt($ch, CURLOPT_URL, $url);
1183
  $data2 = curl_exec($ch);
1184
+ curl_close($ch);
1185
+ return $data2;
1186
+ }
1187
+ /**
1188
+ * CURL function to send request to the Sendinblue API server
1189
+ */
1190
+ public function curlRequestAsyc($data)
1191
+ {
1192
+ $url = $this->api_url; // WS URL
1193
+ $ch = curl_init();
1194
+ $ndata = '';
1195
+ $data['source'] = 'MagentoNew';
1196
+ if (is_array($data))
1197
+ {
1198
+ foreach ($data as $key => $value)
1199
+ $ndata .= $key.'='.urlencode($value).'&';
1200
+ } else
1201
+ $ndata = $data;
1202
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1203
+ 'Expect:'
1204
+ ));
1205
+
1206
+ $ndata = trim($ndata,'&');
1207
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1208
+ curl_setopt($ch, CURLOPT_POST, 1);
1209
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $ndata);
1210
+ curl_setopt($ch, CURLOPT_HEADER, 0);
1211
+ curl_setopt($ch, CURLOPT_TIMEOUT, 0);
1212
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1213
+ curl_setopt($ch, CURLOPT_URL, $url);
1214
+ $data2 = curl_exec($ch);
1215
+ curl_close($ch);
1216
  return $data2;
1217
  }
1218
 
1236
  $this->_modifyResourceDb(self::TYPE_DB_UNINSTALL, $version, '');
1237
  return $this;
1238
  }
1239
+ /**
1240
+ * This method is used to fetch all subscribe users from the default customer table to list
1241
+ * them in the Sendinblue magento module.
1242
+ */
1243
+ public function smsCampaignList()
1244
+ {
1245
+ $value_langauge = $this->getApiConfigValue();
1246
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname');
1247
+ foreach ($collection as $customer)
1248
+ {
1249
+
1250
+ $email = $customer->getData('email');
1251
+ $firstname = $customer->getData('firstname');
1252
+ $lastname = $customer->getData('lastname');
1253
+ $cid = $customer->getData('entity_id');
1254
+
1255
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
1256
+ $telephone = '';
1257
+ foreach ($collectionAddress as $customerPhno) {
1258
+ $telephone = $customerPhno->getData('telephone');
1259
+ $country_id = $customerPhno->getData('country_id');
1260
+ }
1261
+
1262
+ if ($value_langauge->language == 'fr')
1263
+ {
1264
+ $customer_select[$email] = array(
1265
+ 'email' => $email,
1266
+ 'PRENOM' => $firstname,
1267
+ 'NOM' => $lastname,
1268
+ 'SMS' => $telephone,
1269
+ 'country_id' => $country_id,
1270
+ 'CLIENT' => $cid>0?1:0
1271
+ );
1272
+ }
1273
+ else {
1274
+ $customer_select[$email] = array(
1275
+ 'email' => $email,
1276
+ 'NAME' => $firstname,
1277
+ 'SURNAME' => $lastname,
1278
+ 'SMS' => $telephone,
1279
+ 'country_id' => $country_id,
1280
+ 'CLIENT' => $cid>0?1:0
1281
+ );
1282
+ }
1283
+ }
1284
+
1285
+ $newsletterArr = array();
1286
+ $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->load();
1287
+ $cnt = 0;
1288
+ foreach ( $newsletter->getItems() as $subscriber )
1289
+ {
1290
+ $customer_id = $subscriber->getCustomerId();;
1291
+ $subscriber_email = $subscriber->getSubscriberEmail();
1292
+ $subscriber_status = $subscriber->getSubscriberStatus();
1293
+
1294
+ if ( !empty($customer_select[$subscriber_email]) ) {
1295
+ $newsletterArr[$cnt] = $customer_select[$subscriber_email];
1296
+ $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
1297
+ unset($customer_select[$subscriber_email]);
1298
+ }
1299
+ else {
1300
+ if ($value_langauge->language == 'fr')
1301
+ {
1302
+ $newsletterArr[$cnt] = array(
1303
+ 'email' => $subscriber_email,
1304
+ 'PRENOM' => '',
1305
+ 'NOM' => '',
1306
+ 'SMS' => '',
1307
+ 'country_id' => ''
1308
+ );
1309
+ $newsletterArr[$cnt]['CLIENT'] = $customer_id>0?1:0;
1310
+ $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
1311
+ }
1312
+ else
1313
+ {
1314
+ $newsletterArr[$cnt] = array(
1315
+ 'email' => $subscriber_email,
1316
+ 'NAME' => '',
1317
+ 'SURNAME' => '',
1318
+ 'SMS' => '',
1319
+ 'country_id' => ''
1320
+ );
1321
+ $newsletterArr[$cnt]['CLIENT'] = $customer_id>0?1:0;
1322
+ $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
1323
+ }
1324
+ }
1325
+ $cnt++;
1326
+ }
1327
+ $i = 0;
1328
+ $data = array();
1329
+ foreach($newsletterArr as $result)
1330
+ {
1331
+
1332
+ if(!empty($result['SMS']))
1333
+ {
1334
+ $data[$i]= $result;
1335
+ }
1336
+ $i++;
1337
+ }
1338
+ return json_encode($data);
1339
+ }
1340
+ /**
1341
+ * API config value from SendinBlue.
1342
+ */
1343
+ public function getApiConfigValue()
1344
+ {
1345
+ $data = array();
1346
+ $data['key'] = $this->api_key;
1347
+ $data['webaction'] = 'PLUGIN-CONFIG';
1348
+ $value_config = $this->curlRequest($data);
1349
+ $result = json_decode($value_config);
1350
+ return $result;
1351
+ }
1352
+ /**
1353
+ * Send template email by sendinblue for newsletter subscriber user .
1354
+ */
1355
+ public function sendWsTemplateMail($to)
1356
+ {
1357
+ $mail_url = "http://mysmtp.mailin.fr/ws/template/"; //Curl url
1358
+
1359
+ $key = $this->api_key;
1360
+ $user = $this->getUserName();
1361
+
1362
+ $to = str_replace('+', '%2B', $to);
1363
+ $temp_id_value = $this->getTemplateId();
1364
+ $templateid = !empty($temp_id_value) ? $temp_id_value : ''; // should be the campaign id of template created on mailin. Please remember this template should be active than only it will be sent, otherwise it will return error.
1365
+
1366
+ $post_data = "to=$to&key=$key&user=$user&templateid=$templateid";
1367
+
1368
+ $ch = curl_init();
1369
+
1370
+ curl_setopt ($ch, CURLOPT_POST, 1);
1371
+
1372
+ curl_setopt ($ch, CURLOPT_URL, $mail_url);
1373
+
1374
+ curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
1375
+
1376
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
1377
+
1378
+ $return_data = curl_exec ($ch);
1379
+
1380
+ curl_close ($ch);
1381
+
1382
+ $res = json_decode($return_data, true);
1383
+ return $res;
1384
+
1385
+ }
1386
+ /**
1387
+ * Get all temlpate list id by sendinblue.
1388
  */
1389
+ public function templateDisplay()
1390
  {
1391
  $data = array();
1392
  $data['key'] = $this->api_key;
1393
+ $data['webaction'] = 'CAMPAIGNDETAIL';
1394
+ $data['show'] = 'ALL';
1395
+ $data['messageType'] = 'template';
1396
+ return json_decode($this->curlRequest($data));
1397
+
1398
+ }
1399
+ }
app/code/local/Sendinblue/Sendinblue/controllers/Adminhtml/MyformController.php CHANGED
@@ -11,11 +11,14 @@
11
  class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Controller_Action
12
  {
13
  public function indexAction()
14
- {
15
- Mage::getModel('sendinblue/sendinblue')->createFolderCaseTwo();
 
 
 
 
16
  $this->loadLayout();
17
  $this->renderLayout();
18
-
19
  }
20
  public function syncronizepostAction()
21
  {
@@ -27,6 +30,12 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
27
  if (isset($post['syncronizeSubmit']))
28
  {
29
  $sendin_switch->saveConfig('sendinblue/syncronize', $post['syncronize']);
 
 
 
 
 
 
30
  if (!empty($post['sendin_list']))
31
  {
32
  $list = implode('|', $post['sendin_list']);
@@ -38,7 +47,9 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
38
  $message = $this->__('Please select a list');
39
  Mage::getSingleton('adminhtml/session')->addError($message);
40
  }
 
41
  }
 
42
  }
43
  catch (Exception $e)
44
  {
@@ -46,6 +57,51 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
46
  }
47
  $this->_redirect('*/*');
48
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  public function apikeypostAction()
50
  {
51
  $post = $this->getRequest()->getPost();
@@ -58,7 +114,6 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
58
  $result = Mage::getModel('sendinblue/sendinblue')->checkApikey(trim($post['sendin_apikey']));
59
  if (empty($result['error']))
60
  {
61
- Mage::getModel('sendinblue/sendinblue')->amdRequest(trim($post['sendin_apikey']));
62
  $get_key = Mage::getModel('sendinblue/sendinblue')->getApiKey();
63
  if ($get_key == '')
64
  Mage::getModel('sendinblue/sendinblue')->createFolderName($post['sendin_apikey']);
@@ -69,8 +124,17 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
69
  $sendin_switch->saveConfig('sendinblue/enabled', $post['sendin_api_status']);
70
  $sendin_switch->saveConfig('sendinblue/syncronize', 1);
71
  Mage::getModel('sendinblue/sendinblue')->removeOldEntry();
 
 
 
 
 
 
 
72
  $message = $this->__('Your setting has been successfully saved');
73
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
 
 
74
  } else if (isset($result['error']))
75
  {
76
  $message = $this->__('You have entered wrong api key');
@@ -386,20 +450,21 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
386
  foreach ($results as $i => $result)
387
  {
388
 
389
- if(!empty($result['shipping_telephone']))
390
  {
391
- $sql = 'SELECT * FROM sendinblue_country_codes WHERE iso_code = "'.$result['shipping_country_code'].'" ';
 
392
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
393
  $data = $connection->fetchRow($sql);
394
  $number = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($result['shipping_telephone'],$data['country_prefix']);
395
- $firstname = $result['firstname'];
396
- $lastname = $result['lastname'];
397
- $msgbody = $post['sender_campaign_message'];
398
  $fname = str_replace('{first_name}', $firstname, $msgbody);
399
  $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
400
  $arr = array();
401
  $arr['to'] = $number;
402
- $arr['from'] = $post['sender_campaign'];
403
  $arr['text'] = $msgbody;
404
  Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
405
  }
@@ -418,95 +483,74 @@ class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Co
418
  }
419
  else if(isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 2)
420
  {
421
- $smscredit = Mage::getModel('sendinblue/sendinblue')->getSmsCredit();
422
- $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname');
423
- foreach ($collection as $customer)
424
- {
425
-
426
- $email = $customer->getData('email');
427
- $firstname = $customer->getData('firstname');
428
- $lastname = $customer->getData('lastname');
429
- $cid = $customer->getData('entity_id');
430
-
431
- $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$cid);
432
- $telephone = '';
433
- foreach ($collectionAddress as $customerPhno) {
434
- $telephone = $customerPhno->getData('telephone');
435
- $country_id = $customerPhno->getData('country_id');
436
- }
437
-
438
- $customer_select[$email] = array(
439
- 'email' => $email,
440
- 'firstname' => $firstname,
441
- 'lastname' => $lastname,
442
- 'telephone' => $telephone,
443
- 'country_id' => $country_id,
444
- 'customer_id' => $cid
445
- );
446
- }
447
-
448
- $newsletterArr = array();
449
- $newsletter = Mage::getResourceModel('newsletter/subscriber_collection')->load();
450
- $cnt = 0;
451
- foreach ( $newsletter->getItems() as $subscriber )
452
- {
453
- $customer_id = $subscriber->getCustomerId();;
454
- $subscriber_email = $subscriber->getSubscriberEmail();
455
- $subscriber_status = $subscriber->getSubscriberStatus();
456
-
457
- if ( !empty($customer_select[$subscriber_email]) ) {
458
- $newsletterArr[$cnt] = $customer_select[$subscriber_email];
459
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
460
- unset($customer_select[$subscriber_email]);
461
- }
462
- else {
463
- $newsletterArr[$cnt] = array(
464
- 'email' => $subscriber_email,
465
- 'firstname' => '',
466
- 'lastname' => '',
467
- 'telephone' => '',
468
- 'country_id' => ''
469
- );
470
- $newsletterArr[$cnt]['customer_id'] = $customer_id;
471
- $newsletterArr[$cnt]['subscriber_status'] = $subscriber_status;
472
- }
473
- $cnt++;
474
- }
475
- foreach($newsletterArr as $result)
476
- {
477
-
478
-
479
- if(!empty($result['telephone']))
480
- {
481
-
482
- $sql = 'SELECT * FROM sendinblue_country_codes WHERE iso_code = "'.$result['country_id'].'" ';
483
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
484
- $data = $connection->fetchRow($sql);
485
- $number = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($result['telephone'],$data['country_prefix']);
486
- $msgbody = $post['sender_campaign_message'];
487
- $firstname = $result['firstname'];
488
- $lastname = $result['lastname'];
489
- $fname = str_replace('{first_name}', $firstname, $msgbody);
490
- $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
491
- $arr = array();
492
- $arr['to'] = $number;
493
- $arr['from'] = $post['sender_campaign'];
494
- $arr['text'] = $msgbody;
495
- Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
496
-
497
-
498
- }
499
- }
500
- if ($smscredit >= 1)
501
- {
502
- $message = $this->__('Message has been sent successfully');
503
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
504
- }
505
- else
506
- {
507
- $message = $this->__('Message has not been sent successfully');
508
- Mage::getSingleton('adminhtml/session')->addError($message);
509
- }
510
  }
511
 
512
  }
11
  class Sendinblue_Sendinblue_Adminhtml_MyformController extends Mage_Adminhtml_Controller_Action
12
  {
13
  public function indexAction()
14
+ {
15
+ $params = Mage::app()->getRequest()->getParams();
16
+ $params = empty($params)?array():$params;
17
+ if (isset($params['sendin_apikey']) && $params['sendin_apikey'] != '')
18
+ $this->CreateFolderCaseTwo();
19
+
20
  $this->loadLayout();
21
  $this->renderLayout();
 
22
  }
23
  public function syncronizepostAction()
24
  {
30
  if (isset($post['syncronizeSubmit']))
31
  {
32
  $sendin_switch->saveConfig('sendinblue/syncronize', $post['syncronize']);
33
+ if (!empty($post['template']))
34
+ {
35
+ $sendin_switch->saveConfig('sendinblue/Sendin_Template_Id', $post['template']);
36
+ $message = $this->__('Your setting has been successfully saved');
37
+ }
38
+
39
  if (!empty($post['sendin_list']))
40
  {
41
  $list = implode('|', $post['sendin_list']);
47
  $message = $this->__('Please select a list');
48
  Mage::getSingleton('adminhtml/session')->addError($message);
49
  }
50
+
51
  }
52
+
53
  }
54
  catch (Exception $e)
55
  {
57
  }
58
  $this->_redirect('*/*');
59
  }
60
+
61
+ public function reimportpostAction()
62
+ {
63
+ $post = $this->getRequest()->getPost();
64
+ try {
65
+ if (empty($post))
66
+ Mage::throwException($this->__('Invalid form data.'));
67
+ $sendin_switch = new Mage_Core_Model_Config();
68
+ if (isset($post['importoldSubmit']) && !empty($post['importoldSubmit']))
69
+ {
70
+ $list = Mage::getModel('sendinblue/sendinblue')->getUserlists();
71
+ $list_id = str_replace('|', ',', $list);
72
+ $apikey = Mage::getModel('sendinblue/sendinblue')->getApiKey();
73
+ $allemail = Mage::getModel('sendinblue/sendinblue')->getcustomers();
74
+ $params = array();
75
+ $params['webaction'] = 'IMPORTUSERS';
76
+ $params['key'] = $apikey;
77
+ $params['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportSubUsersToSendinblue.csv';
78
+ $params['listids'] = $list_id;
79
+ $params['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptySubsUserToSendinblue';
80
+ $responce_data = Mage::getModel('sendinblue/sendinblue')->curlRequestAsyc($params);
81
+
82
+ $res_value = json_decode($responce_data);
83
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 0);
84
+ if (empty($res_value->process_id))
85
+ {
86
+ $sendin_switch->saveConfig('sendinblue/importOldUserStatus', 1);
87
+ $message = $this->__('Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again');
88
+ Mage::getSingleton('adminhtml/session')->addError($message);
89
+ }
90
+ else
91
+ {
92
+ $message = $this->__('Your setting has been successfully saved');
93
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
94
+ }
95
+ }
96
+
97
+ }
98
+ catch (Exception $e)
99
+ {
100
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
101
+ }
102
+ $this->_redirect('*/*');
103
+ }
104
+
105
  public function apikeypostAction()
106
  {
107
  $post = $this->getRequest()->getPost();
114
  $result = Mage::getModel('sendinblue/sendinblue')->checkApikey(trim($post['sendin_apikey']));
115
  if (empty($result['error']))
116
  {
 
117
  $get_key = Mage::getModel('sendinblue/sendinblue')->getApiKey();
118
  if ($get_key == '')
119
  Mage::getModel('sendinblue/sendinblue')->createFolderName($post['sendin_apikey']);
124
  $sendin_switch->saveConfig('sendinblue/enabled', $post['sendin_api_status']);
125
  $sendin_switch->saveConfig('sendinblue/syncronize', 1);
126
  Mage::getModel('sendinblue/sendinblue')->removeOldEntry();
127
+ if(Mage::getModel('sendinblue/sendinblue')->getImportOldSubsStatus()==1)
128
+ {
129
+ $message = $this->__('Old subscribers not imported successfully, please click on Import Old Subscribers button to import them again');
130
+ Mage::getSingleton('core/session')->addError($message);
131
+ }
132
+ else
133
+ {
134
  $message = $this->__('Your setting has been successfully saved');
135
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
136
+ }
137
+
138
  } else if (isset($result['error']))
139
  {
140
  $message = $this->__('You have entered wrong api key');
450
  foreach ($results as $i => $result)
451
  {
452
 
453
+ if(isset($result['shipping_telephone']) && !empty($result['shipping_telephone']))
454
  {
455
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
456
+ $sql = 'SELECT * FROM '.$tableCountry.' WHERE iso_code = "'.$result['shipping_country_code'].'" ';
457
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
458
  $data = $connection->fetchRow($sql);
459
  $number = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($result['shipping_telephone'],$data['country_prefix']);
460
+ $firstname = !empty($result['firstname'])?$result['firstname']:'';
461
+ $lastname = !empty($result['lastname'])?$result['lastname']:'';
462
+ $msgbody = !empty($post['sender_campaign_message'])?$post['sender_campaign_message']:'';
463
  $fname = str_replace('{first_name}', $firstname, $msgbody);
464
  $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
465
  $arr = array();
466
  $arr['to'] = $number;
467
+ $arr['from'] = !empty($post['sender_campaign'])?$post['sender_campaign']:'';
468
  $arr['text'] = $msgbody;
469
  Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
470
  }
483
  }
484
  else if(isset($post['sender_campaign_save']) && $post['Sendin_Sms_Choice'] == 2)
485
  {
486
+ $smscredit = Mage::getModel('sendinblue/sendinblue')->getSmsCredit();
487
+
488
+ $camp_name = 'SMS_'.date('Ymd');
489
+ $key = Mage::getModel('sendinblue/sendinblue')->getApiKey();
490
+ if ($key == '')
491
+ return false;
492
+ $param['key'] = $key;
493
+ $param['listname'] = $camp_name;
494
+ $param['webaction'] = 'NEWLIST';
495
+ $param['list_parent'] = '1';
496
+ //folder id
497
+ $list_response = Mage::getModel('sendinblue/sendinblue')->curlRequest($param);
498
+ $res = json_decode($list_response);
499
+ $list_id = $res->result;
500
+ // import old user to SendinBlue
501
+
502
+ $iso_code = $this->context->language->iso_code;
503
+ $allemail = Mage::getModel('sendinblue/sendinblue')->smsCampaignList();
504
+
505
+ $data['webaction'] = 'MULTI-USERCREADIT';
506
+ $data['key'] = $key;
507
+ $data['attributes'] = $allemail;
508
+ $data['listid'] = $list_id;
509
+ // List id should be optional
510
+
511
+ $data_responce = Mage::getModel('sendinblue/sendinblue')->curlRequest($data);
512
+
513
+ $msgbody = $post['sender_campaign_message'];
514
+ $value_langauge = Mage::getModel('sendinblue/sendinblue')->getApiConfigValue();
515
+ if ($value_langauge->language == 'fr')
516
+ {
517
+ $firstname = '{NOM}';
518
+ $lastname = '{PRENOM}';
519
+ }
520
+ else
521
+ {
522
+ $firstname = '{NAME}';
523
+ $lastname = '{SURNAME}';
524
+ }
525
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
526
+ $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
527
+ $arr = array();
528
+ $sender_campaign = $post['sender_campaign'];
529
+ $content = $msgbody;
530
+ //Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
531
+ $arr['key'] = Mage::getModel('sendinblue/sendinblue')->getApiKey();
532
+ $arr['webaction'] = 'SMSCAMPCREADIT';
533
+ $arr['camp_name'] = $camp_name; // mandatory
534
+ $arr['sender'] = $sender_campaign;
535
+ $arr['content'] = $content;
536
+ $arr['bat_sent'] = '';
537
+ $arr['listids'] = $list_id; // mandatory if SMS campaign is scheduled
538
+ $arr['exclude_list'] = '';
539
+ $arr['schedule'] = date('Y-m-d H:i:s', time() + 300);
540
+
541
+ $data_camp = Mage::getModel('sendinblue/sendinblue')->curlRequest($arr);
542
+
543
+
544
+ if ($smscredit >= 1)
545
+ {
546
+ $message = $this->__('Message has been sent successfully');
547
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
548
+ }
549
+ else
550
+ {
551
+ $message = $this->__('Message has not been sent successfully');
552
+ Mage::getSingleton('adminhtml/session')->addError($message);
553
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  }
555
 
556
  }
app/code/local/Sendinblue/Sendinblue/controllers/Adminhtml/NotifyController.php CHANGED
@@ -13,7 +13,7 @@ class Sendinblue_Sendinblue_Adminhtml_NotifyController extends Mage_Adminhtml_Co
13
  public function indexAction()
14
  {
15
  $responce = Mage::getModel('sendinblue/sendinblue')->notifySmsEmail();
16
- $this->loadLayout()->_setActiveMenu('system')->_addContent()->renderLayout();
17
  $msg_disp = $this->__('The CRON has been well executed.');
18
  Mage::getSingleton('adminhtml/session')->addSuccess($msg_disp);
19
  $this->_redirect("sendinblue/adminhtml_myform/");
13
  public function indexAction()
14
  {
15
  $responce = Mage::getModel('sendinblue/sendinblue')->notifySmsEmail();
16
+
17
  $msg_disp = $this->__('The CRON has been well executed.');
18
  Mage::getSingleton('adminhtml/session')->addSuccess($msg_disp);
19
  $this->_redirect("sendinblue/adminhtml_myform/");
app/code/local/Sendinblue/Sendinblue/controllers/Adminhtml/SyncController.php CHANGED
@@ -13,7 +13,7 @@ class Sendinblue_Sendinblue_Adminhtml_SyncController extends Mage_Adminhtml_Cont
13
  public function indexAction()
14
  {
15
  $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
16
- $this->loadLayout()->_setActiveMenu('system')->_addContent()->renderLayout();
17
  $msg_disp = $this->__('The CRON has been well executed.');
18
  Mage::getSingleton('adminhtml/session')->addSuccess($msg_disp);
19
  $this->_redirect("sendinblue/adminhtml_myform/");
13
  public function indexAction()
14
  {
15
  $responce = Mage::getModel('sendinblue/sendinblue')->syncData();
16
+
17
  $msg_disp = $this->__('The CRON has been well executed.');
18
  Mage::getSingleton('adminhtml/session')->addSuccess($msg_disp);
19
  $this->_redirect("sendinblue/adminhtml_myform/");
app/code/local/Sendinblue/Sendinblue/controllers/AjaxController.php CHANGED
@@ -14,7 +14,10 @@ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Ac
14
  {
15
  $this->loadLayout();
16
  $this->renderLayout();
17
- Mage::getModel('sendinblue/sendinblue')->createFolderCaseTwo();
 
 
 
18
  }
19
 
20
  public function campaignAction()
@@ -85,12 +88,135 @@ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Ac
85
  Mage::throwException($this->__('Invalid form data.'));
86
  $sendin_switch = new Mage_Core_Model_Config();
87
  $sendin_switch->saveConfig('sendinblue/tracking/code', $post['script']);
 
88
  echo $this->__('Your setting has been successfully saved');
89
  }
90
  catch (Exception $e)
91
  {
92
  echo $this->__($e->getMessage());
93
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
  public function smtppostAction()
96
  {
@@ -144,6 +270,8 @@ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Ac
144
  {
145
  $title1 = 'Inscrire le contact';
146
  $title2 = 'Désinscrire le contact';
 
 
147
  $first = 'Première page';
148
  $last = 'Dernière page';
149
  $previous = 'Précédente';
@@ -154,6 +282,8 @@ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Ac
154
  {
155
  $title1 = 'Unsubscribe the contact';
156
  $title2 = 'Subscribe the contact';
 
 
157
  $first = 'First';
158
  $last = 'Last';
159
  $previous = 'Previous';
@@ -193,44 +323,78 @@ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Ac
193
  }
194
  $collection = Mage::getModel('sendinblue/sendinblue')->getNewsletterSubscribe($start, $per_page);
195
  $sendin_status = Mage::getModel('sendinblue/sendinblue')->checkUserSendinStatus($collection);
196
- $sendin_result = $sendin_status['result'];
197
- if (count($collection) != 0)
198
  {
199
  $i = 1;
200
  $msg = '';
201
  foreach ($collection as $subscriber)
202
  {
203
- $email = $subscriber['email'];
204
- $phone = !empty($subscriber['telephone'])?$subscriber['telephone'] : '';
205
- $country_id = !empty($subscriber['country_id'])?$subscriber['country_id'] : '';
206
  if($phone != '')
207
  {
208
- $sql = 'SELECT * FROM sendinblue_country_codes WHERE iso_code = "'.$country_id.'" ';
 
209
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
210
  $data = $connection->fetchRow($sql);
211
  $phone = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($phone,$data['country_prefix']);
212
  }
213
- if ($subscriber['customer_id'] != 0)
214
  $client = $yes;
215
  else
216
  $client = $no;
217
- if ($sendin_result[$email] === 1 || $sendin_result[$email] === null)
218
- $show_status = 0;
219
- if ($sendin_result[$email] === 0)
220
- $show_status = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  if ($subscriber['subscriber_status'] != 3)
222
  $img_magento = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/enabled.gif" >';
223
  else
224
  $img_magento = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/disabled.gif" >';
225
- if ($show_status)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  $img_sendin = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/enabled.gif"
227
  id="ajax_contact_status_'.$i.'" title="'.$title1.'" >';
228
  else
229
  $img_sendin = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/disabled.gif"
230
  id="ajax_contact_status_'.$i.'" title="'.$title2.'" >';
231
  $msg .= '<tr class="even pointer"><td class="a-left">'.$email.'</td><td class="a-left">'.$client.'</td><td class="a-left">'.$phone.'</td><td class="a-left">'.$img_magento.'</td>
232
- <td class="a-left last"><a status="'.$show_status.'" email="'.$email.'" class="ajax_contacts_href" href="javascript:void(0)">
233
- '.$img_sendin.'</a></td></tr>';
 
234
  $i++;
235
  }
236
  }
@@ -271,84 +435,114 @@ class Sendinblue_Sendinblue_AjaxController extends Mage_Core_Controller_Front_Ac
271
  echo $this->__($e->getMessage());
272
  }
273
  }
274
- public function ajaxupdateAction()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  {
276
  $post = $this->getRequest()->getPost();
 
 
277
  try {
278
  if (empty($post))
279
  Mage::throwException($this->__('Invalid form data.'));
280
- $temp_sub_status = ($post['newsletter'] == 0) ? 1 : 3;
281
- if (!empty($post['email']) && $post['newsletter'] == 0)
 
 
282
  {
283
- $responce = Mage::getModel('sendinblue/sendinblue')->emailSubscribe($post['email']);
284
- $responce_data = json_decode($responce);
285
- $sql = 'SELECT * from customer_entity where email = "'.$post['email'].'" ';
 
 
286
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
287
  $custdata = $connection->fetchRow($sql);
288
 
289
- if ($responce_data->errorMsg == 'User not exists')
290
- {
291
- if ($custdata['entity_id'] != '')
292
- {
293
- $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$custdata['entity_id']);
294
- $telephone = '';
295
- foreach ($collectionAddress as $customerPhno) {
296
- $telephone = $customerPhno->getData('telephone');
297
- $country_id = $customerPhno->getData('country_id');
 
 
298
 
299
- }
300
 
301
- $customer = Mage::getModel("customer/customer");
302
- $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
303
- $customer->loadByEmail($post['email']); //load customer by email id
304
- $customer_name = $customer->getData();
305
-
306
- if (!empty($telephone))
307
- {
308
- $sql = 'SELECT * FROM sendinblue_country_codes WHERE iso_code = "'.$country_id.'" ';
309
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
310
- $data = $connection->fetchRow($sql);
311
- $number = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($telephone,$data['country_prefix']);
312
- }
313
- $client = 1;
314
- $telephone = (isset($number))? $number : '';
315
- $firstname = (isset($customer_name['firstname']))?$customer_name['firstname'] : '';
316
- $lasttname = (isset($customer_name['lastname']))?$customer_name['lastname'] : '';
317
-
318
- $extra = $firstname.'|'.$lasttname.'|'.$client.'|'.$telephone;
 
 
319
 
320
- $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($post['email'], $extra);
321
-
322
- }
323
- else
324
- {
325
- $client = 0;
326
- $extra = ''.'|'.''.'|'.$client.'|'.'';
327
- $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($post['email'], $extra);
328
- }
329
- }
330
- $sql = 'SELECT * from newsletter_subscriber where subscriber_email = "'.$post['email'].'" ';
331
  $custdatanews = $connection->fetchRow($sql);
332
  if ($custdata['entity_id'] !='' && $custdatanews['subscriber_email'] == '' )
333
- {
334
 
335
- $connection->query("insert into newsletter_subscriber(store_id, customer_id, subscriber_email, subscriber_status)
336
- values('".$custdata['store_id']."','".$custdata['entity_id']."','".$custdata['email']."','1')");
337
 
338
  }
339
  else
340
  {
341
- $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($post['email']);
342
  $costomer_data->setStatus($temp_sub_status);
343
  $costomer_data->setIsStatusChanged(true);
344
  $costomer_data->save();
345
  }
346
-
347
  }
348
  else{
349
- $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($post['email']);
350
- $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($post['email']);
351
- $sql = 'SELECT * from customer_entity where email = "'.$post['email'].'" ';
352
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
353
  $custdata = $connection->fetchRow($sql);
354
 
@@ -369,7 +563,7 @@ public function ajaxupdateAction()
369
  }
370
  }
371
 
372
- public function ajaxordersmsAction($sender, $message, $number)
373
  {
374
  $post = $this->getRequest()->getPost();
375
  try {
@@ -383,16 +577,39 @@ public function ajaxupdateAction()
383
 
384
  if (isset($number))
385
  {
386
- $arr = array();
387
- $arr['to'] = $number;
388
- $arr['from'] = $post['sender'];
389
- $arr['text'] = $post['message'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
 
391
- $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
392
- if (isset($result->status) && $result->status == 'OK')
393
- echo 'OK';
394
- else
395
- echo 'KO';
396
  }
397
 
398
  }
@@ -402,7 +619,7 @@ public function ajaxupdateAction()
402
  }
403
  }
404
 
405
- public function ajaxordershippedAction($sender,$message,$number)
406
  {
407
  $post = $this->getRequest()->getPost();
408
  try {
@@ -418,12 +635,35 @@ public function ajaxupdateAction()
418
 
419
  if (isset($number))
420
  {
421
- $arr = array();
422
- $arr['to'] = $number;
423
- $arr['from'] = $post['sender'];
424
- $arr['text'] = $post['message'];
425
-
426
- $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  if (isset($result->status) && $result->status == 'OK')
428
  echo 'OK';
429
  else
@@ -437,7 +677,7 @@ public function ajaxupdateAction()
437
  }
438
  }
439
 
440
- public function ajaxsmscampaignAction($sender,$message,$number)
441
  {
442
  $post = $this->getRequest()->getPost();
443
  try {
@@ -451,12 +691,20 @@ public function ajaxupdateAction()
451
 
452
  if (isset($number))
453
  {
454
- $arr = array();
455
- $arr['to'] = $number;
456
- $arr['from'] = $post['sender'];
457
- $arr['text'] = $post['message'];
458
- $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
459
- $locale = Mage::app()->getLocale()->getLocaleCode();
 
 
 
 
 
 
 
 
460
  if (isset($result->status) && $result->status == 'OK')
461
  echo 'OK';
462
  else
14
  {
15
  $this->loadLayout();
16
  $this->renderLayout();
17
+ $params = Mage::app()->getRequest()->getParams();
18
+ $params = empty($params)?array():$params;
19
+ if (isset($params['sendin_apikey']) && $params['sendin_apikey'] != '')
20
+ $this->CreateFolderCaseTwo();
21
  }
22
 
23
  public function campaignAction()
88
  Mage::throwException($this->__('Invalid form data.'));
89
  $sendin_switch = new Mage_Core_Model_Config();
90
  $sendin_switch->saveConfig('sendinblue/tracking/code', $post['script']);
91
+ $sendin_switch->saveConfig('sendinblue/improt/history', $post['script']);
92
  echo $this->__('Your setting has been successfully saved');
93
  }
94
  catch (Exception $e)
95
  {
96
  echo $this->__($e->getMessage());
97
  }
98
+ }
99
+ public function emptySubsUserToSendinblueAction()
100
+ {
101
+ $post = $this->getRequest()->getPost();
102
+ try {
103
+ if (empty($post))
104
+ Mage::throwException($this->__('Invalid form data.'));
105
+ if ($post['proc_success'] != '')
106
+ {
107
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportSubUsersToSendinblue.csv', 'w+');
108
+ $key_value = array();
109
+ $key_value[] = '';
110
+ fputcsv($handle, $key_value);
111
+ fclose($handle);
112
+ }
113
+ }
114
+ catch (Exception $e)
115
+ {
116
+ echo $this->__($e->getMessage());
117
+ }
118
+ }
119
+ public function emptyImportOldOrderAction()
120
+ {
121
+ $post = $this->getRequest()->getPost();
122
+ try {
123
+ if (empty($post))
124
+ Mage::throwException($this->__('Invalid form data.'));
125
+ if ($post['proc_success'] != '')
126
+ {
127
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportOldOrdersToSendinblue.csv', 'w+');
128
+ $key_value = array();
129
+ $key_value[] = '';
130
+ fputcsv($handle, $key_value);
131
+ fclose($handle);
132
+ }
133
+ }
134
+ catch (Exception $e)
135
+ {
136
+ echo $this->__($e->getMessage());
137
+ }
138
+ }
139
+ public function orderhistoryAction()
140
+ {
141
+ $post = $this->getRequest()->getPost();
142
+ try {
143
+ if (empty($post))
144
+ Mage::throwException($this->__('Invalid form data.'));
145
+
146
+ if ($post['history_status'] == 1)
147
+ {
148
+ $value = Mage::getModel('sendinblue/sendinblue')->TrackingSmtp();
149
+ $date_value = Mage::getModel('sendinblue/sendinblue')->getApiConfigValue();
150
+ if (!is_dir(Mage::getBaseDir('media').'/sendinblue_csv'))
151
+ mkdir(Mage::getBaseDir('media').'/sendinblue_csv', 0777, true);
152
+
153
+ $handle = fopen(Mage::getBaseDir('media').'/sendinblue_csv/ImportOldOrdersToSendinblue.csv', 'w+');
154
+
155
+ fwrite($handle, 'EMAIL,ORDER_ID,ORDER_PRICE,ORDER_DATE'.PHP_EOL);
156
+
157
+
158
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email');
159
+ foreach ($collection as $customer)
160
+ {
161
+ $cid = $customer->getData('entity_id');
162
+ $email = $customer->getData('email');
163
+ $total_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $cid);
164
+ $orderCnt = $total_orders->count();
165
+ if ($orderCnt > 0)
166
+ {
167
+ $data = array();
168
+ $data['key'] = Mage::getModel('sendinblue/sendinblue')->getApiKey();
169
+ $data['webaction'] = 'USERS-STATUS';
170
+ $data['email'] = $email;
171
+ $curl_responce = Mage::getModel('sendinblue/sendinblue')->curlRequest($data);
172
+ $user_status = json_decode($curl_responce);
173
+ }
174
+ if (isset($user_status->result) != '')
175
+ {
176
+ foreach($total_orders as $order_data)
177
+ {
178
+ if ($date_value->date_format == 'dd-mm-yyyy')
179
+ $date = date('d-m-Y', strtotime($order_data['created_at']));
180
+ else
181
+ $date = date('m-d-Y', strtotime($order_data['created_at']));
182
+ $history_data= array();
183
+ $history_data[] = array($order_data['customer_email'],$order_data['increment_id'],$order_data['grand_total'],$date);
184
+ foreach ($history_data as $line)
185
+ fputcsv($handle, $line);
186
+ }
187
+ }
188
+ }
189
+
190
+ fclose($handle);
191
+
192
+ $get_User_lists = Mage::getModel('sendinblue/sendinblue')->getUserlists();
193
+ $list = str_replace('|', ',', $get_User_lists);
194
+ if (preg_match('/^[0-9,]+$/', $list))
195
+ $list = $list;
196
+ else
197
+ $list = '';
198
+
199
+ $import_data = array();
200
+ $import_data['webaction'] = 'IMPORTUSERS';
201
+ $import_data['key'] = Mage::getModel('sendinblue/sendinblue')->getApiKey();
202
+ $import_data['url'] = Mage::getBaseUrl('media').'sendinblue_csv/ImportOldOrdersToSendinblue.csv';
203
+ $import_data['listids'] = $list;
204
+ $import_data['notify_url'] = Mage::getBaseUrl().'sendinblue/ajax/emptyImportOldOrder';
205
+ /**
206
+ * List id should be optional
207
+ */
208
+ Mage::getModel('sendinblue/sendinblue')->curlRequestAsyc($import_data);
209
+
210
+
211
+ $sendin_switch = new Mage_Core_Model_Config();
212
+ $sendin_switch->saveConfig('sendinblue/improt/history', 0);
213
+ echo $this->__('Order history has been import successfully');
214
+ }
215
+ }
216
+ catch (Exception $e)
217
+ {
218
+ echo $this->__($e->getMessage());
219
+ }
220
  }
221
  public function smtppostAction()
222
  {
270
  {
271
  $title1 = 'Inscrire le contact';
272
  $title2 = 'Désinscrire le contact';
273
+ $title3 = 'Inscrire le sms';
274
+ $title4 = 'Désinscrire le sms';
275
  $first = 'Première page';
276
  $last = 'Dernière page';
277
  $previous = 'Précédente';
282
  {
283
  $title1 = 'Unsubscribe the contact';
284
  $title2 = 'Subscribe the contact';
285
+ $title3 = 'Unsubscribe the sms';
286
+ $title4 = 'Subscribe the sms';
287
  $first = 'First';
288
  $last = 'Last';
289
  $previous = 'Previous';
323
  }
324
  $collection = Mage::getModel('sendinblue/sendinblue')->getNewsletterSubscribe($start, $per_page);
325
  $sendin_status = Mage::getModel('sendinblue/sendinblue')->checkUserSendinStatus($collection);
326
+ $sendin_result = isset($sendin_status['result'])?$sendin_status['result']:'';
327
+ if (count($collection) > 0)
328
  {
329
  $i = 1;
330
  $msg = '';
331
  foreach ($collection as $subscriber)
332
  {
333
+ $email = isset($subscriber['email'])?$subscriber['email']:'';
334
+ $phone = isset($subscriber['telephone'])?$subscriber['telephone'] : '';
335
+ $country_id = isset($subscriber['country_id'])?$subscriber['country_id'] : '';
336
  if($phone != '')
337
  {
338
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
339
+ $sql = 'SELECT * FROM '.$tableCountry.' WHERE iso_code = "'.$country_id.'" ';
340
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
341
  $data = $connection->fetchRow($sql);
342
  $phone = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($phone,$data['country_prefix']);
343
  }
344
+ if (isset($subscriber['customer_id']) != 0)
345
  $client = $yes;
346
  else
347
  $client = $no;
348
+
349
+ $show_status = '';
350
+ $sms_status = '';
351
+ if(isset($sendin_result[$email])) {
352
+ $email_bl_value = isset($sendin_result[$email]['email_bl'])?$sendin_result[$email]['email_bl']:'';
353
+ if ($email_bl_value === 1 || $sendin_result[$email] == null)
354
+ $show_status = 0;
355
+ if ($email_bl_value === 0)
356
+ $show_status = 1;
357
+
358
+ $sms_bl = isset($sendin_result[$email]['sms_bl'])?$sendin_result[$email]['sms_bl']:'';
359
+ $sms_exist = isset($sendin_result[$email]['sms_exist'])?$sendin_result[$email]['sms_exist']:'';
360
+ $subs_telephone = isset($subscriber['telephone'])?$subscriber['telephone']:'';
361
+ if ($sms_bl === 1 && $sms_exist > 0)
362
+ $sms_status = 0;
363
+ elseif ($sms_bl === 0 && $sms_exist > 0)
364
+ $sms_status = 1;
365
+ elseif ($sms_exist <= 0 && empty($subs_telephone))
366
+ $sms_status = 2;
367
+ else if ($sms_exist <= 0 && !empty($subs_telephone))
368
+ $sms_status = 3;
369
+ }
370
  if ($subscriber['subscriber_status'] != 3)
371
  $img_magento = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/enabled.gif" >';
372
  else
373
  $img_magento = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/disabled.gif" >';
374
+
375
+ $sms_status = $sms_status >= 0?$sms_status:'';
376
+
377
+ if ($sms_status === 1)
378
+ $img_sms = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/enabled.gif"
379
+ id="ajax_contact_status_'.$i.'" title="'.$title3.'" >';
380
+ else if ($sms_status === 0)
381
+ $img_sms = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/disabled.gif"
382
+ id="ajax_contact_status_'.$i.'" title="'.$title4.'" >';
383
+ else if ($sms_status === 2 || $sms_status === '')
384
+ $img_sms = '';
385
+ else if ($sms_status === 3)
386
+ $img_sms = 'Not synchronized';
387
+ $show_status = !empty($show_status)?$show_status:'0';
388
+ if ($show_status == 1)
389
  $img_sendin = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/enabled.gif"
390
  id="ajax_contact_status_'.$i.'" title="'.$title1.'" >';
391
  else
392
  $img_sendin = '<img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'adminhtml/default/default/sendinblue/images/disabled.gif"
393
  id="ajax_contact_status_'.$i.'" title="'.$title2.'" >';
394
  $msg .= '<tr class="even pointer"><td class="a-left">'.$email.'</td><td class="a-left">'.$client.'</td><td class="a-left">'.$phone.'</td><td class="a-left">'.$img_magento.'</td>
395
+ <td class="a-left"><a status="'.$show_status.'" email="'.$email.'" class="ajax_contacts_href" href="javascript:void(0)">
396
+ '.$img_sendin.'</a></td><td class="a-left last"><a status="'.$sms_status.'" email="'.$email.'" class="ajax_sms_subs_href" href="javascript:void(0)">
397
+ '.$img_sms.'</a></td></tr>';
398
  $i++;
399
  }
400
  }
435
  echo $this->__($e->getMessage());
436
  }
437
  }
438
+ public function ajaxsmssubscribeAction()
439
+ {
440
+ $post = $this->getRequest()->getPost();
441
+ try {
442
+ if (empty($post))
443
+ Mage::throwException($this->__('Invalid form data.'));
444
+ $email = $post['email'];
445
+ //$sms = $post['sms'];
446
+ $data = array();
447
+ $data['key'] = Mage::getModel('sendinblue/sendinblue')->getApiKey();
448
+ $data['webaction'] = 'USERUNSUBSCRIBEDSMS';
449
+ $data['email'] = $email;
450
+ Mage::getModel('sendinblue/sendinblue')->curlRequest($data);
451
+
452
+ }
453
+ catch (Exception $e)
454
+ {
455
+ echo $this->__($e->getMessage());
456
+ }
457
+ }
458
+ public function ajaxupdateAction()
459
  {
460
  $post = $this->getRequest()->getPost();
461
+ $tableCustomer = Mage::getSingleton('core/resource')->getTableName('customer/entity');
462
+ $tableNewsletter = Mage::getSingleton('core/resource')->getTableName('newsletter/subscriber');
463
  try {
464
  if (empty($post))
465
  Mage::throwException($this->__('Invalid form data.'));
466
+ $post_email = isset($post['email'])?$post['email']:'';
467
+ $post_newsletter = isset($post['newsletter'])?$post['newsletter']:'';
468
+ $temp_sub_status = ($post_newsletter == 0) ? 1 : 3;
469
+ if (!empty($post_email) && $post_newsletter == 0)
470
  {
471
+ $locale = Mage::app()->getLocale()->getLocaleCode();
472
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailSubscribe($post_email);
473
+ $responce_data = json_decode($responce);
474
+
475
+ $sql = 'SELECT * from '.$tableCustomer.' where email = "'.$post_email.'" ';
476
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
477
  $custdata = $connection->fetchRow($sql);
478
 
479
+ // if (isset($responce_data->errorMsg) == 'User not exists')
480
+ // {
481
+ if (isset($custdata['entity_id']) != '')
482
+ {
483
+ $collectionAddress = Mage::getModel('customer/address')->getCollection()->addAttributeToSelect('telephone')->addAttributeToSelect('country_id')->addAttributeToFilter('parent_id',(int)$custdata['entity_id']);
484
+ $telephone = '';
485
+ foreach ($collectionAddress as $customerPhno) {
486
+ $phn_sms = $customerPhno->getData('telephone');
487
+ $country_id_value = $customerPhno->getData('country_id');
488
+ $telephone = !empty($phn_sms) ? $phn_sms : '';
489
+ $country_id = !empty($country_id_value) ? $country_id_value : '';
490
 
491
+ }
492
 
493
+ $customer = Mage::getModel("customer/customer");
494
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
495
+ $customer->loadByEmail($post_email); //load customer by email id
496
+ $customer_name = $customer->getData();
497
+ $user_lang = isset($customer_name['created_in'])?$customer_name['created_in'] : '';
498
+
499
+ if (!empty($telephone))
500
+ {
501
+ $tableCountry = Mage::getSingleton('core/resource')->getTableName('sendinblue_country_codes');
502
+ $sql = 'SELECT * FROM '.$tableCountry.' WHERE iso_code = "'.$country_id.'" ';
503
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
504
+ $data = $connection->fetchRow($sql);
505
+ $number = Mage::getModel('sendinblue/sendinblue')->checkMobileNumber($telephone,$data['country_prefix']);
506
+ }
507
+ $client = 1;
508
+ $telephone = (isset($number))? $number : '';
509
+ $firstname = (isset($customer_name['firstname']))?$customer_name['firstname'] : '';
510
+ $lasttname = (isset($customer_name['lastname']))?$customer_name['lastname'] : '';
511
+
512
+ $extra = $firstname.'|'.$lasttname.'|'.$user_lang.'|'.$client.'|'.$telephone;
513
 
514
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($post_email, $extra, $post_newsletter);
515
+
516
+ }
517
+ else
518
+ {
519
+ $client = 0;
520
+ $extra = ''.'|'.''.'|'.''.'|'.$client.'|'.'';
521
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailAdd($post_email, $extra, $post_newsletter);
522
+ }
523
+ // }
524
+ $sql = 'SELECT * from '.$tableNewsletter.' where subscriber_email = "'.$post_email.'" ';
525
  $custdatanews = $connection->fetchRow($sql);
526
  if ($custdata['entity_id'] !='' && $custdatanews['subscriber_email'] == '' )
527
+ {
528
 
529
+ $connection->query("insert into ".$tableNewsletter."(store_id, customer_id, subscriber_email, subscriber_status)
530
+ values('".$custdata['store_id']."','".$custdata['entity_id']."','".$custdata['email']."','1')");
531
 
532
  }
533
  else
534
  {
535
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($post_email);
536
  $costomer_data->setStatus($temp_sub_status);
537
  $costomer_data->setIsStatusChanged(true);
538
  $costomer_data->save();
539
  }
540
+
541
  }
542
  else{
543
+ $responce = Mage::getModel('sendinblue/sendinblue')->emailDelete($post_email);
544
+ $costomer_data = Mage::getModel('newsletter/subscriber')->loadByEmail($post_email);
545
+ $sql = 'SELECT * from '.$tableCustomer.' where email = "'.$post_email.'" ';
546
  $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
547
  $custdata = $connection->fetchRow($sql);
548
 
563
  }
564
  }
565
 
566
+ public function ajaxordersmsAction($sender='', $message='', $number='')
567
  {
568
  $post = $this->getRequest()->getPost();
569
  try {
577
 
578
  if (isset($number))
579
  {
580
+ $adminUserModel = Mage::getModel('admin/user');
581
+ $userCollection = $adminUserModel->getCollection()->load();
582
+ $admin_data = $userCollection->getData();
583
+ $firstname = isset($admin_data[0]['firstname'])?$admin_data[0]['firstname']:'';
584
+ $lastname = isset($admin_data[0]['lastname'])?$admin_data[0]['lastname']:'';
585
+ $characters = '1234567890';
586
+ $ref_num = '';
587
+ for ($i = 0; $i < 9; $i++)
588
+ $ref_num .= $characters[rand(0, strlen($characters) - 1)];
589
+
590
+ $locale = Mage::app()->getLocale()->getLocaleCode();
591
+ if ($locale == 'fr_FR')
592
+ $ord_date = date('d/m/Y');
593
+ else
594
+ $ord_date = date('m/d/Y');
595
+ $orderprice = rand(10, 1000);
596
+ $total_pay = $orderprice.'.00'.' '.Mage::app()->getStore()-> getCurrentCurrencyCode();
597
+ $msgbody = $post['message'];
598
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
599
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
600
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
601
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
602
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
603
+ $arr = array();
604
+ $arr['to'] = $number;
605
+ $arr['from'] = isset($post['sender'])?$post['sender']:'';
606
+ $arr['text'] = $msgbody;
607
 
608
+ $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
609
+ if (isset($result->status) && $result->status == 'OK')
610
+ echo 'OK';
611
+ else
612
+ echo 'KO';
613
  }
614
 
615
  }
619
  }
620
  }
621
 
622
+ public function ajaxordershippedAction($sender='', $message='', $number='')
623
  {
624
  $post = $this->getRequest()->getPost();
625
  try {
635
 
636
  if (isset($number))
637
  {
638
+ $adminUserModel = Mage::getModel('admin/user');
639
+ $userCollection = $adminUserModel->getCollection()->load();
640
+ $admin_data = $userCollection->getData();
641
+ $firstname = isset($admin_data[0]['firstname'])?$admin_data[0]['firstname']:'';
642
+ $lastname = isset($admin_data[0]['lastname'])?$admin_data[0]['lastname']:'';
643
+ $characters = '1234567890';
644
+ $ref_num = '';
645
+ for ($i = 0; $i < 9; $i++)
646
+ $ref_num .= $characters[rand(0, strlen($characters) - 1)];
647
+
648
+ $locale = Mage::app()->getLocale()->getLocaleCode();
649
+ if ($locale == 'fr_FR')
650
+ $ord_date = date('d/m/Y');
651
+ else
652
+ $ord_date = date('m/d/Y');
653
+ $orderprice = rand(10, 1000);
654
+ $total_pay = $orderprice.'.00'.' '.Mage::app()->getStore()-> getCurrentCurrencyCode();
655
+ $msgbody = $post['message'];
656
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
657
+ $lname = str_replace('{last_name}', $lastname."\r\n", $fname);
658
+ $procuct_price = str_replace('{order_price}', $total_pay, $lname);
659
+ $order_date = str_replace('{order_date}', $ord_date."\r\n", $procuct_price);
660
+ $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
661
+ $arr = array();
662
+ $arr['to'] = $number;
663
+ $arr['from'] = !empty($post['sender'])?$post['sender']:'';
664
+ $arr['text'] = $msgbody;
665
+
666
+ $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
667
  if (isset($result->status) && $result->status == 'OK')
668
  echo 'OK';
669
  else
677
  }
678
  }
679
 
680
+ public function ajaxsmscampaignAction($sender='', $message='', $number='')
681
  {
682
  $post = $this->getRequest()->getPost();
683
  try {
691
 
692
  if (isset($number))
693
  {
694
+ $adminUserModel = Mage::getModel('admin/user');
695
+ $userCollection = $adminUserModel->getCollection()->load();
696
+ $admin_data = $userCollection->getData();
697
+
698
+ $firstname = isset($admin_data[0]['firstname'])?$admin_data[0]['firstname']:'';
699
+ $lastname = isset($admin_data[0]['lastname'])?$admin_data[0]['lastname']:'';
700
+ $msgbody = $post['message'];
701
+ $fname = str_replace('{first_name}', $firstname, $msgbody);
702
+ $msgbody = str_replace('{last_name}', $lastname."\r\n", $fname);
703
+ $arr = array();
704
+ $arr['to'] = $number;
705
+ $arr['from'] = !empty($post['sender'])?$post['sender']:'';
706
+ $arr['text'] = $msgbody;
707
+ $result = Mage::getModel('sendinblue/sendinblue')->sendSmsApi($arr);
708
  if (isset($result->status) && $result->status == 'OK')
709
  echo 'OK';
710
  else
app/code/local/Sendinblue/Sendinblue/etc/config.xml CHANGED
@@ -1,325 +1,316 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Sendinblue_Sendinblue>
5
- <version>1.1.0</version>
6
- <platform>ce</platform>
7
- </Sendinblue_Sendinblue>
8
- </modules>
9
- <adminhtml>
10
- <menu>
11
- <system>
12
- <children>
13
- <mails translate="title" module="sendinblue">
14
- <title>SendinBlue Settings</title>
15
- <action>sendinblue/adminhtml_myform</action>
16
- <sort_order>0</sort_order>
17
-
18
- </mails>
19
- </children>
20
- </system>
21
- </menu>
22
- <translate></translate>
23
- <events>
24
-
25
- <!--use for delete customer (post) -->
26
- <controller_action_postdispatch_adminhtml_customer_massDelete>
27
- <observers>
28
- <sendinblue_admin_customer_massDelete>
29
- <type>singleton</type>
30
- <class>Sendinblue_Sendinblue_Model_Observer</class>
31
- <method>adminCustomerDelete</method>
32
- </sendinblue_admin_customer_massDelete>
33
- </observers>
34
- </controller_action_postdispatch_adminhtml_customer_massDelete>
35
-
36
- <!--use for delete newsletter subcriber (post) -->
37
- <controller_action_postdispatch_adminhtml_newsletter_subscriber_massDelete>
38
- <observers>
39
- <sendinblue_admin_newsletter_massDelete>
40
- <type>singleton</type>
41
- <class>Sendinblue_Sendinblue_Model_Observer</class>
42
- <method>adminSubcriberDelete</method>
43
- </sendinblue_admin_newsletter_massDelete>
44
- </observers>
45
- </controller_action_postdispatch_adminhtml_newsletter_subscriber_massDelete>
46
-
47
- <!--use for subscribe customer (subscribe customer for newsletter from admin) (post) -->
48
- <controller_action_postdispatch_adminhtml_customer_massSubscribe>
49
- <observers>
50
- <sendinblue_admin_customer_massSubscribe>
51
- <type>singleton</type>
52
- <class>Sendinblue_Sendinblue_Model_Observer</class>
53
- <method>adminCustomerSubscribe</method>
54
- </sendinblue_admin_customer_massSubscribe>
55
- </observers>
56
- </controller_action_postdispatch_adminhtml_customer_massSubscribe>
57
-
58
- <!--use for unsubscribe customer (post) -->
59
- <controller_action_postdispatch_adminhtml_customer_massUnsubscribe>
60
- <observers>
61
- <sendinblue_admin_customer_massUnsubscribe>
62
- <type>singleton</type>
63
- <class>Sendinblue_Sendinblue_Model_Observer</class>
64
- <method>adminCustomerDelete</method>
65
- </sendinblue_admin_customer_massUnsubscribe>
66
- </observers>
67
- </controller_action_postdispatch_adminhtml_customer_massUnsubscribe>
68
-
69
- <!--use for unsubscribe newsletter subscriber (post) -->
70
- <controller_action_predispatch_adminhtml_newsletter_subscriber_massUnsubscribe>
71
- <observers>
72
- <sendinblue_admin_newsletter_massUnsubscribe>
73
- <type>singleton</type>
74
- <class>Sendinblue_Sendinblue_Model_Observer</class>
75
- <method>adminSubcriberDelete</method>
76
- </sendinblue_admin_newsletter_massUnsubscribe>
77
- </observers>
78
- </controller_action_predispatch_adminhtml_newsletter_subscriber_massUnsubscribe>
79
-
80
-
81
- <sales_order_save_after>
82
- <observers>
83
- <sendinblue_update_data>
84
- <type>singleton</type>
85
- <class>Sendinblue_Sendinblue_Model_Observer</class>
86
- <method>updateStatus</method>
87
- </sendinblue_update_data>
88
- </observers>
89
- </sales_order_save_after>
90
-
91
- </events>
92
- <acl>
93
- <resources>
94
- <all>
95
- <title>Allow Everything</title>
96
- </all>
97
- <admin>
98
- <children>
99
- <mails>
100
- <children>
101
- <mails>
102
- <title>Sendinblue</title>
103
- </mails>
104
- </children>
105
- </mails>
106
- <system>
107
- <children>
108
- <config>
109
- <children>
110
- <sendinblue>
111
- <title>Sendinblue</title>
112
- </sendinblue>
113
- </children>
114
- </config>
115
- </children>
116
- </system>
117
- </children>
118
- <children>
119
- <system>
120
- <children>
121
- <mails translate="title" module="sendinblue">
122
- <title>Sendinblue Settings</title>
123
- <sort_order>0</sort_order>
124
- <action></action>
125
- </mails>
126
- </children>
127
- </system>
128
- </children>
129
- </admin>
130
- </resources>
131
- </acl>
132
- <translate>
133
- <modules>
134
- <Sendinblue_Sendinblue>
135
- <files>
136
- <default>Sendinblue.csv</default>
137
- </files>
138
- </Sendinblue_Sendinblue>
139
- </modules>
140
- </translate>
141
-
142
-
143
- <layout>
144
- <updates>
145
- <sendinblue_sendinblue>
146
- <file>sendinblue.xml</file>
147
- </sendinblue_sendinblue>
148
- </updates>
149
- </layout>
150
-
151
- </adminhtml>
152
- <admin>
153
- <routers>
154
- <sendinblue_admin>
155
- <use>admin</use>
156
- <args>
157
- <module>Sendinblue_Sendinblue</module>
158
- <frontName>sendinblue</frontName>
159
- </args>
160
- </sendinblue_admin>
161
- </routers>
162
- <children>
163
- <system>
164
- <children>
165
- <mails translate="label" module="sendinblue">
166
- <title>Sendinblue Settings</title>
167
- <sort_order>40</sort_order>
168
- <action>adminhtml/system_config/edit/section/sendinblue</action>
169
- </mails>
170
- </children>
171
- </system>
172
- </children>
173
- </admin>
174
- <global>
175
- <events>
176
- <newsletter_subscriber_save_commit_after>
177
- <observers>
178
- <sendinblue_sendinblue_model_observer>
179
- <class>Sendinblue_Sendinblue_Model_Observer</class>
180
- <method>subscribedToNewsletter</method>
181
- </sendinblue_sendinblue_model_observer>
182
- </observers>
183
- </newsletter_subscriber_save_commit_after>
184
- <customer_save_after>
185
- <observers>
186
- <sendinblue_update_data>
187
- <type>singleton</type>
188
- <class>Sendinblue_Sendinblue_Model_Observer</class>
189
- <method>updateNewObserver</method>
190
- </sendinblue_update_data>
191
- </observers>
192
- </customer_save_after>
193
- </events>
194
-
195
- <template>
196
- <email>
197
- <custom_template>
198
- <label>Sendinblue custom email module</label>
199
- <file>sendinsmtp_conf.html</file>
200
- <type>html</type>
201
- </custom_template>
202
- <notification_template>
203
- <label>Sendinblue notification email module</label>
204
- <file>sendin_notification.html</file>
205
- <type>html</type>
206
- </notification_template>
207
- </email>
208
- </template>
209
-
210
- <models>
211
- <core>
212
- <rewrite>
213
- <email>Sendinblue_Sendinblue_Model_Email</email>
214
- <email_template>Sendinblue_Sendinblue_Model_Email_Template</email_template>
215
- </rewrite>
216
- </core>
217
- <sendinblue>
218
- <class>Sendinblue_Sendinblue_Model</class>
219
- <resourceModel>sendinblue_mysql4</resourceModel>
220
- </sendinblue>
221
- <sendinblue_mysql4>
222
- <class>Sendinblue_Sendinblue_Model_Mysql4</class>
223
- <entities>
224
- <sendinblue>
225
- <table>sendinblue_country_codes</table>
226
- </sendinblue>
227
- </entities>
228
- </sendinblue_mysql4>
229
- </models>
230
- <resources>
231
- <sendinblue_setup>
232
- <setup>
233
- <module>Sendinblue_Sendinblue</module>
234
- </setup>
235
- <connection>
236
- <use>core_setup</use>
237
- </connection>
238
- </sendinblue_setup>
239
- <sendinblue_write>
240
- <connection>
241
- <use>core_write</use>
242
- </connection>
243
- </sendinblue_write>
244
- <sendinblue_read>
245
- <connection>
246
- <use>core_read</use>
247
- </connection>
248
- </sendinblue_read>
249
- </resources>
250
-
251
- <helpers>
252
- <sendinblue>
253
- <class>Sendinblue_Sendinblue_Helper</class>
254
- </sendinblue>
255
- </helpers>
256
- <blocks>
257
- <sendinblue>
258
- <class>Sendinblue_Sendinblue_Block</class>
259
- </sendinblue>
260
- </blocks>
261
-
262
- </global>
263
- <crontab>
264
- <jobs>
265
- <sendinblue_sendinblue>
266
- <schedule>
267
- <cron_expr>*/5 * * * *</cron_expr>
268
- </schedule>
269
- <run>
270
- <model>sendinblue/observer::syncData</model>
271
- </run>
272
- </sendinblue_sendinblue>
273
- </jobs>
274
- </crontab>
275
- <default>
276
- <sendinblue>
277
- <general>
278
- <enabled>0</enabled>
279
- <test>0</test>
280
- <test_address />
281
- </general>
282
- <smtp>
283
- <host>sendinblue.fr</host>
284
- <port />
285
- <login />
286
- <password />
287
- <ssl />
288
- </smtp>
289
- </sendinblue>
290
- </default>
291
- <frontend>
292
- <events>
293
- <!--use when new subcriber add for newsletter-->
294
- <controller_action_postdispatch_newsletter_subscriber_new>
295
- <observers>
296
- <sendinblue_subscribe_new_observer>
297
- <type>singleton</type>
298
- <class>Sendinblue_Sendinblue_Model_Observer</class>
299
- <method>subscribeObserver</method>
300
- </sendinblue_subscribe_new_observer>
301
- </observers>
302
- </controller_action_postdispatch_newsletter_subscriber_new>
303
-
304
- <!--use when new user register check (is_subscribed = 1)-->
305
- <checkout_submit_all_after>
306
- <observers>
307
- <sendinblue_sendinblue_model_observer>
308
- <class>Sendinblue_Sendinblue_Model_Observer</class>
309
- <method>ordersucess</method>
310
- </sendinblue_sendinblue_model_observer>
311
- </observers>
312
- </checkout_submit_all_after>
313
-
314
- </events>
315
-
316
- <layout>
317
- <updates>
318
- <sendinblue_sendinblue>
319
- <file>sendinblue.xml</file>
320
- </sendinblue_sendinblue>
321
- </updates>
322
- </layout>
323
-
324
- </frontend>
325
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Sendinblue_Sendinblue>
5
+ <version>1.1.9</version>
6
+ <platform>ce</platform>
7
+ </Sendinblue_Sendinblue>
8
+ </modules>
9
+ <adminhtml>
10
+ <menu>
11
+ <system>
12
+ <children>
13
+ <mails translate="title" module="sendinblue">
14
+ <title>SendinBlue Settings</title>
15
+ <action>sendinblue/adminhtml_myform</action>
16
+ <sort_order>0</sort_order>
17
+
18
+ </mails>
19
+ </children>
20
+ </system>
21
+ </menu>
22
+ <translate></translate>
23
+ <events>
24
+
25
+ <!--use for delete customer (post) -->
26
+ <controller_action_postdispatch_adminhtml_customer_massDelete>
27
+ <observers>
28
+ <sendinblue_admin_customer_massDelete>
29
+ <type>singleton</type>
30
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
31
+ <method>adminCustomerDelete</method>
32
+ </sendinblue_admin_customer_massDelete>
33
+ </observers>
34
+ </controller_action_postdispatch_adminhtml_customer_massDelete>
35
+
36
+ <!--use for delete newsletter subcriber (post) -->
37
+ <controller_action_postdispatch_adminhtml_newsletter_subscriber_massDelete>
38
+ <observers>
39
+ <sendinblue_admin_newsletter_massDelete>
40
+ <type>singleton</type>
41
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
42
+ <method>adminSubcriberDelete</method>
43
+ </sendinblue_admin_newsletter_massDelete>
44
+ </observers>
45
+ </controller_action_postdispatch_adminhtml_newsletter_subscriber_massDelete>
46
+
47
+ <!--use for subscribe customer (subscribe customer for newsletter from admin) (post) -->
48
+ <controller_action_postdispatch_adminhtml_customer_massSubscribe>
49
+ <observers>
50
+ <sendinblue_admin_customer_massSubscribe>
51
+ <type>singleton</type>
52
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
53
+ <method>adminCustomerSubscribe</method>
54
+ </sendinblue_admin_customer_massSubscribe>
55
+ </observers>
56
+ </controller_action_postdispatch_adminhtml_customer_massSubscribe>
57
+
58
+ <!--use for unsubscribe customer (post) -->
59
+ <controller_action_postdispatch_adminhtml_customer_massUnsubscribe>
60
+ <observers>
61
+ <sendinblue_admin_customer_massUnsubscribe>
62
+ <type>singleton</type>
63
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
64
+ <method>adminCustomerDelete</method>
65
+ </sendinblue_admin_customer_massUnsubscribe>
66
+ </observers>
67
+ </controller_action_postdispatch_adminhtml_customer_massUnsubscribe>
68
+
69
+ <!--use for unsubscribe newsletter subscriber (post) -->
70
+ <controller_action_predispatch_adminhtml_newsletter_subscriber_massUnsubscribe>
71
+ <observers>
72
+ <sendinblue_admin_newsletter_massUnsubscribe>
73
+ <type>singleton</type>
74
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
75
+ <method>adminSubcriberDelete</method>
76
+ </sendinblue_admin_newsletter_massUnsubscribe>
77
+ </observers>
78
+ </controller_action_predispatch_adminhtml_newsletter_subscriber_massUnsubscribe>
79
+
80
+
81
+ <sales_order_save_after>
82
+ <observers>
83
+ <sendinblue_update_data>
84
+ <type>singleton</type>
85
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
86
+ <method>updateStatus</method>
87
+ </sendinblue_update_data>
88
+ </observers>
89
+ </sales_order_save_after>
90
+
91
+ </events>
92
+ <acl>
93
+ <resources>
94
+ <all>
95
+ <title>Allow Everything</title>
96
+ </all>
97
+ <admin>
98
+ <children>
99
+ <mails>
100
+ <children>
101
+ <mails>
102
+ <title>Sendinblue</title>
103
+ </mails>
104
+ </children>
105
+ </mails>
106
+ <system>
107
+ <children>
108
+ <config>
109
+ <children>
110
+ <sendinblue>
111
+ <title>Sendinblue</title>
112
+ </sendinblue>
113
+ </children>
114
+ </config>
115
+ </children>
116
+ </system>
117
+ </children>
118
+ <children>
119
+ <system>
120
+ <children>
121
+ <mails translate="title" module="sendinblue">
122
+ <title>Sendinblue Settings</title>
123
+ <sort_order>0</sort_order>
124
+ <action></action>
125
+ </mails>
126
+ </children>
127
+ </system>
128
+ </children>
129
+ </admin>
130
+ </resources>
131
+ </acl>
132
+ <translate>
133
+ <modules>
134
+ <Sendinblue_Sendinblue>
135
+ <files>
136
+ <default>Sendinblue.csv</default>
137
+ </files>
138
+ </Sendinblue_Sendinblue>
139
+ </modules>
140
+ </translate>
141
+
142
+
143
+ <layout>
144
+ <updates>
145
+ <sendinblue_sendinblue>
146
+ <file>sendinblue.xml</file>
147
+ </sendinblue_sendinblue>
148
+ </updates>
149
+ </layout>
150
+
151
+ </adminhtml>
152
+ <admin>
153
+ <routers>
154
+ <sendinblue_admin>
155
+ <use>admin</use>
156
+ <args>
157
+ <module>Sendinblue_Sendinblue</module>
158
+ <frontName>sendinblue</frontName>
159
+ </args>
160
+ </sendinblue_admin>
161
+ </routers>
162
+ <children>
163
+ <system>
164
+ <children>
165
+ <mails translate="label" module="sendinblue">
166
+ <title>Sendinblue Settings</title>
167
+ <sort_order>40</sort_order>
168
+ <action>adminhtml/system_config/edit/section/sendinblue</action>
169
+ </mails>
170
+ </children>
171
+ </system>
172
+ </children>
173
+ </admin>
174
+ <global>
175
+ <events>
176
+ <newsletter_subscriber_save_commit_after>
177
+ <observers>
178
+ <sendinblue_sendinblue_model_observer>
179
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
180
+ <method>subscribedToNewsletter</method>
181
+ </sendinblue_sendinblue_model_observer>
182
+ </observers>
183
+ </newsletter_subscriber_save_commit_after>
184
+ <customer_save_after>
185
+ <observers>
186
+ <sendinblue_update_data>
187
+ <type>singleton</type>
188
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
189
+ <method>updateNewObserver</method>
190
+ </sendinblue_update_data>
191
+ </observers>
192
+ </customer_save_after>
193
+ </events>
194
+
195
+ <template>
196
+ <email>
197
+ <custom_template>
198
+ <label>Sendinblue custom email module</label>
199
+ <file>sendinsmtp_conf.html</file>
200
+ <type>html</type>
201
+ </custom_template>
202
+ <notification_template>
203
+ <label>Sendinblue notification email module</label>
204
+ <file>sendin_notification.html</file>
205
+ <type>html</type>
206
+ </notification_template>
207
+ </email>
208
+ </template>
209
+
210
+ <models>
211
+ <core>
212
+ <rewrite>
213
+ <email>Sendinblue_Sendinblue_Model_Email</email>
214
+ <email_template>Sendinblue_Sendinblue_Model_Email_Template</email_template>
215
+ </rewrite>
216
+ </core>
217
+ <sendinblue>
218
+ <class>Sendinblue_Sendinblue_Model</class>
219
+ <resourceModel>sendinblue_mysql4</resourceModel>
220
+ </sendinblue>
221
+ <sendinblue_mysql4>
222
+ <class>Sendinblue_Sendinblue_Model_Mysql4</class>
223
+ <entities>
224
+ <sendinblue>
225
+ <table>sendinblue_country_codes</table>
226
+ </sendinblue>
227
+ </entities>
228
+ </sendinblue_mysql4>
229
+ </models>
230
+ <resources>
231
+ <sendinblue_setup>
232
+ <setup>
233
+ <module>Sendinblue_Sendinblue</module>
234
+ </setup>
235
+ <connection>
236
+ <use>core_setup</use>
237
+ </connection>
238
+ </sendinblue_setup>
239
+ <sendinblue_write>
240
+ <connection>
241
+ <use>core_write</use>
242
+ </connection>
243
+ </sendinblue_write>
244
+ <sendinblue_read>
245
+ <connection>
246
+ <use>core_read</use>
247
+ </connection>
248
+ </sendinblue_read>
249
+ </resources>
250
+
251
+ <helpers>
252
+ <sendinblue>
253
+ <class>Sendinblue_Sendinblue_Helper</class>
254
+ </sendinblue>
255
+ </helpers>
256
+ <blocks>
257
+ <sendinblue>
258
+ <class>Sendinblue_Sendinblue_Block</class>
259
+ </sendinblue>
260
+ </blocks>
261
+
262
+ </global>
263
+ <crontab>
264
+ <jobs>
265
+ <sendinblue_sendinblue>
266
+ <schedule>
267
+ <cron_expr>*/5 * * * *</cron_expr>
268
+ </schedule>
269
+ <run>
270
+ <model>sendinblue/observer::syncData</model>
271
+ </run>
272
+ </sendinblue_sendinblue>
273
+ </jobs>
274
+ </crontab>
275
+ <default>
276
+ <sendinblue>
277
+ <general>
278
+ <enabled>0</enabled>
279
+ <test>0</test>
280
+ <test_address />
281
+ </general>
282
+ <smtp>
283
+ <host>sendinblue.fr</host>
284
+ <port />
285
+ <login />
286
+ <password />
287
+ <ssl />
288
+ </smtp>
289
+ </sendinblue>
290
+ </default>
291
+ <frontend>
292
+ <events>
293
+ <!--use when new subcriber add for newsletter-->
294
+ <controller_action_postdispatch_newsletter_subscriber_new>
295
+ <observers>
296
+ <sendinblue_subscribe_new_observer>
297
+ <type>singleton</type>
298
+ <class>Sendinblue_Sendinblue_Model_Observer</class>
299
+ <method>subscribeObserver</method>
300
+ </sendinblue_subscribe_new_observer>
301
+ </observers>
302
+ </controller_action_postdispatch_newsletter_subscriber_new>
303
+
304
+ <!--use when new user register check (is_subscribed = 1)-->
305
+ </events>
306
+
307
+ <layout>
308
+ <updates>
309
+ <sendinblue_sendinblue>
310
+ <file>sendinblue.xml</file>
311
+ </sendinblue_sendinblue>
312
+ </updates>
313
+ </layout>
314
+
315
+ </frontend>
316
+ </config>
 
 
 
 
 
 
 
 
 
app/code/local/Sendinblue/Sendinblue/sql/sendinblue_setup/{install-0.1.0.php → mysql4-install-0.1.0.php} RENAMED
File without changes
app/code/local/Sendinblue/Sendinblue/sql/sendinblue_setup/mysql4-upgrade-0.1.0-0.2.0.php CHANGED
@@ -11,12 +11,13 @@
11
  //echo 'Testing our upgrade script (upgrade-0.1.0-0.2.0.php) and halting execution to avoid updating the system version number <br />';
12
 
13
  $resource = Mage::getSingleton('core/resource');
 
14
  $writeConnection = $resource->getConnection('core_write');
15
- $sql = "SELECT * FROM `core_config_data` WHERE `path` LIKE 'sendinblue/%'";
16
  echo $datanum = count($writeConnection->fetchAll($sql));
17
  if ($datanum > 0 )
18
  {
19
- $query = "DELETE FROM `core_config_data` WHERE `path` LIKE 'sendinblue/%'";
20
  $writeConnection->query($query);
21
  }
22
  ?>
11
  //echo 'Testing our upgrade script (upgrade-0.1.0-0.2.0.php) and halting execution to avoid updating the system version number <br />';
12
 
13
  $resource = Mage::getSingleton('core/resource');
14
+ $tableName = $resource->getTableName('core/config_data');
15
  $writeConnection = $resource->getConnection('core_write');
16
+ $sql = "SELECT * FROM ".$tableName." WHERE `path` LIKE 'sendinblue/%'";
17
  echo $datanum = count($writeConnection->fetchAll($sql));
18
  if ($datanum > 0 )
19
  {
20
+ $query = "DELETE FROM ".$tableName." WHERE `path` LIKE 'sendinblue/%'";
21
  $writeConnection->query($query);
22
  }
23
  ?>
app/design/adminhtml/default/default/layout/sendinblue.xml CHANGED
@@ -1,16 +1,12 @@
1
  <?xml version="1.0"?>
2
  <layout>
3
  <sendinblue_admin_adminhtml_myform_index>
 
 
 
 
4
  <reference name="content">
5
  <block type="adminhtml/template" name="sendinblue" template="sendinblue/myform.phtml"/>
6
  </reference>
7
  </sendinblue_admin_adminhtml_myform_index>
8
- <!-- Code to add for js and css -->
9
- <default>
10
- <reference name="head">
11
- <action method="addItem"><type>skin_css</type><name>sendinblue/css/styles.css</name><params/></action>
12
- <action method="addItem"><type>skin_css</type><name>sendinblue/css/jquery.multiselect.css</name><params/></action>
13
- </reference>
14
- </default>
15
- <!-- [end] -->
16
  </layout>
1
  <?xml version="1.0"?>
2
  <layout>
3
  <sendinblue_admin_adminhtml_myform_index>
4
+ <reference name="head">
5
+ <action method="addItem"><type>skin_css</type><name>sendinblue/css/styles.css</name><params/></action>
6
+ <action method="addItem"><type>skin_css</type><name>sendinblue/css/jquery.multiselect.css</name><params/></action>
7
+ </reference>
8
  <reference name="content">
9
  <block type="adminhtml/template" name="sendinblue" template="sendinblue/myform.phtml"/>
10
  </reference>
11
  </sendinblue_admin_adminhtml_myform_index>
 
 
 
 
 
 
 
 
12
  </layout>
app/design/adminhtml/default/default/template/sendinblue/myform.phtml CHANGED
@@ -8,7 +8,7 @@
8
  * needs then we can't provide a technical support.
9
  **/
10
  ?>
11
- <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
12
  <script>
13
  var selectoption = "<?php echo $this->__('Select option'); ?>";
14
  var selected = "<?php echo $this->__('Selected'); ?>";
@@ -116,6 +116,7 @@ $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()
116
  <?php if ($api_key != '') { ?>
117
  <div class="sendin_row alldiv" <?php echo $style; ?> >
118
  <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/syncronizepost'); ?>">
 
119
  <div class="section-config active">
120
  <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
121
  <fieldset id="my-fieldset" class="fields">
@@ -154,7 +155,24 @@ $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()
154
  <span title="<?php echo $this->__('Select the contact list where you want to save the contacts of your site Magento. By default, we have created a list Magento in your SendinBlue account and we have selected it'); ?>" class="toolTip">&nbsp;</span>
155
  </td>
156
  </tr>
157
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  <tr>
159
  <td>&nbsp;</td>
160
  <td class="a-left">
@@ -162,6 +180,19 @@ $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()
162
  <input type="submit" class="btn" name="syncronizeSubmit" value ="<?php echo $this->__('Update'); ?>" /></div>
163
  </td>
164
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  <tr><td colspan="2">
166
  <?php echo $this->__('To synchronize the emails of your customers from SendinBlue platform to your e-commerce website, you should run '); ?><a href="<?php echo Mage::helper("adminhtml")->getUrl("sendinblue/adminhtml_sync/index/",array()); ?>" style="color: #000000; outline: 0 none; text-decoration: none;"><?php echo $this->__('this link'); ?> </a><?php echo $this->__('each day'); ?><span class="toolTip" title="<?php echo $this->__('Note that if you change the name of your Shop (currently ');?><?php echo ucfirst(Mage::app()->getFrontController()->getRequest()->getModuleName());?><?php echo $this->__(') the token value changes.'); ?>">&nbsp;</span>
167
  </td></tr>
@@ -173,7 +204,7 @@ $get_syncronize = Mage::getModel('sendinblue/sendinblue')->getSyncronizeStatus()
173
  </table>
174
  </fieldset>
175
  </div>
176
- </form>
177
  </div>
178
  <?php
179
  }
@@ -232,6 +263,19 @@ $style_smtp = '';
232
  <span title="<?php echo $this->__('This feature will allow you to transfer all your customers orders from Magento into SendinBlue to implement your email marketing strategy.'); ?>" class="toolTip">&nbsp;</span>
233
  </td>
234
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  </table>
236
  </fieldset>
237
  </div>
@@ -248,8 +292,10 @@ $style_smtp = '';
248
  <td class="row1" colspan="2" style="border:none; padding-top:10px;">
249
  <span style="margin-bottom:10px; color:#333333;">
250
  <?php echo $this->__('Currently you have '); ?>
251
- <?php $credit = Mage::getModel('sendinblue/sendinblue')->getSmsCredit(); ?>
252
- <?php if ($credit >= 10){ ?> <strong style="color:#000000;"><?php echo $credit; ?></strong><?php } else {?><strong style="color:#F03D25;"><?php echo $credit; ?></strong><?php } ?>
 
 
253
 
254
  <?php echo $this->__(' credits sms. To buy more credits, please click'); ?>
255
  <a target="_blank" href ="<?php echo $this->__('https://www.sendinblue.com/pricing'); ?>" style="color: #000000; outline: 0 none; text-decoration: none;">
@@ -335,7 +381,7 @@ $style_smtp = '';
335
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
336
  <td>
337
  <textarea name="sender_order_message" id="sender_order_message" cols="45" rows="5" class="textarea_bx"><?php echo Mage::getModel('sendinblue/sendinblue')->getSendSmsmOrderMessage(); ?></textarea>
338
- <span class="toolTip" style="float:left; margin-top: 85px;" title="<?php echo $this->__(' Create the content of your SMS with the limit of 160-character.Beyond 160 characters, it will be counted as a second SMS. Thus, if you write SMS of 240 characters, it will be recorded using two SMS.'); ?>">&nbsp;</span>
339
  <span style="float:left; line-height:16px; margin-bottom:15px; width:490px; clear:both;"><?php echo $this->__('Number of SMS used: '); ?><span id="sender_order_message_text_count">0</span>
340
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_order_message_text">160</span></div>
341
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
@@ -418,7 +464,7 @@ $style_smtp = '';
418
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
419
  <td>
420
  <textarea name="sender_shipment_message" id="sender_shipment_message" cols="45" rows="5" class="textarea_bx"><?php echo Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingMessage(); ?></textarea>
421
- <span class="toolTip" style="float:left; margin-top: 85px;" title="<?php echo $this->__(' Create the content of your SMS with the limit of 160-character.Beyond 160 characters, it will be counted as a second SMS. Thus, if you write SMS of 240 characters, it will be recorded using two SMS.'); ?>">&nbsp;</span>
422
  <span style="float:left; line-height:16px; margin-bottom:15px; width:470px; clear:both;"><?php echo $this->__('Number of SMS used: '); ?><span id="sender_shipment_message_text_count">0</span>
423
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_shipment_message_text">160</span></div>
424
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
@@ -529,7 +575,7 @@ $style_smtp = '';
529
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
530
  <td>
531
  <textarea name="sender_campaign_message" id="sender_campaign_message" cols="45" rows="5" class="textarea_bx"></textarea>
532
- <span class="toolTip" style="float:left; margin-top: 85px;" title="<?php echo $this->__(' Create the content of your SMS with the limit of 160-character.Beyond 160 characters, it will be counted as a second SMS. Thus, if you write SMS of 240 characters, it will be recorded using two SMS.'); ?>">&nbsp;</span>
533
  <span style="float:left; line-height:16px; margin-bottom:15px; width:470px; clear:both;"><?php echo $this->__('Number of SMS used: '); ?><span id="sender_campaign_message_text_count">0</span>
534
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_campaign_message_text">160</span></div>
535
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
@@ -583,6 +629,7 @@ $style_smtp = '';
583
  <input name="ajaxOrderSmsUrl" type="hidden" id="ajaxOrderSmsUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxordersms'); ?>" />
584
  <input name="ajaxOrderShippedUrl" type="hidden" id="ajaxOrderShippedUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxordershipped'); ?>" />
585
  <input name="ajaxSmsCampaignUrl" type="hidden" id="ajaxSmsCampaignUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxsmscampaign'); ?>" />
 
586
  <input type="hidden" name="pagenumber" id="pagenumber" value="1" />
587
  <div id="userGrid">
588
  <div class="grid">
@@ -603,7 +650,8 @@ $style_smtp = '';
603
  <th class="no-link"><span class="nobr"><?php echo $this->__('clients'); ?></span></th>
604
  <th class="no-link"><span class="nobr"><?php echo $this->__('SMS'); ?></span></th>
605
  <th class="no-link"><span class="nobr"><?php echo $this->__('Newsletter Magento Status'); ?></span></th>
606
- <th class="no-link last"><span class="nobr"><?php echo $this->__('Newsletter SendinBlue Status'); ?><span title="<?php echo $this->__('Click on the icon to subscribe / unsubscribe the contact from SendinBlue and Magento.'); ?>" class="toolTip">&nbsp;</span></span></th>
 
607
  </tr>
608
  </thead>
609
  <tbody class='midleft'>
8
  * needs then we can't provide a technical support.
9
  **/
10
  ?>
11
+ <link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
12
  <script>
13
  var selectoption = "<?php echo $this->__('Select option'); ?>";
14
  var selected = "<?php echo $this->__('Selected'); ?>";
116
  <?php if ($api_key != '') { ?>
117
  <div class="sendin_row alldiv" <?php echo $style; ?> >
118
  <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/syncronizepost'); ?>">
119
+
120
  <div class="section-config active">
121
  <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
122
  <fieldset id="my-fieldset" class="fields">
155
  <span title="<?php echo $this->__('Select the contact list where you want to save the contacts of your site Magento. By default, we have created a list Magento in your SendinBlue account and we have selected it'); ?>" class="toolTip">&nbsp;</span>
156
  </td>
157
  </tr>
158
+ <tr>
159
+ <td><label><?php echo $this->__('Manage email template'); ?></label></td>
160
+ <td> <select name="template" id="template" style="width: 230.833px;" class ="ui-widget ui-state-default ui-corner-all">
161
+ <option value=""><?php echo $this->__('Select template'); ?></option>
162
+ <?php
163
+ $templatelist = Mage::getModel('sendinblue/sendinblue')->templateDisplay();
164
+
165
+ if (!empty($templatelist->result->campaign_records))
166
+ {
167
+ foreach ($templatelist->result->campaign_records as $template_data)
168
+ { if ($template_data->templ_status === 'Active')
169
+ { ?>
170
+ <option value="<?php echo $template_data->id; ?>" <?php if($template_data->id == Mage::getModel('sendinblue/sendinblue')->getTemplateId()) echo 'selected = "selected"'; ?> ><?php echo $template_data->campaign_name; ?></option>
171
+ <?php }}} ?>
172
+ </select>
173
+
174
+ <span title="<?php echo $this->__('Select a SendinBlue template that will be sent personalized for each contact that subscribes to your newsletter'); ?>" class="toolTip">&nbsp;</span></td>
175
+ </tr>
176
  <tr>
177
  <td>&nbsp;</td>
178
  <td class="a-left">
180
  <input type="submit" class="btn" name="syncronizeSubmit" value ="<?php echo $this->__('Update'); ?>" /></div>
181
  </td>
182
  </tr>
183
+ </form>
184
+
185
+ <?php if(Mage::getModel('sendinblue/sendinblue')->getImportOldSubsStatus()==1){ ?>
186
+ <form id="reimport_form" name="reimport_form" method="post" action="<?php echo $this->getUrl('*/*/reimportpost'); ?>">
187
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
188
+ <tr>
189
+ <td>&nbsp;</td>
190
+ <td class="a-left">
191
+ <div class="btnmrgn-right">
192
+ <input type="submit" class="btn" name="importoldSubmit" value ="<?php echo $this->__('Import Old Subscribers'); ?>" /></div>
193
+ </td>
194
+ </tr></form>
195
+ <?php } ?>
196
  <tr><td colspan="2">
197
  <?php echo $this->__('To synchronize the emails of your customers from SendinBlue platform to your e-commerce website, you should run '); ?><a href="<?php echo Mage::helper("adminhtml")->getUrl("sendinblue/adminhtml_sync/index/",array()); ?>" style="color: #000000; outline: 0 none; text-decoration: none;"><?php echo $this->__('this link'); ?> </a><?php echo $this->__('each day'); ?><span class="toolTip" title="<?php echo $this->__('Note that if you change the name of your Shop (currently ');?><?php echo ucfirst(Mage::app()->getFrontController()->getRequest()->getModuleName());?><?php echo $this->__(') the token value changes.'); ?>">&nbsp;</span>
198
  </td></tr>
204
  </table>
205
  </fieldset>
206
  </div>
207
+
208
  </div>
209
  <?php
210
  }
263
  <span title="<?php echo $this->__('This feature will allow you to transfer all your customers orders from Magento into SendinBlue to implement your email marketing strategy.'); ?>" class="toolTip">&nbsp;</span>
264
  </td>
265
  </tr>
266
+ <?php
267
+ if (Mage::getModel('sendinblue/sendinblue')->getTrackingStatus()==1 && Mage::getModel('sendinblue/sendinblue')->getTrackingHistoryStatus()==1)
268
+ $style_track = '';
269
+ else
270
+ $style_track = 'style="display:none;"';
271
+ if(Mage::getModel('sendinblue/sendinblue')->getTrackingStatus()==1 && Mage::getModel('sendinblue/sendinblue')->getTrackingHistoryStatus()==1) { ?>
272
+ <tr <?php echo $style_track; ?> class='ordertracking'>
273
+ <td>&nbsp;</td>
274
+ <input type="hidden" name="history_status" value="<?php echo Mage::getModel('sendinblue/sendinblue')->getTrackingHistoryStatus(); ?>" id="history_status">
275
+ <input name="importordertrackingUrl" type="hidden" id="importordertrackingUrl" value="<?php echo $this->getUrl('sendinblue/ajax/orderhistory'); ?>" />
276
+ <td class="input-ele"><label style="text-align:left;"><a href="javascript:void(0);" class="Trackhistory button btn" style="color: #000000; outline: 0 none; text-decoration: none; font-weight: normal;"><?php echo $this->__('Import the data of previous orders'); ?></a></label></td>
277
+ </tr>
278
+ <?php } ?>
279
  </table>
280
  </fieldset>
281
  </div>
292
  <td class="row1" colspan="2" style="border:none; padding-top:10px;">
293
  <span style="margin-bottom:10px; color:#333333;">
294
  <?php echo $this->__('Currently you have '); ?>
295
+ <?php $credit = Mage::getModel('sendinblue/sendinblue')->getSmsCredit();
296
+ $notify_value = Mage::getModel('sendinblue/sendinblue')->getNotifyValueStatus();
297
+ ?>
298
+ <?php if ($credit >= $notify_value){ ?> <strong style="color:#000000;"><?php echo $credit; ?></strong><?php } else {?><strong style="color:#F03D25;"><?php echo $credit; ?></strong><?php } ?>
299
 
300
  <?php echo $this->__(' credits sms. To buy more credits, please click'); ?>
301
  <a target="_blank" href ="<?php echo $this->__('https://www.sendinblue.com/pricing'); ?>" style="color: #000000; outline: 0 none; text-decoration: none;">
381
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
382
  <td>
383
  <textarea name="sender_order_message" id="sender_order_message" cols="45" rows="5" class="textarea_bx"><?php echo Mage::getModel('sendinblue/sendinblue')->getSendSmsmOrderMessage(); ?></textarea>
384
+ <span class="toolTip" style="float:left; margin-top: 85px;" title="<?php echo $this->__(' Create the content of your SMS with the limit of 160-character.Beyond 160 characters, it will be counted as a second SMS. Thus, if you write SMS of 240 characters, it will be recorded using two SMS.'); ?>">&nbsp;</span>
385
  <span style="float:left; line-height:16px; margin-bottom:15px; width:490px; clear:both;"><?php echo $this->__('Number of SMS used: '); ?><span id="sender_order_message_text_count">0</span>
386
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_order_message_text">160</span></div>
387
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
464
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
465
  <td>
466
  <textarea name="sender_shipment_message" id="sender_shipment_message" cols="45" rows="5" class="textarea_bx"><?php echo Mage::getModel('sendinblue/sendinblue')->getSendSmsShipingMessage(); ?></textarea>
467
+ <span class="toolTip" style="float:left; margin-top: 85px;" title="<?php echo $this->__(' Create the content of your SMS with the limit of 160-character.Beyond 160 characters, it will be counted as a second SMS. Thus, if you write SMS of 240 characters, it will be recorded using two SMS.'); ?>">&nbsp;</span>
468
  <span style="float:left; line-height:16px; margin-bottom:15px; width:470px; clear:both;"><?php echo $this->__('Number of SMS used: '); ?><span id="sender_shipment_message_text_count">0</span>
469
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_shipment_message_text">160</span></div>
470
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
575
  <td valign="top"><label><?php echo $this->__('Message'); ?></label></td>
576
  <td>
577
  <textarea name="sender_campaign_message" id="sender_campaign_message" cols="45" rows="5" class="textarea_bx"></textarea>
578
+ <span class="toolTip" style="float:left; margin-top: 85px;" title="<?php echo $this->__(' Create the content of your SMS with the limit of 160-character.Beyond 160 characters, it will be counted as a second SMS. Thus, if you write SMS of 240 characters, it will be recorded using two SMS.'); ?>">&nbsp;</span>
579
  <span style="float:left; line-height:16px; margin-bottom:15px; width:470px; clear:both;"><?php echo $this->__('Number of SMS used: '); ?><span id="sender_campaign_message_text_count">0</span>
580
  <div class="hintmsg"><em><?php echo $this->__('Number of characters left: '); ?></em><span id="sender_campaign_message_text">160</span></div>
581
  <div class="hintmsg"><em><?php echo $this->__('Attention line break is counted as a single character.'); ?></em>
629
  <input name="ajaxOrderSmsUrl" type="hidden" id="ajaxOrderSmsUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxordersms'); ?>" />
630
  <input name="ajaxOrderShippedUrl" type="hidden" id="ajaxOrderShippedUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxordershipped'); ?>" />
631
  <input name="ajaxSmsCampaignUrl" type="hidden" id="ajaxSmsCampaignUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxsmscampaign'); ?>" />
632
+ <input name="ajaxSmsSubscribeUrl" type="hidden" id="ajaxSmsSubscribeUrl" value="<?php echo $this->getUrl('sendinblue/ajax/ajaxsmssubscribe'); ?>" />
633
  <input type="hidden" name="pagenumber" id="pagenumber" value="1" />
634
  <div id="userGrid">
635
  <div class="grid">
650
  <th class="no-link"><span class="nobr"><?php echo $this->__('clients'); ?></span></th>
651
  <th class="no-link"><span class="nobr"><?php echo $this->__('SMS'); ?></span></th>
652
  <th class="no-link"><span class="nobr"><?php echo $this->__('Newsletter Magento Status'); ?></span></th>
653
+ <th class="no-link"><span class="nobr"><?php echo $this->__('Newsletter SendinBlue Status'); ?><span title="<?php echo $this->__('Click on the icon to subscribe / unsubscribe the contact from SendinBlue and Magento.'); ?>" class="toolTip">&nbsp;</span></span></th>
654
+ <th class="no-link last"><span class="nobr"><?php echo $this->__('SMS SendinBlue Status'); ?><span title="<?php echo $this->__('Click on the icon to subscribe / unsubscribe the sms from SendinBlue and Magento.'); ?>" class="toolTip">&nbsp;</span></span></th>
655
  </tr>
656
  </thead>
657
  <tbody class='midleft'>
app/locale/fr_FR/Sendinblue.csv CHANGED
@@ -127,4 +127,12 @@
127
  "The phone number should be in this form: 0033663309741 for this France mobile 06 63 30 97 41 (0033 is France prefix)", "Le numéro de téléphone mobile devrait être sous cette forme: 0033663309741 pour le numéro français 06 63 30 97 41 (0033 est l'indicatif de la France)"
128
  "Select option", "Sélectionnez"
129
  "Synchronize your Magento contacts with SendinBlue platform, easily send your marketing and transactional emails and SMS.", "Synchronisez les contacts de votre site Magento avec SendinBlue & envoyez facilement tous vos emails & SMS marketing et transactionnels."
130
- "With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email & SMS campaigns to your prospects and customers.", "Avec le module SendinBlue, retrouvez tout ce dont vous avez besoin pour envoyer simplement et efficacement vos campagnes emailing & SMS à vos prospects et clients :"
 
 
 
 
 
 
 
 
127
  "The phone number should be in this form: 0033663309741 for this France mobile 06 63 30 97 41 (0033 is France prefix)", "Le numéro de téléphone mobile devrait être sous cette forme: 0033663309741 pour le numéro français 06 63 30 97 41 (0033 est l'indicatif de la France)"
128
  "Select option", "Sélectionnez"
129
  "Synchronize your Magento contacts with SendinBlue platform, easily send your marketing and transactional emails and SMS.", "Synchronisez les contacts de votre site Magento avec SendinBlue & envoyez facilement tous vos emails & SMS marketing et transactionnels."
130
+ "With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email & SMS campaigns to your prospects and customers.", "Avec le module SendinBlue, retrouvez tout ce dont vous avez besoin pour envoyer simplement et efficacement vos campagnes emailing & SMS à vos prospects et clients :"
131
+ "Order history has been import successfully", "Historique des commandes a été importé avec succès."
132
+ "Import the data of previous orders", "Importer les données des anciennes commandes"
133
+ "Not synchronized", "non synchronized"
134
+ "Click on the icon to subscribe / unsubscribe the sms from SendinBlue and Magento.", "Cliquez sur l'icône pour inscrire / désinscrire un sms de SendinBlue et Magento."
135
+ "SMS SendinBlue Status", "Statut SMS sur Sendinblue"
136
+ "Select template", "Sélectionnez un template"
137
+ "Manage email template", "Gestion des templates email"
138
+ "Select a SendinBlue template that will be sent personalized for each contact that subscribes to your newsletter", "Sélectionnez un template SendinBlue qui sera envoyé pour chaque contact qui s'abonne à votre newsletter"
package.xml CHANGED
@@ -1,27 +1,27 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sendinblue</name>
4
- <version>1.1.0</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/osl-3.0.php">OSL V1.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Synchronize your Magento contacts with SendinBlue platform, easily send your marketing and transactional emails and SMS.</summary>
10
- <description>With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email and SMS campaigns to your prospects and customers.
11
- Synchronize your subscribers with SendinBlue (subscribed and unsubscribed contacts)
12
- Easily create good looking emailings
13
- Schedule your campaigns
14
- Track your results and optimize
15
- Monitor your transactional emails (purchase confirmation, password reset, etc) with a better deliverability and real-time analytics
16
- Why should you use SendinBlue
17
- Optimized deliverability
18
- Unbeatable pricingbest value in the industry
19
  Technical support, by phone or by email</description>
20
  <notes>Synchronize your Magento contacts with SendinBlue platform, send your marketing and transactional emails and SMS</notes>
21
- <authors><author><name>SendinBlue</name><user>Sendinblue_Team</user><email>contact@sendinblue.com</email></author></authors>
22
- <date>2014-02-28</date>
23
- <time>10:05:32</time>
24
- <contents><target name="magelocal"><dir name="Sendinblue"><dir name="Sendinblue"><dir name="Block"><file name="Sendinblue.php" hash="4b5adae031b714e188d576e306bfd5a1"/></dir><dir name="Helper"><file name="Data.php" hash="0532b48f611c1cc623589d5792e0dbf2"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="6d2d6eac00b7bd6da3ff53d2abe40dd4"/></dir><file name="Email.php" hash="fe07aa2dba951ee117bda2cefebfb875"/><dir name="Mysql4"><dir name="Sendinblue"><file name="Collection.php" hash="d6aff03eda9a6b2ee1c42b8dd50df402"/></dir><file name="Sendinblue.php" hash="c000c1f6a277f7c9a91ad628b02eb001"/></dir><file name="Observer.php" hash="250cc069aa5194652f6503e2cc0f8194"/><file name="Sendinblue.php" hash="963c473c2f3ca66f23d00de0c4c9292f"/><file name="Status.php" hash="444fe4d099bd23a9d87cdf7e2b2e6cbb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MyformController.php" hash="67dd963b1f003d2b2f25c8b4643d4715"/><file name="NotifyController.php" hash="e3b43db59f8c5b7c8cd54a58a7bc2d1b"/><file name="SyncController.php" hash="352fd0d804701d0228bad7e7b92afb58"/></dir><file name="AjaxController.php" hash="b4914ddac9d4e836ecf53869055a6a82"/><file name="IndexController.php" hash="2cf5287ba31d6960eb28c2cbc03a60ed"/></dir><dir name="etc"><file name="adminhtml.xml" hash="640ba5382a16c749fc56a2a8283682ee"/><file name="config.xml" hash="ba48680b7267a4b2d27f4645792b2393"/></dir><dir name="sql"><dir name="sendinblue_setup"><file name="install-0.1.0.php" hash="58bb365dcb29115c66f2fa3f17dcb697"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="b50e876441a247cd5feb2614ff649fd3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sendinblue.xml" hash="e23253764fbbf0e3a2f1cb5ff65eb318"/></dir><dir name="template"><dir name="sendinblue"><file name="myform.phtml" hash="2a4748e2e456d2b95d9828bf2da90bd8"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sendinblue.xml" hash="61346d8b2b321b10c09a77fef39ec112"/></dir><dir name="template"><dir name="sendinblue"><dir name="account"><file name="edit.phtml" hash="c2b17e90e59e1d13791feded28982330"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sendinblue_Sendinblue.xml" hash="1a245999d412c36ea9666b56bfc63e2d"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Sendinblue.csv" hash="72507895f18a8c4a80611065790aba56"/></dir></target><target name="mage"><dir name="app"><dir name="locale"><dir name="fr_FR"><dir name="template"><dir name="email"><file name="sendin_notification.html" hash="557ddb7212800b4a99937b2d8956270c"/><file name="sendinsmtp_conf.html" hash="b1c790c78605b2beb4cd38152cd8f0ca"/>
25
  </dir></dir></dir><dir name="en_US"><dir name="template"><dir name="email"><file name="sendin_notification.html" hash="de646d23657f68387d32683d14ea215a"/><file name="sendinsmtp_conf.html" hash="a35979191ec11cd5cbebc0efece1c472"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sendinblue"><dir name="css"><file name="jquery-ui.css" hash="3f3d39116de928eb9c3cc33004efae77"/><file name="jquery.multiselect.css" hash="b2ecda55b895b485e49baa5759cc61fe"/><file name="styles.css" hash="61f4da300d2b59cc4d22af19d6abc742"/></dir><dir name="images"><file name="close.png" hash="223ea7c82841be9da96aec80bd68b7f5"/><file name="disabled.gif" hash="21ff0e6ba24381e63789116139180cf0"/><file name="enabled.gif" hash="0db2c4f24c0f0c3f7958a05181af897a"/><file name="help.gif" hash="19002f53dd724465717c27f0399c0a90"/><file name="index.php" hash="507d846db3efc2563672c8f60ac080f4"/><file name="loader.gif" hash="394bafc3cc4dfb3a0ee48c1f54669539"/><file name="loading_anim.gif" hash="b494fceca79586281a29c9462b09c85a"/><file name="logo.gif" hash="b13ce89934c4aa2aeb76d75896efe40f"/><file name="logo.png" hash="76ecf5757c096639a3b27ed5fc470d48"/><file name="sendinblue.png" hash="4bb823a9290b79546cc99d57de304db9"/><file name="ui-icons_ef8c08_256x240.png" hash="47fc08e06aba0b7ac0a6d3b9f92894cb"/><file name="ui-icons_ef8c08_256x240.png.png" hash="47fc08e06aba0b7ac0a6d3b9f92894cb"/></dir><dir name="js"><file name="index.php" hash="36aa6e5d248b48fd910a4dfa1987ca56"/><file name="jquery-1.9.1.min.js" hash="397754ba49e9e0cf4e7c190da78dda05"/><file name="jquery-ui.min.js" hash="3e6acb1e6426ef90d2e786a006a4ea28"/><file name="jquery.multiselect.js" hash="9851bb7a2509099e28ee789fc864570e"/><file name="jquery.multiselect.min.js" hash="efb34f759712b9da1172c3a2efe8ef6b"/><file name="sendinblue.js" hash="e5d8ac61766af444255eb9226a0cb344"/><file name="sendinblue.min.js" hash="60a1241bec9edc538c360ac459890927"/></dir></dir></dir></dir></dir></target></contents>
26
  <compatible/>
27
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sendinblue</name>
4
+ <version>1.1.9</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Synchronize your Magento contacts with SendinBlue platform, easily send your marketing and transactional emails and SMS.</summary>
10
+ <description>With the SendinBlue plugin, you can find everything you need to easily and efficiently send your email and SMS campaigns to your prospects and customers.&#xD;
11
+ Synchronize your subscribers with SendinBlue (subscribed and unsubscribed contacts)&#xD;
12
+ Easily create good looking emailings&#xD;
13
+ Schedule your campaigns&#xD;
14
+ Track your results and optimize&#xD;
15
+ Monitor your transactional emails (purchase confirmation, password reset, etc) with a better deliverability and real-time analytics&#xD;
16
+ Why should you use SendinBlue&#xD;
17
+ Optimized deliverability&#xD;
18
+ Unbeatable pricing&#x2013;best value in the industry&#xD;
19
  Technical support, by phone or by email</description>
20
  <notes>Synchronize your Magento contacts with SendinBlue platform, send your marketing and transactional emails and SMS</notes>
21
+ <authors><author><name>Sendinblue</name><user>Sendinblue_Team</user><email>contact@sendinblue.com</email></author></authors>
22
+ <date>2014-03-04</date>
23
+ <time>10:55:22</time>
24
+ <contents><target name="magelocal"><dir name="Sendinblue"><dir name="Sendinblue"><dir name="Block"><file name="Sendinblue.php" hash="4b5adae031b714e188d576e306bfd5a1"/></dir><dir name="Helper"><file name="Data.php" hash="0532b48f611c1cc623589d5792e0dbf2"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="6d2d6eac00b7bd6da3ff53d2abe40dd4"/></dir><file name="Email.php" hash="fe07aa2dba951ee117bda2cefebfb875"/><dir name="Mysql4"><dir name="Sendinblue"><file name="Collection.php" hash="d6aff03eda9a6b2ee1c42b8dd50df402"/></dir><file name="Sendinblue.php" hash="c000c1f6a277f7c9a91ad628b02eb001"/></dir><file name="Observer.php" hash="250cc069aa5194652f6503e2cc0f8194"/><file name="Sendinblue.php" hash="963c473c2f3ca66f23d00de0c4c9292f"/><file name="Status.php" hash="444fe4d099bd23a9d87cdf7e2b2e6cbb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MyformController.php" hash="67dd963b1f003d2b2f25c8b4643d4715"/><file name="NotifyController.php" hash="e3b43db59f8c5b7c8cd54a58a7bc2d1b"/><file name="SyncController.php" hash="352fd0d804701d0228bad7e7b92afb58"/></dir><file name="AjaxController.php" hash="b4914ddac9d4e836ecf53869055a6a82"/><file name="IndexController.php" hash="2cf5287ba31d6960eb28c2cbc03a60ed"/></dir><dir name="etc"><file name="adminhtml.xml" hash="640ba5382a16c749fc56a2a8283682ee"/><file name="config.xml" hash="ba48680b7267a4b2d27f4645792b2393"/></dir><dir name="sql"><dir name="sendinblue_setup"><file name="mysql4-install-0.1.0.php" hash="58bb365dcb29115c66f2fa3f17dcb697"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="b50e876441a247cd5feb2614ff649fd3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sendinblue.xml" hash="e23253764fbbf0e3a2f1cb5ff65eb318"/></dir><dir name="template"><dir name="sendinblue"><file name="myform.phtml" hash="2a4748e2e456d2b95d9828bf2da90bd8"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sendinblue.xml" hash="61346d8b2b321b10c09a77fef39ec112"/></dir><dir name="template"><dir name="sendinblue"><dir name="account"><file name="edit.phtml" hash="c2b17e90e59e1d13791feded28982330"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sendinblue_Sendinblue.xml" hash="1a245999d412c36ea9666b56bfc63e2d"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Sendinblue.csv" hash="72507895f18a8c4a80611065790aba56"/></dir></target><target name="mage"><dir name="app"><dir name="locale"><dir name="fr_FR"><dir name="template"><dir name="email"><file name="sendin_notification.html" hash="557ddb7212800b4a99937b2d8956270c"/><file name="sendinsmtp_conf.html" hash="b1c790c78605b2beb4cd38152cd8f0ca"/>
25
  </dir></dir></dir><dir name="en_US"><dir name="template"><dir name="email"><file name="sendin_notification.html" hash="de646d23657f68387d32683d14ea215a"/><file name="sendinsmtp_conf.html" hash="a35979191ec11cd5cbebc0efece1c472"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sendinblue"><dir name="css"><file name="jquery-ui.css" hash="3f3d39116de928eb9c3cc33004efae77"/><file name="jquery.multiselect.css" hash="b2ecda55b895b485e49baa5759cc61fe"/><file name="styles.css" hash="61f4da300d2b59cc4d22af19d6abc742"/></dir><dir name="images"><file name="close.png" hash="223ea7c82841be9da96aec80bd68b7f5"/><file name="disabled.gif" hash="21ff0e6ba24381e63789116139180cf0"/><file name="enabled.gif" hash="0db2c4f24c0f0c3f7958a05181af897a"/><file name="help.gif" hash="19002f53dd724465717c27f0399c0a90"/><file name="index.php" hash="507d846db3efc2563672c8f60ac080f4"/><file name="loader.gif" hash="394bafc3cc4dfb3a0ee48c1f54669539"/><file name="loading_anim.gif" hash="b494fceca79586281a29c9462b09c85a"/><file name="logo.gif" hash="b13ce89934c4aa2aeb76d75896efe40f"/><file name="logo.png" hash="76ecf5757c096639a3b27ed5fc470d48"/><file name="sendinblue.png" hash="4bb823a9290b79546cc99d57de304db9"/><file name="ui-icons_ef8c08_256x240.png" hash="47fc08e06aba0b7ac0a6d3b9f92894cb"/><file name="ui-icons_ef8c08_256x240.png.png" hash="47fc08e06aba0b7ac0a6d3b9f92894cb"/></dir><dir name="js"><file name="index.php" hash="36aa6e5d248b48fd910a4dfa1987ca56"/><file name="jquery-1.9.1.min.js" hash="397754ba49e9e0cf4e7c190da78dda05"/><file name="jquery-ui.min.js" hash="3e6acb1e6426ef90d2e786a006a4ea28"/><file name="jquery.multiselect.js" hash="9851bb7a2509099e28ee789fc864570e"/><file name="jquery.multiselect.min.js" hash="efb34f759712b9da1172c3a2efe8ef6b"/><file name="sendinblue.js" hash="e5d8ac61766af444255eb9226a0cb344"/><file name="sendinblue.min.js" hash="60a1241bec9edc538c360ac459890927"/></dir></dir></dir></dir></dir></target></contents>
26
  <compatible/>
27
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
skin/adminhtml/default/default/sendinblue/css/styles.css CHANGED
@@ -6,6 +6,10 @@
6
  * versions in the future. If you wish to customize Sendinblue magento plugin for your
7
  * needs then we can't provide a technical support.
8
  */
 
 
 
 
9
 
10
  .pagination{width:620px; height:25px; margin:0 auto;}
11
  .pagination ul li{list-style:none; float:left; border:1px solid #000; padding:2px 6px 2px 6px; margin:0 3px 0 3px; font-family:arial; font-size:12px; color:#000; font-weight:bold; background-color:#f2f2f2;}
@@ -20,7 +24,7 @@
20
  .sendin_row {clear:both; margin-top:40px; width:100%;}
21
  .contact-details {border:1px dashed #666666; float:right; height:205px; margin-left:12px; margin-right:12px; margin-top:10px; padding:8px; width:350px; position: absolute; right: 0;}
22
  fieldset.fields {background-color:#EBEDF4; border:1px solid; margin-bottom:10px; padding:20px 0 10px 10px; position:relative;}
23
- fieldset legend {background-color:#EBEDF4; border:1px solid #DFD5C3; display:inline; visibility:visible; float:left; font:bold 13px/13px Arial; margin:0; padding:4px 10px; position:absolute; top:-15px; width:inherit !important; height:auto;}
24
  ul.listt {text-align:justify; margin:8px 0px 8px 0px;list-style:none; padding:0px; width:800px;}
25
  ul.listt li:before{ content:"-"; position:relative; left:-2px;}
26
  ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
@@ -35,9 +39,6 @@ ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
35
  width: 491px;
36
  }
37
 
38
-
39
-
40
-
41
  .btn {
42
  display: inline-block;
43
  *display: inline;
@@ -159,10 +160,7 @@ ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
159
  .tab_content {
160
  display: none;
161
  }
162
- /*.wrapper {
163
- width:820px;
164
- margin:0px auto;
165
- }*/
166
  .wrapper .row1 {
167
  padding:/*10px 12px*/0px;
168
  border:none;
@@ -172,9 +170,7 @@ ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
172
  margin-top:23px;
173
  clear:both;
174
  }
175
- .wrapper p {
176
- margin-bottom:12px;
177
- }
178
  .r_label {
179
  float:left;
180
  width: auto;
@@ -240,28 +236,6 @@ ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
240
  /* padding: 0 4px 0 6px;*/
241
  }
242
 
243
- /*Form*/
244
- /*.table tr td {
245
- color: #996633;
246
- font-size:12px;
247
- }
248
- .sendin_row .form-list label{ width:670px; float:left; padding-right:20px; padding-top:0px; text-align:right;}
249
- .sendin_row .form-list2 label{ width:385px; padding-right:20px; padding-top:0px;}
250
- .sendin_row .form-list3 label{ width:295px; padding-right:20px; padding-top:0px;text-align:left!important;}
251
-
252
-
253
-
254
- .label-small{ width:30px!important; text-align:left!important;}
255
- .no-padding td{ padding:0px!important;}
256
- .clear{ clear:both;}
257
- .module_error.error{ padding-top: 8px!important;}
258
- .module_error.error p{ display:inline-block;}
259
- #content .alert{ width:auto!important;}
260
- .tablepadding td{padding:5px 0px;}
261
- .btnmrgn-right{
262
- margin-top:12px;
263
- margin-right:26px;
264
- float:right;}*/
265
  .radio_nospaceing{
266
  margin:0px 10px 0px 0px;}
267
  .radio_spaceing {
@@ -280,11 +254,7 @@ ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
280
 
281
  .mrgin-left{ margin-left:466px;}
282
  /*Design matched style*/
283
-
284
- p {
285
- color: #585A69;
286
- margin: 0.5em 0;
287
- }
288
 
289
  .fix_width{width:450px}
290
  .fix_width2{width:350px}
@@ -324,9 +294,7 @@ color:#585A69;
324
  }
325
 
326
  input.input-text, textarea, select { border:1px solid #c8c8c8;}
327
- input.input-text{padding:3px 5px;}
328
- a {
329
- color: #000000;
330
- outline: 0 none;
331
- text-decoration: none;
332
- }
6
  * versions in the future. If you wish to customize Sendinblue magento plugin for your
7
  * needs then we can't provide a technical support.
8
  */
9
+ a {
10
+ color: #000;
11
+ text-decoration: underline;
12
+ }
13
 
14
  .pagination{width:620px; height:25px; margin:0 auto;}
15
  .pagination ul li{list-style:none; float:left; border:1px solid #000; padding:2px 6px 2px 6px; margin:0 3px 0 3px; font-family:arial; font-size:12px; color:#000; font-weight:bold; background-color:#f2f2f2;}
24
  .sendin_row {clear:both; margin-top:40px; width:100%;}
25
  .contact-details {border:1px dashed #666666; float:right; height:205px; margin-left:12px; margin-right:12px; margin-top:10px; padding:8px; width:350px; position: absolute; right: 0;}
26
  fieldset.fields {background-color:#EBEDF4; border:1px solid; margin-bottom:10px; padding:20px 0 10px 10px; position:relative;}
27
+ fieldset legend.lgend {background-color:#EBEDF4; border:1px solid #DFD5C3; display:inline; visibility:visible; float:left; font:bold 13px/13px Arial; margin:0; padding:4px 10px; position:absolute; top:-15px; width:inherit !important; height:auto;}
28
  ul.listt {text-align:justify; margin:8px 0px 8px 0px;list-style:none; padding:0px; width:800px;}
29
  ul.listt li:before{ content:"-"; position:relative; left:-2px;}
30
  ul.listt li{ text-indent:-5px; padding:5px 0px 5px 10px;}
39
  width: 491px;
40
  }
41
 
 
 
 
42
  .btn {
43
  display: inline-block;
44
  *display: inline;
160
  .tab_content {
161
  display: none;
162
  }
163
+
 
 
 
164
  .wrapper .row1 {
165
  padding:/*10px 12px*/0px;
166
  border:none;
170
  margin-top:23px;
171
  clear:both;
172
  }
173
+
 
 
174
  .r_label {
175
  float:left;
176
  width: auto;
236
  /* padding: 0 4px 0 6px;*/
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  .radio_nospaceing{
240
  margin:0px 10px 0px 0px;}
241
  .radio_spaceing {
254
 
255
  .mrgin-left{ margin-left:466px;}
256
  /*Design matched style*/
257
+
 
 
 
 
258
 
259
  .fix_width{width:450px}
260
  .fix_width2{width:350px}
294
  }
295
 
296
  input.input-text, textarea, select { border:1px solid #c8c8c8;}
297
+ /*input.input-text{padding:3px 5px;}*/
298
+
299
+ .grid table td a{color: #000000;
300
+ text-decoration: none;}
 
 
skin/adminhtml/default/default/sendinblue/js/sendinblue.js CHANGED
@@ -124,6 +124,11 @@ jQuery(document)
124
  }
125
  });
126
 
 
 
 
 
 
127
 
128
 
129
  if(jQuery('#sender_order').val() != '')
@@ -200,6 +205,11 @@ jQuery(document)
200
 
201
  }
202
  });
 
 
 
 
 
203
 
204
  if(jQuery('#sender_shipment').val() != '')
205
  {
@@ -273,6 +283,11 @@ jQuery(document)
273
 
274
  }
275
  });
 
 
 
 
 
276
 
277
  if(jQuery('#sender_campaign').val() != '')
278
  {
@@ -527,6 +542,12 @@ jQuery(document)
527
  {
528
  var Tracking = jQuery(this).val();
529
  var trackingUrl = jQuery("#trackingUrl").val();
 
 
 
 
 
 
530
  jQuery.ajax({
531
  type : "POST",
532
  async : false,
@@ -540,6 +561,27 @@ jQuery(document)
540
  }
541
  });
542
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
 
544
 
545
 
@@ -616,6 +658,32 @@ jQuery(document)
616
 
617
  });
618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
  });
620
 
621
  function testsmssend(sendererr,messageerr,mobileerr) {
@@ -859,8 +927,10 @@ function smtpvalidate(emailerr)
859
  function apikvalidate(apierr)
860
  {
861
  var sendin_apikey_val = jQuery('#sendin_apikey_val').val();
 
 
862
 
863
- if(sendin_apikey_val.trim() == "")
864
  {
865
  alert(apierr);
866
  jQuery('#sendin_apikey_val').focus();
124
  }
125
  });
126
 
127
+ jQuery("#sender_order").keydown(function (event) {
128
+ if (event.keyCode == 32) {
129
+ event.preventDefault();
130
+ }
131
+ });
132
 
133
 
134
  if(jQuery('#sender_order').val() != '')
205
 
206
  }
207
  });
208
+ jQuery("#sender_shipment").keydown(function (event) {
209
+ if (event.keyCode == 32) {
210
+ event.preventDefault();
211
+ }
212
+ });
213
 
214
  if(jQuery('#sender_shipment').val() != '')
215
  {
283
 
284
  }
285
  });
286
+ jQuery("#sender_campaign").keydown(function (event) {
287
+ if (event.keyCode == 32) {
288
+ event.preventDefault();
289
+ }
290
+ });
291
 
292
  if(jQuery('#sender_campaign').val() != '')
293
  {
542
  {
543
  var Tracking = jQuery(this).val();
544
  var trackingUrl = jQuery("#trackingUrl").val();
545
+ if (Tracking == 0) {
546
+ jQuery('.ordertracking').hide();
547
+ }
548
+ if (Tracking == 1) {
549
+ jQuery('.ordertracking').show();
550
+ }
551
  jQuery.ajax({
552
  type : "POST",
553
  async : false,
561
  }
562
  });
563
  });
564
+ //for import old order history
565
+ jQuery(".Trackhistory").click(function()
566
+ {
567
+ var history_status = jQuery("#history_status").val();
568
+ var ordertrackingUrl = jQuery("#importordertrackingUrl").val();
569
+
570
+ jQuery.ajax({
571
+ type : "POST",
572
+ async : false,
573
+ url : ordertrackingUrl,
574
+ data : "history_status=" + history_status,
575
+ beforeSend : function(){
576
+ jQuery('#ajax-busy').show();
577
+ },
578
+ success : function(msg){
579
+ jQuery('#ajax-busy').hide();
580
+ jQuery('.ordertracking').hide();
581
+ alert(msg);
582
+ }
583
+ });
584
+ });
585
 
586
 
587
 
658
 
659
  });
660
 
661
+
662
+
663
+ jQuery('body').on('click', '.ajax_sms_subs_href', function (e) {
664
+
665
+ var email = jQuery(this).attr('email');
666
+ var status = jQuery(this).attr('status');
667
+ var ajaxSmsUrl = jQuery("#ajaxSmsSubscribeUrl").val();
668
+
669
+ jQuery.ajax({
670
+ type : "POST",
671
+ async : false,
672
+ url : ajaxSmsUrl,
673
+ data : {"email":email,"sms":status},
674
+ beforeSend : function() {
675
+ jQuery('#ajax-busy').show();
676
+ },
677
+ success : function(msg) {
678
+ jQuery('#ajax-busy').hide();
679
+ }
680
+ });
681
+
682
+ var page_no = jQuery('#pagenumber').val();
683
+ loadData(page_no); // For first time page load
684
+
685
+ });
686
+
687
  });
688
 
689
  function testsmssend(sendererr,messageerr,mobileerr) {
927
  function apikvalidate(apierr)
928
  {
929
  var sendin_apikey_val = jQuery('#sendin_apikey_val').val();
930
+ var sendin_api_check = jQuery("input[name=sendin_api_status]:checked").val();
931
+
932
 
933
+ if(sendin_apikey_val.trim() == "" && sendin_api_check !=0)
934
  {
935
  alert(apierr);
936
  jQuery('#sendin_apikey_val').focus();
skin/adminhtml/default/default/sendinblue/js/sendinblue.min.js CHANGED
@@ -7,4 +7,4 @@
7
  * needs then we can't provide a technical support.
8
  **/
9
 
10
- jQuery.noConflict();jQuery(document).ready(function(){var apistatuskey=jQuery("#apistatuskey").val();jQuery("#select").multiselect();jQuery(".sendin_api_status").click(function(){if(apistatuskey==1&&jQuery(this).val()==1){jQuery("#sendin_apikey").show();jQuery(".alldiv").show();jQuery(".hidetableblock").show();}else{if(jQuery(this).val()==1){jQuery("#sendin_apikey").show();}else{jQuery("#sendin_apikey").hide();jQuery(".alldiv").hide();}}});function loadData(page){var ajaxcontentUrl=jQuery("#ajaxcontentUrl").val();jQuery.ajax({type:"POST",async:false,url:ajaxcontentUrl,data:"page="+page,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();jQuery(".midleft").html(msg);jQuery(".midleft").ajaxComplete(function(event,request,settings){jQuery(".midleft").html(msg);});}});}jQuery(".hdtab").click(function(){if(parseInt(jQuery(this).val())){jQuery("#hidetabselect").css("display","block");}});jQuery("body").on("click"," .pagination li.active",function(){var page=jQuery(this).attr("p");jQuery("#pagenumber").val(page);loadData(page);});jQuery(".toolTip").hover(function(){var title=jQuery(this).attr("title");var offset=jQuery(this).offset();jQuery("body").append('<div id="tipkk" style="top:'+offset.top+"px; left:"+offset.left+'px; ">'+title+"</div>");var tipContentHeight=jQuery("#tipkk").height()+25;jQuery("#tipkk").css("top",(offset.top-tipContentHeight)+"px");},function(){jQuery("#tipkk").remove();});jQuery("#sender_order").mouseover(function(){var val=jQuery(this).val();if(isInteger(val)||val==""){jQuery("#sender_order").attr("maxlength","17");jQuery("#sender_order_text").text((17-val.length));}else{jQuery("#sender_order").attr("maxlength","11");var str7=val.length>11?val.substr(1,11):val;jQuery("#sender_order").val(str7);jQuery("#sender_order_text").text((11-val.length));}});jQuery("#sender_order").keyup(function(){var val=jQuery(this).val();if(isInteger(val)||val==""){jQuery("#sender_order").attr("maxlength","17");jQuery("#sender_order_text").text((17-val.length));}else{jQuery("#sender_order").attr("maxlength","11");var str7=val.length>11?val.substr(1,11):val;jQuery("#sender_order").val(str7);jQuery("#sender_order_text").text((11-val.length));}});if(jQuery("#sender_order").val()!=""){var val=jQuery("#sender_order").val();if(isInteger(val)){jQuery("#sender_order").attr("maxlength","17");jQuery("#sender_order_text").text((17-val.length));}else{jQuery("#sender_order").attr("maxlength","11");jQuery("#sender_order_text").text((11-val.length));}}jQuery("#sender_order_message").keyup(function(){var chars=this.value.length,messages=Math.ceil(chars/160),remaining=messages*160-(chars%(messages*160)||messages*160);if(remaining==0){remaining=160;}jQuery("#sender_order_message_text").text(remaining);jQuery("#sender_order_message_text_count").text(messages);});if(jQuery("#sender_order_message").val()!=""){var chars=jQuery("#sender_order_message").val().length,messages=Math.ceil(chars/160),remaining=messages*160-(chars%(messages*160)||messages*160);jQuery("#sender_order_message_text").text(remaining);jQuery("#sender_order_message_text_count").text(messages);}jQuery("#sender_shipment").mouseover(function(){var val=jQuery(this).val();if(isInteger(val)||val==""){jQuery("#sender_shipment").attr("maxlength","17");jQuery("#sender_shipment_text").text((17-val.length));}else{jQuery("#sender_shipment").attr("maxlength","11");var str7=val.length>11?val.substr(1,11):val;jQuery("#sender_shipment").val(str7);jQuery("#sender_shipment_text").text((11-val.length));}});jQuery("#sender_shipment").keyup(function(){var val=jQuery(this).val();if(isInteger(val)||val==""){jQuery("#sender_shipment").attr("maxlength","17");jQuery("#sender_shipment_text").text((17-val.length));}else{jQuery("#sender_shipment").attr("maxlength","11");var str7=val.length>11?val.substr(1,11):val;jQuery("#sender_shipment").val(str7);jQuery("#sender_shipment_text").text((11-val.length));}});if(jQuery("#sender_shipment").val()!=""){var val=jQuery("#sender_shipment").val();if(isInteger(val)){jQuery("#sender_shipment").attr("maxlength","17");jQuery("#sender_shipment_text").text((17-val.length));}else{jQuery("#sender_shipment").attr("maxlength","11");jQuery("#sender_shipment_text").text((11-val.length));}}jQuery("#sender_shipment_message").keyup(function(){var chars=this.value.length,messages=Math.ceil(chars/160),remaining=messages*160-(chars%(messages*160)||messages*160);if(remaining==0){remaining=160;}jQuery("#sender_shipment_message_text").text(remaining);jQuery("#sender_shipment_message_text_count").text(messages);});if(jQuery("#sender_shipment_message").val()!=""){var chars=jQuery("#sender_shipment_message").val().length,messages=Math.ceil(chars/160),remaining=messages*160-(chars%(messages*160)||messages*160);jQuery("#sender_shipment_message_text").text(remaining);jQuery("#sender_shipment_message_text_count").text(messages);}jQuery("#sender_campaign").mouseover(function(){var val=jQuery(this).val();if(isInteger(val)||val==""){jQuery("#sender_campaign").attr("maxlength","17");jQuery("#sender_campaign_text").text((17-val.length));}else{jQuery("#sender_campaign").attr("maxlength","11");var str7=val.length>11?val.substr(1,11):val;jQuery("#sender_campaign").val(str7);jQuery("#sender_campaign_text").text((11-val.length));}});jQuery("#sender_campaign").keyup(function(){var val=jQuery(this).val();if(isInteger(val)||val==""){jQuery("#sender_campaign").attr("maxlength","17");jQuery("#sender_campaign_text").text((17-val.length));}else{jQuery("#sender_campaign").attr("maxlength","11");var str7=val.length>11?val.substr(1,11):val;jQuery("#sender_campaign").val(str7);jQuery("#sender_campaign_text").text((11-val.length));}});if(jQuery("#sender_campaign").val()!=""){var val=jQuery("#sender_campaign").val();if(isInteger(val)){jQuery("#sender_campaign").attr("maxlength","17");jQuery("#sender_campaign_text").text((17-val.length));}else{jQuery("#sender_campaign").attr("maxlength","11");jQuery("#sender_campaign_text").text((11-val.length));}}jQuery("#sender_campaign_message").keyup(function(){var chars=this.value.length,messages=Math.ceil(chars/160),remaining=messages*160-(chars%(messages*160)||messages*160);if(remaining==0){remaining=160;}jQuery("#sender_campaign_message_text").text(remaining);jQuery("#sender_campaign_message_text_count").text(messages);});if(jQuery("#sender_campaign_message").val()!=""){var chars=jQuery("#sender_campaign_message").val().length,messages=Math.ceil(chars/160),remaining=messages*160-(chars%(messages*160)||messages*160);jQuery("#sender_campaign_message_text").text(remaining);jQuery("#sender_campaign_message_text_count").text(messages);}jQuery(".sms_order_setting").click(function(){var orderSetting=jQuery(this).val();var orderUrl=jQuery("#order").val();jQuery.ajax({type:"POST",async:false,url:orderUrl,data:"orderSetting="+orderSetting,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(orderSetting==1){jQuery(".hideOrder").show();}else{jQuery(".hideOrder").hide();}}});});jQuery(".sms_shiping_setting").click(function(){var shipingSetting=jQuery(this).val();var shipingUrl=jQuery("#shiping").val();jQuery.ajax({type:"POST",async:false,url:shipingUrl,data:"shipingSetting="+shipingSetting,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(shipingSetting==1){jQuery(".hideShiping").show();}else{jQuery(".hideShiping").hide();}}});});jQuery(".sms_campaign_setting").click(function(){var campaignSetting=jQuery(this).val();var campaignUrl=jQuery("#campaign").val();jQuery.ajax({type:"POST",async:false,url:campaignUrl,data:"campaignSetting="+campaignSetting,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(campaignSetting==1){jQuery(".hideCampaign").show();}else{jQuery(".hideCampaign").hide();}}});});if(jQuery("input:radio[name=sms_order_setting]:checked").val()==0){jQuery(".hideOrder").hide();}else{jQuery(".hideOrder").show();}jQuery(".Sendin_Sms_Choice").click(function(){if(jQuery(this).val()==1){jQuery(".multiplechoice").hide();jQuery(".singlechoice").show();}else{jQuery(".multiplechoice").show();jQuery(".singlechoice").hide();}});if(jQuery("input:radio[name=Sendin_Sms_Choice]:checked").val()==0){jQuery(".multiplechoice").show();jQuery(".singlechoice").hide();}else{jQuery(".singlechoice").show();jQuery(".multiplechoice").hide();}jQuery(".sms_shiping_setting").click(function(){if(jQuery(this).val()==1){jQuery(".hideShiping").show();}else{jQuery(".hideShiping").hide();}});if(jQuery("input:radio[name=sms_credit]:checked").val()==0){jQuery(".hideCredit").hide();}else{jQuery(".hideCredit").show();}jQuery(".sms_credit").click(function(){var sms_credit=jQuery(this).val();var creditUrl=jQuery("#credits").val();var type="sms_credit";jQuery.ajax({type:"POST",async:false,url:creditUrl,data:"sms_credit="+sms_credit,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(sms_credit==1){jQuery(".hideCredit").show();}else{jQuery(".hideCredit").hide();}}});});if(jQuery("input:radio[name=sms_shiping_setting]:checked").val()==0){jQuery(".hideShiping").hide();}else{jQuery(".hideShiping").show();}jQuery(".sms_campaign_setting").click(function(){if(jQuery(this).val()==1){jQuery(".hideCampaign").show();}else{jQuery(".hideCampaign").hide();}});if(jQuery("input:radio[name=sms_campaign_setting]:checked").val()==0){jQuery(".hideCampaign").hide();}else{jQuery(".hideCampaign").show();}jQuery("#selectSmsList").multiselect({header:false,checkall:false});jQuery("#tabs li").click(function(){jQuery("#tabs li").removeClass("active");jQuery(this).addClass("active");jQuery(".tab_content").hide();var selected_tab=jQuery(this).find("a").attr("href");jQuery(selected_tab).fadeIn();return false;});function isInteger(val){var numberRegex=/^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;if(numberRegex.test(val)){return true;}return false;}jQuery("#showUserlist").click(function(){if(jQuery(".userDetails").is(":hidden")){loadData(1);jQuery("#Spantextless").show();jQuery("#Spantextmore").hide();}else{jQuery("#Spantextmore").show();jQuery("#Spantextless").hide();}jQuery(".userDetails").slideToggle();});var base_url=getBaseURL();jQuery(".Tracking").click(function(){var Tracking=jQuery(this).val();var trackingUrl=jQuery("#trackingUrl").val();jQuery.ajax({type:"POST",async:false,url:trackingUrl,data:"script="+Tracking,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();}});});jQuery(".smtpStatus").click(function(){var smtptest=jQuery(this).val();var smtpUrl=jQuery("#smtpUrl").val();if(smtptest==0){jQuery(".smtptest").hide();}if(smtptest==1){jQuery(".smtptest").show();}jQuery.ajax({type:"POST",async:false,url:smtpUrl,data:"smtptest="+smtptest,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();}});});var skin_url=jQuery("#skin_url").val();jQuery('<div id="ajax-busy"/> loading..').css({opacity:0.5,position:"fixed",top:0,left:0,width:"100%",height:jQuery(window).height()+"px",background:"white url("+skin_url+"adminhtml/default/default/sendinblue/images/loader.gif) no-repeat center"}).hide().appendTo("body");function getBaseURL(){var sBase=location.href.substr(0,location.href.lastIndexOf("/")+1);var sp=sBase.split("/");var lastFolder=sp[sp.length-2];return sBase.replace(lastFolder+"/","");}jQuery("body").on("click",".ajax_contacts_href",function(e){var email=jQuery(this).attr("email");var status=jQuery(this).attr("status");var ajaxUrl=jQuery("#ajaxUrl").val();jQuery.ajax({type:"POST",async:false,url:ajaxUrl,data:{email:email,newsletter:status},beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();}});var page_no=jQuery("#pagenumber").val();loadData(page_no);});});function testsmssend(sendererr,messageerr,mobileerr){var sender=jQuery("#sender_order").val();var message=jQuery("#sender_order_message").val();var number=jQuery("#sender_order_number").val();var ajaxOrderSmsUrl=jQuery("#ajaxOrderSmsUrl").val();var smsCampError=jQuery("#smsCampError").val();var smsCampSuccess=jQuery("#smsCampSuccess").val();if(sender==""||isValid(sender)==false){alert(sendererr);}else{if(message==""){alert(messageerr);}else{if(number==""){alert(mobileerr);}else{jQuery.ajax({type:"POST",async:false,url:ajaxOrderSmsUrl,data:"sender="+sender+"&message="+message+"&number="+number,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(msg.trim()=="OK"){alert(smsCampSuccess);}else{alert(smsCampError);}}});}}}return false;}function testShippedSmsSend(sendererr,messageerr,mobileerr){var sender=jQuery("#sender_shipment").val();var message=jQuery("#sender_shipment_message").val();var number=jQuery("#sender_shipment_number").val();var ajaxOrderShippedUrl=jQuery("#ajaxOrderShippedUrl").val();var smsCampError=jQuery("#smsCampError").val();var smsCampSuccess=jQuery("#smsCampSuccess").val();if(sender==""||isValid(sender)==false){alert(sendererr);}else{if(message==""){alert(messageerr);}else{if(number==""){alert(mobileerr);}else{jQuery.ajax({type:"POST",async:false,url:ajaxOrderShippedUrl,data:"sender="+sender+"&message="+message+"&number="+number,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(msg.trim()=="OK"){alert(smsCampSuccess);}else{alert(smsCampError);}}});}}}return false;}function testCampaignSmsSend(sendererr,messageerr,mobileerr){var sender=jQuery("#sender_campaign").val();var message=jQuery("#sender_campaign_message").val();var number=jQuery("#sender_campaigntest_number").val();var ajaxSmsCampaignUrl=jQuery("#ajaxSmsCampaignUrl").val();var smsCampError=jQuery("#smsCampError").val();var smsCampSuccess=jQuery("#smsCampSuccess").val();if(sender==""||isValid(sender)==false){alert(sendererr);}else{if(message==""){alert(messageerr);}else{if(number==""||isMobilevalidation(number)==false){alert(mobileerr);}else{jQuery.ajax({type:"POST",async:false,url:ajaxSmsCampaignUrl,data:"sender="+sender+"&message="+message+"&number="+number,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(msg){jQuery("#ajax-busy").hide();if(msg.trim()=="OK"){alert(smsCampSuccess);}else{alert(smsCampError);}}});}}}return false;}function senderOrderSaveValid(sendererr,messageerr){var sender=jQuery("#sender_order").val();var message=jQuery("#sender_order_message").val();if(sender==""||isValid(sender)==false){alert(sendererr);return false;}else{if(message==""){alert(messageerr);return false;}}}function senderShipmentSaveValid(sendererr,messageerr){var sender=jQuery("#sender_shipment").val();var message=jQuery("#sender_shipment_message").val();if(sender==""||isValid(sender)==false){alert(sendererr);return false;}else{if(message==""){alert(messageerr);return false;}}}function senderCampaignSaveValid(sendererr,messageerr,mobileerr){var sender=jQuery("#sender_campaign").val();var message=jQuery("#sender_campaign_message").val();var number=jQuery("#singlechoice").val();var radiovalue=jQuery("input[name=Sendin_Sms_Choice]:checked").val();if(radiovalue==1){if(number==""||isMobilevalidation(number)==false){alert(mobileerr);return false;}else{if(sender==""||isValid(sender)==false){alert(sendererr);return false;}else{if(message==""){alert(messageerr);return false;}}}}else{if(sender==""||isValid(sender)==false){alert(sendererr);return false;}else{if(message==""){alert(messageerr);return false;}}}}function isMobilevalidation(str){return/^(?:\+|00)[1-9][0-9]{5,15}$/.test(str);}function isNormalInteger(str){return/^\+?(0|[1-9]\d*)$/.test(str);}function isValid(str){var iChars="~`!#$%^&*+=-[]\\';,/{}|\":<>?";for(var i=0;i<str.length;i++){if(iChars.indexOf(str.charAt(i))!=-1){return false;}}return true;}function RegexEmail(email){var emailRegexStr=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;var isvalid=emailRegexStr.test(email);return isvalid;}function validate(emailerr,limiter){if(document.notify_sms_mail_form.sendin_notify_email.value==""||RegexEmail(document.notify_sms_mail_form.sendin_notify_email.value)==false){alert(emailerr);document.notify_sms_mail_form.sendin_notify_email.focus();return false;}if(document.notify_sms_mail_form.sendin_notify_value.value==""||isNormalInteger(document.notify_sms_mail_form.sendin_notify_value.value)==false){alert(limiter);document.notify_sms_mail_form.sendin_notify_value.focus();return false;}return(true);}function smtpvalidate(emailerr){var email=jQuery("#email").val();if(email==""||RegexEmail(email)==false){alert(emailerr);jQuery("#email").focus();return false;}}function apikvalidate(apierr){var sendin_apikey_val=jQuery("#sendin_apikey_val").val();if(sendin_apikey_val.trim()==""){alert(apierr);jQuery("#sendin_apikey_val").focus();return false;}}
7
  * needs then we can't provide a technical support.
8
  **/
9
 
10
+ jQuery.noConflict();jQuery(document).ready(function(){var f=jQuery("#apistatuskey").val();jQuery("#select").multiselect();jQuery(".sendin_api_status").click(function(){if(f==1&&jQuery(this).val()==1){jQuery("#sendin_apikey").show();jQuery(".alldiv").show();jQuery(".hidetableblock").show();}else{if(jQuery(this).val()==1){jQuery("#sendin_apikey").show();}else{jQuery("#sendin_apikey").hide();jQuery(".alldiv").hide();}}});function g(l){var k=jQuery("#ajaxcontentUrl").val();jQuery.ajax({type:"POST",async:false,url:k,data:"page="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();jQuery(".midleft").html(m);jQuery(".midleft").ajaxComplete(function(p,o,n){jQuery(".midleft").html(m);});}});}jQuery(".hdtab").click(function(){if(parseInt(jQuery(this).val())){jQuery("#hidetabselect").css("display","block");}});jQuery("body").on("click"," .pagination li.active",function(){var k=jQuery(this).attr("p");jQuery("#pagenumber").val(k);g(k);});jQuery(".toolTip").hover(function(){var m=jQuery(this).attr("title");var l=jQuery(this).offset();jQuery("body").append('<div id="tipkk" style="top:'+l.top+"px; left:"+l.left+'px; ">'+m+"</div>");var k=jQuery("#tipkk").height()+25;jQuery("#tipkk").css("top",(l.top-k)+"px");},function(){jQuery("#tipkk").remove();});jQuery("#sender_order").mouseover(function(){var l=jQuery(this).val();if(j(l)||l==""){jQuery("#sender_order").attr("maxlength","17");jQuery("#sender_order_text").text((17-l.length));}else{jQuery("#sender_order").attr("maxlength","11");var k=l.length>11?l.substr(1,11):l;jQuery("#sender_order").val(k);jQuery("#sender_order_text").text((11-l.length));}});jQuery("#sender_order").keyup(function(){var l=jQuery(this).val();if(j(l)||l==""){jQuery("#sender_order").attr("maxlength","17");jQuery("#sender_order_text").text((17-l.length));}else{jQuery("#sender_order").attr("maxlength","11");var k=l.length>11?l.substr(1,11):l;jQuery("#sender_order").val(k);jQuery("#sender_order_text").text((11-l.length));}});jQuery("#sender_order").keydown(function(k){if(k.keyCode==32){k.preventDefault();}});if(jQuery("#sender_order").val()!=""){var c=jQuery("#sender_order").val();if(j(c)){jQuery("#sender_order").attr("maxlength","17");jQuery("#sender_order_text").text((17-c.length));}else{jQuery("#sender_order").attr("maxlength","11");jQuery("#sender_order_text").text((11-c.length));}}jQuery("#sender_order_message").keyup(function(){var m=this.value.length,l=Math.ceil(m/160),k=l*160-(m%(l*160)||l*160);if(k==0){k=160;}jQuery("#sender_order_message_text").text(k);jQuery("#sender_order_message_text_count").text(l);});if(jQuery("#sender_order_message").val()!=""){var h=jQuery("#sender_order_message").val().length,e=Math.ceil(h/160),d=e*160-(h%(e*160)||e*160);jQuery("#sender_order_message_text").text(d);jQuery("#sender_order_message_text_count").text(e);}jQuery("#sender_shipment").mouseover(function(){var l=jQuery(this).val();if(j(l)||l==""){jQuery("#sender_shipment").attr("maxlength","17");jQuery("#sender_shipment_text").text((17-l.length));}else{jQuery("#sender_shipment").attr("maxlength","11");var k=l.length>11?l.substr(1,11):l;jQuery("#sender_shipment").val(k);jQuery("#sender_shipment_text").text((11-l.length));}});jQuery("#sender_shipment").keyup(function(){var l=jQuery(this).val();if(j(l)||l==""){jQuery("#sender_shipment").attr("maxlength","17");jQuery("#sender_shipment_text").text((17-l.length));}else{jQuery("#sender_shipment").attr("maxlength","11");var k=l.length>11?l.substr(1,11):l;jQuery("#sender_shipment").val(k);jQuery("#sender_shipment_text").text((11-l.length));}});jQuery("#sender_shipment").keydown(function(k){if(k.keyCode==32){k.preventDefault();}});if(jQuery("#sender_shipment").val()!=""){var c=jQuery("#sender_shipment").val();if(j(c)){jQuery("#sender_shipment").attr("maxlength","17");jQuery("#sender_shipment_text").text((17-c.length));}else{jQuery("#sender_shipment").attr("maxlength","11");jQuery("#sender_shipment_text").text((11-c.length));}}jQuery("#sender_shipment_message").keyup(function(){var m=this.value.length,l=Math.ceil(m/160),k=l*160-(m%(l*160)||l*160);if(k==0){k=160;}jQuery("#sender_shipment_message_text").text(k);jQuery("#sender_shipment_message_text_count").text(l);});if(jQuery("#sender_shipment_message").val()!=""){var h=jQuery("#sender_shipment_message").val().length,e=Math.ceil(h/160),d=e*160-(h%(e*160)||e*160);jQuery("#sender_shipment_message_text").text(d);jQuery("#sender_shipment_message_text_count").text(e);}jQuery("#sender_campaign").mouseover(function(){var l=jQuery(this).val();if(j(l)||l==""){jQuery("#sender_campaign").attr("maxlength","17");jQuery("#sender_campaign_text").text((17-l.length));}else{jQuery("#sender_campaign").attr("maxlength","11");var k=l.length>11?l.substr(1,11):l;jQuery("#sender_campaign").val(k);jQuery("#sender_campaign_text").text((11-l.length));}});jQuery("#sender_campaign").keyup(function(){var l=jQuery(this).val();if(j(l)||l==""){jQuery("#sender_campaign").attr("maxlength","17");jQuery("#sender_campaign_text").text((17-l.length));}else{jQuery("#sender_campaign").attr("maxlength","11");var k=l.length>11?l.substr(1,11):l;jQuery("#sender_campaign").val(k);jQuery("#sender_campaign_text").text((11-l.length));}});jQuery("#sender_campaign").keydown(function(k){if(k.keyCode==32){k.preventDefault();}});if(jQuery("#sender_campaign").val()!=""){var c=jQuery("#sender_campaign").val();if(j(c)){jQuery("#sender_campaign").attr("maxlength","17");jQuery("#sender_campaign_text").text((17-c.length));}else{jQuery("#sender_campaign").attr("maxlength","11");jQuery("#sender_campaign_text").text((11-c.length));}}jQuery("#sender_campaign_message").keyup(function(){var m=this.value.length,l=Math.ceil(m/160),k=l*160-(m%(l*160)||l*160);if(k==0){k=160;}jQuery("#sender_campaign_message_text").text(k);jQuery("#sender_campaign_message_text_count").text(l);});if(jQuery("#sender_campaign_message").val()!=""){var h=jQuery("#sender_campaign_message").val().length,e=Math.ceil(h/160),d=e*160-(h%(e*160)||e*160);jQuery("#sender_campaign_message_text").text(d);jQuery("#sender_campaign_message_text_count").text(e);}jQuery(".sms_order_setting").click(function(){var l=jQuery(this).val();var k=jQuery("#order").val();jQuery.ajax({type:"POST",async:false,url:k,data:"orderSetting="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();if(l==1){jQuery(".hideOrder").show();}else{jQuery(".hideOrder").hide();}}});});jQuery(".sms_shiping_setting").click(function(){var l=jQuery(this).val();var k=jQuery("#shiping").val();jQuery.ajax({type:"POST",async:false,url:k,data:"shipingSetting="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();if(l==1){jQuery(".hideShiping").show();}else{jQuery(".hideShiping").hide();}}});});jQuery(".sms_campaign_setting").click(function(){var l=jQuery(this).val();var k=jQuery("#campaign").val();jQuery.ajax({type:"POST",async:false,url:k,data:"campaignSetting="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();if(l==1){jQuery(".hideCampaign").show();}else{jQuery(".hideCampaign").hide();}}});});if(jQuery("input:radio[name=sms_order_setting]:checked").val()==0){jQuery(".hideOrder").hide();}else{jQuery(".hideOrder").show();}jQuery(".Sendin_Sms_Choice").click(function(){if(jQuery(this).val()==1){jQuery(".multiplechoice").hide();jQuery(".singlechoice").show();}else{jQuery(".multiplechoice").show();jQuery(".singlechoice").hide();}});if(jQuery("input:radio[name=Sendin_Sms_Choice]:checked").val()==0){jQuery(".multiplechoice").show();jQuery(".singlechoice").hide();}else{jQuery(".singlechoice").show();jQuery(".multiplechoice").hide();}jQuery(".sms_shiping_setting").click(function(){if(jQuery(this).val()==1){jQuery(".hideShiping").show();}else{jQuery(".hideShiping").hide();}});if(jQuery("input:radio[name=sms_credit]:checked").val()==0){jQuery(".hideCredit").hide();}else{jQuery(".hideCredit").show();}jQuery(".sms_credit").click(function(){var k=jQuery(this).val();var m=jQuery("#credits").val();var l="sms_credit";jQuery.ajax({type:"POST",async:false,url:m,data:"sms_credit="+k,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(n){jQuery("#ajax-busy").hide();if(k==1){jQuery(".hideCredit").show();}else{jQuery(".hideCredit").hide();}}});});if(jQuery("input:radio[name=sms_shiping_setting]:checked").val()==0){jQuery(".hideShiping").hide();}else{jQuery(".hideShiping").show();}jQuery(".sms_campaign_setting").click(function(){if(jQuery(this).val()==1){jQuery(".hideCampaign").show();}else{jQuery(".hideCampaign").hide();}});if(jQuery("input:radio[name=sms_campaign_setting]:checked").val()==0){jQuery(".hideCampaign").hide();}else{jQuery(".hideCampaign").show();}jQuery("#selectSmsList").multiselect({header:false,checkall:false});jQuery("#tabs li").click(function(){jQuery("#tabs li").removeClass("active");jQuery(this).addClass("active");jQuery(".tab_content").hide();var k=jQuery(this).find("a").attr("href");jQuery(k).fadeIn();return false;});function j(l){var k=/^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;if(k.test(l)){return true;}return false;}jQuery("#showUserlist").click(function(){if(jQuery(".userDetails").is(":hidden")){g(1);jQuery("#Spantextless").show();jQuery("#Spantextmore").hide();}else{jQuery("#Spantextmore").show();jQuery("#Spantextless").hide();}jQuery(".userDetails").slideToggle();});var i=a();jQuery(".Tracking").click(function(){var l=jQuery(this).val();var k=jQuery("#trackingUrl").val();if(l==0){jQuery(".ordertracking").hide();}if(l==1){jQuery(".ordertracking").show();}jQuery.ajax({type:"POST",async:false,url:k,data:"script="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();}});});jQuery(".Trackhistory").click(function(){var l=jQuery("#history_status").val();var k=jQuery("#importordertrackingUrl").val();jQuery.ajax({type:"POST",async:false,url:k,data:"history_status="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();jQuery(".ordertracking").hide();alert(m);}});});jQuery(".smtpStatus").click(function(){var l=jQuery(this).val();var k=jQuery("#smtpUrl").val();if(l==0){jQuery(".smtptest").hide();}if(l==1){jQuery(".smtptest").show();}jQuery.ajax({type:"POST",async:false,url:k,data:"smtptest="+l,beforeSend:function(){jQuery("#ajax-busy").show();},success:function(m){jQuery("#ajax-busy").hide();}});});var b=jQuery("#skin_url").val();jQuery('<div id="ajax-busy"/> loading..').css({opacity:0.5,position:"fixed",top:0,left:0,width:"100%",height:jQuery(window).height()+"px",background:"white url("+b+"adminhtml/default/default/sendinblue/images/loader.gif) no-repeat center"}).hide().appendTo("body");function a(){var k=location.href.substr(0,location.href.lastIndexOf("/")+1);var m=k.split("/");var l=m[m.length-2];return k.replace(l+"/","");}jQuery("body").on("click",".ajax_contacts_href",function(o){var m=jQuery(this).attr("email");var l=jQuery(this).attr("status");var n=jQuery("#ajaxUrl").val();jQuery.ajax({type:"POST",async:false,url:n,data:{email:m,newsletter:l},beforeSend:function(){jQuery("#ajax-busy").show();},success:function(p){jQuery("#ajax-busy").hide();}});var k=jQuery("#pagenumber").val();g(k);});jQuery("body").on("click",".ajax_sms_subs_href",function(o){var m=jQuery(this).attr("email");var l=jQuery(this).attr("status");var n=jQuery("#ajaxSmsSubscribeUrl").val();jQuery.ajax({type:"POST",async:false,url:n,data:{email:m,sms:l},beforeSend:function(){jQuery("#ajax-busy").show();},success:function(p){jQuery("#ajax-busy").hide();}});var k=jQuery("#pagenumber").val();g(k);});});function testsmssend(h,a,c){var f=jQuery("#sender_order").val();var i=jQuery("#sender_order_message").val();var d=jQuery("#sender_order_number").val();var e=jQuery("#ajaxOrderSmsUrl").val();var b=jQuery("#smsCampError").val();var g=jQuery("#smsCampSuccess").val();if(f==""||isValid(f)==false){alert(h);}else{if(i==""){alert(a);}else{if(d==""){alert(c);}else{jQuery.ajax({type:"POST",async:false,url:e,data:{sender:f,message:i,number:d},beforeSend:function(){jQuery("#ajax-busy").show();},success:function(j){jQuery("#ajax-busy").hide();if(j.trim()=="OK"){alert(g);}else{alert(b);}}});}}}return false;}function testShippedSmsSend(h,a,c){var e=jQuery("#sender_shipment").val();var i=jQuery("#sender_shipment_message").val();var d=jQuery("#sender_shipment_number").val();var f=jQuery("#ajaxOrderShippedUrl").val();var b=jQuery("#smsCampError").val();var g=jQuery("#smsCampSuccess").val();if(e==""||isValid(e)==false){alert(h);}else{if(i==""){alert(a);}else{if(d==""){alert(c);}else{jQuery.ajax({type:"POST",async:false,url:f,data:{sender:e,message:i,number:d},beforeSend:function(){jQuery("#ajax-busy").show();},success:function(j){jQuery("#ajax-busy").hide();if(j.trim()=="OK"){alert(g);}else{alert(b);}}});}}}return false;}function testCampaignSmsSend(h,a,c){var e=jQuery("#sender_campaign").val();var i=jQuery("#sender_campaign_message").val();var d=jQuery("#sender_campaigntest_number").val();var f=jQuery("#ajaxSmsCampaignUrl").val();var b=jQuery("#smsCampError").val();var g=jQuery("#smsCampSuccess").val();if(e==""||isValid(e)==false){alert(h);}else{if(i==""){alert(a);}else{if(d==""||isMobilevalidation(d)==false){alert(c);}else{jQuery.ajax({type:"POST",async:false,url:f,data:{sender:e,message:i,number:d},beforeSend:function(){jQuery("#ajax-busy").show();},success:function(j){jQuery("#ajax-busy").hide();if(j.trim()=="OK"){alert(g);}else{alert(b);}}});}}}return false;}function senderOrderSaveValid(c,a){var b=jQuery("#sender_order").val();var d=jQuery("#sender_order_message").val();if(b==""||isValid(b)==false){alert(c);return false;}else{if(d==""){alert(a);return false;}}}function senderShipmentSaveValid(c,a){var b=jQuery("#sender_shipment").val();var d=jQuery("#sender_shipment_message").val();if(b==""||isValid(b)==false){alert(c);return false;}else{if(d==""){alert(a);return false;}}}function senderCampaignSaveValid(d,a,b){var c=jQuery("#sender_campaign").val();var f=jQuery("#sender_campaign_message").val();var e=jQuery("#singlechoice").val();var g=jQuery("input[name=Sendin_Sms_Choice]:checked").val();if(g==1){if(e==""||isMobilevalidation(e)==false){alert(b);return false;}else{if(c==""||isValid(c)==false){alert(d);return false;}else{if(f==""){alert(a);return false;}}}}else{if(c==""||isValid(c)==false){alert(d);return false;}else{if(f==""){alert(a);return false;}}}}function isMobilevalidation(a){return/^(?:\+|00)[1-9][0-9]{5,15}$/.test(a);}function isNormalInteger(a){return/^\+?(0|[1-9]\d*)$/.test(a);}function isValid(c){var b="~`!#$%^&*+=-[]\\';,/{}|\":<>?";for(var a=0;a<c.length;a++){if(b.indexOf(c.charAt(a))!=-1){return false;}}return true;}function RegexEmail(b){var c=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;var a=c.test(b);return a;}function validate(b,a){if(document.notify_sms_mail_form.sendin_notify_email.value==""||RegexEmail(document.notify_sms_mail_form.sendin_notify_email.value)==false){alert(b);document.notify_sms_mail_form.sendin_notify_email.focus();return false;}if(document.notify_sms_mail_form.sendin_notify_value.value==""||isNormalInteger(document.notify_sms_mail_form.sendin_notify_value.value)==false){alert(a);document.notify_sms_mail_form.sendin_notify_value.focus();return false;}return(true);}function smtpvalidate(b){var a=jQuery("#email").val();if(a==""||RegexEmail(a)==false){alert(b);jQuery("#email").focus();return false;}}function apikvalidate(c){var a=jQuery("#sendin_apikey_val").val();var b=jQuery("input[name=sendin_api_status]:checked").val();if(a.trim()==""&&b!=0){alert(c);jQuery("#sendin_apikey_val").focus();return false;}}